mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 18:39:09 +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;
|
procedure setFrame(newValue: NSRect); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LCLScrollViewAdjustSize(control: TWinControl);
|
||||||
|
|
||||||
function isMouseEventInScrollBar(host: TCocoaManualScrollView; event: NSEvent): Boolean;
|
function isMouseEventInScrollBar(host: TCocoaManualScrollView; event: NSEvent): Boolean;
|
||||||
|
|
||||||
// These settings are set by a user in "System Preferences"
|
// These settings are set by a user in "System Preferences"
|
||||||
@ -167,6 +169,9 @@ function AdjustScrollerPage(sc: TCocoaScrollBar; prt: NSScrollerPart): Boolean;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
CocoaWSCommon;
|
||||||
|
|
||||||
function SysPrefScrollShow: string;
|
function SysPrefScrollShow: string;
|
||||||
begin
|
begin
|
||||||
Result := NSStringToString(NSUserDefaults.standardUserDefaults.stringForKey(NSSTR('AppleShowScrollBars')));
|
Result := NSStringToString(NSUserDefaults.standardUserDefaults.stringForKey(NSSTR('AppleShowScrollBars')));
|
||||||
@ -633,6 +638,13 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure LCLScrollViewAdjustSize(control: TWinControl);
|
||||||
|
begin
|
||||||
|
if NSScroller.preferredScrollerStyle = NSScrollerStyleOverlay then
|
||||||
|
Exit;
|
||||||
|
ASyncLCLControlAdjustSizer.adjustSize(control);
|
||||||
|
end;
|
||||||
|
|
||||||
function isMouseEventInScrollBar(host: TCocoaManualScrollView; event: NSEvent): Boolean;
|
function isMouseEventInScrollBar(host: TCocoaManualScrollView; event: NSEvent): Boolean;
|
||||||
var
|
var
|
||||||
pt : NSPoint;
|
pt : NSPoint;
|
||||||
|
@ -1835,6 +1835,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
sc.ensureDocumentViewSizeChanged(documentSize, ensureWidth, ensureHeight);
|
sc.ensureDocumentViewSizeChanged(documentSize, ensureWidth, ensureHeight);
|
||||||
|
LCLScrollViewAdjustSize(lclControl);
|
||||||
|
|
||||||
// frame changed, Need to update another ScrollBar too
|
// frame changed, Need to update another ScrollBar too
|
||||||
if SbStyle=SB_Horz then begin
|
if SbStyle=SB_Horz then begin
|
||||||
|
@ -170,6 +170,18 @@ type
|
|||||||
const ABorderStyle: TBorderStyle); override;
|
const ABorderStyle: TBorderStyle); override;
|
||||||
end;
|
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
|
// Utility WS functions. todo: it makes sense to put them into CocoaScollers
|
||||||
|
|
||||||
function EmbedInScrollView(AView: NSView; AReleaseView: Boolean = true): TCocoaScrollView;
|
function EmbedInScrollView(AView: NSView; AReleaseView: Boolean = true): TCocoaScrollView;
|
||||||
@ -188,6 +200,9 @@ function NSObjectDebugStr(obj: NSObject): string;
|
|||||||
function CallbackDebugStr(cb: ICommonCallback): string;
|
function CallbackDebugStr(cb: ICommonCallback): string;
|
||||||
procedure DebugDumpParents(fromView: NSView);
|
procedure DebugDumpParents(fromView: NSView);
|
||||||
|
|
||||||
|
var
|
||||||
|
ASyncLCLControlAdjustSizer: TASyncLCLControlAdjustSizer;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
@ -2061,6 +2076,23 @@ begin
|
|||||||
ScrollViewSetBorderStyle( TCocoaManualScrollHost(AWinControl.Handle), ABorderStyle );
|
ScrollViewSetBorderStyle( TCocoaManualScrollHost(AWinControl.Handle), ABorderStyle );
|
||||||
end;
|
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;
|
function NSObjectDebugStr(obj: NSObject): string;
|
||||||
begin
|
begin
|
||||||
Result := IntToStr(PtrUInt(obj));
|
Result := IntToStr(PtrUInt(obj));
|
||||||
@ -2094,5 +2126,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
ASyncLCLControlAdjustSizer:= TASyncLCLControlAdjustSizer.Create;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user