mirror of
https://github.com/salvadordf/CEF4Delphi.git
synced 2024-11-15 15:55:56 +01:00
Fixed colors in FMXExternalPumpBrowser for MacOS
Added functions to copy the CEF binaries and the CEF helpers automatically to FMXExternalPumpBrowser for MacOS Added TFMXBufferPanel.OnResized Added more comments with missing functionality in Linux and MacOS
This commit is contained in:
parent
76fc979882
commit
fec1b3be79
@ -47,11 +47,25 @@ uses
|
||||
uCEFApplication,
|
||||
uCEFFMXWorkScheduler,
|
||||
uFMXExternalPumpBrowser in 'uFMXExternalPumpBrowser.pas' {FMXExternalPumpBrowserFrm},
|
||||
uFMXApplicationService in 'uFMXApplicationService.pas';
|
||||
uFMXApplicationService in 'uFMXApplicationService.pas',
|
||||
uFMXMiscFunctions in 'uFMXMiscFunctions.pas';
|
||||
|
||||
{$R *.res}
|
||||
|
||||
begin
|
||||
{$IFDEF DEBUG}
|
||||
// Copy the CEF framework and the CEF helpers locally instead of deploying
|
||||
// them to debug faster.
|
||||
// Copy the "Chromium Embedded Framework.framework" directory into the same
|
||||
// directory where this project is deployed on the Mac.
|
||||
// The 4 "helper" projects in this group should also be deployed in the same
|
||||
// directory as this project.
|
||||
// CopyCEFHelpers requires that the helper projects end with "_helper",
|
||||
// "_helper_gpu", "_helper_plugin" and "_helper_renderer".
|
||||
CopyCEFFramework;
|
||||
CopyCEFHelpers('FMXExternalPumpBrowser');
|
||||
{$ENDIF}
|
||||
|
||||
CreateGlobalCEFApp;
|
||||
|
||||
if GlobalCEFApp.StartMainProcess then
|
||||
|
@ -160,6 +160,7 @@
|
||||
<Form>FMXExternalPumpBrowserFrm</Form>
|
||||
</DCCReference>
|
||||
<DCCReference Include="uFMXApplicationService.pas"/>
|
||||
<DCCReference Include="uFMXMiscFunctions.pas"/>
|
||||
<BuildConfiguration Include="Release">
|
||||
<Key>Cfg_2</Key>
|
||||
<CfgParent>Base</CfgParent>
|
||||
|
@ -88,7 +88,6 @@ object FMXExternalPumpBrowserFrm: TFMXExternalPumpBrowserFrm
|
||||
object Panel1: TFMXBufferPanel
|
||||
Align = Client
|
||||
TabOrder = 0
|
||||
Color = claTomato
|
||||
CanFocus = True
|
||||
Size.Width = 800.000000000000000000
|
||||
Size.Height = 600.000000000000000000
|
||||
|
@ -167,13 +167,12 @@ type
|
||||
var
|
||||
FMXExternalPumpBrowserFrm : TFMXExternalPumpBrowserFrm;
|
||||
|
||||
// ***************************************************************************
|
||||
// ********************************* WARNING *********************************
|
||||
// ***************************************************************************
|
||||
// This demo is in ALFA state. It's incomplete and some features may not work!
|
||||
// ***************************************************************************
|
||||
// ****************************************************************************
|
||||
// ********************************* WARNING **********************************
|
||||
// ****************************************************************************
|
||||
// This demo is in ALPHA state. It's incomplete and some features may not work!
|
||||
// ****************************************************************************
|
||||
// Known issues and missing features :
|
||||
// - Wrong colors : Red and blue channels are swapped.
|
||||
// - Keyboard support not implemented yet.
|
||||
// - Maximize event is not handled correctly.
|
||||
// - Missing CrAppProtocol implementation in NSApplication. The original file in
|
||||
@ -781,20 +780,22 @@ begin
|
||||
TempBufferBits := TempBitmapData.GetScanline(dirtyRects[n].y + i);
|
||||
dst := @PByte(TempBufferBits)[TempDstOffset];
|
||||
{$ENDIF}
|
||||
{
|
||||
|
||||
srcPixel := src;
|
||||
dstPixel := dst;
|
||||
k := TempLineSize;
|
||||
k := TempLineSize div SizeOf(TRGBQuad);
|
||||
|
||||
while (k > 0) do
|
||||
begin
|
||||
PCardinal(dstPixel)^ := (srcPixel[0] shl 24) or (srcPixel[1] shl 16) or (srcPixel[2] shl 8) or srcPixel[3];
|
||||
// Switch the red and blue channels
|
||||
dstPixel[0] := srcPixel[2];
|
||||
dstPixel[1] := srcPixel[1];
|
||||
dstPixel[2] := srcPixel[0];
|
||||
dstPixel[3] := srcPixel[3];
|
||||
inc(dstPixel, SizeOf(TRGBQuad));
|
||||
inc(srcPixel, SizeOf(TRGBQuad));
|
||||
dec(k);
|
||||
end; }
|
||||
|
||||
Move(src^, dst^, TempLineSize);
|
||||
end;
|
||||
|
||||
{$IFNDEF DELPHI17_UP}
|
||||
inc(dst, DstStride);
|
||||
|
@ -0,0 +1,218 @@
|
||||
// ************************************************************************
|
||||
// ***************************** CEF4Delphi *******************************
|
||||
// ************************************************************************
|
||||
//
|
||||
// CEF4Delphi is based on DCEF3 which uses CEF to embed a chromium-based
|
||||
// browser in Delphi applications.
|
||||
//
|
||||
// The original license of DCEF3 still applies to CEF4Delphi.
|
||||
//
|
||||
// For more information about CEF4Delphi visit :
|
||||
// https://www.briskbard.com/index.php?lang=en&pageid=cef
|
||||
//
|
||||
// Copyright © 2021 Salvador Diaz Fau. All rights reserved.
|
||||
//
|
||||
// ************************************************************************
|
||||
// ************ vvvv Original license and comments below vvvv *************
|
||||
// ************************************************************************
|
||||
(*
|
||||
* Delphi Chromium Embedded 3
|
||||
*
|
||||
* Usage allowed under the restrictions of the Lesser GNU General Public License
|
||||
* or alternatively the restrictions of the Mozilla Public License 1.1
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
* the specific language governing rights and limitations under the License.
|
||||
*
|
||||
* Unit owner : Henri Gourvest <hgourvest@gmail.com>
|
||||
* Web site : http://www.progdigy.com
|
||||
* Repository : http://code.google.com/p/delphichromiumembedded/
|
||||
* Group : http://groups.google.com/group/delphichromiumembedded
|
||||
*
|
||||
* Embarcadero Technologies, Inc is not permitted to use or redistribute
|
||||
* this source code without explicit permission.
|
||||
*
|
||||
*)
|
||||
|
||||
unit uFMXMiscFunctions;
|
||||
|
||||
interface
|
||||
|
||||
procedure CopyCEFFramework;
|
||||
procedure CopyCEFHelpers(const aProjectName : string);
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
System.SysUtils, System.Types, System.IOUtils, Posix.Stdio,
|
||||
uCEFMiscFunctions;
|
||||
|
||||
const
|
||||
PRJ_HELPER_SUBFIX = '_helper';
|
||||
PRJ_GPU_SUBFIX = '_helper_gpu';
|
||||
PRJ_PLUGIN_SUBFIX = '_helper_plugin';
|
||||
PRJ_RENDERER_SUBFIX = '_helper_renderer';
|
||||
HELPER_SUBFIX = ' Helper';
|
||||
GPU_SUBFIX = ' Helper (GPU)';
|
||||
PLUGIN_SUBFIX = ' Helper (Plugin)';
|
||||
RENDERER_SUBFIX = ' Helper (Renderer)';
|
||||
|
||||
procedure CopyAllFiles(const aSrcPath, aDstPath: string);
|
||||
var
|
||||
TempDirectories, TempFiles : TStringDynArray;
|
||||
i : integer;
|
||||
TempNewDstPath, TempSrcFile, TempDstFile : string;
|
||||
begin
|
||||
try
|
||||
TempDirectories := TDirectory.GetDirectories(aSrcPath);
|
||||
|
||||
for i := 0 to pred(Length(TempDirectories)) do
|
||||
begin
|
||||
TempNewDstPath := aDstPath + TempDirectories[i].Substring(TDirectory.GetParent(TempDirectories[i]).Length);
|
||||
|
||||
if not(TDirectory.Exists(TempNewDstPath)) then
|
||||
TDirectory.CreateDirectory(TempNewDstPath);
|
||||
|
||||
CopyAllFiles(TempDirectories[i], TempNewDstPath);
|
||||
end;
|
||||
|
||||
TempFiles := TDirectory.GetFiles(aSrcPath);
|
||||
|
||||
for i := 0 to pred(Length(TempFiles)) do
|
||||
begin
|
||||
TempSrcFile := TempFiles[i];
|
||||
TempDstFile := aDstPath + TPath.DirectorySeparatorChar + TPath.GetFileName(TempFiles[i]);
|
||||
TFile.Copy(TempSrcFile, TempDstFile);
|
||||
TFile.SetAttributes(TempDstFile, TFile.GetAttributes(TempSrcFile));
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
WriteLn('CopyAllFiles error : ' + e.Message);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CopyCEFFramework;
|
||||
const
|
||||
CEF_FRAMEWORK_DIR = 'Chromium Embedded Framework.framework';
|
||||
var
|
||||
appFrameworksPath, dstCEFPath, srcCEFPath : string;
|
||||
begin
|
||||
try
|
||||
appFrameworksPath := TDirectory.GetParent(ExtractFileDir(ParamStr(0))) + TPath.DirectorySeparatorChar + 'Frameworks';
|
||||
dstCEFPath := appFrameworksPath + TPath.DirectorySeparatorChar + CEF_FRAMEWORK_DIR;
|
||||
srcCEFPath := TDirectory.GetParent(GetModulePath) + TPath.DirectorySeparatorChar + CEF_FRAMEWORK_DIR;
|
||||
|
||||
if not(TDirectory.Exists(appFrameworksPath)) then
|
||||
TDirectory.CreateDirectory(appFrameworksPath);
|
||||
|
||||
if TDirectory.Exists(srcCEFPath) and
|
||||
not(TDirectory.Exists(dstCEFPath)) then
|
||||
begin
|
||||
TDirectory.CreateDirectory(dstCEFPath);
|
||||
CopyAllFiles(srcCEFPath, dstCEFPath);
|
||||
end;
|
||||
except
|
||||
on e : exception do
|
||||
WriteLn('CopyCEFFramework error : ' + e.Message);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure RenameCEFHelper(const aHelperPrjPath : string);
|
||||
var
|
||||
appBundleName, appBundlePath, appNewBundlePath, appExecutable, appExecPath,
|
||||
appNewName, appOldSubfix, appNewSubfix : string;
|
||||
begin
|
||||
try
|
||||
appBundleName := TPath.GetFileNameWithoutExtension(aHelperPrjPath);
|
||||
|
||||
if appBundleName.EndsWith(PRJ_HELPER_SUBFIX) then
|
||||
begin
|
||||
appOldSubfix := PRJ_HELPER_SUBFIX;
|
||||
appNewSubfix := HELPER_SUBFIX;
|
||||
end
|
||||
else
|
||||
if appBundleName.EndsWith(PRJ_GPU_SUBFIX) then
|
||||
begin
|
||||
appOldSubfix := PRJ_GPU_SUBFIX;
|
||||
appNewSubfix := GPU_SUBFIX;
|
||||
end
|
||||
else
|
||||
if appBundleName.EndsWith(PRJ_PLUGIN_SUBFIX) then
|
||||
begin
|
||||
appOldSubfix := PRJ_PLUGIN_SUBFIX;
|
||||
appNewSubfix := PLUGIN_SUBFIX;
|
||||
end
|
||||
else
|
||||
if appBundleName.EndsWith(PRJ_RENDERER_SUBFIX) then
|
||||
begin
|
||||
appOldSubfix := PRJ_RENDERER_SUBFIX;
|
||||
appNewSubfix := RENDERER_SUBFIX;
|
||||
end
|
||||
else
|
||||
exit;
|
||||
|
||||
appBundlePath := TPath.GetDirectoryName(aHelperPrjPath);
|
||||
appExecPath := aHelperPrjPath + TPath.DirectorySeparatorChar +
|
||||
'Contents' + TPath.DirectorySeparatorChar +
|
||||
'MacOS' + TPath.DirectorySeparatorChar;
|
||||
appNewName := appBundleName.Remove(appBundleName.LastIndexOf(appOldSubfix)) +
|
||||
appNewSubfix;
|
||||
appExecutable := appExecPath + TPath.DirectorySeparatorChar + appBundleName;
|
||||
|
||||
if TFile.Exists(appExecutable) then
|
||||
begin
|
||||
RenameFile(appExecutable, appExecPath + TPath.DirectorySeparatorChar + appNewName);
|
||||
appNewBundlePath := appBundlePath + TPath.DirectorySeparatorChar + appNewName + '.app';
|
||||
|
||||
if TDirectory.Exists(appNewBundlePath) then
|
||||
TDirectory.Delete(appNewBundlePath, True);
|
||||
|
||||
RenameFile(aHelperPrjPath, appNewBundlePath);
|
||||
end;
|
||||
except
|
||||
on e: exception do
|
||||
WriteLn('RenameCEFHelper error : ' + e.Message);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CopyCEFHelpers(const aProjectName : string);
|
||||
const
|
||||
projectSubfixes : array [0..3] of string = (PRJ_HELPER_SUBFIX, PRJ_GPU_SUBFIX, PRJ_PLUGIN_SUBFIX, PRJ_RENDERER_SUBFIX);
|
||||
helperSubfixes : array [0..3] of string = (HELPER_SUBFIX, GPU_SUBFIX, PLUGIN_SUBFIX, RENDERER_SUBFIX);
|
||||
var
|
||||
appParentPath, appFrameworksPath : string;
|
||||
srcBundlePath, dstBundlePath : string;
|
||||
helperBundlePath, prjBundleName, helperBundleName : string;
|
||||
i : integer;
|
||||
begin
|
||||
appParentPath := TDirectory.GetParent(GetModulePath);
|
||||
appFrameworksPath := TDirectory.GetParent(ExtractFileDir(ParamStr(0))) + TPath.DirectorySeparatorChar + 'Frameworks';
|
||||
|
||||
for i := 0 to 3 do
|
||||
begin
|
||||
prjBundleName := aProjectName + projectSubfixes[i] + '.app';
|
||||
helperBundleName := aProjectName + helperSubfixes[i] + '.app';
|
||||
|
||||
srcBundlePath := appParentPath + TPath.DirectorySeparatorChar + prjBundleName;
|
||||
dstBundlePath := appFrameworksPath + TPath.DirectorySeparatorChar + prjBundleName;
|
||||
helperBundlePath := appFrameworksPath + TPath.DirectorySeparatorChar + helperBundleName;
|
||||
|
||||
if TDirectory.Exists(srcBundlePath) then
|
||||
begin
|
||||
if TDirectory.Exists(dstBundlePath) then
|
||||
TDirectory.Delete(dstBundlePath, True);
|
||||
|
||||
if not(TDirectory.Exists(helperBundlePath)) or
|
||||
(TDirectory.GetCreationTimeUtc(srcBundlePath) > TDirectory.GetCreationTimeUtc(helperBundlePath)) then
|
||||
begin
|
||||
CopyAllFiles(srcBundlePath, dstBundlePath);
|
||||
RenameCEFHelper(dstBundlePath);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
end.
|
@ -406,7 +406,7 @@ type
|
||||
property NoSandbox : Boolean read FNoSandbox write FNoSandbox;
|
||||
property BrowserSubprocessPath : ustring read FBrowserSubprocessPath write SetBrowserSubprocessPath;
|
||||
property FrameworkDirPath : ustring read FFrameworkDirPath write SetFrameworkDirPath;
|
||||
property MainBundlePath : ustring read FMainBundlePath write FMainBundlePath; // Only used in macOS
|
||||
property MainBundlePath : ustring read FMainBundlePath write FMainBundlePath; // Only used in macOS
|
||||
property ChromeRuntime : boolean read FChromeRuntime write FChromeRuntime;
|
||||
property MultiThreadedMessageLoop : boolean read FMultiThreadedMessageLoop write FMultiThreadedMessageLoop;
|
||||
property ExternalMessagePump : boolean read FExternalMessagePump write FExternalMessagePump;
|
||||
@ -1480,13 +1480,13 @@ begin
|
||||
|
||||
TempThread := TCEFDirectoryDeleterThread.Create(TempNewDir);
|
||||
{$IFDEF DELPHI14_UP}
|
||||
TempThread.Start;
|
||||
TempThread.Start;
|
||||
{$ELSE}
|
||||
{$IFNDEF FPC}
|
||||
TempThread.Resume;
|
||||
{$ELSE}
|
||||
TempThread.Start;
|
||||
{$ENDIF}
|
||||
{$IFNDEF FPC}
|
||||
TempThread.Resume;
|
||||
{$ELSE}
|
||||
TempThread.Start;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
end
|
||||
else
|
||||
@ -1537,14 +1537,24 @@ begin
|
||||
begin
|
||||
{$IFDEF MSWINDOWS}
|
||||
MessageBox(0, PChar(aError + #0), PChar('Error' + #0), MB_ICONERROR or MB_OK or MB_TOPMOST);
|
||||
{$ELSE}
|
||||
{$IFDEF LINUX}
|
||||
{$IFDEF FPC}
|
||||
if (WidgetSet <> nil) then
|
||||
Application.MessageBox(PChar(aError + #0), PChar('Error' + #0), MB_ICONERROR or MB_OK)
|
||||
else
|
||||
ShowX11Message(aError);
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
{$IFDEF FPC}
|
||||
if (WidgetSet <> nil) then
|
||||
Application.MessageBox(PChar(aError + #0), PChar('Error' + #0), MB_ICONERROR or MB_OK)
|
||||
else
|
||||
ShowX11Message(aError);
|
||||
{$ELSE}
|
||||
// TO-DO: Find a way to show message boxes in FMXLinux
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF MACOSX}
|
||||
{$IFDEF FPC}
|
||||
// TO-DO: Find a way to show message boxes in Lazarus/FPC for MacOS
|
||||
{$ELSE}
|
||||
// TO-DO: Find a way to show message boxes in FMX for MacOS
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
@ -136,6 +136,7 @@ type
|
||||
property RotationCenter;
|
||||
property Scale;
|
||||
property Size;
|
||||
property OnResized;
|
||||
{$ENDIF}
|
||||
{$IFNDEF DELPHI23_UP}
|
||||
property Hint;
|
||||
|
@ -945,6 +945,21 @@ begin
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$IFDEF LINUX}
|
||||
{$IFDEF FPC}
|
||||
// TO-DO: Find a way to write in the error console using Lazarus in Linux
|
||||
{$ELSE}
|
||||
// TO-DO: Find a way to write in the error console using FMXLinux
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$IFDEF MACOSX}
|
||||
{$IFDEF FPC}
|
||||
// TO-DO: Find a way to write in the error console using Lazarus in MacOS
|
||||
{$ELSE}
|
||||
// TO-DO: Find a way to write in the error console using FMX for MacOS
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
if (GlobalCEFApp <> nil) and GlobalCEFApp.LibLoaded then
|
||||
CefLog('CEF4Delphi', DEFAULT_LINE, CEF_LOG_SEVERITY_ERROR, aMessage);
|
||||
{$ENDIF}
|
||||
|
Loading…
Reference in New Issue
Block a user