It is currently April 26th, 2024, 2:32 pm

Duplicate padding in MeterStyle inheritance scenario

Get help with creating, editing & fixing problems with skins
User avatar
Yincognito
Rainmeter Sage
Posts: 7171
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Duplicate padding in MeterStyle inheritance scenario

Post by Yincognito »

Optional reading:
Ok, so up until now I used a system in my skins to make them "font dimensions - aware", by setting the width/height of the skins to multiples of FontSize value. The system worked, but I had to keep two user-modifiable options in my Settings skin that would further multiply those widths/heights in relation to whether a font was wider or narrower (I called them TextWidthRatio/TextHeightRatio).

Recently I thought about changing the system to be more flexible, without setting any more additional options except FontSize (and obviously FontFace). That led me to a hybrid of DynamicWindowSize=1 and string (width/height) references that would make the actual text occupy a fixed width/height in the skin (but a width/height that is dynamically adjusting to the width/height of the reference string). Yeah, I know, it sounds complicated and absurd (one part dynamic, the other fixed, what's up with that?!), but I didn't find another way to make the text occupy a fixed frame that is also font specific - something like a width/height - aware 1em unit...
The problem I have is that while attempting to do the above, I used MeterStyle inheritance (with the reference string supposed to become transparent for the actual string that would occupy the frame that the reference string "built" for it) and since I also apply some padding (on both strings), I noticed that the padding becomes "duplicated", even though the manual says that options on the child meter and later parents override (not duplicate, right?) the options on (previous) parents. Sure, the manual also says that Padding will dynamically adjust the width/height of the meter, but should that happen multiple times instead of just once (since it's only one instance of padding in the "chain")?

But enough with the history, let's see the (simplified) example:

Code: Select all

[Rainmeter]
DynamicWindowSize=1
AccurateText=1

[Styles]

[SCol]
SolidColor=64,64,96,160
ClipString=2
FontFace=Tahoma
FontColor=0,0,0,255
FontSize=12
AntiAlias=1
Y=5
Padding=4,0,4,0

[STitleCol]
StringStyle=Bold
X=5

[STitleColText]
FontColor=255,255,255,255
X=5
W=[MT_TitleCol:W]
H=[MT_TitleCol:H]
DynamicVariables=1

---Meters---

[MT_TitleCol]
Meter=STRING
MeterStyle=SCol | STitleCol
Text="DK.W"
UpdateDivider=-1
DynamicVariables=1

[MT_Actual_Title]
Meter=STRING
MeterStyle=SCol | STitleCol | STitleColText
Text="CPU"
DynamicVariables=1

[MT_Info]
Meter=STRING
FontSize=12
FontColor=255,255,255,255
SolidColor=0,0,0,255
AntiAlias=1
H=20
X=5
Y=50
Text=Reference Title (fixed) W: [MT_TitleCol:W], Actual Title (variable) W: [MT_Actual_Title:W]
DynamicVariables=1
...and the result...
Duplicate Padding In MeterStyle Inheritance.jpg
What happens is that MT_TitleCol is setting up a fixed (but font dependant) width/height for MT_Actual_Title, but since both meters have (a single) instance of padding in their MeterStyle inheritance "chain", that padding gets duplicated. I would like either to eliminate the double padding, if possible (while still be able to set up a width for MT_Actual_Title using MT_TitleCol or similar reference) or ... find another way of achieving a font specific width that should be the "placeholder" for the actual title meter (which, in practice, will be "up to" the width of the reference string/meter, aka MT_TitleCol).

Hopefully, I wasn't too ellaborate in my description, but I had to explain what I would like to achieve so that if a better way is available, you could point me in that direction.
You do not have the required permissions to view the files attached to this post.
Last edited by Yincognito on January 20th, 2019, 2:32 pm, edited 1 time in total.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Duplicate padding in MeterStyle inheritance scenario

Post by ikarus1969 »

Just for the case that you haven't already thought about that - i would do:
  • define a variable for the padding, e.g. MyPadding=4
  • use that variable in the style SCol: Padding=#MyPadding#,0,#MyPadding#,0
  • use that variable in the style STitleColText: W=([MT_TitleCol:W] - 2 * #MyPadding#)
User avatar
Yincognito
Rainmeter Sage
Posts: 7171
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Duplicate padding in MeterStyle inheritance scenario

Post by Yincognito »

ikarus1969 wrote: January 17th, 2019, 8:00 am Just for the case that you haven't already thought about that - i would do:
  • define a variable for the padding, e.g. MyPadding=4
  • use that variable in the style SCol: Padding=#MyPadding#,0,#MyPadding#,0
  • use that variable in the style STitleColText: W=([MT_TitleCol:W] - 2 * #MyPadding#)
Yeah, that would be a good idea ... if it worked. You estimated correctly, I already thought about that (my previous system was already using variables to store paddings, although I did not apply this method at the time of posting). But I did in the meantime, and what happens is that the W and H come out correctly when displaying them in the info meter (being the same as the reference meter), yet the width on which the text is drawn in the actual title is less than the same width for the reference meter. Basically, although the total widths (including paddings) seem the same in both cases (reference and the actual string), because of the subtraction the width of the actual string text (excludind paddings, that is) is less than the corresponding width of the reference meter.

It looks like paddings are applied not at the time of defining them, but at the time of actually drawing the meters on the screen (or immediately after). This leads to consistent differences between the widths reported in an info meter (i.e. at the time of drawing) compared to the widths defined in the code, probably because the double padding is applied nevertheless:

Code: Select all

[Variables]
TextPaddingTop=0
TextPaddingLeft=4
TextPaddingBottom=-6
TextPaddingRight=4

[Rainmeter]
DynamicWindowSize=1
AccurateText=1

[Styles]

[SCol]
SolidColor=64,64,96,160
ClipString=2
FontFace=Tahoma
StringEffect=Shadow
FontColor=0,0,0,255
FontSize=12
AntiAlias=1
Y=5
Padding=#TextPaddingLeft#,#TextPaddingTop#,#TextPaddingRight#,#TextPaddingBottom#

[STitleCol]
StringStyle=Bold
X=5

[STitleColText]
FontColor=255,255,255,255
X=5
W=([MT_TitleCol:W]-(#TextPaddingLeft#+#TextPaddingRight#))
H=([MT_TitleCol:H]-(#TextPaddingTop#+#TextPaddingBottom#))

---Meters---

[MT_TitleCol]
Meter=STRING
MeterStyle=SCol | STitleCol
Text="DK.W"
UpdateDivider=-1
DynamicVariables=1

[MT_Actual_Title]
Meter=STRING
MeterStyle=SCol | STitleCol | STitleColText
Text="DK.W"
DynamicVariables=1

[MT_Info]
Meter=STRING
FontSize=12
FontColor=255,255,255,255
SolidColor=0,0,0,255
AntiAlias=1
H=20
X=5
Y=50
Text="Reference Title (fixed) W: [MT_TitleCol:W], Actual Title (variable) W: [MT_Actual_Title:W]; Reference Title (fixed) H: [MT_TitleCol:H], Actual Title (variable) H: [MT_Actual_Title:H]"
DynamicVariables=1
Double Padding Issue.jpg
So, you see, the W/H are the same, yet the text in the actual title is truncated, despite it supposed to be the same width as the text of the reference meter and even the strings being the same. I intentionally let a negative padding for the bottom, to show up another interesting (read: annoying) behavior: the text is drawn outside the background, even though in theory this is negatively padded at the bottom. And that happens for both meters, so it's not the double padding at fault here.
You do not have the required permissions to view the files attached to this post.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: Duplicate padding in MeterStyle inheritance scenario

Post by ikarus1969 »

Another strange behavior:
there's no clipping with font-sizes 48, 96, 144, 192, and so on (multiples of 48)
In the following code i've just inserted the mouse actions to change the font size dynamically:

Code: Select all

[Variables]
TextPaddingTop=0
TextPaddingLeft=4
TextPaddingBottom=-6
TextPaddingRight=4
FS=12

[Rainmeter]
DynamicWindowSize=1
AccurateText=1

[Styles]

[SCol]
SolidColor=64,64,96,160
ClipString=2
FontFace=Tahoma
StringEffect=Shadow
FontColor=0,0,0,255
FontSize=#FS#
; InlineSetting=Size | 128
AntiAlias=1
Y=5
Padding=#TextPaddingLeft#,#TextPaddingTop#,#TextPaddingRight#,#TextPaddingBottom#
DynamicVariables=1
MouseScrollUpAction=  [!SetVariable "FS" "(CLAMP(#FS# + 1, 12, 256))"][!UpdateMeter "*"][!Redraw]
MouseScrollDownAction=[!SetVariable "FS" "(CLAMP(#FS# - 1, 12, 256))"][!UpdateMeter "*"][!Redraw]

[STitleCol]
StringStyle=Bold
X=5

[STitleColText]
FontColor=255,255,255,255
; X=5
W=([MT_TitleCol:W]-(#TextPaddingLeft#+#TextPaddingRight#))
H=([MT_TitleCol:H]-(#TextPaddingTop#+#TextPaddingBottom#))
; DynamicVariables=1

---Meters---

[MT_TitleCol]
Meter=STRING
MeterStyle=SCol | STitleCol
Text="1234"
; UpdateDivider=-1

[MT_Actual_Title]
Meter=STRING
MeterStyle=SCol | STitleCol | STitleColText
Text="1234"

[MT_Info]
Meter=STRING
FontSize=12
FontColor=255,255,255,255
SolidColor=0,0,0,255
AntiAlias=1
; H=20
X=5
Y=10R
Text="FontSize=#FS##CRLF#Reference Title (fixed) W: [MT_TitleCol:W], Actual Title (variable) W: [MT_Actual_Title:W]; Reference Title (fixed) H: [MT_TitleCol:H], Actual Title (variable) H: [MT_Actual_Title:H]"
DynamicVariables=1
User avatar
Brian
Developer
Posts: 2684
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Duplicate padding in MeterStyle inheritance scenario

Post by Brian »

User avatar
Yincognito
Rainmeter Sage
Posts: 7171
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Duplicate padding in MeterStyle inheritance scenario

Post by Yincognito »

The most recent Rainmeter version (4.3.0.3277b), coupled with ikarus1969 solution of subtracting the padding from the width of the actual string solved the issue, so I'm marking this as solved. Thank you!
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth