Recent

Author Topic: Adapt window titlebar color to app color  (Read 4089 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2387
    • UVviewsoft
Adapt window titlebar color to app color
« 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.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Adapt window titlebar color to app color
« Reply #1 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?

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Adapt window titlebar color to app color
« Reply #2 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.
« Last Edit: January 30, 2020, 02:41:53 am by lainz »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Adapt window titlebar color to app color
« Reply #3 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.  

AlexTP

  • Hero Member
  • *****
  • Posts: 2387
    • UVviewsoft
Re: Adapt window titlebar color to app color
« Reply #4 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?

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Adapt window titlebar color to app color
« Reply #5 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
« Last Edit: January 30, 2020, 05:24:38 pm by skalogryz »

AlexTP

  • Hero Member
  • *****
  • Posts: 2387
    • UVviewsoft
Re: Adapt window titlebar color to app color
« Reply #6 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.

AlexTP

  • Hero Member
  • *****
  • Posts: 2387
    • UVviewsoft
Re: Adapt window titlebar color to app color
« Reply #7 on: March 09, 2020, 07:41:32 am »
Can we have some global function for Cocoa only, please?

 

TinyPortal © 2005-2018