From ab8d8ec53ec37b7493c488395d3f0f19aff52d23 Mon Sep 17 00:00:00 2001 From: salvadordf Date: Sun, 1 Jan 2023 18:17:22 +0100 Subject: [PATCH] Fixed screen scale issue in SimpleFMXBrowser Added a status bar to SimpleFMXBrowser and FMXTabbedBrowser --- .../FMXTabbedBrowser/FMXTabbedBrowser.dproj | 385 +++------------ .../FMXTabbedBrowser/uBrowserFrame.fmx | 23 +- .../FMXTabbedBrowser/uBrowserFrame.pas | 35 +- .../SimpleFMXBrowser/SimpleFMXBrowser.dproj | 465 ++++-------------- .../SimpleFMXBrowser/uSimpleFMXBrowser.fmx | 28 +- .../SimpleFMXBrowser/uSimpleFMXBrowser.pas | 35 +- source/uCEFFMXWindowParent.pas | 30 +- update_CEF4Delphi.json | 2 +- 8 files changed, 278 insertions(+), 725 deletions(-) diff --git a/demos/Delphi_FMX_Windows/FMXTabbedBrowser/FMXTabbedBrowser.dproj b/demos/Delphi_FMX_Windows/FMXTabbedBrowser/FMXTabbedBrowser.dproj index 0bd8a9bd..17baf105 100644 --- a/demos/Delphi_FMX_Windows/FMXTabbedBrowser/FMXTabbedBrowser.dproj +++ b/demos/Delphi_FMX_Windows/FMXTabbedBrowser/FMXTabbedBrowser.dproj @@ -1,7 +1,7 @@  {7AA2E07C-ACFB-4174-A9F1-083E9BB483BC} - 19.4 + 19.5 FMX FMXTabbedBrowser.dpr True @@ -28,6 +28,11 @@ Base true + + true + Base + true + true Base @@ -175,6 +180,31 @@ $(BDS)\bin\Artwork\iOS\iPad\FM_SettingIcon_58x58.png $(BDS)\bin\Artwork\iOS\iPad\FM_NotificationIcon_40x40.png + + CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false;NSBluetoothAlwaysUsageDescription=The reason for accessing bluetooth;NSBluetoothPeripheralUsageDescription=The reason for accessing bluetooth peripherals;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSMotionUsageDescription=The reason for accessing the accelerometer;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple's speech recognition servers + iPhoneAndiPad + true + $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_1024x1024.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_120x120.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_180x180.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImage_2x.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImageDark_2x.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImage_3x.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImageDark_3x.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_80x80.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_120x120.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_SettingIcon_58x58.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_SettingIcon_87x87.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_NotificationIcon_40x40.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_NotificationIcon_60x60.png + $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_152x152.png + $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_167x167.png + $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImage_2x.png + $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImageDark_2x.png + $(BDS)\bin\Artwork\iOS\iPad\FM_SpotlightSearchIcon_80x80.png + $(BDS)\bin\Artwork\iOS\iPad\FM_SettingIcon_58x58.png + $(BDS)\bin\Artwork\iOS\iPad\FM_NotificationIcon_40x40.png + CFBundleName=$(MSBuildProjectName);CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);NSHighResolutionCapable=true;LSApplicationCategoryType=public.app-category.utilities;NSLocationUsageDescription=The reason for accessing the location information of the user;NSContactsUsageDescription=The reason for accessing the contacts;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSCameraUsageDescription=The reason for accessing the camera;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSMotionUsageDescription=The reason for accessing the accelerometer;NSDesktopFolderUsageDescription=The reason for accessing the Desktop folder;NSDocumentsFolderUsageDescription=The reason for accessing the Documents folder;NSDownloadsFolderUsageDescription=The reason for accessing the Downloads folder;NSNetworkVolumesUsageDescription=The reason for accessing files on a network volume;NSRemovableVolumesUsageDescription=The reason for accessing files on a removable volume;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple's speech recognition servers Debug @@ -279,7 +309,7 @@ Microsoft Office XP Sample Automation Server Wrapper Components - + true @@ -295,12 +325,7 @@ true - - - FMXTabbedBrowser.exe - true - - + 1 @@ -323,16 +348,6 @@ 64 - - - classes - 1 - - - classes - 1 - - res\xml @@ -642,7 +657,7 @@ 1 .dylib - + 1 .dylib @@ -675,7 +690,7 @@ 1 .dylib - + 1 .dylib @@ -712,7 +727,7 @@ 0 - + 0 @@ -736,13 +751,17 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -752,137 +771,27 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -892,7 +801,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -902,7 +811,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -912,7 +821,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -922,7 +831,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -932,191 +841,37 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -1126,7 +881,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -1136,7 +891,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1146,7 +901,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1156,7 +911,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1166,7 +921,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1176,7 +931,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1186,7 +941,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1208,12 +963,8 @@ ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - - - - 1 - - + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 @@ -1226,6 +977,10 @@ ..\ 1 + + ..\ + 1 + @@ -1234,7 +989,7 @@ 1 - + 1 @@ -1243,7 +998,7 @@ ..\$(PROJECTNAME).launchscreen 64 - + ..\$(PROJECTNAME).launchscreen 64 @@ -1255,7 +1010,7 @@ 1 - + 1 @@ -1326,7 +1081,7 @@ 1 - + 1 @@ -1386,6 +1141,7 @@ + @@ -1398,6 +1154,7 @@ False False False + False False False True diff --git a/demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.fmx b/demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.fmx index c1d84a56..4e12749e 100644 --- a/demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.fmx +++ b/demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.fmx @@ -94,7 +94,7 @@ object BrowserFrame: TBrowserFrame object WindowParentLay: TLayout Align = Client Size.Width = 998.000000000000000000 - Size.Height = 696.000000000000000000 + Size.Height = 674.000000000000000000 Size.PlatformDefault = False TabOrder = 4 OnResize = WindowParentLayResize @@ -107,12 +107,33 @@ object BrowserFrame: TBrowserFrame TabOrder = 0 end end + object StatusBar1: TStatusBar + Padding.Left = 3.000000000000000000 + Padding.Top = 3.000000000000000000 + Padding.Right = 30.000000000000000000 + Padding.Bottom = 3.000000000000000000 + Position.X = 1.000000000000000000 + Position.Y = 710.000000000000000000 + ShowSizeGrip = True + Size.Width = 998.000000000000000000 + Size.Height = 22.000000000000000000 + Size.PlatformDefault = False + TabOrder = 1 + object StatusLbl: TLabel + Align = Client + Size.Width = 965.000000000000000000 + Size.Height = 16.000000000000000000 + Size.PlatformDefault = False + TabOrder = 0 + end + end object FMXChromium1: TFMXChromium OnLoadError = FMXChromium1LoadError OnLoadingStateChange = FMXChromium1LoadingStateChange OnGotFocus = FMXChromium1GotFocus OnAddressChange = FMXChromium1AddressChange OnTitleChange = FMXChromium1TitleChange + OnStatusMessage = FMXChromium1StatusMessage OnBeforePopup = FMXChromium1BeforePopup OnAfterCreated = FMXChromium1AfterCreated OnBeforeClose = FMXChromium1BeforeClose diff --git a/demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.pas b/demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.pas index f9255092..3e8ccc0d 100644 --- a/demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.pas +++ b/demos/Delphi_FMX_Windows/FMXTabbedBrowser/uBrowserFrame.pas @@ -64,6 +64,8 @@ type URLEdt: TEdit; WindowParentLay: TLayout; FocusWorkaroundBtn: TButton; + StatusBar1: TStatusBar; + StatusLbl: TLabel; procedure BackBtnClick(Sender: TObject); procedure ForwardBtnClick(Sender: TObject); @@ -82,6 +84,8 @@ type procedure FMXChromium1LoadingStateChange(Sender: TObject; const browser: ICefBrowser; isLoading, canGoBack, canGoForward: Boolean); procedure FMXChromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring); procedure FMXChromium1GotFocus(Sender: TObject; const browser: ICefBrowser); + procedure FMXChromium1StatusMessage(Sender: TObject; + const browser: ICefBrowser; const value: ustring); protected FClosing : boolean; // Indicates that this frame is destroying the browser @@ -143,14 +147,12 @@ end; function TBrowserFrame.GetFMXWindowParentRect : TRect; var TempPoint : TPointF; - TempScale : single; begin - TempScale := FMXChromium1.ScreenScale; TempPoint := LocalToAbsolute(WindowParentLay.Position.Point); Result.Left := round(TempPoint.x); Result.Top := round(TempPoint.y); - Result.Right := round(TempPoint.x + (WindowParentLay.Width * TempScale)); - Result.Bottom := round(TempPoint.y + (WindowParentLay.Height * TempScale)); + Result.Right := round(TempPoint.x + WindowParentLay.Width); + Result.Bottom := round(TempPoint.y + WindowParentLay.Height); end; procedure TBrowserFrame.ReloadBtnClick(Sender: TObject); @@ -161,7 +163,10 @@ end; procedure TBrowserFrame.ResizeBrowser; begin if (FMXWindowParent <> nil) then - FMXWindowParent.SetBounds(GetFMXWindowParentRect); + begin + FMXWindowParent.SetBounds(GetFMXWindowParentRect); + FMXWindowParent.UpdateSize; + end; end; procedure TBrowserFrame.ShowBrowser; @@ -204,7 +209,8 @@ procedure TBrowserFrame.CreateFMXWindowParent; begin if (FMXWindowParent = nil) then begin - FMXWindowParent := TFMXWindowParent.CreateNew(nil); + FMXWindowParent := TFMXWindowParent.CreateNew(nil); + FMXWindowParent.Chromium := FMXChromium1; FMXWindowParent.Reparent(ParentForm.Handle); ResizeBrowser; FMXWindowParent.Show; @@ -226,6 +232,7 @@ begin TThread.Queue(nil, procedure begin AddressLay.Enabled := True; + ResizeBrowser; end); end; @@ -311,6 +318,16 @@ begin Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]); end; +procedure TBrowserFrame.FMXChromium1StatusMessage(Sender: TObject; + const browser: ICefBrowser; const value: ustring); +begin + TThread.Queue(nil, + procedure + begin + StatusLbl.Text := value; + end); +end; + procedure TBrowserFrame.FMXChromium1TitleChange(Sender: TObject; const browser: ICefBrowser; const title: ustring); begin @@ -358,6 +375,7 @@ var TempHandle : HWND; TempRect : System.Types.TRect; TempClientRect : TRectF; + TempScale : single; {$ENDIF} begin CreateFMXWindowParent; @@ -367,10 +385,11 @@ begin {$IFDEF MSWINDOWS} TempHandle := FmxHandleToHWND(FMXWindowParent.Handle); TempClientRect := FMXWindowParent.ClientRect; + TempScale := FMXChromium1.ScreenScale; TempRect.Left := round(TempClientRect.Left); TempRect.Top := round(TempClientRect.Top); - TempRect.Right := round(TempClientRect.Right); - TempRect.Bottom := round(TempClientRect.Bottom); + TempRect.Right := round(TempClientRect.Right * TempScale); + TempRect.Bottom := round(TempClientRect.Bottom * TempScale); FMXChromium1.DefaultUrl := FHomepage; FMXChromium1.CreateBrowser(TempHandle, TempRect); diff --git a/demos/Delphi_FMX_Windows/SimpleFMXBrowser/SimpleFMXBrowser.dproj b/demos/Delphi_FMX_Windows/SimpleFMXBrowser/SimpleFMXBrowser.dproj index 19814f7a..d195c280 100644 --- a/demos/Delphi_FMX_Windows/SimpleFMXBrowser/SimpleFMXBrowser.dproj +++ b/demos/Delphi_FMX_Windows/SimpleFMXBrowser/SimpleFMXBrowser.dproj @@ -1,7 +1,7 @@  {5967B4A4-5E6D-420E-B524-A52A1240AC82} - 19.3 + 19.5 FMX SimpleFMXBrowser.dpr True @@ -28,6 +28,11 @@ Base true + + true + Base + true + true Base @@ -177,6 +182,31 @@ $(BDS)\bin\Artwork\iOS\iPad\FM_SettingIcon_58x58.png $(BDS)\bin\Artwork\iOS\iPad\FM_NotificationIcon_40x40.png + + CFBundleName=$(MSBuildProjectName);CFBundleDevelopmentRegion=en;CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleInfoDictionaryVersion=7.1;CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;LSRequiresIPhoneOS=true;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);UIDeviceFamily=iPhone & iPad;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSLocationAlwaysAndWhenInUseUsageDescription=The reason for accessing the location information of the user;UIBackgroundModes=;NSContactsUsageDescription=The reason for accessing the contacts;NSPhotoLibraryUsageDescription=The reason for accessing the photo library;NSPhotoLibraryAddUsageDescription=The reason for adding to the photo library;NSCameraUsageDescription=The reason for accessing the camera;NSFaceIDUsageDescription=The reason for accessing the face id;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSSiriUsageDescription=The reason for accessing Siri;ITSAppUsesNonExemptEncryption=false;NSBluetoothAlwaysUsageDescription=The reason for accessing bluetooth;NSBluetoothPeripheralUsageDescription=The reason for accessing bluetooth peripherals;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSMotionUsageDescription=The reason for accessing the accelerometer;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple's speech recognition servers + iPhoneAndiPad + true + $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_1024x1024.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_120x120.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_ApplicationIcon_180x180.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImage_2x.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImageDark_2x.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImage_3x.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_LaunchImageDark_3x.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_80x80.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_SpotlightSearchIcon_120x120.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_SettingIcon_58x58.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_SettingIcon_87x87.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_NotificationIcon_40x40.png + $(BDS)\bin\Artwork\iOS\iPhone\FM_NotificationIcon_60x60.png + $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_152x152.png + $(BDS)\bin\Artwork\iOS\iPad\FM_ApplicationIcon_167x167.png + $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImage_2x.png + $(BDS)\bin\Artwork\iOS\iPad\FM_LaunchImageDark_2x.png + $(BDS)\bin\Artwork\iOS\iPad\FM_SpotlightSearchIcon_80x80.png + $(BDS)\bin\Artwork\iOS\iPad\FM_SettingIcon_58x58.png + $(BDS)\bin\Artwork\iOS\iPad\FM_NotificationIcon_40x40.png + CFBundleName=$(MSBuildProjectName);CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleVersion=1.0.0;CFBundleShortVersionString=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);NSHighResolutionCapable=true;LSApplicationCategoryType=public.app-category.utilities;NSLocationUsageDescription=The reason for accessing the location information of the user;NSContactsUsageDescription=The reason for accessing the contacts;NSCalendarsUsageDescription=The reason for accessing the calendar data;NSRemindersUsageDescription=The reason for accessing the reminders;NSCameraUsageDescription=The reason for accessing the camera;NSMicrophoneUsageDescription=The reason for accessing the microphone;NSMotionUsageDescription=The reason for accessing the accelerometer;NSDesktopFolderUsageDescription=The reason for accessing the Desktop folder;NSDocumentsFolderUsageDescription=The reason for accessing the Documents folder;NSDownloadsFolderUsageDescription=The reason for accessing the Downloads folder;NSNetworkVolumesUsageDescription=The reason for accessing files on a network volume;NSRemovableVolumesUsageDescription=The reason for accessing files on a removable volume;NSSpeechRecognitionUsageDescription=The reason for requesting to send user data to Apple's speech recognition servers Debug @@ -277,43 +307,26 @@ Microsoft Office XP Sample Automation Server Wrapper Components - - - - true - - - - - true - - + true - - - true - - - - - SimpleFMXBrowser.exe + + + true + true - - - true - - + + 1 @@ -336,16 +349,6 @@ 64 - - - classes - 1 - - - classes - 1 - - res\xml @@ -655,7 +658,7 @@ 1 .dylib - + 1 .dylib @@ -688,7 +691,7 @@ 1 .dylib - + 1 .dylib @@ -725,7 +728,7 @@ 0 - + 0 @@ -749,13 +752,17 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -765,181 +772,27 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -949,7 +802,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -959,7 +812,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -969,7 +822,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -979,7 +832,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -989,191 +842,37 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - - - - 1 - - - 1 - - - 1 - - ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -1183,7 +882,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 @@ -1193,7 +892,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1203,7 +902,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1213,7 +912,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1223,7 +922,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1233,7 +932,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1243,7 +942,7 @@ ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 @@ -1265,12 +964,8 @@ ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - - - - 1 - - + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 @@ -1283,6 +978,10 @@ ..\ 1 + + ..\ + 1 + @@ -1291,7 +990,7 @@ 1 - + 1 @@ -1300,7 +999,7 @@ ..\$(PROJECTNAME).launchscreen 64 - + ..\$(PROJECTNAME).launchscreen 64 @@ -1312,7 +1011,7 @@ 1 - + 1 @@ -1383,7 +1082,7 @@ 1 - + 1 @@ -1439,22 +1138,24 @@ 1 - - - - - - + - + + + + + + + False False False + False False False True diff --git a/demos/Delphi_FMX_Windows/SimpleFMXBrowser/uSimpleFMXBrowser.fmx b/demos/Delphi_FMX_Windows/SimpleFMXBrowser/uSimpleFMXBrowser.fmx index 0c4a706d..d32a4af4 100644 --- a/demos/Delphi_FMX_Windows/SimpleFMXBrowser/uSimpleFMXBrowser.fmx +++ b/demos/Delphi_FMX_Windows/SimpleFMXBrowser/uSimpleFMXBrowser.fmx @@ -2,7 +2,7 @@ object SimpleFMXBrowserFrm: TSimpleFMXBrowserFrm Left = 0 Top = 0 Caption = 'Initializing browser. Please wait...' - ClientHeight = 600 + ClientHeight = 657 ClientWidth = 1000 Position = ScreenCenter FormFactor.Width = 320 @@ -23,7 +23,7 @@ object SimpleFMXBrowserFrm: TSimpleFMXBrowserFrm Size.Width = 1000.000000000000000000 Size.Height = 35.000000000000000000 Size.PlatformDefault = False - TabOrder = 1 + TabOrder = 2 object AddressEdt: TEdit Touch.InteractiveGestures = [LongTap, DoubleTap] Align = Client @@ -81,9 +81,9 @@ object SimpleFMXBrowserFrm: TSimpleFMXBrowserFrm object BrowserLay: TLayout Align = Client Size.Width = 1000.000000000000000000 - Size.Height = 565.000000000000000000 + Size.Height = 600.000000000000000000 Size.PlatformDefault = False - TabOrder = 6 + TabOrder = 7 object FocusWorkaroundBtn: TButton Position.X = 368.000000000000000000 Position.Y = 208.000000000000000000 @@ -93,10 +93,30 @@ object SimpleFMXBrowserFrm: TSimpleFMXBrowserFrm TabOrder = 0 end end + object StatusBar1: TStatusBar + Padding.Left = 3.000000000000000000 + Padding.Top = 3.000000000000000000 + Padding.Right = 30.000000000000000000 + Padding.Bottom = 3.000000000000000000 + Position.Y = 635.000000000000000000 + ShowSizeGrip = True + Size.Width = 1000.000000000000000000 + Size.Height = 22.000000000000000000 + Size.PlatformDefault = False + TabOrder = 1 + object StatusLbl: TLabel + Align = Client + Size.Width = 967.000000000000000000 + Size.Height = 16.000000000000000000 + Size.PlatformDefault = False + TabOrder = 0 + end + end object FMXChromium1: TFMXChromium OnGotFocus = FMXChromium1GotFocus OnBeforeContextMenu = FMXChromium1BeforeContextMenu OnContextMenuCommand = FMXChromium1ContextMenuCommand + OnStatusMessage = FMXChromium1StatusMessage OnBeforePopup = FMXChromium1BeforePopup OnAfterCreated = FMXChromium1AfterCreated OnBeforeClose = FMXChromium1BeforeClose diff --git a/demos/Delphi_FMX_Windows/SimpleFMXBrowser/uSimpleFMXBrowser.pas b/demos/Delphi_FMX_Windows/SimpleFMXBrowser/uSimpleFMXBrowser.pas index bbe78f24..ab6f9b0f 100644 --- a/demos/Delphi_FMX_Windows/SimpleFMXBrowser/uSimpleFMXBrowser.pas +++ b/demos/Delphi_FMX_Windows/SimpleFMXBrowser/uSimpleFMXBrowser.pas @@ -68,6 +68,8 @@ type SnapShotBtn: TButton; BrowserLay: TLayout; FocusWorkaroundBtn: TButton; + StatusBar1: TStatusBar; + StatusLbl: TLabel; procedure GoBtnClick(Sender: TObject); procedure Timer1Timer(Sender: TObject); @@ -85,6 +87,7 @@ type procedure FMXChromium1BeforeContextMenu(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; const model: ICefMenuModel); procedure FMXChromium1ContextMenuCommand(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; const params: ICefContextMenuParams; commandId: Integer; eventFlags: Cardinal; out Result: Boolean); procedure FMXChromium1GotFocus(Sender: TObject; const browser: ICefBrowser); + procedure FMXChromium1StatusMessage(Sender: TObject; const browser: ICefBrowser; const value: ustring); protected // Variables to control when can we destroy the form safely @@ -249,6 +252,16 @@ begin end); end; +procedure TSimpleFMXBrowserFrm.FMXChromium1StatusMessage(Sender: TObject; + const browser: ICefBrowser; const value: ustring); +begin + TThread.Queue(nil, + procedure + begin + StatusLbl.Text := value; + end); +end; + function TSimpleFMXBrowserFrm.PostCustomMessage(aMsg : cardinal; aWParam : WPARAM; aLParam : LPARAM) : boolean; {$IFDEF MSWINDOWS} var @@ -320,6 +333,7 @@ begin begin Caption := 'Simple FMX Browser'; AddressPnl.Enabled := True; + ResizeChild; end; CEF_DESTROY : @@ -413,20 +427,20 @@ begin end; function TSimpleFMXBrowserFrm.GetFMXWindowParentRect : System.Types.TRect; -var - TempScale : single; begin - TempScale := FMXChromium1.ScreenScale; Result.Left := round(BrowserLay.Position.x); Result.Top := round(BrowserLay.Position.y); - Result.Right := Result.Left + round(BrowserLay.Width * TempScale); - Result.Bottom := Result.Top + round(BrowserLay.Height * TempScale); + Result.Right := round(Result.Left + BrowserLay.Width); + Result.Bottom := round(Result.Top + BrowserLay.Height); end; procedure TSimpleFMXBrowserFrm.ResizeChild; begin if (FMXWindowParent <> nil) then - FMXWindowParent.SetBounds(GetFMXWindowParentRect); + begin + FMXWindowParent.SetBounds(GetFMXWindowParentRect); + FMXWindowParent.UpdateSize; + end; end; procedure TSimpleFMXBrowserFrm.SnapShotBtnClick(Sender: TObject); @@ -455,7 +469,8 @@ procedure TSimpleFMXBrowserFrm.CreateFMXWindowParent; begin if (FMXWindowParent = nil) then begin - FMXWindowParent := TFMXWindowParent.CreateNew(nil); + FMXWindowParent := TFMXWindowParent.CreateNew(nil); + FMXWindowParent.Chromium := FMXChromium1; FMXWindowParent.Reparent(Handle); ResizeChild; FMXWindowParent.Show; @@ -467,6 +482,7 @@ var TempHandle : HWND; TempRect : System.Types.TRect; TempClientRect : TRectF; + TempScale : single; begin // TFMXWindowParent has to be created at runtime CreateFMXWindowParent; @@ -481,10 +497,11 @@ begin begin TempHandle := FmxHandleToHWND(FMXWindowParent.Handle); TempClientRect := FMXWindowParent.ClientRect; + TempScale := FMXChromium1.ScreenScale; TempRect.Left := round(TempClientRect.Left); TempRect.Top := round(TempClientRect.Top); - TempRect.Right := round(TempClientRect.Right); - TempRect.Bottom := round(TempClientRect.Bottom); + TempRect.Right := round(TempClientRect.Right * TempScale); + TempRect.Bottom := round(TempClientRect.Bottom * TempScale); FMXChromium1.DefaultUrl := AddressEdt.Text; diff --git a/source/uCEFFMXWindowParent.pas b/source/uCEFFMXWindowParent.pas index 3a78da64..4a5b2e99 100644 --- a/source/uCEFFMXWindowParent.pas +++ b/source/uCEFFMXWindowParent.pas @@ -50,28 +50,32 @@ uses WinApi.Windows, {$ENDIF} FMX.Controls, FMX.Types, FMX.Forms, - uCEFConstants; + uCEFConstants, uCEFFMXChromium; type {$IFNDEF FPC}{$IFDEF DELPHI16_UP}[ComponentPlatformsAttribute(pfidWindows or pfidOSX or pfidLinux)]{$ENDIF}{$ENDIF} TFMXWindowParent = class(TCommonCustomForm) protected {$IFDEF MSWINDOWS} + FChromium : TFMXChromium; function GetChildWindowHandle : HWND; - procedure UpdateSize; {$ENDIF} + procedure Notification(AComponent: TComponent; Operation: TOperation); override; {$IFDEF DELPHI17_UP} procedure Resize; override; {$ENDIF} public {$IFDEF MSWINDOWS} procedure Reparent(const aNewParentHandle : {$IFDEF DELPHI18_UP}TWindowHandle{$ELSE}TFmxHandle{$ENDIF}); - property ChildWindowHandle : HWND read GetChildWindowHandle; + procedure UpdateSize; + property ChildWindowHandle : HWND read GetChildWindowHandle; + property Chromium : TFMXChromium read FChromium write FChromium; {$ENDIF} {$IFNDEF DELPHI17_UP} procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override; {$ENDIF} + published property Visible; property Height; @@ -91,7 +95,8 @@ implementation // It's also necessary to call "Reparent" to add this component as a child component to your form. uses - System.SysUtils, FMX.Platform, FMX.Platform.Win; + System.SysUtils, FMX.Platform, FMX.Platform.Win, + uCEFApplicationCore; {$IFDEF DELPHI17_UP} procedure TFMXWindowParent.Resize; @@ -127,6 +132,7 @@ var TempHWND, TempChildHWND : HWND; TempRect : System.Types.TRect; TempClientRect : TRectF; + TempScale : single; begin TempChildHWND := ChildWindowHandle; if (TempChildHWND = 0) then exit; @@ -134,11 +140,16 @@ begin TempHWND := BeginDeferWindowPos(1); try + if assigned(FChromium) then + TempScale := FChromium.ScreenScale + else + TempScale := GlobalCEFApp.DeviceScaleFactor; + TempClientRect := ClientRect; TempRect.Left := round(TempClientRect.Left); TempRect.Top := round(TempClientRect.Top); - TempRect.Right := round(TempClientRect.Right); - TempRect.Bottom := round(TempClientRect.Bottom); + TempRect.Right := round(TempClientRect.Right * TempScale); + TempRect.Bottom := round(TempClientRect.Bottom * TempScale); TempHWND := DeferWindowPos(TempHWND, TempChildHWND, HWND_TOP, TempRect.left, TempRect.top, TempRect.right - TempRect.left, TempRect.bottom - TempRect.top, @@ -170,5 +181,12 @@ begin end; {$ENDIF} +procedure TFMXWindowParent.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited Notification(AComponent, Operation); + + if (Operation = opRemove) and (AComponent = FChromium) then FChromium := nil; +end; + end. diff --git a/update_CEF4Delphi.json b/update_CEF4Delphi.json index 9b95f1a1..8b07c482 100644 --- a/update_CEF4Delphi.json +++ b/update_CEF4Delphi.json @@ -2,7 +2,7 @@ "UpdateLazPackages" : [ { "ForceNotify" : true, - "InternalVersion" : 451, + "InternalVersion" : 452, "Name" : "cef4delphi_lazarus.lpk", "Version" : "108.4.13" }