It is currently December 10th, 2018, 6:35 pm

[Feature] CURRENTROOTSECTION

Report bugs with the Rainmeter application and suggest features.
User avatar
Active Colors
Moderator
Posts: 498
Joined: February 16th, 2012, 3:32 am

[Feature] CURRENTROOTSECTION

Active Colors » November 14th, 2018, 7:15 pm

Have you ever made a modular skin with many repetitive sections and combined meter styles? Tired or writing same formulas with just a little change in every meter to make skin adaptive? #CURRENTROOTSECTION# is a solution.

Basically, what I suggest is inverse #CURRENTSECTION#. The difference is this.
With #CURRENTSECTION# you can do such thing as placing or taking value based on another meter (or measure) like this:

[MeterBatteryName]
Meter=String
X=10
Y=10
Text=Battery:

[MeterBattery]
Meter=String
MeasureName=MeasureBattery
X=([#CURRENTSECTION#Name:X]+30)
Y=([#CURRENTSECTION#Name:Y]+0)
Text=%1

So, in MeterBattery to the #CURRENTSECTION# I can attach some ending (or beginning) to get a value from another meter. But this method has a big limitation. I cannot have multiple meters like MeterBattery, which means if I have a base where several meters a drawn it will be a lot of effort to place meters to the base.

With #CURRENTROOTSECTION# it will be possible.
I Imagine the root name will be separated with pipe sign | and #CURRENTROOTSECTION# will look for a name that is before the pipe sign.
Example:

[MeterBattery]
Meter=String
X=10
Y=10
Text=Battery:

[MeterBattery|Value]
Meter=String
MeasureName=MeasureBattery
X=([#CURRENTROOTSECTION#:X]+30)
Y=([#CURRENTROOTSECTION#:Y]+0)
Text=%1

And to the root meter I can attach more meters, let's say, a bar:

[MeterBattery|Bar]
Meter=Bar
X=([#CURRENTROOTSECTION#:X]+0)
Y=([#CURRENTROOTSECTION#:Y]+10)

--------------
To conclude everything I will demonstrate two example skins: one with regular way and another with #CURRENTROOTSECTION# way to show why #CURRENTROOTSECTION# is better.

Imagine this case.
You have a skin with several metric, like, illustro system stats. Each metric composed of the elements:
image meter = a base/container where all the elements will be placed (can be invisible if you use one background image for the whole skin)
string meter - title CPU
string meter - value x%
bar meter - visual representation of how full it is
image meter= visual representation of a category, will be a small cpu icon

And besides CPU you have more categories like RAM, Battery, Video memory, Cores, etc.. Everything has similar patternalistic structure as above.

Example of a regular skin:
[CPUMeasure]
Measure=CPU

[CPU]
;Canvas/Background for just one group of elements to be placed within
Meter=Image
X=10
Y=10
W=150
H=80

[CPUIcon]
Meter=Image
X=([CPU:X]+10)
Y=([CPU:Y]+15)
W=24
H=24

[CPUTitle]
Meter=String
X=([CPU:X]+35)
Y=([CPU:Y]+10)
Text=CPU

[CPUValue]
Meter=String
MeasureName=CPUMeasure
X=([CPU:X]+[CPU:W]-15)
StringAlign=Right
Text=%1 %

[CPUBar]
Meter=Bar
X=([CPU:X]+15)
Y=([CPU:Y]+[CPU:H]-[#CURRENTSECTION#:H])
W=([CPU:W]-([#CURRENTSECTION#:X]*2))
H=3

And now imagine you need to show ram. You realize that you will have to copy all the elements of cpu, paste below , and rename all the meter names in the formulas. You were able to use #CURRENTSECTION# in two places which save you some time. You copy it, paste it, rename the meters, repeat the same process for battery metric, gpu, and whoever knows what, and then you realize you need to change a formula or change a layout completely. You need either to do the same thing for every meter, or delete all the meters except one group of meter where you will do the changes, copy the new group, paste, and again rename all the meters. Sounds awful, right? MeterStyles could save a lot of time using one MeterStyle for each type of the meter, like, bar, since every bar looks same. We could use that if we had an example from the very very beginning with #CURRENTSECTION# however you realize that everything is tightened to the root meter and you cannot use #CURRENSECTION# everywhere.
Now look how the same skin can look with #CURRENTROOTSECTION#

[CPU|Measure]
Measure=CPU

[CPU] <-This is the root name
;Canvas/Background for just one group of elements to be placed within
Meter=Image
X=10
Y=10
W=150
H=80

[CPU|Icon] <-The element of the root is divided with a pipe character
Meter=Image
X=([#CURRENTROOTSECTION#:X]+10)
Y=([#CURRENTROOTSECTION#:Y]+15)
W=24
H=24

[CPU|Title]
Meter=String
X=([#CURRENTROOTSECTION#:X]+35)
Y=([#CURRENTROOTSECTION#:Y]+10)
Text=CPU

[CPU|Value]
Meter=String
MeasureName=#CURRENTROOTSECTION#|Measure
X=([#CURRENTROOTSECTION#:X]+[#CURRENTROOTSECTION#:W]-15)
StringAlign=Right
Text=%1 %

[CPU|Bar]
Meter=Bar
X=([#CURRENTROOTSECTION#:X]+15)
Y=([#CURRENTROOTSECTION#:Y]+[#CURRENTROOTSECTION#:H]-[#CURRENTSECTION#:H])
W=([#CURRENTROOTSECTION#:W]-([#CURRENTSECTION#:X]*2))
H=3

In this case #CURRENTROOTSECTION# is referred to the meter named CPU. Now you realize when you copy everything to make a same thing but for ram you don't need to rename anything in the contents. Moreover, you realize that since all the formulas and values look exactly same everywhere you can combine them into several meterstyles. Just look at this beauty:

;MeterStyles
[StyleRoot]
X=10
W=150
H=80

[StyleIcon]
X=([#CURRENTROOTSECTION#:X]+10)
Y=([#CURRENTROOTSECTION#:Y]+15)
W=24
H=24

[StyleTitle]
X=([#CURRENTROOTSECTION#:X]+35)
Y=([#CURRENTROOTSECTION#:Y]+10)

[StyleValue]
MeasureName=#CURRENTROOTSECTION#|Measure
X=([#CURRENTROOTSECTION#:X]+[#CURRENTROOTSECTION#:W]-15)
StringAlign=Right
Text=%1 %

[StyleBar]
X=([#CURRENTROOTSECTION#:X]+15)
Y=([#CURRENTROOTSECTION#:Y]+[#CURRENTROOTSECTION#:H]-[#CURRENTSECTION#:H])
W=([#CURRENTROOTSECTION#:W]-([#CURRENTSECTION#:X]*2))
H=3

;CPU
[CPU|Measure]
Measure=CPU

[CPU]
Meter=Image
MeterStyle=StyleRoot
Y=10

[CPU|Icon]
Meter=Image
MeterStyle=StyleIcon

[CPU|Title]
Meter=String
MeterStyle=StyleTitle
Text=CPU

[CPU|Value]
Meter=String
MeterStyle=StyleValue

[CPU|Bar]
Meter=Bar
MeterStyle=StyleBar

;RAM
[RAM|Measure]
Measure=RAM

[RAM]
Meter=Image
MeterStyle=StyleRoot
Y=10

[RAM|Icon]
Meter=Image
MeterStyle=StyleIcon

[RAM|Title]
Meter=String
MeterStyle=StyleTitle
Text=RAM

[RAM|Value]
Meter=String
MeterStyle=StyleValue

[RAM|Bar]
Meter=Bar
MeterStyle=StyleBar

-AC

This approach saves a lot of time and opens a huge door for modular skins like docs, launchers, and who knows what more.
oZone
Posts: 57
Joined: May 14th, 2018, 4:46 pm

Re: [Feature] CURRENTROOTSECTION

oZone » November 14th, 2018, 8:40 pm

Interesting, this could help to avoid repeating code.
I would suggest using something like local variables

SectionVariableMode=0
Variables in [Variables] will be ignored

SectionVariableMode=1
Variables in [Variables] will be used, but only last occurrence of variables will be used.
In example below [Meter] variables will be used.

SectionVariableMode=2
Variables in [Variables] will be used, if there is no variable variant in [Variables] section variable will be used.


SectionVariableN

Using N could be similar to N in @include option

Code: Select all

[Rainmeter]
SectionVariableMode=2

[Variables]
SectionVariableText=Default text
SectionVariableColor1=255,0,255
SectionVariableColor2=0,255,0

[Style]
SectionVariable=10
SectionVariable2=25
X=#SectionVariable#
Y=#SectionVariable2#
Text=#SectionVariableText#
MouseOverAction=[!SetOption #SectionVariableS# FontColor #SectionVariableColor1#][!UpdateMeter #SectionVariableS#][!Redraw]
MouseLeaveAction=[!SetOption #SectionVariableS# FontColor #SectionVariableColor2#][!UpdateMeter #SectionVariableS#][!Redraw]
DynamicVariables=1

[Meter]
SectionVariable=5
SectionVariable2=5
SectionVariableText=Some text
SectionVariableS=Meter
Meter=String
MeterStyle=Style

[Meter2]
SectionVariableText=[Variables:SectionVariableText]
SectionVariableS=[Meter:SectionVariableS]
Meter=String
MeterStyle=Style
User avatar
raiguard
Posts: 493
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

Re: [Feature] CURRENTROOTSECTION

raiguard » November 17th, 2018, 4:06 am

YES. I want this feature so badly.

My usecase is for button regions. When I made my skins scalable, that required me to create invisible meters for every button that would be able to detect mouse actions (since TransformationMatrix doesn't alter a meter's mouse action region). In order to accomplish this with MeterStyles, I had to rename the base meters to include an underscore at the end, and the button meter would contain the base name, like so:

Code: Select all

[MeterConfigButton_]
Meter=Image
MeterStyle=StyleConfigButton

[MeterConfigButton]
Meter=Image
MeterStyle=StyleMouseRegion | StyleMouseRegionImgButtonHover
LeftMouseUpAction=[!SkinCustomMenu]
Group=ConfigButton
Hidden=1
I really don't like this method, as it doesn't make much sense. I would like to be able to make the button meter identify itself. Hence, #CURRENTROOTSECTION#:

Code: Select all

[MeterConfigButton]
Meter=Image
MeterStyle=StyleConfigButton

[MeterConfigButton|MouseRegion]
Meter=Image
MeterStyle=StyleMouseRegion | StyleMouseRegionImgButtonHover
LeftMouseUpAction=[!SkinCustomMenu]
Group=ConfigButton
Hidden=1
So, this is a +1 from me. :thumbup:
”We are pretty sure that r2922 resolves the regression in resolution caused by a reversion to a revision.” - jsmorley, 2017
User avatar
jsmorley
Developer
Posts: 18445
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Feature] CURRENTROOTSECTION

jsmorley » November 17th, 2018, 6:44 am

Sorry, but in my opinion this is just not likely to happen. This is just a huge amount of code to implement something that will be of use for less than 1% of authors who write massive skins and can't figure out how copy/paste works, and at the same time is just incomprehensible to the average or new user. To be honest, it's close to incomprehensible for me...

What we look at when we decide to spend limited resources is whether or not some change adds a new feature that is something that extends the functionality of Rainmeter, and is going to be something a majority of authors / users would want.
oZone
Posts: 57
Joined: May 14th, 2018, 4:46 pm

Re: [Feature] CURRENTROOTSECTION

oZone » November 17th, 2018, 6:48 pm

I wish I had time and could program in c++.