Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to next message
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 #61142 is a reply to message #61139] Sat, 23 November 2024 18:10 Go to previous messageGo to next message
Tom1
Messages: 1303
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: 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 #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: 14261
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: 1303
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: 14261
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: 14261
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: 14261
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: 1303
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: 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 #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: 14261
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: 1303
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: 728
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: 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 Go to previous messageGo to next message
Tom1
Messages: 1303
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: 1303
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: 14261
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: 1303
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: 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
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: 14261
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: Tue Jun 17 16:52:11 CEST 2025

Total time taken to generate the page: 0.05362 seconds