AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

NSVisualEffectView

Ein Thema von Peter666 · begonnen am 13. Nov 2021 · letzter Beitrag vom 15. Nov 2021
 
CHackbart

Registriert seit: 22. Okt 2012
267 Beiträge
 
#5

AW: NSVisualEffectView

  Alt 15. Nov 2021, 10:18
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
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:19 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz