It is currently November 21st, 2018, 3:06 pm

Black/White font toggle

Help with creating, editing & fixing problems with skins
J0wNs
Posts: 32
Joined: June 16th, 2018, 9:27 pm

Black/White font toggle

J0wNs » July 13th, 2018, 11:56 am

Hello, I'm currently working on a button that lets me change my font color between black and white. I've set a #MainColour# in the @Variables.inc file and included it in all the skins. So far so good, but how do I make the icon toggle between the two colors? Picture for reference: https://i.imgur.com/UXWCbCS.jpg
User avatar
balala
Rainmeter Sage
Posts: 7029
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Black/White font toggle

balala » July 13th, 2018, 12:18 pm

J0wNs wrote:Hello, I'm currently working on a button that lets me change my font color between black and white. I've set a #MainColour# in the @Variables.inc file and included it in all the skins. So far so good, but how do I make the icon toggle between the two colors? Picture for reference: https://i.imgur.com/UXWCbCS.jpg

Code: Select all

[Variables]
Color=0

[MeasureColor]
Measure=Calc
Formula=#Color#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!SetOption MeterColor FontColor "255,255,255"][!UpdateMeter "MeterColor"][!Redraw]
IfFalseAction=[!SetOption MeterColor FontColor "0,0,0"][!UpdateMeter "MeterColor"][!Redraw]
DynamicVariables=1

[MeterColor]
Meter=String
SolidColor=0,0,0,100
Text=Click to change color
LeftMouseUpAction=[!SetVariable Color "(1-#Color#)"][!UpdateMeasure "MeasureColor"]
DynamicVariables=1
The color of the [MeterColor] meter is set by the !SetOption bangs of the IfTrueAction and IfFalseAction options of the [MeasureColor] measure. The state of this measure is controlled through the Color variable, which varies between 0 and 1 when you click the string.
Obviously if you have a MainColour variable set into an included file, you can use it. Just have to replace the explicitly set color into the appropriate !SetBang. Eg instead of [!SetOption MeterColor FontColor "255,255,255"] use [!SetOption MeterColor FontColor "#MainColour#"].
J0wNs
Posts: 32
Joined: June 16th, 2018, 9:27 pm

Re: Black/White font toggle

J0wNs » July 13th, 2018, 12:38 pm

Thanks, but now how do I make it change the font color of all the other skins? Is it possible?
User avatar
balala
Rainmeter Sage
Posts: 7029
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Black/White font toggle

balala » July 13th, 2018, 5:09 pm

J0wNs wrote:Thanks, but now how do I make it change the font color of all the other skins? Is it possible?
I'd do the following: would include all String meters of the first skin (will have to do the same with all other skins) which should have to change the color, into a group, adding a Group=MyGroup (obviously you can name it as you'd like) option to all such String meters. Then I'd modify the !SetOption bang as it follows: [!SetOptionGroup MyGroup FontColor "255,255,255" "FirstConfig"][!UpdateMeterGroup "MyGroup" "FirstConfig"][!Redraw "FirstConfig"]. The last parameter is the name of one config which contains one or more String meters belonging to the "MyGroup" group. You should have to add so many this kind of !SetOptionGroup bangs, as many configs do you have, which has one or more such String meters.
J0wNs
Posts: 32
Joined: June 16th, 2018, 9:27 pm

Re: Black/White font toggle

J0wNs » July 13th, 2018, 9:14 pm

I don't think I understood the config part, could you please be more specific?
User avatar
balala
Rainmeter Sage
Posts: 7029
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Black/White font toggle

balala » July 13th, 2018, 9:39 pm

J0wNs wrote:I don't think I understood the config part, could you please be more specific?
Let's say you have the following skins:
  • Skins\FirstConfig\Skin1.ini
  • Skins\SecondConfig\Skin2.ini
  • Skins\ThirdConfig\Skin3.ini
  • Skin1.ini has the following String meters: [MeterStringFirst1], [MeterStringFirst2] and [MeterStringFirst3]
  • Skin2.ini the following meters: [MeterStringSecond1], [MeterStringSecond2] and [MeterStringSecond3]
  • Finally Skin3.ini has the following meters: [MeterStringThird1], [MeterStringThird2] and [MeterStringThird3]
Each of these meters must have to have added a Group=MyGroup option.
My previously posted [MeasureColor] measure should have to look like:

Code: Select all

[MeasureColor]
Measure=Calc
Formula=#Color#
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction= [!SetOptionGroup MyGroup FontColor "255,255,255" "FirstConfig"][!SetOptionGroup MyGroup FontColor "255,255,255" "SecondConfig"][!SetOptionGroup MyGroup FontColor "255,255,255" "ThirdConfig"][!UpdateMeterGroup "MyGroup" "FirstConfig"][!UpdateMeterGroup "MyGroup" "SecondConfig"][!UpdateMeterGroup "MyGroup" "ThirdConfig"] [!Redraw "FirstConfig"][!Redraw "SecondConfig"]
[!Redraw "ThirdConfig"]
IfFalseAction= [!SetOptionGroup MyGroup FontColor "0,0,0" "FirstConfig"][!SetOptionGroup MyGroup FontColor "0,0,0" "SecondConfig"][!SetOptionGroup MyGroup FontColor "0,0,0" "ThirdConfig"][!UpdateMeterGroup "MyGroup" "FirstConfig"][!UpdateMeterGroup "MyGroup" "SecondConfig"][!UpdateMeterGroup "MyGroup" "ThirdConfig"] [!Redraw "FirstConfig"][!Redraw "SecondConfig"]
[!Redraw "ThirdConfig"]
DynamicVariables=1
See that in the three !SetOptionGroup bangs belonging to any of the above IfTrueAction / IfFalseAction options, are set the color for all meters belonging to the MyGroup meter group of the appropriate config (three this kind of bangs, because there are three configs).
Same for the !UpdateMeterGroup and !RedrawGroup bangs.

A few details about the config: https://docs.rainmeter.net/manual/skins/#Config
J0wNs
Posts: 32
Joined: June 16th, 2018, 9:27 pm

Re: Black/White font toggle

J0wNs » July 13th, 2018, 10:08 pm

Now that's clear. However, even if I swapped the FirstConfig and so on with the proper names, the "click to change" button doesn't work anymore
User avatar
balala
Rainmeter Sage
Posts: 7029
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Black/White font toggle

balala » July 14th, 2018, 5:41 am

J0wNs wrote:However, even if I swapped the FirstConfig and so on with the proper names, the "click to change" button doesn't work anymore
What the "doesn't work anymore" means? You can't click it or when you click it does nothing?
J0wNs
Posts: 32
Joined: June 16th, 2018, 9:27 pm

Re: Black/White font toggle

J0wNs » July 14th, 2018, 8:04 am

When I click it it does nothing
User avatar
balala
Rainmeter Sage
Posts: 7029
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Black/White font toggle

balala » July 14th, 2018, 9:14 am

J0wNs wrote:When I click it it does nothing
Please post the code of both, the [MeasureColor] measure and the "Click to change" button.