Gtk3: improved scrollbars when scroll overlay is enabled.

This commit is contained in:
zeljan1 2025-03-07 11:32:39 +01:00
parent a07324e56d
commit e4aee44726

View File

@ -3956,8 +3956,6 @@ begin
ASize := R.Height ASize := R.Height
else else
ASize := R.Width; ASize := R.Width;
if ScrollInfo.nMax >= ASize - ScrollInfo.nPage then
exit;
if ScrollInfo.nPage <= 0 then if ScrollInfo.nPage <= 0 then
exit; exit;
APixelsPerUnit := ASize / ScrollInfo.nPage; APixelsPerUnit := ASize / ScrollInfo.nPage;
@ -4148,7 +4146,6 @@ var
begin begin
if bRedraw then if bRedraw then
begin begin
//gtk_adjustment_changed(Adjustment);
if IsScrollWindow then // seem that gtk3 does not like this if IsScrollWindow then // seem that gtk3 does not like this
begin begin
ScrollWin^.get_policy(@AHorzPolicy, @AVertPolicy); ScrollWin^.get_policy(@AHorzPolicy, @AVertPolicy);
@ -4162,7 +4159,10 @@ var
begin begin
ScrollBar^.set_can_focus(False); ScrollBar^.set_can_focus(False);
if (csDesigning in AControl.LCLObject.ComponentState) then if (csDesigning in AControl.LCLObject.ComponentState) then
ScrollBar^.sensitive := false; ScrollBar^.sensitive := false
else
if HaveLogicalValues and Gtk3IsGdkWindow(ScrollBar^.window) then
ScrollBar^.window^.raise_;
end; end;
end; end;
SB_VERT: SB_VERT:
@ -4174,7 +4174,10 @@ var
begin begin
ScrollBar^.set_can_focus(False); ScrollBar^.set_can_focus(False);
if (csDesigning in AControl.LCLObject.ComponentState) then if (csDesigning in AControl.LCLObject.ComponentState) then
ScrollBar^.sensitive := false; ScrollBar^.sensitive := false
else
if HaveLogicalValues and Gtk3IsGdkWindow(ScrollBar^.window) then
ScrollBar^.window^.raise_;
end; end;
end; end;
end; end;
@ -4187,10 +4190,6 @@ begin
Result := 0; Result := 0;
if not IsValidHandle(Handle) then Exit; if not IsValidHandle(Handle) then Exit;
//if GTK3WidgetSet.OverlayScrolling then
// OverlayFactor := 2
//else
// OverlayFactor := 1;
HasChanged := False; HasChanged := False;
HaveLogicalValues := False; HaveLogicalValues := False;
@ -4243,12 +4242,15 @@ begin
begin begin
Adjustment := gtk_scrolled_window_get_hadjustment(ScrollWin); Adjustment := gtk_scrolled_window_get_hadjustment(ScrollWin);
ScrollBar := TGtk3ScrollableWin(AControl).getHorizontalScrollbar; ScrollBar := TGtk3ScrollableWin(AControl).getHorizontalScrollbar;
if ScrollInfo.nMax < ScrollWin^.get_allocated_width then
begin
R := AControl.getClientRect; R := AControl.getClientRect;
if ([wtScrollingWinControl] * AControl.WidgetType = []) and
(Scrollinfo.nMax - (R.Width - ScrollInfo.nPage) < R.Width) then
begin
HaveLogicalValues := True; HaveLogicalValues := True;
ChangeLogicalToAbsolute(AControl, ScrollInfo, SB_HORZ, R); ChangeLogicalToAbsolute(AControl, ScrollInfo, SB_HORZ, R);
end; end;
end else end else
Adjustment := ScrollBar^.adjustment; Adjustment := ScrollBar^.adjustment;
end; end;
@ -4259,11 +4261,14 @@ begin
Adjustment := gtk_scrolled_window_get_vadjustment(ScrollWin); Adjustment := gtk_scrolled_window_get_vadjustment(ScrollWin);
ScrollBar := TGtk3ScrollableWin(AControl).getVerticalScrollbar; ScrollBar := TGtk3ScrollableWin(AControl).getVerticalScrollbar;
R := AControl.getClientRect; R := AControl.getClientRect;
if ScrollInfo.nMax < ScrollWin^.get_allocated_height then
if ([wtScrollingWinControl] * AControl.WidgetType = []) and
(Scrollinfo.nMax - (R.Height - ScrollInfo.nPage) < R.Height) then
begin begin
HaveLogicalValues := True; HaveLogicalValues := True;
ChangeLogicalToAbsolute(AControl, ScrollInfo, SB_VERT, R); ChangeLogicalToAbsolute(AControl, ScrollInfo, SB_VERT, R);
end; end;
end else end else
Adjustment := ScrollBar^.adjustment; Adjustment := ScrollBar^.adjustment;
end; end;