Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 716

Help: Rainmeter Skins • Re: Hide & Seek

$
0
0
The Home button and Favorites button always remain fixed. Adding/expanding of the new Icons happens to the right, also the skin enlarge to the right side.
Well, in the end I found it easier and clearer to showcase it in a sample (had it ready since yesterday, but couldn't post it then)...

Sample:

Code:

[Variables]OriginalW=120InitialW=120Add=40Pad=(10-#Add#)Insert=3Addon1=0Addon2=0Addon3=0IStyle=0[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1---Styles---[Texts]Y=10SolidColor=0,0,0,1FontColor=150,150,150,255FontSize=22AntiAlias=1Text=#CURRENTSECTION#UpdateDivider=-1DynamicVariables=1---Meters---[Background]Meter=ShapeShape=Rectangle 0,0,[#OriginalW],50,10 | Fill Color 0,0,0,150 | StrokeWidth 2 | Stroke Color 0,0,0,140AntiAlias=1UpdateDivider=-1MiddleMouseUpAction=[!SetVariable IStyle (1-#IStyle#)][!SetVariable Insert ([#IStyle]=0?#Insert#:3+Sgn(#Addon1#)+Sgn(#Addon2#)+Sgn(#Addon3#))][!UpdateMeasure *][!UpdateMeter *][!Redraw]DynamicVariables=1[A]Meter=StringMeterStyle=TextsX=(#Pad#+#Add#*1)[B]Meter=StringMeterStyle=TextsX=(#Pad#+#Add#*2)[X]Meter=StringMeterStyle=TextsX=(#Pad#+#Add#*#Addon1#)Hidden=(1-Sgn(#Addon1#))[Y]Meter=StringMeterStyle=TextsX=(#Pad#+#Add#*#Addon2#)Hidden=(1-Sgn(#Addon2#))[Z]Meter=StringMeterStyle=TextsX=(#Pad#+#Add#*#Addon3#)Hidden=(1-Sgn(#Addon3#))[C]Meter=StringMeterStyle=TextsX=(#Pad#+#Add#*(3+Sgn(#Addon1#)+Sgn(#Addon2#)+Sgn(#Addon3#)))[XToggle]Meter=StringMeterStyle=TextsX=(#Pad#+#Add#)Y=(#Pad#+#Add#)RLeftMouseUpAction=[!SetVariable Addon1 ([#Addon1]=0?[#Insert]:0)][!SetVariable Addon2 ([#Addon2]-([#Addon1]=0)*([#Addon2]>#Addon1#)+([#Addon1]>0)*([#Addon2]>=[#Insert]))][!SetVariable Addon3 ([#Addon3]-([#Addon1]=0)*([#Addon3]>#Addon1#)+([#Addon1]>0)*([#Addon3]>=[#Insert]))][!SetVariable Insert ([#Addon1]=0?([#IStyle]=0?#Addon1#:[#Insert]-1):[#Insert]+1)][!SetVariable OriginalW ([#InitialW]+#Add#*(Sgn([#Addon1])+Sgn([#Addon2])+Sgn([#Addon3])))][!UpdateMeasure *][!UpdateMeter *][!Redraw][YToggle]Meter=StringMeterStyle=TextsX=(#Pad#+#Add#)Y=(#Pad#+#Add#)RLeftMouseUpAction=[!SetVariable Addon2 ([#Addon2]=0?[#Insert]:0)][!SetVariable Addon1 ([#Addon1]-([#Addon2]=0)*([#Addon1]>#Addon2#)+([#Addon2]>0)*([#Addon1]>=[#Insert]))][!SetVariable Addon3 ([#Addon3]-([#Addon2]=0)*([#Addon3]>#Addon2#)+([#Addon2]>0)*([#Addon3]>=[#Insert]))][!SetVariable Insert ([#Addon2]=0?([#IStyle]=0?#Addon2#:[#Insert]-1):[#Insert]+1)][!SetVariable OriginalW ([#InitialW]+#Add#*(Sgn([#Addon1])+Sgn([#Addon2])+Sgn([#Addon3])))][!UpdateMeasure *][!UpdateMeter *][!Redraw][ZToggle]Meter=StringMeterStyle=TextsX=(#Pad#+#Add#)Y=(#Pad#+#Add#)RLeftMouseUpAction=[!SetVariable Addon3 ([#Addon3]=0?[#Insert]:0)][!SetVariable Addon1 ([#Addon1]-([#Addon3]=0)*([#Addon1]>#Addon3#)+([#Addon3]>0)*([#Addon1]>=[#Insert]))][!SetVariable Addon2 ([#Addon2]-([#Addon3]=0)*([#Addon2]>#Addon3#)+([#Addon3]>0)*([#Addon2]>=[#Insert]))][!SetVariable Insert ([#Addon3]=0?([#IStyle]=0?#Addon3#:[#Insert]-1):[#Insert]+1)][!SetVariable OriginalW ([#InitialW]+#Add#*(Sgn([#Addon1])+Sgn([#Addon2])+Sgn([#Addon3])))][!UpdateMeasure *][!UpdateMeter *][!Redraw]
Details:
The Add variable is the width of a button. The Pad variable is the horizontal offset of buttons, minus the width of a button so that button indexes start at 1 and not 0 (since 0 is needed for the removed state of an addon button). AddonN and Insert are thus button indexes, with AddonN being 0 if that addon button is removed, and Insert being the index of the next addon button to be inserted (initially 3, since the 2 static A and B buttons are before the X, Y, or Z addon buttons, with C the last static button). This way, each button is easily positioned by adding Pad to the product between Add and that button index. As a result, to get the 0 or 1 needed to find out how many addon buttons were inserted so that their widths can be added to the static InitialW to make up OriginalW in the mouse actions, I used Sgn(<buttonindex>) which will return 0 if the index is 0 (removed) and 1 if the index is greater than 0 (inserted). The IStyle variable is the insert style, either at the last removal position (0) or to the right of the existing addon buttons (1).

In the mouse actions, I do the following:
- toggle the index of the clicked addon button between the insertion index (inserted state) and 0 (removed state)
- reindex the other addon buttons to avoid indexing gaps or overlaps depending on its style (like when removing 4 from 3,4,5 or inserting 3 in 3,4)
- adjust the insertion index based on whether the clicked addon button was removed or inserted and the insert style
- recompute the OriginalW based on the static InitialW and the product between the width of a button and how many addon buttons were inserted

Behavior:
- an addon button can be inserted in two possible ways based on the insert style
- an addon button is always removed from its existing position in the button list
- the insert style can be toggled by middle clicking on the background meter and can produce more static or dynamic arrangements of the addons

The slightly more complex part is the reindexing of the other addon buttons, e.g. for the Addon1 index from the mouse actions in YToggle:
[!SetVariable Addon1 ([#Addon1]-([#Addon2]=0)*([#Addon1]>#Addon2#)+([#Addon2]>0)*([#Addon1]>=[#Insert]))]
Above, the subtraction handles avoiding indexing gaps and the addition handles avoiding indexing overlaps. The former is needed when IStyle is 1 and the latter is needed when IStyle is 0, and both use the equivalence of the logical FALSE and TRUE in the conditions with the mathematical 0 and 1 values, to shorten the formula. Similarly, when setting the Insert index in the same option, some parts are only needed based on the same IStyle:
[!SetVariable Insert ([#Addon2]=0?([#IStyle]=0?#Addon2#:[#Insert]-1):[#Insert]+1)]
which means that if you want to settle on one of the insert styles (0 or 1), you can shorten the formulas above to leave only the desired parts. By the way, using the #Addon2# 'old' value and its [#Addon2] 'new' value DOES matter.
P.S. I left the [!UpdateMeasure *] part only to make the changes in the About > Skins tab instantaneous, apparently even if you only have variables and no measures in a skin, one still needs to use such a bang to make the values in that tab update immediately when changed.

Statistics: Posted by Yincognito — Yesterday, 6:55 pm



Viewing all articles
Browse latest Browse all 716

Trending Articles