tvplanit: Minor refactoring of NavBar scrollbuttons

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4998 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2016-07-18 20:24:58 +00:00
parent 4f73e6effd
commit 0aaccd7fee

View File

@ -76,6 +76,8 @@ type
procedure DrawTopFolderButtons(Canvas: TCanvas; ARect: TRect; procedure DrawTopFolderButtons(Canvas: TCanvas; ARect: TRect;
DrawFolder: Boolean; var CurPos: Integer); DrawFolder: Boolean; var CurPos: Integer);
procedure ProcessScrollButtons;
public public
constructor Create(ANavBar: TVpCustomNavBar); constructor Create(ANavBar: TVpCustomNavBar);
procedure Paint; procedure Paint;
@ -891,9 +893,23 @@ begin
{ Draw the folder buttons at the bottom } { Draw the folder buttons at the bottom }
DrawBottomFolderButtons(DrawBmp.Canvas, MyRect, CurPos); DrawBottomFolderButtons(DrawBmp.Canvas, MyRect, CurPos);
{ Copy the buffer bitmap to the control }
FNavBar.Canvas.CopyMode := cmSrcCopy;
FNavBar.Canvas.CopyRect(MyRect, DrawBmp.Canvas, Rect(0, 0, DrawBmp.Width,DrawBmp.Height));
{ Show/hide scroll buttons }
ProcessScrollButtons;
finally
DrawBmp.Free;
end;
end;
procedure TVpNavBarPainter.ProcessScrollButtons;
begin
if not (csDesigning in FNavBar.ComponentState) then begin if not (csDesigning in FNavBar.ComponentState) then begin
{show the top scroll button} {show the top scroll button}
if TVpNavBarOpener(FNavBar).nabShowScrollUp then begin if TVpNavBarOpener(FNavBar).nabShowScrollUp() then begin
nabScrollUpBtn.Top := FNavBar.Folders[FActiveFolder].Rect.Bottom + 5; nabScrollUpBtn.Top := FNavBar.Folders[FActiveFolder].Rect.Bottom + 5;
nabScrollUpBtn.Left := FNavBar.ClientWidth - 20; nabScrollUpBtn.Left := FNavBar.ClientWidth - 20;
nabScrollUpBtn.Visible := True; nabScrollUpBtn.Visible := True;
@ -901,7 +917,7 @@ begin
nabScrollUpBtn.Visible := False; nabScrollUpBtn.Visible := False;
{show the bottom scroll button} {show the bottom scroll button}
if TVpNavBarOpener(FnavBar).nabShowScrollDown then begin if TVpNavBarOpener(FnavBar).nabShowScrollDown() then begin
if FActiveFolder = FNavBar.FolderCount-1 then if FActiveFolder = FNavBar.FolderCount-1 then
{there are no folders beyond the active one} {there are no folders beyond the active one}
nabScrollDownBtn.Top := FNavBar.ClientHeight -20 nabScrollDownBtn.Top := FNavBar.ClientHeight -20
@ -912,17 +928,7 @@ begin
end else end else
nabScrollDownBtn.Visible := False; nabScrollDownBtn.Visible := False;
end; end;
finally
{ Copy the buffer bitmap to the control }
FNavBar.Canvas.CopyMode := cmSrcCopy;
FNavBar.Canvas.CopyRect(MyRect, DrawBmp.Canvas, Rect(0, 0, DrawBmp.Width,DrawBmp.Height));
DrawBmp.Free;
end; end;
end;
{ Given a string, and a rectangle, find the string that can be displayed { Given a string, and a rectangle, find the string that can be displayed
using two lines. Add ellipsis to the end of each line if necessary and using two lines. Add ellipsis to the end of each line if necessary and