Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Cross-Platform-Entwicklung (https://www.delphipraxis.net/91-cross-platform-entwicklung/)
-   -   NSVisualEffectView (https://www.delphipraxis.net/209233-nsvisualeffectview.html)

Peter666 13. Nov 2021 17:55

NSVisualEffectView
 
Hallo,

hat schon einmal jemand https://developer.apple.com/document...sualeffectview verwendet, um das Formular so halbtransparent und Milchglasig zu gestalten? Ich habe im Netz leider nirgends eine Übersetzung gefunden.

Peter

venice2 13. Nov 2021 18:13

AW: NSVisualEffectView
 
Zitat:

Zitat von Peter666 (Beitrag 1497509)
Hallo,

hat schon einmal jemand https://developer.apple.com/document...sualeffectview verwendet, um das Formular so halbtransparent und Milchglasig zu gestalten? Ich habe im Netz leider nirgends eine Übersetzung gefunden.

Peter

Nein aber meine Engine Unterstützt das alles.. Allerdings nur Ohne VCL.
Damit kann alles Transparent gestaltet werden inclusive aufgesetzten Controls die alle auf Interface basieren.

EDIT:
Es geht hier aber wohl um macOS? (FMX?) Damit kann ich nicht dienen.

Peter666 13. Nov 2021 20:00

AW: NSVisualEffectView
 
Genau,

dieses View wurde später eingeführt und erlaubt so hardwarebeschleunigte Spezialeffekte, wie den Hintergrund des Fensters durchschimmern zu lassen. Das klingt jetzt erstmal nach nichts essentiellem, aber wenn du eine Anwendung unter Mac anbieten möchtest, dann wirkt diese ein bisschen wie ein Fremdkörper. Gefühlt jede Anwendung nutzt dieses neue View. Man kann jetzt tricksen und ein transparentes Fenster erstellen und dann die Rahmen selber malen, aber das ist friem und jedes Mal, wenn Apple sich entscheidet die Fenster mehr bzw. weniger abzurunden, musst du das dann anpassen.

Peter

venice2 13. Nov 2021 20:08

AW: NSVisualEffectView
 
Zitat:

hardwarebeschleunigte Spezialeffekte
Jo kopiert von MS. Siehe DWM hier werden die Effekte auch über die Hardware gerendert.
Nun gut wie schon gesagt für macOs kann ich leider nichts tun. Sorry

CHackbart 15. Nov 2021 09:18

AW: NSVisualEffectView
 
Man kann so etwas machen. Ich hab es aber nicht wirklich getestet.

Delphi-Quellcode:
unit UNSVisualEffectView;

interface

{$IFDEF MACOS}
{$IFNDEF IOS}

uses MacApi.CocoaTypes, MacApi.AppKit, MacApi.ObjectiveC, FMX.Forms;

const
  NSVisualEffectMaterialAppearanceBased = 0;
  NSVisualEffectMaterialLight = 1;
  NSVisualEffectMaterialDark = 2;
  NSVisualEffectMaterialTitlebar = 3;

  NSVisualEffectBlendingModeBehindWindow = 0;
  NSVisualEffectBlendingModeWithinWindow = 1;
  NSVisualEffectStateFollowsWindowActiveState = 0;
  NSVisualEffectStateActive = 1;
  NSVisualEffectStateInactive = 2;

  NSVisualEffectViewMaterialFullScreenUI = 15;

type
  NSVisualEffectMaterial = NSInteger;
  NSVisualEffectMaterialPtr = ^NSVisualEffectMaterial;
  NSVisualEffectBlendingMode = NSInteger;
  NSVisualEffectBlendingModePtr = ^NSVisualEffectBlendingMode;
  NSVisualEffectState = NSInteger;
  NSVisualEffectStatePtr = ^NSVisualEffectState;

  NSVisualEffectViewClass = interface(NSViewClass)
    ['{EF4AB3D6-5620-44CD-82F0-FD80FB79FB9D}']
    { class } procedure setMaterial(newValue: NSVisualEffectMaterial); cdecl;
    { class } function material: NSVisualEffectMaterial; cdecl;
    { class } function interiorBackgroundStyle: NSBackgroundStyle; cdecl;
    { class } procedure setBlendingMode
      (newValue: NSVisualEffectBlendingMode); cdecl;
    { class } function blendingMode: NSVisualEffectBlendingMode; cdecl;
    { class } procedure setState(newValue: NSVisualEffectState); cdecl;
    { class } function state: NSVisualEffectState; cdecl;
    { class } procedure setMaskImage(newValue: NSImage); cdecl;
    { class } function maskImage: NSImage; cdecl;
    { class } procedure viewDidMoveToWindow; cdecl;
    { class } procedure viewWillMoveToWindow(newWindow: NSWindow); cdecl;
  end;

  NSVisualEffectView = interface(NSView)
    procedure setMaterial(newValue: NSVisualEffectMaterial); cdecl;
    function material: NSVisualEffectMaterial; cdecl;
    function interiorBackgroundStyle: NSBackgroundStyle; cdecl;
    procedure setBlendingMode(newValue: NSVisualEffectBlendingMode); cdecl;
    function blendingMode: NSVisualEffectBlendingMode; cdecl;
    procedure setState(newValue: NSVisualEffectState); cdecl;
    function state: NSVisualEffectState; cdecl;
    procedure setMaskImage(newValue: NSImage); cdecl;
    function maskImage: NSImage;cdecl;
    procedure viewDidMoveToWindow;cdecl;
    procedure viewWillMoveToWindow(newWindow: NSWindow);cdecl;
  end;

  TNSVisualEffectView = class(TOCGenericImport<NSVisualEffectViewClass,
    NSVisualEffectView>)
  end;

procedure AppendToForm(const AForm: TCommonCustomForm);
{$ENDIF}
{$ENDIF}

implementation

{$IFDEF MACOS}
{$IFNDEF IOS}

uses FMX.Platform.Mac;

procedure AppendToForm(const AForm: TCommonCustomForm);
var
  NSWin: NSWindow;
  BlurView: NSVisualEffectView;
  ContentView: NSView;
begin
  NSWin := WindowHandleToPlatform(AForm.Handle).Wnd;
  NSWin.setOpaque(false);
  NSWin.setAlphaValue(0.98);

  BlurView := TNSVisualEffectView.Wrap(
   TNSVisualEffectView.Alloc.initWithFrame(
    MakeNSRect(0,0, AForm.Width, AForm.Height)));
  BlurView.setBlendingMode(NSVisualEffectBlendingModeBehindWindow);
  BlurView.setMaterial(NSVisualEffectViewMaterialFullScreenUI);
  BlurView.setState(NSVisualEffectStateActive);

  ContentView := TNSView.Wrap(NSWin.ContentView);
  ContentView.setAutoresizesSubviews(True);
  ContentView.addSubview(BlurView);
end;
{$ENDIF}
{$ENDIF}

end.
Christian


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:52 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz