It is currently April 26th, 2024, 6:27 am

Help me to create a widget with the system-wide theme.

Get help with creating, editing & fixing problems with skins
xmha97
Posts: 1
Joined: June 8th, 2020, 6:44 pm

Help me to create a widget with the system-wide theme.

Post by xmha97 »

Hello Rainmeter lovers
Please help me to create a widget with the system-wide theme.

Image

I want the widget background to match the theme.

In this way, in the light theme, the background of the widget will be white.
And in the dark theme, the background of the widget will be black.

Also please see the issue below:
https://github.com/MinhThienDX/win10widgets/issues/30
There is information that may be helpful.

Thanks.
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help me to create a widget with the system-wide theme.

Post by balala »

xmha97 wrote: June 8th, 2020, 6:49 pm I want the widget background to match the theme.

In this way, in the light theme, the background of the widget will be white.
And in the dark theme, the background of the widget will be black.
Sorry for the very late reply.
What you should do is to check the appropriate registry key (described into the posted link) and modify the color of a meter used as background accordingly.
So, first you need a Registry measure, to check the registry key. Add the following measure to your code:

Code: Select all

[MeasureWindowsTheme]
Measure=Registry
RegHKey=HKEY_CURRENT_USER
RegKey=Software\Microsoft\Windows\CurrentVersion\Themes\Personalize
RegValue=SystemUsesLightTheme
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption MeterBackground SolidColor "0,0,0,150"][!UpdateMeter "MeterBackground"][!Redraw]
IfFalseAction=[!SetOption MeterBackground SolidColor "255,255,255,150"][!UpdateMeter "MeterBackground"][!Redraw]
See that based on the returned value, the !SetOption bangs of the IfTrueAction and IfFalseAction options set appropriate background color for the [MeterBackground] meter, which will be used as background.
Accordingly the [MeterBackground] meter is a simply Image meter. There is not needed to specifically set a SolidColor for it, because this option is set through the !SetOption bangs (as described above):

Code: Select all

[MeterBackground]
Meter=Image
X=0
Y=0
W=250
H=150
Obviously a Shape meter can be used instead of this simple Image meter, this was just an example. Also note that the size of the meter will have to be changed, I added the above size completely arbitrary.
Please let me know if this is what you expect.