mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 06:56:10 +02:00
fix for #11190, implicit invalidates by SetBounds or SetVisibility inside OnPaint events are supported
git-svn-id: trunk@19601 -
This commit is contained in:
parent
fa42e89af3
commit
4ff5a5562a
@ -294,6 +294,16 @@ implementation
|
|||||||
uses InterfaceBase, CarbonInt, CarbonProc, CarbonDbgConsts, CarbonUtils,
|
uses InterfaceBase, CarbonInt, CarbonProc, CarbonDbgConsts, CarbonUtils,
|
||||||
CarbonWSStdCtrls, CarbonCanvas, CarbonCaret;
|
CarbonWSStdCtrls, CarbonCanvas, CarbonCaret;
|
||||||
|
|
||||||
|
var
|
||||||
|
// recursive number of draw events called by OSX
|
||||||
|
IsDrawEvent : Integer = 0;
|
||||||
|
// invalidated inside OnPaint event
|
||||||
|
InvalidPaint : Boolean = false;
|
||||||
|
// invalidating
|
||||||
|
IsRepaint : Boolean = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Name: GetCarbonWidget
|
Name: GetCarbonWidget
|
||||||
Params: AWidget - Pointer to control or window widget
|
Params: AWidget - Pointer to control or window widget
|
||||||
|
@ -39,12 +39,16 @@ function CarbonCommon_Draw(ANextHandler: EventHandlerCallRef;
|
|||||||
AEvent: EventRef;
|
AEvent: EventRef;
|
||||||
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
|
||||||
var
|
var
|
||||||
AStruct: PPaintStruct;
|
AStruct : PPaintStruct;
|
||||||
|
Win : WindowRef;
|
||||||
|
Content : HIViewRef;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
{$IFDEF VerbosePaint}
|
{$IFDEF VerbosePaint}
|
||||||
Debugln('CarbonCommon_Draw ', DbgSName(AWidget.LCLObject));
|
Debugln('CarbonCommon_Draw ', DbgSName(AWidget.LCLObject));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
inc(IsDrawEvent);
|
||||||
|
|
||||||
AWidget.Context := TCarbonControlContext.Create(AWidget);
|
AWidget.Context := TCarbonControlContext.Create(AWidget);
|
||||||
try
|
try
|
||||||
@ -57,11 +61,17 @@ begin
|
|||||||
AWidget.Context.Reset;
|
AWidget.Context.Reset;
|
||||||
|
|
||||||
// let carbon draw/update
|
// let carbon draw/update
|
||||||
Result := CallNextEventHandler(ANextHandler, AEvent);
|
if not isRepaint or ( AWidget.InheritsFrom(TCarbonCustomControl) and not (AWidget is TCarbonScrollingWinControl)) then
|
||||||
|
Result := CallNextEventHandler(ANextHandler, AEvent)
|
||||||
|
else
|
||||||
|
Result := noErr;
|
||||||
|
|
||||||
if (AWidget is TCarbonControl) and
|
if (AWidget is TCarbonControl) and
|
||||||
(cceDraw in (AWidget as TCarbonControl).GetValidEvents) then
|
(cceDraw in (AWidget as TCarbonControl).GetValidEvents) then
|
||||||
|
begin
|
||||||
|
// todo: find a way to erase old content
|
||||||
(AWidget as TCarbonControl).Draw;
|
(AWidget as TCarbonControl).Draw;
|
||||||
|
end;
|
||||||
|
|
||||||
New(AStruct);
|
New(AStruct);
|
||||||
FillChar(AStruct^, SizeOf(TPaintStruct), 0);
|
FillChar(AStruct^, SizeOf(TPaintStruct), 0);
|
||||||
@ -76,8 +86,23 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
if AWidget.HasCaret then DrawCaret;
|
if AWidget.HasCaret then DrawCaret;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
FreeAndNil(AWidget.Context);
|
FreeAndNil(AWidget.Context);
|
||||||
|
dec(IsDrawEvent);
|
||||||
|
if (IsDrawEvent = 0) and InvalidPaint then
|
||||||
|
begin
|
||||||
|
if not IsRepaint then
|
||||||
|
begin
|
||||||
|
IsRepaint := true;
|
||||||
|
Win:=HIViewGetWindow(AWidget.Widget);
|
||||||
|
HIViewFindByID( HIViewGetRoot(Win), kHIViewWindowContentID, Content);
|
||||||
|
HIViewSetNeedsDisplay(Content, true);
|
||||||
|
HIViewRender(Content);
|
||||||
|
IsRepaint:=false;
|
||||||
|
end;
|
||||||
|
InvalidPaint:=false;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
{$IFDEF VerbosePaint}
|
{$IFDEF VerbosePaint}
|
||||||
Debugln('CarbonCommon_Draw end ', DbgSName(AWidget.LCLObject));
|
Debugln('CarbonCommon_Draw end ', DbgSName(AWidget.LCLObject));
|
||||||
@ -453,3 +478,5 @@ begin
|
|||||||
SizeOf(TLMessage), @AMessage);
|
SizeOf(TLMessage), @AMessage);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -748,13 +748,21 @@ end;
|
|||||||
parent
|
parent
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function TCarbonControl.SetBounds(const ARect: TRect): Boolean;
|
function TCarbonControl.SetBounds(const ARect: TRect): Boolean;
|
||||||
|
var
|
||||||
|
B :CGRect;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
|
|
||||||
|
if (IsDrawEvent > 0) then HIViewGetBounds(Frames[0], B);
|
||||||
|
|
||||||
if OSError(HIViewSetFrame(Frames[0], RectToCGRect(ARect)),
|
if OSError(HIViewSetFrame(Frames[0], RectToCGRect(ARect)),
|
||||||
Self, SSetBounds, SViewFrame) then Exit;
|
Self, SSetBounds, SViewFrame) then Exit;
|
||||||
// ensure bounds are send back to LCL once after creation
|
// ensure bounds are send back to LCL once after creation
|
||||||
BoundsChanged;
|
BoundsChanged;
|
||||||
|
|
||||||
|
if (IsDrawEvent > 0) and not Types.EqualRect( CGRectToRect(B), ARect) then
|
||||||
|
InvalidPaint := true;
|
||||||
|
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -885,11 +893,17 @@ end;
|
|||||||
procedure TCarbonControl.ShowHide(AVisible: Boolean);
|
procedure TCarbonControl.ShowHide(AVisible: Boolean);
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
|
v: Boolean;
|
||||||
begin
|
begin
|
||||||
//DebugLn('TCarbonControl.ShowHide ' + DbgSName(LCLobject),' ', DbgS(AVisible));
|
//DebugLn('TCarbonControl.ShowHide ' + DbgSName(LCLobject),' ', DbgS(AVisible));
|
||||||
|
v := IsVisible;
|
||||||
|
|
||||||
for I := 0 to GetFrameCount - 1 do
|
for I := 0 to GetFrameCount - 1 do
|
||||||
OSError(HIViewSetVisible(Frames[I], AVisible or (csDesigning in LCLobject.ComponentState)),
|
OSError(HIViewSetVisible(Frames[I], AVisible or (csDesigning in LCLobject.ComponentState)),
|
||||||
Self, 'ShowHide', SViewVisible);
|
Self, 'ShowHide', SViewVisible);
|
||||||
|
|
||||||
|
if (IsDrawEvent > 0) and (AVisible <> v) and (AVisible or (csDesigning in LCLobject.ComponentState)) and (GetFrameCount>0) then
|
||||||
|
InvalidPaint := true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user