mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 08:38:19 +02:00
Cocoa: fix the size issue of Scrolling Control with Overlay Style Scroller
This commit is contained in:
parent
1459f56c95
commit
595fd26f3f
@ -150,6 +150,8 @@ type
|
||||
procedure setFrame(newValue: NSRect); override;
|
||||
end;
|
||||
|
||||
procedure LCLScrollViewAdjustSize(control: TWinControl);
|
||||
|
||||
function isMouseEventInScrollBar(host: TCocoaManualScrollView; event: NSEvent): Boolean;
|
||||
|
||||
// These settings are set by a user in "System Preferences"
|
||||
@ -167,6 +169,9 @@ function AdjustScrollerPage(sc: TCocoaScrollBar; prt: NSScrollerPart): Boolean;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
CocoaWSCommon;
|
||||
|
||||
function SysPrefScrollShow: string;
|
||||
begin
|
||||
Result := NSStringToString(NSUserDefaults.standardUserDefaults.stringForKey(NSSTR('AppleShowScrollBars')));
|
||||
@ -633,6 +638,13 @@ begin
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
procedure LCLScrollViewAdjustSize(control: TWinControl);
|
||||
begin
|
||||
if NSScroller.preferredScrollerStyle = NSScrollerStyleOverlay then
|
||||
Exit;
|
||||
ASyncLCLControlAdjustSizer.adjustSize(control);
|
||||
end;
|
||||
|
||||
function isMouseEventInScrollBar(host: TCocoaManualScrollView; event: NSEvent): Boolean;
|
||||
var
|
||||
pt : NSPoint;
|
||||
|
@ -1835,6 +1835,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
sc.ensureDocumentViewSizeChanged(documentSize, ensureWidth, ensureHeight);
|
||||
LCLScrollViewAdjustSize(lclControl);
|
||||
|
||||
// frame changed, Need to update another ScrollBar too
|
||||
if SbStyle=SB_Horz then begin
|
||||
|
@ -170,6 +170,18 @@ type
|
||||
const ABorderStyle: TBorderStyle); override;
|
||||
end;
|
||||
|
||||
{ ASyncLCLControlAdjustSizer }
|
||||
|
||||
TASyncLCLControlAdjustSizer = class
|
||||
private
|
||||
_control: TWinControl;
|
||||
_doing: Boolean;
|
||||
procedure doAdjustSize(data: PtrInt);
|
||||
public
|
||||
procedure adjustSize(control: TWinControl);
|
||||
end;
|
||||
|
||||
|
||||
// Utility WS functions. todo: it makes sense to put them into CocoaScollers
|
||||
|
||||
function EmbedInScrollView(AView: NSView; AReleaseView: Boolean = true): TCocoaScrollView;
|
||||
@ -188,6 +200,9 @@ function NSObjectDebugStr(obj: NSObject): string;
|
||||
function CallbackDebugStr(cb: ICommonCallback): string;
|
||||
procedure DebugDumpParents(fromView: NSView);
|
||||
|
||||
var
|
||||
ASyncLCLControlAdjustSizer: TASyncLCLControlAdjustSizer;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -2061,6 +2076,23 @@ begin
|
||||
ScrollViewSetBorderStyle( TCocoaManualScrollHost(AWinControl.Handle), ABorderStyle );
|
||||
end;
|
||||
|
||||
{ TASyncLCLControlAdjustSizer }
|
||||
|
||||
procedure TASyncLCLControlAdjustSizer.doAdjustSize(data: PtrInt);
|
||||
begin
|
||||
_control.AdjustSize;
|
||||
_doing:= False;
|
||||
end;
|
||||
|
||||
procedure TASyncLCLControlAdjustSizer.adjustSize(control: TWinControl);
|
||||
begin
|
||||
_control:= control;
|
||||
_control.InvalidateClientRectCache(true);
|
||||
if NOT _doing then
|
||||
Application.QueueAsyncCall(@doAdjustSize, 0);
|
||||
_doing:= True;
|
||||
end;
|
||||
|
||||
function NSObjectDebugStr(obj: NSObject): string;
|
||||
begin
|
||||
Result := IntToStr(PtrUInt(obj));
|
||||
@ -2094,5 +2126,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
ASyncLCLControlAdjustSizer:= TASyncLCLControlAdjustSizer.Create;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user