Home » Developing U++ » U++ Developers corner » Dynamic skin changes...
|
Re: Dynamic skin changes... [message #61089 is a reply to message #61087] |
Thu, 14 November 2024 16:32   |
Tom1
Messages: 1303 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. 
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   |
 |
mirek
Messages: 14261 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   |
Tom1
Messages: 1303 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 #61113 is a reply to message #61106] |
Mon, 18 November 2024 21:04   |
Tom1
Messages: 1303 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   |
Tom1
Messages: 1303 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   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
Tom1 wrote on Mon, 18 November 2024 22:04Hi 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 #61117 is a reply to message #61115] |
Tue, 19 November 2024 10:15   |
 |
mirek
Messages: 14261 Registered: November 2005
|
Ultimate Member |
|
|
Tom1 wrote on Tue, 19 November 2024 08:42Tom1 wrote on Mon, 18 November 2024 22:04Hi 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   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
mirek wrote on Tue, 19 November 2024 11:15SetDarkThemeEnabled 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   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
mirek wrote on Tue, 19 November 2024 11:14Tom1 wrote on Tue, 19 November 2024 07:44Hi,
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   |
 |
mirek
Messages: 14261 Registered: November 2005
|
Ultimate Member |
|
|
Tom1 wrote on Tue, 19 November 2024 14:22mirek wrote on Tue, 19 November 2024 11:14Tom1 wrote on Tue, 19 November 2024 07:44Hi,
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   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
mirek wrote on Wed, 20 November 2024 11:29Tom1 wrote on Tue, 19 November 2024 14:22mirek wrote on Tue, 19 November 2024 11:14Tom1 wrote on Tue, 19 November 2024 07:44Hi,
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   |
 |
mirek
Messages: 14261 Registered: November 2005
|
Ultimate Member |
|
|
Tom1 wrote on Wed, 20 November 2024 12:23mirek wrote on Wed, 20 November 2024 11:29Tom1 wrote on Tue, 19 November 2024 14:22mirek wrote on Tue, 19 November 2024 11:14Tom1 wrote on Tue, 19 November 2024 07:44Hi,
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   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
mirek wrote on Wed, 20 November 2024 13:40Tom1 wrote on Wed, 20 November 2024 12:23mirek wrote on Wed, 20 November 2024 11:29Tom1 wrote on Tue, 19 November 2024 14:22mirek wrote on Tue, 19 November 2024 11:14Tom1 wrote on Tue, 19 November 2024 07:44Hi,
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   |
 |
mirek
Messages: 14261 Registered: November 2005
|
Ultimate Member |
|
|
Tom1 wrote on Wed, 20 November 2024 12:57mirek wrote on Wed, 20 November 2024 13:40Tom1 wrote on Wed, 20 November 2024 12:23mirek wrote on Wed, 20 November 2024 11:29Tom1 wrote on Tue, 19 November 2024 14:22mirek wrote on Tue, 19 November 2024 11:14Tom1 wrote on Tue, 19 November 2024 07:44Hi,
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   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
mirek wrote on Wed, 20 November 2024 16:37Tom1 wrote on Wed, 20 November 2024 12:57mirek wrote on Wed, 20 November 2024 13:40Tom1 wrote on Wed, 20 November 2024 12:23mirek wrote on Wed, 20 November 2024 11:29Tom1 wrote on Tue, 19 November 2024 14:22mirek wrote on Tue, 19 November 2024 11:14Tom1 wrote on Tue, 19 November 2024 07:44Hi,
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. 
BR, Tom
|
|
|
|
Re: Dynamic skin changes... [message #61135 is a reply to message #61133] |
Fri, 22 November 2024 08:40   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
mirek wrote on Thu, 21 November 2024 21:30OK, finally figured out that I misunderstood which line we are talking about, should be now fixed... 
Thanks!
Looks good now. 
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
|
|
|
Goto Forum:
Current Time: Sat Jun 14 22:53:24 CEST 2025
Total time taken to generate the page: 0.07561 seconds
|