From 570352971d2144492a261b2bdf7d62947f5f9413 Mon Sep 17 00:00:00 2001 From: rich2014 Date: Mon, 1 Jul 2024 00:57:14 +0800 Subject: [PATCH] Cocoa: fix a few issues in Scroller --- lcl/interfaces/cocoa/cocoascrollers.pas | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoascrollers.pas b/lcl/interfaces/cocoa/cocoascrollers.pas index f233223aa4..aed97d7976 100644 --- a/lcl/interfaces/cocoa/cocoascrollers.pas +++ b/lcl/interfaces/cocoa/cocoascrollers.pas @@ -806,6 +806,7 @@ begin fhscroll := allocScroller( self, r, avisible); fhscroll.setAutoresizingMask(NSViewWidthSizable); Result := fhscroll; + _manager.updateLayout; end; end; @@ -829,6 +830,7 @@ begin else fvscroll.setAutoresizingMask(NSViewHeightSizable or NSViewMinXMargin); Result := fvscroll; + _manager.updateLayout; end; end; @@ -1107,6 +1109,8 @@ procedure TCocoaScrollBar.setDoubleValue(newValue: double); var proportion: CGFloat; begin + if newValue < 0 then newValue:= 0; + if newValue > 1 then newValue:= 1; proportion:= self.knobProportion; _manager.onKnobValueUpdated( self, newValue, proportion ); inherited; @@ -1116,6 +1120,8 @@ procedure TCocoaScrollBar.setKnobProportion(newValue: CGFloat); var position: CGFloat; begin + if newValue < 0 then newValue:= 0; + if newValue > 1 then newValue:= 1; position:= self.doubleValue; _manager.onKnobValueUpdated( self, position, newValue ); inherited; @@ -1723,7 +1729,6 @@ var begin effect:= TCocoaScrollBarEffectOverlay(scrollBar.effect); - slotRect:= scroller.rectForPart(NSScrollerKnobSlot); if scrollBar.IsHorizontal then slotSize:= slotRect.size.width @@ -1796,7 +1801,7 @@ end; function TCocoaScrollStyleManagerOverlay.isAvailableScrollBar(scroller: NSScroller ): Boolean; begin - Result:= Assigned(scroller) and (scroller.knobProportion<1); + Result:= Assigned(scroller) and (0