mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 14:59:08 +02:00
fixed gtkglarea
git-svn-id: trunk@4143 -
This commit is contained in:
parent
f44c4f4556
commit
774b820d84
@ -20,28 +20,41 @@ unit GTKGLArea;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Controls, Graphics, LMessages, VCLGlobals,
|
Classes, SysUtils, {$IFDEF VER1_0}Linux{$ELSE}Unix{$ENDIF}, Forms,
|
||||||
InterfaceBase, GTKInt, LResources, GLib, NVGL, NVGLX, GTKGLArea_Int;
|
Controls, Graphics, LMessages, VCLGlobals, InterfaceBase, GTKInt, LResources,
|
||||||
|
GLib, NVGL, NVGLX, GTKGLArea_Int;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
{ TCustomGTKGLAreaControl }
|
||||||
|
|
||||||
TCustomGTKGLAreaControl = class(TWinControl)
|
TCustomGTKGLAreaControl = class(TWinControl)
|
||||||
private
|
private
|
||||||
FCanvas: TCanvas; // only valid at designtime
|
FCanvas: TCanvas; // only valid at designtime
|
||||||
FOnPaint: TNotifyEvent;
|
FOnPaint: TNotifyEvent;
|
||||||
|
FCurrentFrameTime: integer; // in msec
|
||||||
|
FLastFrameTime: integer; // in msec
|
||||||
|
FFrameDiffTime: integer; // in msec
|
||||||
|
FPaintOnIdle: boolean;
|
||||||
protected
|
protected
|
||||||
procedure WMPaint(var Message: TLMPaint); message LM_PAINT;
|
procedure WMPaint(var Message: TLMPaint); message LM_PAINT;
|
||||||
function GetWidget: PGtkGLArea;
|
function GetWidget: PGtkGLArea;
|
||||||
procedure CreateComponent(TheOwner: TComponent); override;
|
procedure CreateComponent(TheOwner: TComponent); override;
|
||||||
|
procedure UpdateFrameTimeDiff;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
Procedure Paint; virtual;
|
Procedure Paint; virtual;
|
||||||
procedure DoOnResize; override;
|
procedure DoOnResize; override;
|
||||||
|
procedure DoOnPaint; virtual;
|
||||||
public
|
public
|
||||||
property Widget: PGtkGLArea read GetWidget;
|
property Widget: PGtkGLArea read GetWidget;
|
||||||
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
|
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
|
||||||
|
property FrameDiffTimeInMSecs: integer read FFrameDiffTime;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
{ TGTKGLAreaControl }
|
||||||
|
|
||||||
TGTKGLAreaControl = class(TCustomGTKGLAreaControl)
|
TGTKGLAreaControl = class(TCustomGTKGLAreaControl)
|
||||||
published
|
published
|
||||||
property Align;
|
property Align;
|
||||||
@ -76,7 +89,6 @@ procedure Register;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
InitAttrList: array [1..11] of LongInt = (
|
InitAttrList: array [1..11] of LongInt = (
|
||||||
GDK_GL_RGBA,
|
GDK_GL_RGBA,
|
||||||
@ -116,16 +128,26 @@ end;
|
|||||||
|
|
||||||
procedure TCustomGTKGLAreaControl.Paint;
|
procedure TCustomGTKGLAreaControl.Paint;
|
||||||
begin
|
begin
|
||||||
if Assigned(OnPaint) then OnPaint(Self);
|
if (not (csDesigning in ComponentState))
|
||||||
|
and Enabled and Visible and HandleAllocated
|
||||||
|
and (gint(True) = gtk_gl_area_make_current(Widget)) then begin
|
||||||
|
UpdateFrameTimeDiff;
|
||||||
|
DoOnPaint;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomGTKGLAreaControl.DoOnResize;
|
procedure TCustomGTKGLAreaControl.DoOnResize;
|
||||||
begin
|
begin
|
||||||
if (gint(True) = gtk_gl_area_make_current(Widget)) then
|
if HandleAllocated and (gint(True) = gtk_gl_area_make_current(Widget)) then
|
||||||
glViewport (0, 0, Width, Height);
|
glViewport (0, 0, Width, Height);
|
||||||
inherited DoOnResize;
|
inherited DoOnResize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomGTKGLAreaControl.DoOnPaint;
|
||||||
|
begin
|
||||||
|
if Assigned(OnPaint) then OnPaint(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomGTKGLAreaControl.WMPaint(var Message: TLMPaint);
|
procedure TCustomGTKGLAreaControl.WMPaint(var Message: TLMPaint);
|
||||||
begin
|
begin
|
||||||
Include(FControlState, csCustomPaint);
|
Include(FControlState, csCustomPaint);
|
||||||
@ -141,9 +163,7 @@ begin
|
|||||||
LineTo(Width,0);
|
LineTo(Width,0);
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
if (Widget<>nil)
|
Paint;
|
||||||
and (gint(True) = gtk_gl_area_make_current(Widget)) then
|
|
||||||
Paint;
|
|
||||||
end;
|
end;
|
||||||
Exclude(FControlState, csCustomPaint);
|
Exclude(FControlState, csCustomPaint);
|
||||||
end;
|
end;
|
||||||
@ -169,6 +189,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomGTKGLAreaControl.UpdateFrameTimeDiff;
|
||||||
|
var
|
||||||
|
hour, minutes, secs, msecs, usecs: word;
|
||||||
|
begin
|
||||||
|
GetTime(hour, minutes, secs, msecs, usecs);
|
||||||
|
FCurrentFrameTime:=(((minutes*60)+secs) * 1000)+msecs;
|
||||||
|
if FLastFrameTime=0 then
|
||||||
|
FLastFrameTime:=FCurrentFrameTime;
|
||||||
|
// calculate time since last call:
|
||||||
|
FFrameDiffTime:=FCurrentFrameTime-FLastFrameTime;
|
||||||
|
// if the hour changed, the minutes restarts:
|
||||||
|
if (FFrameDiffTime<0) then inc(FFrameDiffTime,60*60*1000);
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
{$i gtkglarea.lrs}
|
{$i gtkglarea.lrs}
|
||||||
|
|
||||||
|
@ -4078,13 +4078,13 @@ begin
|
|||||||
AButton:=TPathEditorButton(Sender);
|
AButton:=TPathEditorButton(Sender);
|
||||||
if AButton=OtherUnitsPathEditBtn then begin
|
if AButton=OtherUnitsPathEditBtn then begin
|
||||||
OldPath:=edtOtherUnits.Text;
|
OldPath:=edtOtherUnits.Text;
|
||||||
Templates:=
|
Templates:=SetDirSeparators(
|
||||||
'$(LazarusDir)/lcl/units'
|
'$(LazarusDir)/lcl/units'
|
||||||
+';$(LazarusDir)/lcl/units/$(LCLWidgetType)'
|
+';$(LazarusDir)/lcl/units/$(LCLWidgetType)'
|
||||||
+';$(LazarusDir)/components/units'
|
+';$(LazarusDir)/components/units'
|
||||||
+';$(LazarusDir)/components/custom'
|
+';$(LazarusDir)/components/custom'
|
||||||
+';$(LazarusDir)/packager/units'
|
+';$(LazarusDir)/packager/units'
|
||||||
;
|
);
|
||||||
end else
|
end else
|
||||||
if AButton=IncludeFilesPathEditBtn then begin
|
if AButton=IncludeFilesPathEditBtn then begin
|
||||||
OldPath:=edtIncludeFiles.Text;
|
OldPath:=edtIncludeFiles.Text;
|
||||||
|
@ -166,7 +166,14 @@ begin
|
|||||||
AnEdit:=GetEditForPathButton(AButton);
|
AnEdit:=GetEditForPathButton(AButton);
|
||||||
OldPath:=AnEdit.Text;
|
OldPath:=AnEdit.Text;
|
||||||
if AButton=UnitPathButton then begin
|
if AButton=UnitPathButton then begin
|
||||||
Templates:='$(PkgOutDir)';
|
Templates:=SetDirSeparators(
|
||||||
|
'$(PkgOutDir)'
|
||||||
|
+';$(LazarusDir)/lcl/units'
|
||||||
|
+';$(LazarusDir)/lcl/units/$(LCLWidgetType)'
|
||||||
|
+';$(LazarusDir)/components/units'
|
||||||
|
+';$(LazarusDir)/components/custom'
|
||||||
|
+';$(LazarusDir)/packager/units'
|
||||||
|
);
|
||||||
end;
|
end;
|
||||||
if AButton=IncludePathButton then begin
|
if AButton=IncludePathButton then begin
|
||||||
Templates:='include';
|
Templates:='include';
|
||||||
|
Loading…
Reference in New Issue
Block a user