It is currently December 1st, 2021, 6:19 pm

[Feature] CURRENTROOTSECTION

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

[Feature] CURRENTROOTSECTION

Post by Active Colors »

Have you ever made a 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:

Code: Select all

[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 several meters that look the same but have different section name it will be a lot of effort to place same looking meters again. For instance, CPUbar, RAMbar, BatteryBar - all of them I want to look the same but in a different position according to the root where they should be placed.

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:

Code: Select all

[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
[MeterBattery] is a root meter. #CURRENTROOTSECTION of [MeterBattery|Value] meter will be relatively placed to the root meter [MeterBattery]. It reminds a bit the relative positioning but it works only to one meter next to the previous one, and #CURRENTROOTSECTION works from any place. Imagine you have a consequence of meters which you need to relatively place to another meter. To the root meter I can "attach" more meters, let's say, a bar:

Code: Select all

[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

[MeterBattery|Bar]
Meter=Bar
X=([#CURRENTROOTSECTION#:X]+0)
Y=([#CURRENTROOTSECTION#:Y]+10)
And let's assume I put another group of meters like CPU I will have pretty same logic going as in the Battery - showing Value and a Bar. Since the logic is the same and I have everywhere same formula I can put that formula in MeterStyles. So let me show first how it looks in general and then how it looks with MeterStyle.

Code: Select all

[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

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

[MeterCPU]
Meter=String
X=10
Y=30
Text=Battery:

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

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

You see the pattern? Let's simplify it:

Code: Select all

[StyleValue]
X=([#CURRENTROOTSECTION#:X]+30)
Y=([#CURRENTROOTSECTION#:Y]+0)

[StyleBar]
X=([#CURRENTROOTSECTION#:X]+0)
Y=([#CURRENTROOTSECTION#:Y]+10)

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

[MeterBattery|Value]
Meter=String
MeasureName=MeasureBattery
MeterStyle=StyleValue
Text=%1

[MeterBattery|Bar]
Meter=Bar
MeterStyle=StyleBar

[MeterCPU]
Meter=String
X=10
Y=30
Text=Battery:

[MeterCPU|Value]
Meter=String
MeasureName=MeasureBattery
MeterStyle=StyleValue
Text=%1

[MeterCPU|Bar]
Meter=Bar
MeterStyle=StyleBar
Now the same formulas are in one place in the MeterStyles. In such cases as you can see it is not possible to use simply #CURRENTSECTION# and I swear I have had such cases many times.



[HR]

A bit more advanced but real life example.


Imagine this case.
You have a system skin which shows all the system information like CPU, RAM, Battery, Video memory, Cores, etc. For every category of information the construction is pretty repetitive:
  1. 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)
  2. string meter - title (CPU, RAM, Battery, etc)
  3. string meter - value x%
  4. bar meter - visual representation of how full it is
  5. image meter= visual representation of a category like a small cpu icon
BEFORE:

Code: Select all

[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


[RAMMeasure]
Measure=RAM

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

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

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

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

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



AFTER:

Code: Select all

;--- 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

;---METERS
;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=40

[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
oZone
Posts: 146
Joined: May 14th, 2018, 4:46 pm

Re: [Feature] CURRENTROOTSECTION

Post by oZone »

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: 658
Joined: June 25th, 2015, 7:02 pm
Location: The Sky, USA

Re: [Feature] CURRENTROOTSECTION

Post by raiguard »

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: 22416
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Feature] CURRENTROOTSECTION

Post by jsmorley »

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: 146
Joined: May 14th, 2018, 4:46 pm

Re: [Feature] CURRENTROOTSECTION

Post by oZone »

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