|
|
Home » Developing U++ » U++ Developers corner » Dynamic skin changes...
Re: Dynamic skin changes... [message #61139 is a reply to message #61135] |
Fri, 22 November 2024 16:11   |
Tom1
Messages: 1303 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 #61154 is a reply to message #61142] |
Mon, 25 November 2024 15:43   |
Tom1
Messages: 1303 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 #61162 is a reply to message #61161] |
Wed, 27 November 2024 12:14   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
Hi Mirek,
Thanks for the update. 
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   |
 |
mirek
Messages: 14261 Registered: November 2005
|
Ultimate Member |
|
|
Tom1 wrote on Wed, 27 November 2024 12:14Hi Mirek,
Thanks for the update. 
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 #61167 is a reply to message #61165] |
Wed, 27 November 2024 14:37   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
Thanks Mirek!
Looks very good now! 
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. 
Thanks and best regards,
Tom
|
|
|
Re: Dynamic skin changes... [message #61169 is a reply to message #61167] |
Thu, 28 November 2024 10:31   |
Tom1
Messages: 1303 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 #61171 is a reply to message #61170] |
Thu, 28 November 2024 20:48   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
mirek wrote on Thu, 28 November 2024 20:31Tom1 wrote on Thu, 28 November 2024 10:31Hi 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! 
Thanks and best regards,
Tom
|
|
|
|
Re: Dynamic skin changes... [message #61175 is a reply to message #61171] |
Thu, 28 November 2024 22:56   |
Didier
Messages: 728 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   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
Didier wrote on Thu, 28 November 2024 23:46Hi 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   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
Didier wrote on Thu, 28 November 2024 23:56Quote: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 #61186 is a reply to message #61167] |
Sat, 30 November 2024 13:26   |
Tom1
Messages: 1303 Registered: March 2007
|
Ultimate Contributor |
|
|
Tom1 wrote on Wed, 27 November 2024 15:37Thanks Mirek!
Looks very good now! 
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. 
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   |
Tom1
Messages: 1303 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
|
|
|
|
Goto Forum:
Current Time: Tue Jun 17 16:52:11 CEST 2025
Total time taken to generate the page: 0.05362 seconds
|
|
|