mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2025-06-02 21:57:37 +02:00
Update to CEF 80.0.5
- Added overloaded ScreenToClient and ClientToScreen functions to TFMXBufferPanel - Modified TFMXBufferPanel.GetScreenScale to read the current DPI - Modified FMXExternalPumpBrowser and FMXTabbedOSRBrowser demos to read TFMXBufferPanel.ScreenScale and removed some pointer checks.
This commit is contained in:
parent
f4dd3e69a3
commit
e1f3fb5ee3
@ -3,10 +3,10 @@ CEF4Delphi is an open source project created by Salvador D
|
||||
|
||||
CEF4Delphi is based on DCEF3, made by Henri Gourvest. The original license of DCEF3 still applies to CEF4Delphi. Read the license terms in the first lines of any *.pas file.
|
||||
|
||||
CEF4Delphi uses CEF 80.0.4 which includes Chromium 80.0.3987.122.
|
||||
CEF4Delphi uses CEF 80.0.5 which includes Chromium 80.0.3987.132.
|
||||
The CEF binaries used by CEF4Delphi are available for download at spotify :
|
||||
* [32 bits](http://opensource.spotify.com/cefbuilds/cef_binary_80.0.4%2Bg74f7b0c%2Bchromium-80.0.3987.122_windows32.tar.bz2)
|
||||
* [64 bits](http://opensource.spotify.com/cefbuilds/cef_binary_80.0.4%2Bg74f7b0c%2Bchromium-80.0.3987.122_windows64.tar.bz2)
|
||||
* [32 bits](http://opensource.spotify.com/cefbuilds/cef_binary_80.0.5%2Bgdf7fb8e%2Bchromium-80.0.3987.132_windows32.tar.bz2)
|
||||
* [64 bits](http://opensource.spotify.com/cefbuilds/cef_binary_80.0.5%2Bgdf7fb8e%2Bchromium-80.0.3987.132_windows64.tar.bz2)
|
||||
|
||||
|
||||
CEF4Delphi was developed and tested on Delphi 10.3 Rio and it has been tested in Delphi 7, Delphi XE, Delphi 10, Delphi 10.2 and Lazarus 2.0.6/FPC 3.0.4. CEF4Delphi includes VCL, FireMonkey (FMX) and Lazarus components.
|
||||
|
@ -326,7 +326,7 @@ procedure TFMXExternalPumpBrowserFrm.Panel1KeyDown( Sender : TObject;
|
||||
var
|
||||
TempKeyEvent : TCefKeyEvent;
|
||||
begin
|
||||
if not(Panel1.IsFocused) or (chrmosr = nil) then exit;
|
||||
if not(Panel1.IsFocused) then exit;
|
||||
|
||||
if (Key <> 0) and (KeyChar = #0) then
|
||||
begin
|
||||
@ -352,7 +352,7 @@ procedure TFMXExternalPumpBrowserFrm.Panel1KeyUp( Sender : TObject;
|
||||
var
|
||||
TempKeyEvent : TCefKeyEvent;
|
||||
begin
|
||||
if not(Panel1.IsFocused) or (chrmosr = nil) then exit;
|
||||
if not(Panel1.IsFocused) then exit;
|
||||
|
||||
if (Key = 0) and (KeyChar <> #0) then
|
||||
begin
|
||||
@ -408,7 +408,7 @@ var
|
||||
TempEvent : TCefMouseEvent;
|
||||
TempTime : integer;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and (chrmosr <> nil) and not(ssTouch in Shift) then
|
||||
if not(ssTouch in Shift) then
|
||||
begin
|
||||
Panel1.SetFocus;
|
||||
|
||||
@ -454,20 +454,17 @@ end;
|
||||
procedure TFMXExternalPumpBrowserFrm.Panel1MouseLeave(Sender: TObject);
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
TempPoint : TPoint;
|
||||
TempPointF : TPointF;
|
||||
TempPoint : TPointF;
|
||||
TempTime : integer;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and (chrmosr <> nil) and GetMousePosition(TempPointF) then
|
||||
if GetMousePosition(TempPoint) then
|
||||
begin
|
||||
TempPoint.x := round(TempPointF.x);
|
||||
TempPoint.y := round(TempPointF.y);
|
||||
TempPoint := Panel1.ScreenToClient(TempPoint);
|
||||
TempPoint := Panel1.ScreenToClient(TempPoint);
|
||||
|
||||
if CancelPreviousClick(TempPoint.x, TempPoint.y, TempTime) then InitializeLastClick;
|
||||
|
||||
TempEvent.x := TempPoint.x;
|
||||
TempEvent.y := TempPoint.y;
|
||||
TempEvent.x := round(TempPoint.x);
|
||||
TempEvent.y := round(TempPoint.y);
|
||||
TempEvent.modifiers := GetCefMouseModifiers;
|
||||
chrmosr.SendMouseMoveEvent(@TempEvent, True);
|
||||
end;
|
||||
@ -480,12 +477,12 @@ var
|
||||
TempEvent : TCefMouseEvent;
|
||||
TempTime : integer;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and (chrmosr <> nil) and not(ssTouch in Shift) then
|
||||
if not(ssTouch in Shift) then
|
||||
begin
|
||||
if CancelPreviousClick(x, y, TempTime) then InitializeLastClick;
|
||||
|
||||
TempEvent.x := round(X);
|
||||
TempEvent.y := round(Y);
|
||||
TempEvent.x := round(x);
|
||||
TempEvent.y := round(y);
|
||||
TempEvent.modifiers := getModifiers(Shift);
|
||||
chrmosr.SendMouseMoveEvent(@TempEvent, False);
|
||||
end;
|
||||
@ -498,7 +495,7 @@ procedure TFMXExternalPumpBrowserFrm.Panel1MouseUp(Sender : TObject;
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) and (chrmosr <> nil) and not(ssTouch in Shift) then
|
||||
if not(ssTouch in Shift) then
|
||||
begin
|
||||
TempEvent.x := round(X);
|
||||
TempEvent.y := round(Y);
|
||||
@ -512,18 +509,14 @@ procedure TFMXExternalPumpBrowserFrm.Panel1MouseWheel( Sender : TObject;
|
||||
WheelDelta : Integer;
|
||||
var Handled : Boolean);
|
||||
var
|
||||
TempEvent : TCefMouseEvent;
|
||||
TempPoint : TPoint;
|
||||
TempPointF : TPointF;
|
||||
TempEvent : TCefMouseEvent;
|
||||
TempPoint : TPointF;
|
||||
begin
|
||||
if Panel1.IsFocused and (GlobalCEFApp <> nil) and (chrmosr <> nil) and GetMousePosition(TempPointF) then
|
||||
if Panel1.IsFocused and GetMousePosition(TempPoint) then
|
||||
begin
|
||||
TempPoint.x := round(TempPointF.x);
|
||||
TempPoint.y := round(TempPointF.y);
|
||||
TempPoint := Panel1.ScreenToClient(TempPoint);
|
||||
|
||||
TempEvent.x := TempPoint.x;
|
||||
TempEvent.y := TempPoint.y;
|
||||
TempPoint := Panel1.ScreenToClient(TempPoint);
|
||||
TempEvent.x := round(TempPoint.x);
|
||||
TempEvent.y := round(TempPoint.y);
|
||||
TempEvent.modifiers := getModifiers(Shift);
|
||||
chrmosr.SendMouseWheelEvent(@TempEvent, 0, WheelDelta);
|
||||
end;
|
||||
@ -552,8 +545,7 @@ begin
|
||||
chrmosr.SendFocusEvent(False);
|
||||
end;
|
||||
|
||||
procedure TFMXExternalPumpBrowserFrm.chrmosrAfterCreated(Sender: TObject;
|
||||
const browser: ICefBrowser);
|
||||
procedure TFMXExternalPumpBrowserFrm.chrmosrAfterCreated(Sender: TObject; const browser: ICefBrowser);
|
||||
begin
|
||||
// Now the browser is fully initialized we can enable the UI.
|
||||
Caption := 'FMX External Pump Browser';
|
||||
@ -611,24 +603,19 @@ procedure TFMXExternalPumpBrowserFrm.chrmosrGetScreenInfo( Sender : TOb
|
||||
var
|
||||
TempRect : TCEFRect;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
TempRect.x := 0;
|
||||
TempRect.y := 0;
|
||||
TempRect.width := round(Panel1.Width);
|
||||
TempRect.height := round(Panel1.Height);
|
||||
TempRect.x := 0;
|
||||
TempRect.y := 0;
|
||||
TempRect.width := round(Panel1.Width);
|
||||
TempRect.height := round(Panel1.Height);
|
||||
|
||||
screenInfo.device_scale_factor := GlobalCEFApp.DeviceScaleFactor;
|
||||
screenInfo.depth := 0;
|
||||
screenInfo.depth_per_component := 0;
|
||||
screenInfo.is_monochrome := Ord(False);
|
||||
screenInfo.rect := TempRect;
|
||||
screenInfo.available_rect := TempRect;
|
||||
screenInfo.device_scale_factor := Panel1.ScreenScale;
|
||||
screenInfo.depth := 0;
|
||||
screenInfo.depth_per_component := 0;
|
||||
screenInfo.is_monochrome := Ord(False);
|
||||
screenInfo.rect := TempRect;
|
||||
screenInfo.available_rect := TempRect;
|
||||
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
Result := False;
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TFMXExternalPumpBrowserFrm.chrmosrGetScreenPoint( Sender : TObject;
|
||||
@ -641,31 +628,23 @@ procedure TFMXExternalPumpBrowserFrm.chrmosrGetScreenPoint( Sender : TObje
|
||||
var
|
||||
TempScreenPt, TempViewPt : TPoint;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
// TFMXBufferPanel.ClientToScreen applies the scale factor. No need to call LogicalToDevice to set TempViewPt.
|
||||
TempViewPt.x := viewX;
|
||||
TempViewPt.y := viewY;
|
||||
TempScreenPt := Panel1.ClientToScreen(TempViewPt);
|
||||
screenX := TempScreenPt.x;
|
||||
screenY := TempScreenPt.y;
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
Result := False;
|
||||
// TFMXBufferPanel.ClientToScreen applies the scale factor. No need to call LogicalToDevice to set TempViewPt.
|
||||
TempViewPt.x := viewX;
|
||||
TempViewPt.y := viewY;
|
||||
TempScreenPt := Panel1.ClientToScreen(TempViewPt);
|
||||
screenX := TempScreenPt.x;
|
||||
screenY := TempScreenPt.y;
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TFMXExternalPumpBrowserFrm.chrmosrGetViewRect( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
var rect : TCefRect);
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
rect.x := 0;
|
||||
rect.y := 0;
|
||||
rect.width := round(Panel1.Width);
|
||||
rect.height := round(Panel1.Height);
|
||||
end;
|
||||
rect.x := 0;
|
||||
rect.y := 0;
|
||||
rect.width := round(Panel1.Width);
|
||||
rect.height := round(Panel1.Height);
|
||||
end;
|
||||
|
||||
procedure TFMXExternalPumpBrowserFrm.chrmosrPaint( Sender : TObject;
|
||||
@ -827,7 +806,7 @@ begin
|
||||
FShowPopUp := False;
|
||||
FPopUpRect := rect(0, 0, 0, 0);
|
||||
|
||||
if (chrmosr <> nil) then chrmosr.Invalidate(PET_VIEW);
|
||||
chrmosr.Invalidate(PET_VIEW);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -835,13 +814,10 @@ procedure TFMXExternalPumpBrowserFrm.chrmosrPopupSize( Sender : TObject;
|
||||
const browser : ICefBrowser;
|
||||
const rect : PCefRect);
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
FPopUpRect.Left := rect.x;
|
||||
FPopUpRect.Top := rect.y;
|
||||
FPopUpRect.Right := rect.x + rect.width - 1;
|
||||
FPopUpRect.Bottom := rect.y + rect.height - 1;
|
||||
end;
|
||||
FPopUpRect.Left := rect.x;
|
||||
FPopUpRect.Top := rect.y;
|
||||
FPopUpRect.Right := rect.x + rect.width - 1;
|
||||
FPopUpRect.Bottom := rect.y + rect.height - 1;
|
||||
end;
|
||||
|
||||
procedure TFMXExternalPumpBrowserFrm.chrmosrTooltip( Sender : TObject;
|
||||
@ -882,9 +858,10 @@ var
|
||||
PositionChanged: Boolean;
|
||||
begin
|
||||
PositionChanged := (ALeft <> Left) or (ATop <> Top);
|
||||
|
||||
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
|
||||
if PositionChanged then
|
||||
NotifyMoveOrResizeStarted;
|
||||
|
||||
if PositionChanged then NotifyMoveOrResizeStarted;
|
||||
end;
|
||||
|
||||
procedure TFMXExternalPumpBrowserFrm.NotifyMoveOrResizeStarted;
|
||||
|
@ -339,7 +339,7 @@ procedure TBrowserFrame.FMXBufferPanel1KeyDown(Sender: TObject; var Key: Word;
|
||||
var
|
||||
TempKeyEvent : TCefKeyEvent;
|
||||
begin
|
||||
if not(FMXBufferPanel1.IsFocused) or (FMXChromium1 = nil) then exit;
|
||||
if not(FMXBufferPanel1.IsFocused) then exit;
|
||||
|
||||
if (Key <> 0) and (KeyChar = #0) then
|
||||
begin
|
||||
@ -363,7 +363,7 @@ procedure TBrowserFrame.FMXBufferPanel1KeyUp(Sender: TObject; var Key: Word;
|
||||
var
|
||||
TempKeyEvent : TCefKeyEvent;
|
||||
begin
|
||||
if not(FMXBufferPanel1.IsFocused) or (FMXChromium1 = nil) then exit;
|
||||
if not(FMXBufferPanel1.IsFocused) then exit;
|
||||
|
||||
if (Key = 0) and (KeyChar <> #0) then
|
||||
begin
|
||||
@ -567,24 +567,19 @@ procedure TBrowserFrame.FMXChromium1GetScreenInfo(Sender: TObject;
|
||||
var
|
||||
TempRect : TCEFRect;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
TempRect.x := 0;
|
||||
TempRect.y := 0;
|
||||
TempRect.width := round(FMXBufferPanel1.Width);
|
||||
TempRect.height := round(FMXBufferPanel1.Height);
|
||||
TempRect.x := 0;
|
||||
TempRect.y := 0;
|
||||
TempRect.width := round(FMXBufferPanel1.Width);
|
||||
TempRect.height := round(FMXBufferPanel1.Height);
|
||||
|
||||
screenInfo.device_scale_factor := GlobalCEFApp.DeviceScaleFactor;
|
||||
screenInfo.depth := 0;
|
||||
screenInfo.depth_per_component := 0;
|
||||
screenInfo.is_monochrome := Ord(False);
|
||||
screenInfo.rect := TempRect;
|
||||
screenInfo.available_rect := TempRect;
|
||||
screenInfo.device_scale_factor := FMXBufferPanel1.ScreenScale;
|
||||
screenInfo.depth := 0;
|
||||
screenInfo.depth_per_component := 0;
|
||||
screenInfo.is_monochrome := Ord(False);
|
||||
screenInfo.rect := TempRect;
|
||||
screenInfo.available_rect := TempRect;
|
||||
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
Result := False;
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1GetScreenPoint(Sender: TObject;
|
||||
@ -593,30 +588,22 @@ procedure TBrowserFrame.FMXChromium1GetScreenPoint(Sender: TObject;
|
||||
var
|
||||
TempScreenPt, TempViewPt : TPoint;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
// TFMXBufferPanel.ClientToScreen applies the scale factor. No need to call LogicalToDevice to set TempViewPt.
|
||||
TempViewPt.x := viewX;
|
||||
TempViewPt.y := viewY;
|
||||
TempScreenPt := FMXBufferPanel1.ClientToScreen(TempViewPt);
|
||||
screenX := TempScreenPt.x;
|
||||
screenY := TempScreenPt.y;
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
Result := False;
|
||||
// TFMXBufferPanel.ClientToScreen applies the scale factor. No need to call LogicalToDevice to set TempViewPt.
|
||||
TempViewPt.x := viewX;
|
||||
TempViewPt.y := viewY;
|
||||
TempScreenPt := FMXBufferPanel1.ClientToScreen(TempViewPt);
|
||||
screenX := TempScreenPt.x;
|
||||
screenY := TempScreenPt.y;
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1GetViewRect(Sender: TObject;
|
||||
const browser: ICefBrowser; var rect: TCefRect);
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
rect.x := 0;
|
||||
rect.y := 0;
|
||||
rect.width := round(FMXBufferPanel1.Width);
|
||||
rect.height := round(FMXBufferPanel1.Height);
|
||||
end;
|
||||
rect.x := 0;
|
||||
rect.y := 0;
|
||||
rect.width := round(FMXBufferPanel1.Width);
|
||||
rect.height := round(FMXBufferPanel1.Height);
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1LoadError(Sender: TObject;
|
||||
@ -811,20 +798,17 @@ begin
|
||||
FShowPopUp := False;
|
||||
FPopUpRect := rect(0, 0, 0, 0);
|
||||
|
||||
if (FMXChromium1 <> nil) then FMXChromium1.Invalidate(PET_VIEW);
|
||||
FMXChromium1.Invalidate(PET_VIEW);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1PopupSize(Sender: TObject;
|
||||
const browser: ICefBrowser; const rect: PCefRect);
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) then
|
||||
begin
|
||||
FPopUpRect.Left := rect.x;
|
||||
FPopUpRect.Top := rect.y;
|
||||
FPopUpRect.Right := rect.x + LogicalToDevice(rect.width, GlobalCEFApp.DeviceScaleFactor) - 1;
|
||||
FPopUpRect.Bottom := rect.y + LogicalToDevice(rect.height, GlobalCEFApp.DeviceScaleFactor) - 1;
|
||||
end;
|
||||
FPopUpRect.Left := rect.x;
|
||||
FPopUpRect.Top := rect.y;
|
||||
FPopUpRect.Right := rect.x + rect.width - 1;
|
||||
FPopUpRect.Bottom := rect.y + rect.height - 1;
|
||||
end;
|
||||
|
||||
procedure TBrowserFrame.FMXChromium1StatusMessage(Sender: TObject;
|
||||
|
@ -21,7 +21,7 @@
|
||||
</CompilerOptions>
|
||||
<Description Value="CEF4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC."/>
|
||||
<License Value="MPL 1.1"/>
|
||||
<Version Major="80" Release="4"/>
|
||||
<Version Major="80" Release="5"/>
|
||||
<Files Count="147">
|
||||
<Item1>
|
||||
<Filename Value="..\source\uCEFAccessibilityHandler.pas"/>
|
||||
|
@ -62,13 +62,13 @@ uses
|
||||
const
|
||||
CEF_SUPPORTED_VERSION_MAJOR = 80;
|
||||
CEF_SUPPORTED_VERSION_MINOR = 0;
|
||||
CEF_SUPPORTED_VERSION_RELEASE = 4;
|
||||
CEF_SUPPORTED_VERSION_RELEASE = 5;
|
||||
CEF_SUPPORTED_VERSION_BUILD = 0;
|
||||
|
||||
CEF_CHROMEELF_VERSION_MAJOR = 80;
|
||||
CEF_CHROMEELF_VERSION_MINOR = 0;
|
||||
CEF_CHROMEELF_VERSION_RELEASE = 3987;
|
||||
CEF_CHROMEELF_VERSION_BUILD = 122;
|
||||
CEF_CHROMEELF_VERSION_BUILD = 132;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
LIBCEF_DLL = 'libcef.dll';
|
||||
|
@ -43,7 +43,7 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF MSWINDOWS}
|
||||
Winapi.Windows,
|
||||
Winapi.Windows, FMX.Platform.Win,
|
||||
{$ELSE}
|
||||
System.SyncObjs,
|
||||
{$ENDIF}
|
||||
@ -51,7 +51,8 @@ uses
|
||||
{$IFDEF DELPHI17_UP}
|
||||
FMX.Graphics,
|
||||
{$ENDIF}
|
||||
FMX.Types, FMX.Controls;
|
||||
FMX.Types, FMX.Controls, FMX.Forms,
|
||||
uCEFTypes;
|
||||
|
||||
type
|
||||
TDialogKeyEvent = procedure(Sender: TObject; var Key: Word; Shift: TShiftState) of object;
|
||||
@ -79,6 +80,8 @@ type
|
||||
function GetScreenScale : Single;
|
||||
function GetBufferWidth : integer;
|
||||
function GetBufferHeight : integer;
|
||||
function GetParentForm : TCustomForm;
|
||||
function GetParentFormHandle : TCefWindowHandle;
|
||||
|
||||
function CopyBuffer : boolean;
|
||||
function SaveBufferToFile(const aFilename : string) : boolean;
|
||||
@ -97,8 +100,10 @@ type
|
||||
procedure BufferDraw(x, y : integer; const aBitmap : TBitmap);
|
||||
function UpdateBufferDimensions(aWidth, aHeight : integer) : boolean;
|
||||
function BufferIsResized(aUseMutex : boolean = True) : boolean;
|
||||
function ScreenToClient(aPoint : TPoint) : TPoint;
|
||||
function ClientToScreen(aPoint : TPoint) : TPoint;
|
||||
function ScreenToClient(aPoint : TPoint) : TPoint; overload;
|
||||
function ScreenToClient(aPoint : TPointF) : TPointF; overload;
|
||||
function ClientToScreen(aPoint : TPoint) : TPoint; overload;
|
||||
function ClientToScreen(aPoint : TPointF) : TPointF; overload;
|
||||
|
||||
property Buffer : TBitmap read FBuffer;
|
||||
property ScanlineSize : integer read FScanlineSize;
|
||||
@ -155,6 +160,7 @@ implementation
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Math,
|
||||
{$IFDEF MSWINDOWS}FMX.Helpers.Win,{$ENDIF}
|
||||
FMX.Platform, uCEFMiscFunctions, uCEFApplicationCore;
|
||||
|
||||
constructor TFMXBufferPanel.Create(AOwner: TComponent);
|
||||
@ -281,6 +287,7 @@ var
|
||||
TempSrc, TempDst, TempClip : TRectF;
|
||||
TempState : TCanvasSaveState;
|
||||
TempWrongSize : boolean;
|
||||
TempScale : single;
|
||||
begin
|
||||
Result := False;
|
||||
TempWrongSize := False;
|
||||
@ -291,8 +298,9 @@ begin
|
||||
try
|
||||
if (FBuffer <> nil) then
|
||||
begin
|
||||
TempScale := ScreenScale;
|
||||
TempSrc := TRectF.Create(0, 0, FBuffer.Width, FBuffer.Height);
|
||||
TempDst := TRectF.Create(0, 0, FBuffer.Width / ScreenScale, FBuffer.Height / ScreenScale);
|
||||
TempDst := TRectF.Create(0, 0, FBuffer.Width / TempScale, FBuffer.Height / TempScale);
|
||||
TempClip := TRectF.Create(0, 0, Width, Height);
|
||||
|
||||
TempState := Canvas.SaveState;
|
||||
@ -341,12 +349,56 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TFMXBufferPanel.GetScreenScale : Single;
|
||||
function TFMXBufferPanel.GetParentForm : TCustomForm;
|
||||
var
|
||||
TempComp : TComponent;
|
||||
begin
|
||||
if (GlobalCEFApp <> nil) then
|
||||
Result := GlobalCEFApp.DeviceScaleFactor
|
||||
Result := nil;
|
||||
TempComp := Owner;
|
||||
|
||||
while (TempComp <> nil) do
|
||||
if (TempComp is TCustomForm) then
|
||||
begin
|
||||
Result := TCustomForm(TempComp);
|
||||
exit;
|
||||
end
|
||||
else
|
||||
TempComp := TempComp.owner;
|
||||
end;
|
||||
|
||||
function TFMXBufferPanel.GetParentFormHandle : TCefWindowHandle;
|
||||
{$IFDEF MSWINDOWS}
|
||||
var
|
||||
TempForm : TCustomForm;
|
||||
{$ENDIF}
|
||||
begin
|
||||
Result := 0;
|
||||
|
||||
{$IFDEF MSWINDOWS}
|
||||
TempForm := GetParentForm;
|
||||
|
||||
if (TempForm <> nil) then
|
||||
Result := FmxHandleToHWND(TempForm.Handle)
|
||||
else
|
||||
Result := 1;
|
||||
if (Application <> nil) and
|
||||
(Application.MainForm <> nil) then
|
||||
Result := FmxHandleToHWND(Application.MainForm.Handle);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function TFMXBufferPanel.GetScreenScale : Single;
|
||||
var
|
||||
TempHandle : TCefWindowHandle;
|
||||
begin
|
||||
TempHandle := GetParentFormHandle;
|
||||
|
||||
if (TempHandle <> 0) then
|
||||
Result := GetWndScale(TempHandle)
|
||||
else
|
||||
if (GlobalCEFApp <> nil) then
|
||||
Result := GlobalCEFApp.DeviceScaleFactor
|
||||
else
|
||||
Result := 1;
|
||||
end;
|
||||
|
||||
function TFMXBufferPanel.GetBufferWidth : integer;
|
||||
@ -368,11 +420,13 @@ end;
|
||||
procedure TFMXBufferPanel.BufferDraw(x, y : integer; const aBitmap : TBitmap);
|
||||
var
|
||||
TempSrc, TempDst : TRectF;
|
||||
TempScale : single;
|
||||
begin
|
||||
if (FBuffer <> nil) then
|
||||
begin
|
||||
TempSrc := TRectF.Create(0, 0, aBitmap.Width, aBitmap.Height);
|
||||
TempDst := TRectF.Create(x, y, x + (aBitmap.Width / ScreenScale), y + (aBitmap.Height / ScreenScale));
|
||||
TempScale := ScreenScale;
|
||||
TempSrc := TRectF.Create(0, 0, aBitmap.Width, aBitmap.Height);
|
||||
TempDst := TRectF.Create(x, y, x + (aBitmap.Width / TempScale), y + (aBitmap.Height / TempScale));
|
||||
|
||||
if FBuffer.Canvas.BeginScene then
|
||||
try
|
||||
@ -384,18 +438,22 @@ begin
|
||||
end;
|
||||
|
||||
function TFMXBufferPanel.UpdateBufferDimensions(aWidth, aHeight : integer) : boolean;
|
||||
var
|
||||
TempScale : single;
|
||||
begin
|
||||
Result := False;
|
||||
TempScale := ScreenScale;
|
||||
|
||||
if ((FBuffer = nil) or
|
||||
(FBuffer.Width <> aWidth) or
|
||||
(FBuffer.Height <> aHeight)) then
|
||||
if ((FBuffer = nil) or
|
||||
(FBuffer.BitmapScale <> TempScale) or
|
||||
(FBuffer.Width <> aWidth) or
|
||||
(FBuffer.Height <> aHeight)) then
|
||||
begin
|
||||
if (FBuffer <> nil) then FreeAndNil(FBuffer);
|
||||
|
||||
FBuffer := TBitmap.Create(aWidth, aHeight);
|
||||
{$IFDEF DELPHI17_UP}
|
||||
FBuffer.BitmapScale := ScreenScale;
|
||||
FBuffer.BitmapScale := TempScale;
|
||||
FScanlineSize := FBuffer.BytesPerLine;
|
||||
{$ELSE}
|
||||
FScanlineSize := aWidth * SizeOf(TRGBQuad);
|
||||
@ -407,18 +465,20 @@ end;
|
||||
function TFMXBufferPanel.BufferIsResized(aUseMutex : boolean) : boolean;
|
||||
var
|
||||
TempWidth, TempHeight : integer;
|
||||
TempScale : single;
|
||||
begin
|
||||
Result := False;
|
||||
if (GlobalCEFApp = nil) then exit;
|
||||
|
||||
if not(aUseMutex) or BeginBufferDraw then
|
||||
begin
|
||||
TempWidth := round(Width * GlobalCEFApp.DeviceScaleFactor);
|
||||
TempHeight := round(Height * GlobalCEFApp.DeviceScaleFactor);
|
||||
TempScale := ScreenScale;
|
||||
TempWidth := round(Width * TempScale);
|
||||
TempHeight := round(Height * TempScale);
|
||||
|
||||
Result := (FBuffer <> nil) and
|
||||
(FBuffer.Width = TempWidth) and
|
||||
(FBuffer.Height = TempHeight);
|
||||
(FBuffer.BitmapScale = TempScale) and
|
||||
(FBuffer.Width = TempWidth) and
|
||||
(FBuffer.Height = TempHeight);
|
||||
|
||||
if aUseMutex then EndBufferDraw;
|
||||
end;
|
||||
@ -435,6 +495,11 @@ begin
|
||||
Result.y := round(TempPoint.y);
|
||||
end;
|
||||
|
||||
function TFMXBufferPanel.ScreenToClient(aPoint : TPointF) : TPointF;
|
||||
begin
|
||||
Result := ScreenToLocal(aPoint);
|
||||
end;
|
||||
|
||||
function TFMXBufferPanel.ClientToScreen(aPoint : TPoint) : TPoint;
|
||||
var
|
||||
TempPoint : TPointF;
|
||||
@ -446,4 +511,9 @@ begin
|
||||
Result.y := round(TempPoint.y);
|
||||
end;
|
||||
|
||||
function TFMXBufferPanel.ClientToScreen(aPoint : TPointF) : TPointF;
|
||||
begin
|
||||
Result := LocalToScreen(aPoint);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -2,9 +2,9 @@
|
||||
"UpdateLazPackages" : [
|
||||
{
|
||||
"ForceNotify" : true,
|
||||
"InternalVersion" : 105,
|
||||
"InternalVersion" : 106,
|
||||
"Name" : "cef4delphi_lazarus.lpk",
|
||||
"Version" : "80.0.4.0"
|
||||
"Version" : "80.0.5.0"
|
||||
}
|
||||
],
|
||||
"UpdatePackageData" : {
|
||||
|
Loading…
x
Reference in New Issue
Block a user