mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 05:39:14 +02:00
added SharedArea for gtkglarea
git-svn-id: trunk@5345 -
This commit is contained in:
parent
22e70e05cb
commit
4a410591de
@ -39,6 +39,10 @@ type
|
|||||||
FCurrentFrameTime: integer; // in msec
|
FCurrentFrameTime: integer; // in msec
|
||||||
FLastFrameTime: integer; // in msec
|
FLastFrameTime: integer; // in msec
|
||||||
FFrameDiffTime: integer; // in msec
|
FFrameDiffTime: integer; // in msec
|
||||||
|
FSharedArea: TCustomGTKGLAreaControl;
|
||||||
|
FSharingAreas: TList;
|
||||||
|
function GetSharingAreas(Index: integer): TCustomGTKGLAreaControl;
|
||||||
|
procedure SetSharedArea(const AValue: TCustomGTKGLAreaControl);
|
||||||
protected
|
protected
|
||||||
procedure WMPaint(var Message: TLMPaint); message LM_PAINT;
|
procedure WMPaint(var Message: TLMPaint); message LM_PAINT;
|
||||||
function GetWidget: PGtkGLArea;
|
function GetWidget: PGtkGLArea;
|
||||||
@ -52,12 +56,15 @@ type
|
|||||||
procedure SwapBuffers; virtual;
|
procedure SwapBuffers; virtual;
|
||||||
function MakeCurrent: integer; virtual;
|
function MakeCurrent: integer; virtual;
|
||||||
function RestoreOldGtkGLAreaControl: boolean;
|
function RestoreOldGtkGLAreaControl: boolean;
|
||||||
|
function SharingAreasCount: integer;
|
||||||
|
property SharingAreas[Index: integer]: TCustomGTKGLAreaControl read GetSharingAreas;
|
||||||
public
|
public
|
||||||
property Widget: PGtkGLArea read GetWidget;
|
|
||||||
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
|
|
||||||
property FrameDiffTimeInMSecs: integer read FFrameDiffTime;
|
property FrameDiffTimeInMSecs: integer read FFrameDiffTime;
|
||||||
property OnMakeCurrent: TGtkGlAreaMakeCurrentEvent read FOnMakeCurrent
|
property OnMakeCurrent: TGtkGlAreaMakeCurrentEvent read FOnMakeCurrent
|
||||||
write FOnMakeCurrent;
|
write FOnMakeCurrent;
|
||||||
|
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
|
||||||
|
property SharedArea: TCustomGTKGLAreaControl read FSharedArea write SetSharedArea;
|
||||||
|
property Widget: PGtkGLArea read GetWidget;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -88,6 +95,7 @@ type
|
|||||||
property OnResize;
|
property OnResize;
|
||||||
property OnShowHint;
|
property OnShowHint;
|
||||||
property PopupMenu;
|
property PopupMenu;
|
||||||
|
property SharedArea;
|
||||||
property ShowHint;
|
property ShowHint;
|
||||||
property Visible;
|
property Visible;
|
||||||
end;
|
end;
|
||||||
@ -152,6 +160,12 @@ end;
|
|||||||
|
|
||||||
destructor TCustomGTKGLAreaControl.Destroy;
|
destructor TCustomGTKGLAreaControl.Destroy;
|
||||||
begin
|
begin
|
||||||
|
if FSharingAreas<>nil then begin
|
||||||
|
while SharingAreasCount>0 do
|
||||||
|
SharingAreas[SharingAreasCount-1].SharedArea:=nil;
|
||||||
|
FreeAndNil(FSharingAreas);
|
||||||
|
end;
|
||||||
|
SharedArea:=nil;
|
||||||
FCanvas.Free;
|
FCanvas.Free;
|
||||||
FCanvas:=nil;
|
FCanvas:=nil;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
@ -240,6 +254,46 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomGTKGLAreaControl.SharingAreasCount: integer;
|
||||||
|
begin
|
||||||
|
if FSharingAreas=nil then
|
||||||
|
Result:=0
|
||||||
|
else
|
||||||
|
Result:=FSharingAreas.Count;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomGTKGLAreaControl.SetSharedArea(
|
||||||
|
const AValue: TCustomGTKGLAreaControl);
|
||||||
|
begin
|
||||||
|
if FSharedArea=AValue then exit;
|
||||||
|
if AValue=Self then
|
||||||
|
Raise Exception.Create('An area can not be shared by itself.');
|
||||||
|
// unshare old
|
||||||
|
if (AValue<>nil) and (AValue.SharedArea<>nil) then
|
||||||
|
Raise Exception.Create('Target area is sharing too. A sharing area can not be shared.');
|
||||||
|
if FSharedArea<>nil then FSharedArea.FSharingAreas.Remove(Self);
|
||||||
|
// share new
|
||||||
|
if (AValue<>nil) and (csDestroying in AValue.ComponentState) then
|
||||||
|
FSharedArea:=nil
|
||||||
|
else begin
|
||||||
|
FSharedArea:=AValue;
|
||||||
|
if (FSharedArea<>nil) then begin
|
||||||
|
if FSharedArea.FSharingAreas=nil then
|
||||||
|
FSharedArea.FSharingAreas:=TList.Create;
|
||||||
|
FSharedArea.FSharingAreas.Add(Self);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// recreate handle if needed
|
||||||
|
if HandleAllocated and (not (csDesigning in ComponentState)) then
|
||||||
|
ReCreateWnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomGTKGLAreaControl.GetSharingAreas(Index: integer
|
||||||
|
): TCustomGTKGLAreaControl;
|
||||||
|
begin
|
||||||
|
Result:=TCustomGTKGLAreaControl(FSharingAreas[Index]);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomGTKGLAreaControl.WMPaint(var Message: TLMPaint);
|
procedure TCustomGTKGLAreaControl.WMPaint(var Message: TLMPaint);
|
||||||
begin
|
begin
|
||||||
Include(FControlState, csCustomPaint);
|
Include(FControlState, csCustomPaint);
|
||||||
@ -289,10 +343,17 @@ function TWSGTKGLAreaControl.CreateHandle(const AComponent: TComponent;
|
|||||||
const AParams: TCreateParams): THandle;
|
const AParams: TCreateParams): THandle;
|
||||||
var
|
var
|
||||||
NewWidget: Pointer;
|
NewWidget: Pointer;
|
||||||
|
Area: TCustomGTKGLAreaControl;
|
||||||
begin
|
begin
|
||||||
if csDesigning in AComponent.ComponentState then
|
if csDesigning in AComponent.ComponentState then
|
||||||
Result:=inherited CreateHandle(AComponent,AParams)
|
Result:=inherited CreateHandle(AComponent,AParams)
|
||||||
else begin
|
else begin
|
||||||
|
Area:=AComponent as TCustomGTKGLAreaControl;
|
||||||
|
if (Area.SharedArea<>nil) and (not (csDestroying in Area.ComponentState))
|
||||||
|
then
|
||||||
|
NewWidget:=gtk_gl_area_share_new(Plongint(@InitAttrList),
|
||||||
|
Area.SharedArea.Widget)
|
||||||
|
else
|
||||||
NewWidget:=gtk_gl_area_new(Plongint(@InitAttrList));
|
NewWidget:=gtk_gl_area_new(Plongint(@InitAttrList));
|
||||||
Result:=longint(NewWidget);
|
Result:=longint(NewWidget);
|
||||||
TGTKWidgetSet(InterfaceObject).FinishComponentCreate(AComponent,NewWidget,true);
|
TGTKWidgetSet(InterfaceObject).FinishComponentCreate(AComponent,NewWidget,true);
|
||||||
|
Loading…
Reference in New Issue
Block a user