diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2009-11-05 00:53:01 +0200 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2009-11-05 00:53:01 +0200 |
commit | 00fe1d02a270f4cf2b9789de6fd3117e01007e4f (patch) | |
tree | 33c4c7242a35751e4361f0d29ead39455dd1740a /src/gui | |
parent | 129509b03a4d729598d8ebfd712d1cee79dbd5c2 (diff) | |
download | fpGUI-00fe1d02a270f4cf2b9789de6fd3117e01007e4f.tar.xz |
Fixed mouse wheel scrolling in treeview.
* Content does not scroll vertically off the screen anymore.
* Vertical scrollbar button now positions correctly when scrolling
with mouse wheel of scrollbutton slider.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/fpg_tree.pas | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/gui/fpg_tree.pas b/src/gui/fpg_tree.pas index da3e2ddf..94c524d0 100644 --- a/src/gui/fpg_tree.pas +++ b/src/gui/fpg_tree.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2008 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2009 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -853,14 +853,14 @@ end; function TfpgTreeview.VisibleWidth: integer; begin - Result := Width - 2; + Result := Width - 2; // border width = 2 pixels if FVScrollbar.Visible then dec(Result, FVScrollbar.Width); end; function TfpgTreeview.VisibleHeight: integer; begin - Result := Height - 2; + Result := Height - 2; // border width = 2 pixels if FShowColumns then dec(Result, FColumnHeight); if FHScrollbar.Visible then @@ -1086,9 +1086,9 @@ begin {$IFDEF DEBUG} writeln(Classname, '.UpdateScrollbars'); {$ENDIF} - FVScrollbar.Visible := VisibleHeight < GetNodeHeightSum * GetNodeHeight; + FVScrollbar.Visible := VisibleHeight < (GetNodeHeightSum * GetNodeHeight); FVScrollbar.Min := 0; - FVScrollbar.Max := (GetNodeHeightSum - 1) * GetNodeHeight; + FVScrollbar.Max := (GetNodeHeightSum * GetNodeHeight) - VisibleHeight + FHScrollbar.Height; FHScrollbar.Min := 0; FHScrollbar.Max := MaxNodeWidth - VisibleWidth + FVScrollbar.Width; FHScrollbar.Visible := MaxNodeWidth > Width - 2; @@ -1097,13 +1097,18 @@ begin FVScrollbar.Position := 0; FVScrollBar.RepaintSlider; FYOffset := 0; - end; + end + else + FVScrollBar.RepaintSlider; + if not FHScrollbar.Visible then begin FHScrollbar.Position := 0; FHScrollBar.RepaintSlider; FXOffset := 0; - end; + end + else + FHScrollBar.RepaintSlider; end; procedure TfpgTreeview.ResetScrollbar; @@ -1655,21 +1660,25 @@ end; procedure TfpgTreeview.HandleMouseScroll(x, y: integer; shiftstate: TShiftState; delta: smallint); +var + i: integer; begin inherited HandleMouseScroll(x, y, shiftstate, delta); if delta > 0 then begin inc(FYOffset, FScrollWheelDelta); - if FYOffset > VisibleHeight then - FYOffset := VisibleHeight; + i := (GetNodeHeightSum * GetNodeHeight) - VisibleHeight + FHScrollbar.Height; + if FYOffset > i then + FYOffset := i; + inc(FVScrollbar.Position, FScrollWheelDelta); end else begin dec(FYOffset, FScrollWheelDelta); if FYOffset < 0 then FYOffset := 0; + dec(FVScrollbar.Position, FScrollWheelDelta); end; - UpdateScrollbars; RePaint; end; @@ -1805,7 +1814,7 @@ begin FHScrollbar.OnScroll := @HScrollbarScroll; FHScrollbar.Visible := False; FHScrollbar.Position := 0; - FHScrollbar.SliderSize := 0.2; + FHScrollbar.SliderSize := 0.5; FVScrollbar := TfpgScrollbar.Create(self); FVScrollbar.Orientation := orVertical; |