Ignore:
Timestamp:
Jan 19, 2017, 9:04:16 PM (8 years ago)
Author:
chronos
Message:
  • Fixed: To work scrollbar correctly again on Linux where Max behaves differently when on Windows.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/PVSB.pas

    r89 r90  
    1919    FOnUpdate: TNotifyEvent;
    2020    ScrollBar: TScrollBar;
     21    FMax: Integer;
    2122    function GetMax: Integer;
    2223    function GetPageSize: Integer;
     
    2930    constructor Create(Parent: TWinControl);
    3031    destructor Destroy; override;
    31     procedure Init(Max, Page: Integer);
     32    procedure Init(Max, PageSize: Integer);
    3233    procedure SetPos(Pos: Integer);
    3334    function Process(const m: TMessage): boolean;
     
    4849  Count: Integer = 0;
    4950
    50 procedure TPVScrollBar.Init(Max, Page: Integer);
     51procedure TPVScrollBar.Init(Max, PageSize: Integer);
    5152begin
     53  ScrollBar.PageSize := PageSize;
    5254  ScrollBar.Min := 0;
    53   ScrollBar.Max := Max;
    54   ScrollBar.PageSize := Page;
     55  Self.Max := Max;
    5556  ScrollBar.Position := 0;
    56   ScrollBar.Visible := ScrollBar.Max >= ScrollBar.PageSize;
     57  ScrollBar.Visible := Max >= ScrollBar.PageSize;
    5758end;
    5859
     
    6869  NewPos: integer;
    6970begin
    70     if ScrollBar.Max < ScrollBar.PageSize then
     71    if Max < ScrollBar.PageSize then
    7172      result := false
    7273    else
     
    9192        if NewPos < 0 then
    9293          NewPos := 0;
    93         if NewPos > ScrollBar.Max - ScrollBar.PageSize + 1 then
    94           NewPos := ScrollBar.Max - ScrollBar.PageSize + 1;
     94        if NewPos > Max - ScrollBar.PageSize + 1 then
     95          NewPos := Max - ScrollBar.PageSize + 1;
    9596        result := NewPos <> ScrollBar.Position;
    9697        if (NewPos <> ScrollBar.Position) or ((m.wParam and $ffff) = SB_ENDSCROLL) then
     
    106107  NewPos: integer;
    107108begin
    108     if ScrollBar.Max < ScrollBar.PageSize then Result := False
     109    if Max < ScrollBar.PageSize then Result := False
    109110    else begin
    110111      NewPos := ScrollBar.Position - Delta div 300;
    111112      if NewPos < 0 then NewPos := 0;
    112       if NewPos > ScrollBar.Max - ScrollBar.PageSize + 1 then
    113         NewPos := ScrollBar.Max - ScrollBar.PageSize + 1;
     113      if NewPos > Max - ScrollBar.PageSize + 1 then
     114        NewPos := Max - ScrollBar.PageSize + 1;
    114115      Result := NewPos <> ScrollBar.Position;
    115116      if NewPos <> ScrollBar.Position then begin
     
    121122procedure TPVScrollBar.Show(Visible: boolean);
    122123begin
    123   if not Visible or (ScrollBar.Max < ScrollBar.PageSize) then
     124  if not Visible or (Max < ScrollBar.PageSize) then
    124125    ScrollBar.Visible := False
    125126    else ScrollBar.Visible := True;
     
    128129procedure TPVScrollBar.EndSB;
    129130begin
    130   if ScrollBar.Max < ScrollBar.PageSize then
     131  if Max < ScrollBar.PageSize then
    131132    ScrollBar.Position := 0 // hidden
    132133  else begin
    133     ScrollBar.Position := ScrollBar.Max - ScrollBar.PageSize + 1;
     134    ScrollBar.Position := Max - ScrollBar.PageSize + 1;
    134135  end;
    135136end;
     
    151152procedure TPVScrollBar.SetMax(AValue: Integer);
    152153begin
    153   ScrollBar.Max := AValue;
     154  FMax := AValue;
     155  ScrollBar.Max := Max{$IFDEF LINUX} - PageSize + 1{$ENDIF};
    154156end;
    155157
     
    166168function TPVScrollBar.GetMax: Integer;
    167169begin
    168   Result := ScrollBar.Max;
     170  Result := FMax;
    169171end;
    170172
Note: See TracChangeset for help on using the changeset viewer.