U++ framework
Do not panic. Ask here before giving up.

Home » Developing U++ » U++ Developers corner » Dynamic skin changes...
Dynamic skin changes... [message #61087] Wed, 13 November 2024 23:53 Go to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
I am now working on the option of changing the skin of running application, as followup to the discussion here:

https://www.ultimatepp.org/forums/index.php?t=msg&th=123 29&start=20&

It is developed in the "skin" branch and so far I was able to "convert" examples/UWord and it IMO it looks good. Please test. Details will follow...

Mirek
Re: Dynamic skin changes... [message #61089 is a reply to message #61087] Thu, 14 November 2024 16:32 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek!

Great stuff! I just briefly tested this on a couple of my main apps and it worked right out of the box. Smile

Simply added "Ctrl::SkinChangeSensitive();" to the beginning of my main function.

Is it also possible to have some function to call to select between:

- Dynamically changing theme (just this 'follow system theme' that we now get with this)
- Force Light theme regardless of system theme
- Force Dark theme regardless of system theme

and have it realized on the fly?

I guess having this option in GUI apps settings would really please some customers...

Thanks and best regards,

Tom

EDIT: BTW: Can you pump up the UPP_VERSION for this branch so that I can access this new feature only when available?
#if (UPP_VERSION>0x20240900)
	Ctrl::SkinChangeSensitive();
#endif

[Updated on: Thu, 14 November 2024 16:51]

Report message to a moderator

Re: Dynamic skin changes... [message #61090 is a reply to message #61089] Fri, 15 November 2024 09:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
TheIDE should be now sensitive (in skin branch). Needs more testing.

Some preliminary info:

- Problem of derivative colors is resolved with new SColor class, which is principally Color defined by function. Instance has to be static/global.
- Skin virtual method is called on skin changes, the order is from children to parents. So far, I have found that it is necessary to use Skin to reset toolbar so that icons are updated to correct variants. You can also use it to call e.g. ArrayCtrl::EvenRowColor if you want to use custom color that is not SColor.
- As you have guessed, it has to be activated with Ctrl::SkinChangeSensitive().
- To simplify testing, in debug mode Ctrl+Shift+Num[-] flips between dark and light modes.
- And yes, you can use Ctrl::SetSkin to change the theme. Test it with TheIDE Settings....
- One thing where I am reluctant to go is changes of default GUI font - that requires resizing windows and that is too scary for now. So font is fixed on startup

[Updated on: Fri, 15 November 2024 09:08]

Report message to a moderator

Re: Dynamic skin changes... [message #61092 is a reply to message #61090] Sun, 17 November 2024 12:36 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

Looks very nice!

So far only thing I have noticed is that theide file tabs don't get updated when theme is changed.

Best regards,

Tom

EDIT: It would surely be nice to have two separate color palettes of user configurable syntax highlighting colors: One for light and one for dark mode(s). And also have the appropriate palette loaded automatically when theme is changed.

[Updated on: Sun, 17 November 2024 13:28]

Report message to a moderator

Re: Dynamic skin changes... [message #61106 is a reply to message #61092] Mon, 18 November 2024 14:28 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Sun, 17 November 2024 12:36
Hi Mirek,

So far only thing I have noticed is that theide file tabs don't get updated when theme is changed.

EDIT: It would surely be nice to have two separate color palettes of user configurable syntax highlighting colors: One for light and one for dark mode(s). And also have the appropriate palette loaded automatically when theme is changed.


Pls check.
Re: Dynamic skin changes... [message #61113 is a reply to message #61106] Mon, 18 November 2024 21:04 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

Yes, now the tabs look right.

I think TheIDE would need "Ctrl::SkinChangeSensitive();" in main.cpp to properly follow "Host platform" selection automatically when theme changes.

Additionally, it would be nice to have just a minimal reference example for switching themes through a menu with following choices:

"Host platform (dynamic)"
"Host platform (forced dark)"
"Host platform (forced light)"
"Custom theme (static)"

The two middle choices, i.e.:

"Host platform (forced dark)"
"Host platform (forced light)"

are of interest on Windows due to the synthetic nature of dark mode there, but probably irrelevant on other platforms.

Thanks and best regards,

Tom
Re: Dynamic skin changes... [message #61114 is a reply to message #61113] Tue, 19 November 2024 07:44 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi,

Another finding in theide: The color of the 'cross hairs' (one vertical and two horizontal) that show the caret location in the code editor are not updated when theme changes.

Best regards,

Tom
Re: Dynamic skin changes... [message #61115 is a reply to message #61113] Tue, 19 November 2024 08:42 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Tom1 wrote on Mon, 18 November 2024 22:04
Hi Mirek,

Yes, now the tabs look right.

I think TheIDE would need "Ctrl::SkinChangeSensitive();" in main.cpp to properly follow "Host platform" selection automatically when theme changes.

Additionally, it would be nice to have just a minimal reference example for switching themes through a menu with following choices:

"Host platform (dynamic)"
"Host platform (forced dark)"
"Host platform (forced light)"
"Custom theme (static)"

The two middle choices, i.e.:

"Host platform (forced dark)"
"Host platform (forced light)"

are of interest on Windows due to the synthetic nature of dark mode there, but probably irrelevant on other platforms.

Thanks and best regards,

Tom


Mirek,

I mean this is sort of example...
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MainWindow : public TopWindow{
	MenuBar menu;

	MainWindow() {
		Title("Dynamic Theming Sample").Sizeable();
		AddFrame(menu);
		menu.Set([=](Bar& bar) {
			bar.Sub("Theme",[=](Bar& bar) {
				bar.Add("Host platform (dynamic)",[=] { Ctrl::SkinChangeSensitive(true); SetDarkThemeEnabled(true); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Host platform (forced dark)",[=] { Ctrl::SkinChangeSensitive(false); SetDarkThemeEnabled(true); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Host platform (forced light)",[=] { Ctrl::SkinChangeSensitive(false); SetDarkThemeEnabled(false); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Custom theme (static)",[=] { Ctrl::SkinChangeSensitive(false); Ctrl::SetSkin(ChStdSkin); });
			});
		});
	}
	
};


GUI_APP_MAIN{
	Ctrl::SkinChangeSensitive(true);
	
	MainWindow().Run();
}

Additionally, this requires the following change:
void Ctrl::SkinChangeSensitive(bool set){
	s_skin_change_sensitive = set;
}

Best regards,

Tom

EDIT: Fixed sample code...

[Updated on: Tue, 19 November 2024 09:50]

Report message to a moderator

Re: Dynamic skin changes... [message #61116 is a reply to message #61114] Tue, 19 November 2024 10:14 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Tue, 19 November 2024 07:44
Hi,

Another finding in theide: The color of the 'cross hairs' (one vertical and two horizontal) that show the caret location in the code editor are not updated when theme changes.

Best regards,

Tom


Thank you, hopefully fixed, please keep testing.
Re: Dynamic skin changes... [message #61117 is a reply to message #61115] Tue, 19 November 2024 10:15 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Tue, 19 November 2024 08:42
Tom1 wrote on Mon, 18 November 2024 22:04
Hi Mirek,

Yes, now the tabs look right.

I think TheIDE would need "Ctrl::SkinChangeSensitive();" in main.cpp to properly follow "Host platform" selection automatically when theme changes.

Additionally, it would be nice to have just a minimal reference example for switching themes through a menu with following choices:

"Host platform (dynamic)"
"Host platform (forced dark)"
"Host platform (forced light)"
"Custom theme (static)"

The two middle choices, i.e.:

"Host platform (forced dark)"
"Host platform (forced light)"

are of interest on Windows due to the synthetic nature of dark mode there, but probably irrelevant on other platforms.

Thanks and best regards,

Tom


Mirek,

I mean this is sort of example...
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MainWindow : public TopWindow{
	MenuBar menu;

	MainWindow() {
		Title("Dynamic Theming Sample").Sizeable();
		AddFrame(menu);
		menu.Set([=](Bar& bar) {
			bar.Sub("Theme",[=](Bar& bar) {
				bar.Add("Host platform (dynamic)",[=] { Ctrl::SkinChangeSensitive(true); SetDarkThemeEnabled(true); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Host platform (forced dark)",[=] { Ctrl::SkinChangeSensitive(false); SetDarkThemeEnabled(true); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Host platform (forced light)",[=] { Ctrl::SkinChangeSensitive(false); SetDarkThemeEnabled(false); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Custom theme (static)",[=] { Ctrl::SkinChangeSensitive(false); Ctrl::SetSkin(ChStdSkin); });
			});
		});
	}
	
};


GUI_APP_MAIN{
	Ctrl::SkinChangeSensitive(true);
	
	MainWindow().Run();
}

Additionally, this requires the following change:
void Ctrl::SkinChangeSensitive(bool set){
	s_skin_change_sensitive = set;
}

Best regards,

Tom

EDIT: Fixed sample code...


SetDarkThemeEnabled is now sort of deprecated, I am not going to change CtrlCore just because of single reference example and I think the reference example should demonstrate much more than this (Skin, SColor). But yep, it is coming.
Re: Dynamic skin changes... [message #61118 is a reply to message #61117] Tue, 19 November 2024 10:23 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Tue, 19 November 2024 11:15
SetDarkThemeEnabled is now sort of deprecated, I am not going to change CtrlCore just because of single reference example and I think the reference example should demonstrate much more than this (Skin, SColor). But yep, it is coming.

Absolutely, but I wish to know how this exact behavior is supposed to be realized in apps. That's just what I found necessary to realize the desired behavior, but I'm sure your deeper understanding of the internals yields better reference example for the same... and more.

Thanks,

Tom

EDIT: After all, I wish to give my clients a 'Theme' menu with at least three choices: 'System (dynamic)', 'Light (forced)' and 'Dark (forced)'. All based on 'Host platform' on Windows.

[Updated on: Tue, 19 November 2024 10:26]

Report message to a moderator

Re: Dynamic skin changes... [message #61121 is a reply to message #61116] Tue, 19 November 2024 14:22 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Tue, 19 November 2024 11:14
Tom1 wrote on Tue, 19 November 2024 07:44
Hi,

Another finding in theide: The color of the 'cross hairs' (one vertical and two horizontal) that show the caret location in the code editor are not updated when theme changes.

Best regards,

Tom


Thank you, hopefully fixed, please keep testing.

Thanks, it works fine now.

Maybe the "Settings/Editor/Paint line at column [96]" color setting should be automatically converted between light and dark modes. Depending on the user's color selection, the line may draw too much attention after theme change.

Best regards,

Tom
Re: Dynamic skin changes... [message #61122 is a reply to message #61121] Wed, 20 November 2024 10:29 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Tue, 19 November 2024 14:22
mirek wrote on Tue, 19 November 2024 11:14
Tom1 wrote on Tue, 19 November 2024 07:44
Hi,

Another finding in theide: The color of the 'cross hairs' (one vertical and two horizontal) that show the caret location in the code editor are not updated when theme changes.

Best regards,

Tom


Thank you, hopefully fixed, please keep testing.

Thanks, it works fine now.

Maybe the "Settings/Editor/Paint line at column [96]" color setting should be automatically converted between light and dark modes. Depending on the user's color selection, the line may draw too much attention after theme change.

Best regards,

Tom


Not sure what you mean. If Custom colors is not active, it is changed according to the theme. If Custom colors is active, you would be changing color selected by user. Did I misundertood the request?

Oh, BTW, dark theme flip key in debug mode is now "Ctrl + Num[*]" (previously selected key was causing problems).
Re: Dynamic skin changes... [message #61123 is a reply to message #61122] Wed, 20 November 2024 12:23 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Wed, 20 November 2024 11:29
Tom1 wrote on Tue, 19 November 2024 14:22
mirek wrote on Tue, 19 November 2024 11:14
Tom1 wrote on Tue, 19 November 2024 07:44
Hi,

Another finding in theide: The color of the 'cross hairs' (one vertical and two horizontal) that show the caret location in the code editor are not updated when theme changes.

Best regards,

Tom


Thank you, hopefully fixed, please keep testing.

Thanks, it works fine now.

Maybe the "Settings/Editor/Paint line at column [96]" color setting should be automatically converted between light and dark modes. Depending on the user's color selection, the line may draw too much attention after theme change.

Best regards,

Tom


Not sure what you mean. If Custom colors is not active, it is changed according to the theme. If Custom colors is active, you would be changing color selected by user. Did I misundertood the request?

Oh, BTW, dark theme flip key in debug mode is now "Ctrl + Num[*]" (previously selected key was causing problems).

I mean, there is a user selectable color available at: "Settings/Editor/Paint line at column [96]". Currently this is not changed along with theme, although it is visible in the editing area. This color is not set within "Syntax highlighting" either, so it is sort of a fixed color without theme dependence.

Just to test, change the "Settings/Editor/Paint line at column [96]" color to pure white and see how it disappears with light theme and is shown with high contrast on dark theme. I think it should be some way connected to the theme to keep it viewable with any theme while avoiding too much contrast.

Best regards,

Tom
Re: Dynamic skin changes... [message #61124 is a reply to message #61123] Wed, 20 November 2024 12:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Wed, 20 November 2024 12:23
mirek wrote on Wed, 20 November 2024 11:29
Tom1 wrote on Tue, 19 November 2024 14:22
mirek wrote on Tue, 19 November 2024 11:14
Tom1 wrote on Tue, 19 November 2024 07:44
Hi,

Another finding in theide: The color of the 'cross hairs' (one vertical and two horizontal) that show the caret location in the code editor are not updated when theme changes.

Best regards,

Tom


Thank you, hopefully fixed, please keep testing.

Thanks, it works fine now.

Maybe the "Settings/Editor/Paint line at column [96]" color setting should be automatically converted between light and dark modes. Depending on the user's color selection, the line may draw too much attention after theme change.

Best regards,

Tom


Not sure what you mean. If Custom colors is not active, it is changed according to the theme. If Custom colors is active, you would be changing color selected by user. Did I misundertood the request?

Oh, BTW, dark theme flip key in debug mode is now "Ctrl + Num[*]" (previously selected key was causing problems).

I mean, there is a user selectable color available at: "Settings/Editor/Paint line at column [96]". Currently this is not changed along with theme, although it is visible in the editing area. This color is not set within "Syntax highlighting" either, so it is sort of a fixed color without theme dependence.

Just to test, change the "Settings/Editor/Paint line at column [96]" color to pure white and see how it disappears with light theme and is shown with high contrast on dark theme. I think it should be some way connected to the theme to keep it viewable with any theme while avoiding too much contrast.

Best regards,

Tom


If you change it to pure white, you have custom colors. Do you suggest to throw away user choices?

Mirek
Re: Dynamic skin changes... [message #61125 is a reply to message #61124] Wed, 20 November 2024 12:57 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Wed, 20 November 2024 13:40
Tom1 wrote on Wed, 20 November 2024 12:23
mirek wrote on Wed, 20 November 2024 11:29
Tom1 wrote on Tue, 19 November 2024 14:22
mirek wrote on Tue, 19 November 2024 11:14
Tom1 wrote on Tue, 19 November 2024 07:44
Hi,

Another finding in theide: The color of the 'cross hairs' (one vertical and two horizontal) that show the caret location in the code editor are not updated when theme changes.

Best regards,

Tom


Thank you, hopefully fixed, please keep testing.

Thanks, it works fine now.

Maybe the "Settings/Editor/Paint line at column [96]" color setting should be automatically converted between light and dark modes. Depending on the user's color selection, the line may draw too much attention after theme change.

Best regards,

Tom


Not sure what you mean. If Custom colors is not active, it is changed according to the theme. If Custom colors is active, you would be changing color selected by user. Did I misundertood the request?

Oh, BTW, dark theme flip key in debug mode is now "Ctrl + Num[*]" (previously selected key was causing problems).

I mean, there is a user selectable color available at: "Settings/Editor/Paint line at column [96]". Currently this is not changed along with theme, although it is visible in the editing area. This color is not set within "Syntax highlighting" either, so it is sort of a fixed color without theme dependence.

Just to test, change the "Settings/Editor/Paint line at column [96]" color to pure white and see how it disappears with light theme and is shown with high contrast on dark theme. I think it should be some way connected to the theme to keep it viewable with any theme while avoiding too much contrast.

Best regards,

Tom


If you change it to pure white, you have custom colors. Do you suggest to throw away user choices?

Mirek

I do not think I first changed it at all, but I just observed its high contrast on one theme and low contrast on the other, when switching between light and dark on Windows. How do I reset it back to default to get it theme sensitive again?

BR, Tom
Re: Dynamic skin changes... [message #61126 is a reply to message #61125] Wed, 20 November 2024 15:37 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Wed, 20 November 2024 12:57
mirek wrote on Wed, 20 November 2024 13:40
Tom1 wrote on Wed, 20 November 2024 12:23
mirek wrote on Wed, 20 November 2024 11:29
Tom1 wrote on Tue, 19 November 2024 14:22
mirek wrote on Tue, 19 November 2024 11:14
Tom1 wrote on Tue, 19 November 2024 07:44
Hi,

Another finding in theide: The color of the 'cross hairs' (one vertical and two horizontal) that show the caret location in the code editor are not updated when theme changes.

Best regards,

Tom


Thank you, hopefully fixed, please keep testing.

Thanks, it works fine now.

Maybe the "Settings/Editor/Paint line at column [96]" color setting should be automatically converted between light and dark modes. Depending on the user's color selection, the line may draw too much attention after theme change.

Best regards,

Tom


Not sure what you mean. If Custom colors is not active, it is changed according to the theme. If Custom colors is active, you would be changing color selected by user. Did I misundertood the request?

Oh, BTW, dark theme flip key in debug mode is now "Ctrl + Num[*]" (previously selected key was causing problems).

I mean, there is a user selectable color available at: "Settings/Editor/Paint line at column [96]". Currently this is not changed along with theme, although it is visible in the editing area. This color is not set within "Syntax highlighting" either, so it is sort of a fixed color without theme dependence.

Just to test, change the "Settings/Editor/Paint line at column [96]" color to pure white and see how it disappears with light theme and is shown with high contrast on dark theme. I think it should be some way connected to the theme to keep it viewable with any theme while avoiding too much contrast.

Best regards,

Tom


If you change it to pure white, you have custom colors. Do you suggest to throw away user choices?

Mirek

I do not think I first changed it at all, but I just observed its high contrast on one theme and low contrast on the other, when switching between light and dark on Windows. How do I reset it back to default to get it theme sensitive again?

BR, Tom


There is "Custom colors" option. If active, we do not touch editor colors on switch.

Of course, it is possible you have hit some cornercase. But when I am testing it, it looks fine...

Mirek
Re: Dynamic skin changes... [message #61127 is a reply to message #61126] Wed, 20 November 2024 16:16 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Wed, 20 November 2024 16:37
Tom1 wrote on Wed, 20 November 2024 12:57
mirek wrote on Wed, 20 November 2024 13:40
Tom1 wrote on Wed, 20 November 2024 12:23
mirek wrote on Wed, 20 November 2024 11:29
Tom1 wrote on Tue, 19 November 2024 14:22
mirek wrote on Tue, 19 November 2024 11:14
Tom1 wrote on Tue, 19 November 2024 07:44
Hi,

Another finding in theide: The color of the 'cross hairs' (one vertical and two horizontal) that show the caret location in the code editor are not updated when theme changes.

Best regards,

Tom


Thank you, hopefully fixed, please keep testing.

Thanks, it works fine now.

Maybe the "Settings/Editor/Paint line at column [96]" color setting should be automatically converted between light and dark modes. Depending on the user's color selection, the line may draw too much attention after theme change.

Best regards,

Tom


Not sure what you mean. If Custom colors is not active, it is changed according to the theme. If Custom colors is active, you would be changing color selected by user. Did I misundertood the request?

Oh, BTW, dark theme flip key in debug mode is now "Ctrl + Num[*]" (previously selected key was causing problems).

I mean, there is a user selectable color available at: "Settings/Editor/Paint line at column [96]". Currently this is not changed along with theme, although it is visible in the editing area. This color is not set within "Syntax highlighting" either, so it is sort of a fixed color without theme dependence.

Just to test, change the "Settings/Editor/Paint line at column [96]" color to pure white and see how it disappears with light theme and is shown with high contrast on dark theme. I think it should be some way connected to the theme to keep it viewable with any theme while avoiding too much contrast.

Best regards,

Tom


If you change it to pure white, you have custom colors. Do you suggest to throw away user choices?

Mirek

I do not think I first changed it at all, but I just observed its high contrast on one theme and low contrast on the other, when switching between light and dark on Windows. How do I reset it back to default to get it theme sensitive again?

BR, Tom


There is "Custom colors" option. If active, we do not touch editor colors on switch.

Of course, it is possible you have hit some cornercase. But when I am testing it, it looks fine...

Mirek

Hi,

I can't really figure this out: I see, the "Custom colors" option is not checked here. I also note that changing any color in "Syntax highlighting" automatically turns on the "Custom colors" option. However, it's worth noting that "Paint line at column [96]" color selection button is not on "Syntax highlighting" tab, but instead on "Editor" tab. Also, changing "Paint line at column [96]" color does not activate "Custom colors" on "Syntax highlighting" tab. But never mind, this is not a critical issue from my point of view: I can always select transparent color for the line if it really seriously starts bugging me.

I will keep testing... And looking forward to the reference example with Host platform (dynamic) / Light (forced) / Dark (forced) / ++ selections. Smile

BR, Tom
Re: Dynamic skin changes... [message #61133 is a reply to message #61127] Thu, 21 November 2024 20:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
OK, finally figured out that I misunderstood which line we are talking about, should be now fixed... Smile
Re: Dynamic skin changes... [message #61135 is a reply to message #61133] Fri, 22 November 2024 08:40 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Thu, 21 November 2024 21:30
OK, finally figured out that I misunderstood which line we are talking about, should be now fixed... Smile

Thanks!

Looks good now. Smile

BTW: I added "Ctrl::SkinChangeSensitive();" to GUI_APP_MAIN in ide/main.cpp. Works here.

Best regards,

Tom

EDIT: What is the proper way to add "Host platform Dark (forced)" and "Host platform Light (forced)" to the list of available themes, while keeping current "Host platform" dynamic as is?

[Updated on: Fri, 22 November 2024 08:47]

Report message to a moderator

Re: Dynamic skin changes... [message #61139 is a reply to message #61135] Fri, 22 November 2024 16:11 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Mirek,

In TheIDE, the "Help and Topics (in window)" icon is better with Light theme than with Dark theme. Coloring is about the same, so maybe just enable the Light icon for both themes. (?)

Best regards,

Tom
Re: Dynamic skin changes... [message #61142 is a reply to message #61139] Sat, 23 November 2024 18:10 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi,

Just updated to latest on skin... and now ASSERT failed on Color.cpp line 124.

BR, Tom
Re: Dynamic skin changes... [message #61154 is a reply to message #61142] Mon, 25 November 2024 15:43 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

Just noticed on current 'skin' that some widgets no longer look like 'Host platform' on Windows 11. E.g. options (check box) and drop down lists have changed their appearance...

Best regards,

Tom
Re: Dynamic skin changes... [message #61161 is a reply to message #61154] Wed, 27 November 2024 11:28 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
So I think I am done with writing the code, two new features/changes:

- After a long deliberation, I have exploited the fact that Image is reference counted and changed all iml Images to "logical constants". That means that even a copy of Image that is from iml changes its appearance accordingly to dark/light theme. Maybe a bit tricky, but the practical result is that e.g. toolbars work without resetting them in Skin.

- Added a new logical Color kind - AColor. This one is defined with its light theme color and gets "adjusted" if used in dark theme.

Everything is now demonstrated in "reference/ThemeChangeSensitive" example.

Mirek
Re: Dynamic skin changes... [message #61162 is a reply to message #61161] Wed, 27 November 2024 12:14 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

Thanks for the update. Smile

I took a quick look at the example (and ide too) and found some issues...

First, the release mode compilation fails with DDUMP in Color.cpp:
void SColor::Write(Color c, Color val)
{
	int ii = c.GetRaw() & VBITS;
	if(ii == 3)
		DDUMP(val); 


Second, as I mentioned recently, the Option (check mark) button and Drop list buttons do not anymore have Windows 11 look by default, but some other.

Third, it seems that the reaction to 'Toggle dark' button does not retain Windows 11 Host platform skins, but instead switches between ChHostSkin, ChStdSkin and ChDarkSkin. How do I switch between "dynamic Windows 11 Host platform", "static Windows 11 Host platform Light theme" and "static Windows 11 Host platform Light theme"?

Best regards,

Tom

EDIT: Further noted that radio buttons and menu check marks also have wrong appearance in Win11. The default style comes from some other theme.

[Updated on: Wed, 27 November 2024 12:19]

Report message to a moderator

Re: Dynamic skin changes... [message #61163 is a reply to message #61162] Wed, 27 November 2024 12:43 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Wed, 27 November 2024 12:14
Hi Mirek,

Thanks for the update. Smile

I took a quick look at the example (and ide too) and found some issues...

First, the release mode compilation fails with DDUMP in Color.cpp:
void SColor::Write(Color c, Color val)
{
	int ii = c.GetRaw() & VBITS;
	if(ii == 3)
		DDUMP(val); 



Ops, fix pushed.

Quote:

Second, as I mentioned recently, the Option (check mark) button and Drop list buttons do not anymore have Windows 11 look by default, but some other.


Is this different from master?

Quote:

Third, it seems that the reaction to 'Toggle dark' button does not retain Windows 11 Host platform skins, but instead switches between ChHostSkin, ChStdSkin and ChDarkSkin.


It is debugging feature. I cannot (in general) switch Host theme, so I am toggling between the one set by "SetSkin" and one of internal themes. But that does not really matter, it is not meant for user experience, but for developer so that he can switch dark / light quickly to test that everything reacts accordingly.


Quote:

How do I switch between "dynamic Windows 11 Host platform", "static Windows 11 Host platform Light theme" and "static Windows 11 Host platform Light theme"?


There is no such thing as ""static Windows 11 Host platform Light theme" and "static Windows 11 Host platform Dark theme". If you mean "static Windows 11 Host platform theme", then just do not call SkinChangeSensitive.

Well, if you insist, I can add bool parameter to SkinChangeSensite, I just did not consider that very useful. Either your app reacts or not...

Best regards,

Tom

EDIT: Further noted that radio buttons and menu check marks also have wrong appearance in Win11. The default style comes from some other theme.[/quote]
Re: Dynamic skin changes... [message #61164 is a reply to message #61162] Wed, 27 November 2024 12:45 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Wed, 27 November 2024 12:14

Second, as I mentioned recently, the Option (check mark) button and Drop list buttons do not anymore have Windows 11 look by default, but some other.


Ah, sorry, now I can see it in Win10 too. Will fix. (Sorry for ignoring this, I thought it is some Win11 related problem)

Mirek
Re: Dynamic skin changes... [message #61165 is a reply to message #61164] Wed, 27 November 2024 13:06 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
- problem with options fixed
- SkinChangeSensitive now has bool b = true parameter. I wonder what good that will do Smile

Mirek
Re: Dynamic skin changes... [message #61167 is a reply to message #61165] Wed, 27 November 2024 14:37 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Thanks Mirek!

Looks very good now! Smile

As to your question, now we can do this:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MainWindow : public TopWindow{
	MenuBar menu;

	MainWindow() {
		Title("Dynamic Theming Sample").Sizeable();
		AddFrame(menu);
		menu.Set([=](Bar& bar) {
			bar.Sub("Theme",[=](Bar& bar) {
				bar.Add("Host platform (dynamic)",[=] { Ctrl::SkinChangeSensitive(true);  SetDarkThemeEnabled(true); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Host platform (forced dark)",[=] { Ctrl::SkinChangeSensitive(false);  SetDarkThemeEnabled(true); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Host platform (forced light)",[=] { Ctrl::SkinChangeSensitive(false);  SetDarkThemeEnabled(false); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Custom theme (static)",[=] { Ctrl::SkinChangeSensitive(false);  Ctrl::SetSkin(ChStdSkin); });
			});
		});
	}
	
};

GUI_APP_MAIN{
	Ctrl::SkinChangeSensitive(true);
	Ctrl::SetDarkThemeEnabled(true);

	MainWindow().Run();
}

This new automatic theme responsiveness added with manual control keeps maritime users happy: Many of them like to have the entire desktop with all apps dark at night and light during daytime. Night at sea is really dark and it requires dimming each and every light on the ship's bridge to its minimum to be able to see much anything ahead. (There's even a utility available for Windows that automatically switches between light and dark themes based on Sun rise and Sun set times.) But as always, some users wish to have it exactly their way with different themes on different applications. So, now everyone (excluding some even more difficult users) can have it their way. Smile

Thanks and best regards,

Tom
Re: Dynamic skin changes... [message #61169 is a reply to message #61167] Thu, 28 November 2024 10:31 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi Mirek,

It seems that currently the built-in 'Flat' themes in TheIDE look exactly the same as their non-flat counterparts. They used to look different in some way... maybe corner rounding. (?)

Best regards,

Tom
Re: Dynamic skin changes... [message #61170 is a reply to message #61169] Thu, 28 November 2024 19:31 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Tom1 wrote on Thu, 28 November 2024 10:31
Hi Mirek,

It seems that currently the built-in 'Flat' themes in TheIDE look exactly the same as their non-flat counterparts. They used to look different in some way... maybe corner rounding. (?)

Best regards,

Tom


All seems fine here - I am testing with theide...
Re: Dynamic skin changes... [message #61171 is a reply to message #61170] Thu, 28 November 2024 20:48 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
mirek wrote on Thu, 28 November 2024 20:31
Tom1 wrote on Thu, 28 November 2024 10:31
Hi Mirek,

It seems that currently the built-in 'Flat' themes in TheIDE look exactly the same as their non-flat counterparts. They used to look different in some way... maybe corner rounding. (?)

Best regards,

Tom


All seems fine here - I am testing with theide...

Hi,

You're right. It works here at home. I noticed the issue at the office, so I must have sources out of sync there.

Sorry for the false alarm!

BTW: I have been playing around with U++ theming the whole day and it has been a very interesting journey. I have yet to figure out how to adjust color and shape of many widgets, but I think I'm getting there gradually. E.g. I have not been able to figure out yet how LabelBox line color is changed... (?)

Also noticed that exposing "void ChMakeSkin(int roundness, Color button_face, Color thumb, int *adj);" allows creating custom skins -- e.g. ChMyCustomSkin() -- at app level without need to change U++ internals. a very nice feature! Smile

Thanks and best regards,

Tom
Re: Dynamic skin changes... [message #61174 is a reply to message #61171] Thu, 28 November 2024 22:46 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 740
Registered: November 2008
Location: France
Contributor
Hi Mirek and Tom,

I recently noticed that Theide sometimes needs "help" to compile properly : erase all cache directory and all build directory.
I never had to do this since until quite recently (i've been using upp since more than 15 years now) ==> all compiles OK but execution isn't at all what I expect ... until cleaning up cache and build dir.

I compile with clang under windows.

Maybe you are in the same situation ?
Re: Dynamic skin changes... [message #61175 is a reply to message #61171] Thu, 28 November 2024 22:56 Go to previous messageGo to next message
Didier is currently offline  Didier
Messages: 740
Registered: November 2008
Location: France
Contributor
Quote:
I have not been able to figure out yet how LabelBox line color is changed...


here are some examples I figured out how to do it:

struct sChLook_LabelBox {
	Image img;
};

Value Make_ChLook_LabelBox(const Image& img)
{
	sChLook_LabelBox x;
	x.img = MakeButton(8, img, 1, SBlack());
	return RawToValue(x);
}

Value ChLookFn_LabelBox(Draw& w, const Rect& r, const Value& v, int op, Color ink) {
	
	if( v.Is<sChLook_LabelBox>() )
	{
		const sChLook_LabelBox& e = v.To<sChLook_LabelBox>();
		ChPaint(w, r, e.img);
		return 1;
	}
	return Null;
}

INITBLOCK {
	ChLookFn(ChLookFn_LabelBox);
}

GUI_APP_MAIN
{
	LabelBox::SetLook(White());
	LabelBox::SetLook(WithHotSpots(MakeButton(8, MyImg::BACKGND1(), 5, Blue()), DPI(8), DPI(8), 0, 0));
	LabelBox::SetLook( MakeButton(4, MyImg::BACKGND1(), 2, Null) );

	
	static const Value myLabelBoxLook = Make_ChLook_LabelBox(MyImg::BACKGND2);
	LabelBox::SetLook( myLabelBoxLook );

        .....
}

Re: Dynamic skin changes... [message #61178 is a reply to message #61174] Fri, 29 November 2024 09:00 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Didier wrote on Thu, 28 November 2024 23:46
Hi Mirek and Tom,

I recently noticed that Theide sometimes needs "help" to compile properly : erase all cache directory and all build directory.
I never had to do this since until quite recently (i've been using upp since more than 15 years now) ==> all compiles OK but execution isn't at all what I expect ... until cleaning up cache and build dir.

I compile with clang under windows.

Maybe you are in the same situation ?

Hi Didier,

Thanks! Actually I was at 17486 while I should have been at 17490... Now it works properly here at the office too. Don't know the root cause of this, but it's fine now.

Best regards,

Tom
Re: Dynamic skin changes... [message #61179 is a reply to message #61175] Fri, 29 November 2024 09:03 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Didier wrote on Thu, 28 November 2024 23:56
Quote:
I have not been able to figure out yet how LabelBox line color is changed...


here are some examples I figured out how to do it:

struct sChLook_LabelBox {
	Image img;
};

Value Make_ChLook_LabelBox(const Image& img)
{
	sChLook_LabelBox x;
	x.img = MakeButton(8, img, 1, SBlack());
	return RawToValue(x);
}

Value ChLookFn_LabelBox(Draw& w, const Rect& r, const Value& v, int op, Color ink) {
	
	if( v.Is<sChLook_LabelBox>() )
	{
		const sChLook_LabelBox& e = v.To<sChLook_LabelBox>();
		ChPaint(w, r, e.img);
		return 1;
	}
	return Null;
}

INITBLOCK {
	ChLookFn(ChLookFn_LabelBox);
}

GUI_APP_MAIN
{
	LabelBox::SetLook(White());
	LabelBox::SetLook(WithHotSpots(MakeButton(8, MyImg::BACKGND1(), 5, Blue()), DPI(8), DPI(8), 0, 0));
	LabelBox::SetLook( MakeButton(4, MyImg::BACKGND1(), 2, Null) );

	
	static const Value myLabelBoxLook = Make_ChLook_LabelBox(MyImg::BACKGND2);
	LabelBox::SetLook( myLabelBoxLook );

        .....
}


Thanks! I will look into this...

Best regards,

Tom
Re: Dynamic skin changes... [message #61180 is a reply to message #61179] Fri, 29 November 2024 11:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Finished documentation as well. Will merge after 2024 release.

Mirek
Re: Dynamic skin changes... [message #61186 is a reply to message #61167] Sat, 30 November 2024 13:26 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Tom1 wrote on Wed, 27 November 2024 15:37
Thanks Mirek!

Looks very good now! Smile

As to your question, now we can do this:
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct MainWindow : public TopWindow{
	MenuBar menu;

	MainWindow() {
		Title("Dynamic Theming Sample").Sizeable();
		AddFrame(menu);
		menu.Set([=](Bar& bar) {
			bar.Sub("Theme",[=](Bar& bar) {
				bar.Add("Host platform (dynamic)",[=] { Ctrl::SkinChangeSensitive(true);  SetDarkThemeEnabled(true); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Host platform (forced dark)",[=] { Ctrl::SkinChangeSensitive(false);  SetDarkThemeEnabled(true); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Host platform (forced light)",[=] { Ctrl::SkinChangeSensitive(false);  SetDarkThemeEnabled(false); Ctrl::SetSkin(ChHostSkin); });
				bar.Add("Custom theme (static)",[=] { Ctrl::SkinChangeSensitive(false);  Ctrl::SetSkin(ChStdSkin); });
			});
		});
	}
	
};

GUI_APP_MAIN{
	Ctrl::SkinChangeSensitive(true);
	Ctrl::SetDarkThemeEnabled(true);

	MainWindow().Run();
}

This new automatic theme responsiveness added with manual control keeps maritime users happy: Many of them like to have the entire desktop with all apps dark at night and light during daytime. Night at sea is really dark and it requires dimming each and every light on the ship's bridge to its minimum to be able to see much anything ahead. (There's even a utility available for Windows that automatically switches between light and dark themes based on Sun rise and Sun set times.) But as always, some users wish to have it exactly their way with different themes on different applications. So, now everyone (excluding some even more difficult users) can have it their way. Smile

Thanks and best regards,

Tom

Mirek,

Can you hold merging this a little while longer? It turned out that I still cannot 'Force Dark' if Windows is currently in 'Light' mode. I will look into this...

Best regards,

Tom
Re: Dynamic skin changes... [message #61187 is a reply to message #61186] Sat, 30 November 2024 13:56 Go to previous messageGo to next message
Tom1
Messages: 1319
Registered: March 2007
Ultimate Contributor
Hi,

As IsDarkThemeEnabled() is only used in Windows and only below, so I have repurposed it here to actually mean 'dark theme forced'.

In 'void ChHostSkin()' in ChWin32.cpp:
	//sEmulateDarkTheme = Ctrl::IsDarkThemeEnabled() && IsSystemThemeDark() && !IsDark(Color::FromCR(GetSysColor(COLOR_WINDOW)));
	sEmulateDarkTheme = ((Ctrl::IsDarkThemeEnabled()&&!Ctrl::IsSkinChangeSensitive()) || (IsSystemThemeDark()&&Ctrl::IsSkinChangeSensitive())) && !IsDark(Color::FromCR(GetSysColor(COLOR_WINDOW)));

Also 'Ctrl' in Ctrl.cpp:
static bool Ctrl::IsSkinChangeSensitive()
{
	return s_skin_change_sensitive;
}

And the corresponding header change in CtrlCore.h:
static bool IsSkinChangeSensitive();

Best regards,

Tom
Re: Dynamic skin changes... [message #61200 is a reply to message #61187] Tue, 03 December 2024 20:22 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
Does not make sense at all.... I guess you want those function to mean something else than I intended...

Anyway, just for you (I guess), I have added Win32 only

void ChHostSkinLight();
void ChHostSkinDark();

Use with Ctrl::SetSkin ... I guess this should solve your problem.
Previous Topic: Github workflow files for building U++ on Windows, Linux & MacOS
Next Topic: Refactoring Moveable
Goto Forum:
  


Current Time: Thu May 07 07:50:26 GMT+2 2026

Total time taken to generate the page: 0.01334 seconds