Lazarus

Programming => Widgetset => Cocoa => Topic started by: Alextp on January 29, 2020, 11:46:21 pm

Title: Adapt window titlebar color to app color
Post by: Alextp on January 29, 2020, 11:46:21 pm
SublimeText can do this, see 3 screenshots.
https://github.com/dempfi/ayu
i wish we can do it too.
Title: Re: Adapt window titlebar color to app color
Post by: trev on January 30, 2020, 01:38:12 am
I looked at the examples and could not see any difference between those examples and my Lazarus macOS application when changing the desktop theme from light to dark.

Care to elaborate?
Title: Re: Adapt window titlebar color to app color
Post by: lainz on January 30, 2020, 02:37:34 am
I looked at the examples and could not see any difference between those examples and my Lazarus macOS application when changing the desktop theme from light to dark.

Care to elaborate?

I understood that he want to theme the titlebar in all platforms not just macOS, so it get the color of the application selected theme, but not just these colors displayed in these screenshots but any color. Again not the OS theme but the application theme.

For example Visual Studio Code, Chrome... these apps can change everything, including titlebar.
Title: Re: Adapt window titlebar color to app color
Post by: skalogryz on January 30, 2020, 02:53:48 am
i wish we can do it too.
for macOS 10.10+ only
Code: Pascal  [Select][+][-]
  1. {$modeswitch objectivec2}
  2.  
  3. interface
  4.  
  5. uses
  6.   CocoaAll,
  7. ...
  8. const
  9.   NSWindowTitleVisible = 0;
  10.   NSWindowTitleHidden = 1;
  11.  
  12. type
  13.   NSWindowTitleVisibility = NSInteger;
  14.  
  15.   NSWindowGlam = objccategory external (NSWindow)
  16.     function titleVisibility: NSWindowTitleVisibility; message 'titleVisibility';
  17.     procedure setTitleVisibility(AVisibility: NSWindowTitleVisibility); message 'setTitleVisibility:';
  18.     function titlebarAppearsTransparent: Boolean; message 'titlebarAppearsTransparent';
  19.     procedure setTitlebarAppearsTransparent(AFlag: Boolean); message 'setTitlebarAppearsTransparent:';
  20.   end;
  21.  
  22. { TForm1 }
  23.  
  24. procedure TForm1.FormShow(Sender: TObject);
  25. var
  26.   w :NSWindow;
  27. begin
  28.   w := NSView(Self.Handle).window;
  29.   w.setTitlebarAppearsTransparent(true);
  30.   w.setTitleVisibility( NSWindowTitleHidden);
  31.  
  32.   w.setBackgroundColor( NSColor.greenColor ); // <-- not required, and can changed to any color
  33.  
Title: Re: Adapt window titlebar color to app color
Post by: Alextp on January 30, 2020, 03:44:53 pm
I need to change titlebar on Cocoa, when my app theme changes - so e.g. blue theme can change titlebar color to blue.

Dmitry, can we have this as a function in WS (AColor: TColor)? so I don't need Mac only code in CudaText?
Title: Re: Adapt window titlebar color to app color
Post by: skalogryz on January 30, 2020, 05:22:50 pm
are you looking for the functionality in versions prior to 10.10?

This post seems to be describing the functionality
https://stackoverflow.com/questions/20016022/how-to-change-color-of-nswindow-title-bar-in-osx
Title: Re: Adapt window titlebar color to app color
Post by: Alextp on January 30, 2020, 05:50:38 pm
10.10+ is okay, I just need some function in Cocoa which i will call when CudaText changes ui theme.
Title: Re: Adapt window titlebar color to app color
Post by: Alextp on March 09, 2020, 07:41:32 am
Can we have some global function for Cocoa only, please?
TinyPortal © 2005-2018