It is currently October 16th, 2024, 10:24 am

Meters Auto-Adjust to container's height (?)

Get help with creating, editing & fixing problems with skins
RicardoTM
Posts: 366
Joined: December 28th, 2022, 9:30 pm
Location: México

Meters Auto-Adjust to container's height (?)

Post by RicardoTM »

EDIT: ANSWER HERE


Hey, I've been trying to come up with a solution but I think I'm over-burned cause I can't think of anything lol, so maybe someone can help.

The idea is to Auto Adjust meters to the height of their container.

Example:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1

[Text]
Container=Container
FontColor=255,255,255
FontSize=12
StringAlign=Center
X=([Container:W]/2)
Y=([Container:H]/[#NumberOfMeters])r

[Variables]
NumberOfMeters=20
FGW=400
FGH=500

[Background]
Meter=Image
SolidColor=0,0,0
W=500
H=600

[Foreground]
Meter=Image
SolidColor=10,10,10
W=[#FGW]
H=[#FGH]
Y=50
X=([Background:W]-[Container:W])/2
DynamicVariables=1

[Container]
Meter=Image
SolidColor=10,10,10
W=[Foreground:W]
H=[Foreground:H]
Y=50
X=([Background:W]-[Container:W])/2
DynamicVariables=1

[Text1]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
Y=r

[Text2]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text3]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text4]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text5]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text6]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text7]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text8]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text9]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text10]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text11]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text12]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text13]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text14]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text15]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text16]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text17]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text18]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text19]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text20]
Meter=String
MeterStyle=Text
Text=This is a test string.
Sorry for the lazy example. The idea is to make all the strings to be equally spaced, the first string should be at the top of the container (where it is on the example) and the last string should be at the bottom of the container. All strings between them should be equially spaced. The solution should make it so that when there's more or less strings, the outcome is always the same, the first at the top, the last at the bottom, and the strings in between equally spaced.

The idea is basically to do what Y=R on all meters does, but considering the Containers Height for the spacing. In the example all meters have the same size, but the soulution should work even if meters are of different sizes, and types, like meters and shapes for example. The closest I have gotten is Y=([Container:H]/[#NumberOfMeters])r but it's not perfect.

You can play with the FGH variable to see what I mean.

Any ideas?

PS. I edited and changed the code a little.


EDIT: ANSWER HERE
Last edited by RicardoTM on October 12th, 2024, 9:37 pm, edited 3 times in total.
User avatar
balala
Rainmeter Sage
Posts: 16659
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Meters Auto-Adjust to container's height (?)

Post by balala »

RicardoTM wrote: October 10th, 2024, 3:46 pm The idea is to make all the strings to be equally spaced, the first string should be at the top of the container (where it is on the example) and the last string should be at the bottom of the container. All strings between them should be equially spaced. The solution should make it so that when there's more or less strings, the outcome is always the same, the first at the top, the last at the bottom, and the strings in between equally spaced.

The idea is basically to do what Y=R on all meters does, but considering the Containers Height for the spacing.
I'd position the meters absolutely.
For instance:
  • To can simpler check the result, add a NumOfStrings variable into the [Variables] section. This variable will control the number of visible strings: NumOfStrings=20 (NumOfStrings=20 means all 20 meters visible, but you obviously can use any number below 20 - above 20 makes no sense).
  • Remove the Y=R option from the [Text] section, because it'll be not needed. We'll add the position of each meter directly to the meter (however since all meters will have a Y option, you finally can keep this option, but it'll be ignored).
  • Add the following Y and Hidden options to each of the [Text1] - [Text20] meters. Note that Hidden option is only needed to hide the last meters when you set the number of string meters (through the NumOfStrings variable, added above). Depending on your needs, you can remove these options later:

    Code: Select all

    [Text1]
    ...
    Y=(0*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    
    [Text2]
    ...
    Y=(1*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<2)
    
    [Text3]
    ...
    Y=(2*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<3)
    
    [Text4]
    ...
    Y=(3*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<4)
    
    [Text5]
    ...
    Y=(4*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<5)
    
    [Text6]
    ...
    Y=(5*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<6)
    
    [Text7]
    ...
    Y=(6*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<7)
    
    [Text8]
    ...
    Y=(7*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<8)
    
    [Text9]
    ...
    Y=(8*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<9)
    
    [Text10]
    ...
    Y=(9*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<10)
    
    [Text11]
    ...
    Y=(10*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<11)
    
    [Text12]
    ...
    Y=(11*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<12)
    
    [Text13]
    ...
    Y=(12*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<13)
    
    [Text14]
    ...
    Y=(13*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<14)
    
    [Text15]
    ...
    Y=(14*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<15)
    
    [Text16]
    ...
    Y=(15*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<16)
    
    [Text17]
    ...
    Y=(16*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<17)
    
    [Text18]
    ...
    Y=(17*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<18)
    
    [Text19]
    ...
    Y=(18*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<19)
    
    [Text20]
    ...
    Y=(19*([Container:H]-[#CURRENTSECTION#:H])/#NumOfStrings#)
    Hidden=(#NumOfStrings#<20)
    I didn't add a Hidden option to the [Text1] meter, because hiding this meter makes the whole code useless. You must have at least one meter visible (maybe even two).
User avatar
Yincognito
Rainmeter Sage
Posts: 8471
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Meters Auto-Adjust to container's height (?)

Post by Yincognito »

Generally speaking, if we take this LineCount=3 simplified example:

Code: Select all

LineH
GapH
LineH
GapH
LineH
you'll notice that, for no gap at the top and bottom, the ContainerH = LineH * LineCount + GapH * (LineCount - 1) = LineCount * (LineH + GapH) - GapH equation always holds true. So, if you know ContainerH, LineH and LineCount, you can easily deduce GapH.

For gaps at the top and bottom, the above is very slightly different:

Code: Select all

GapH
LineH
GapH
LineH
GapH
LineH
GapH
i.e. ContainerH = LineH * LineCount + GapH * (LineCount + 1) = LineCount * (LineH + GapH) + GapH, making just as easy to deduce GapH if you know the other values.

There are other variations of this, but you get the idea. This can be applied even to the case where meters have different heights (except that instead of LineH * LineCount you'll have something like Meter1H + Meter2H + ... MeterLineCountH), of course, assuming that GapH is the same.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RicardoTM
Posts: 366
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Meters Auto-Adjust to container's height (?)

Post by RicardoTM »

balala wrote: October 10th, 2024, 6:50 pm I'd position the meters absolutely.
For instance:
  • To can simpler check the result, add a NumOfStrings variable into the [Variables] section. This variable will control the number of visible strings: NumOfStrings=20 (NumOfStrings=20 means all 20 meters visible, but you obviously can use any number below 20 - above 20 makes no sense).
  • Remove the Y=R option from the [Text] section, because it'll be not needed. We'll add the position of each meter directly to the meter (however since all meters will have a Y option, you finally can keep this option, but it'll be ignored).
  • Add the following Y and Hidden options to each of the [Text1] - [Text20] meters. Note that Hidden option is only needed to hide the last meters when you set the number of string meters (through the NumOfStrings variable, added above). Depending on your needs, you can remove these options later:
Hey Balala, thanks for your answer, this method is essentially the same as my method described above (it seems you answered right before I finished editing the post lol, please check it again.). Although it works, it's also not perfect, if you change the FGH variable to something like 900 for example, you'll notice the last gap at the end will increase more and more as the Height increases. Which the point is that the last meter stays always at the bottom of the container.
Yincognito wrote: October 10th, 2024, 6:58 pm There are other variations of this, but you get the idea. This can be applied even to the case where meters have different heights (except that instead of LineH * LineCount you'll have something like Meter1H + Meter2H + ... MeterLineCountH), of course, assuming that GapH is the same.
Interesting take, I'll do some testing. Ty
User avatar
Yincognito
Rainmeter Sage
Posts: 8471
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Meters Auto-Adjust to container's height (?)

Post by Yincognito »

And a minor adjustment based on your (edited) code sample:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1

[Text]
Container=Container
FontColor=255,255,255
FontSize=12
StringAlign=Center
X=([Container:W]/2)
Y=(([Container:H]-[#NumberOfMeters]*[#MeterHeight])/([#NumberOfMeters]-1))R
DynamicVariables=1
SolidColor=255,0,0,255

[Variables]
NumberOfMeters=20
FGW=400
FGH=500
MeterHeight=18

[Background]
Meter=Image
SolidColor=0,0,0
W=500
H=600

[Foreground]
Meter=Image
SolidColor=10,10,10
W=[#FGW]
H=[#FGH]
Y=50
X=([Background:W]-[Container:W])/2
DynamicVariables=1

[Container]
Meter=Image
SolidColor=10,10,10
W=[Foreground:W]
H=[Foreground:H]
Y=50
X=([Background:W]-[Container:W])/2
MouseScrollUpAction=[!SetVariable NumberOfMeters (Clamp([#NumberOfMeters]+1,1,100))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable NumberOfMeters (Clamp([#NumberOfMeters]-1,1,100))][!UpdateMeter *][!Redraw]
DynamicVariables=1

[Text1]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
Y=r

[Text2]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text3]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text4]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text5]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text6]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text7]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text8]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text9]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text10]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.

[Text11]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text12]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text13]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text14]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text15]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text16]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text17]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text18]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text19]
Meter=String
MeterStyle=Text
Text=This is a test string.

[Text20]
Meter=String
MeterStyle=Text
Text=This is a test string.
Scroll on the foreground to change the number of meters. Didn't bother to cover the potential division by 0 case when NumberOfMeters is 1, by the way, where a simple conditional will do. Also, since meters other than Shape ones only take integer coordinates, there will be some rounding inconsistencies, that can be alleviated / eliminated via Round(), Trunc() and such.If you change the font or its size, the hardcoded MeterHeight will need to be readjusted (I'd recommend an invisible meter near the top of the skin to first get that value in order to use it afterwards).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RicardoTM
Posts: 366
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Meters Auto-Adjust to container's height (?)

Post by RicardoTM »

Yincognito wrote: October 10th, 2024, 7:36 pm And a minor adjustment based on your (edited) code sample:

Scroll on the foreground to change the number of meters. Didn't bother to cover the potential division by 0 case when NumberOfMeters is 1, by the way, where a simple conditional will do. Also, since meters other than Shape ones only take integer coordinates, there will be some rounding inconsistencies, that can be alleviated / eliminated via Round(), Trunc() and such.If you change the font or its size, the hardcoded MeterHeight will need to be readjusted (I'd recommend an invisible meter near the top of the skin to first get that value in order to use it afterwards).
Hey, thanks for the example code. It works fine, as long as all the meters are the same height. It has to work even if the meters are different Heights.

Here's how it breaks:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1

[Text]
Container=Container
FontColor=255,255,255
FontSize=12
StringAlign=Center
X=([Container:W]/2)
Y=(([Container:H]-[#NumberOfMeters]*[[#CurrentSection]:H])/([#NumberOfMeters]-1))R
DynamicVariables=1
SolidColor=255,0,0,255

[Variables]
NumberOfMeters=20
FGW=400
FGH=500
MeterHeight=18

[Background]
Meter=Image
SolidColor=0,0,0
W=500
H=600

[Foreground]
Meter=Image
SolidColor=10,10,10
W=[#FGW]
H=[#FGH]
Y=50
X=([Background:W]-[Container:W])/2
DynamicVariables=1

[Container]
Meter=Image
SolidColor=10,10,10
W=[Foreground:W]
H=[Foreground:H]
Y=50
X=([Background:W]-[Container:W])/2
MouseScrollUpAction=[!SetVariable FGH (Clamp([#FGH]+1,1,600))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable FGH (Clamp([#FGH]-1,1,600))][!UpdateMeter *][!Redraw]
DynamicVariables=1

[Text1]
Meter=String
MeterStyle=Text
Text=THIS IS THE FIRSTSTRING.
FontSize=25
Y=r

[Text2]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=12

[Text3]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=13

[Text4]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=7

[Text5]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=18

[Text6]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=35

[Text7]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=2

[Text8]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=19

[Text9]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=6

[Text10]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=5

[Text11]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=8

[Text12]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=7

[Text13]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=10

[Text14]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=18

[Text15]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=26

[Text16]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=35

[Text17]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=18

[Text18]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=7

[Text19]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=6

[Text20]
Meter=String
MeterStyle=Text
Text=This is the last string.
FontSize=5
I changed the [#MeterHeight] part to [[#CurrentSection]:H] but sadly it doesn't work as expected. Also change the first and last strings to "This is the first string" and "This is the last string".

Edit. Also changed the mouse action to change the height of the container instead of the number of meters.
RicardoTM
Posts: 366
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Meters Auto-Adjust to container's height (?)

Post by RicardoTM »

I made another post just to let you know I edited the code on my last answer.
User avatar
Yincognito
Rainmeter Sage
Posts: 8471
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Meters Auto-Adjust to container's height (?)

Post by Yincognito »

RicardoTM wrote: October 10th, 2024, 7:45 pmIt has to work even if the meters are different Heights.
It will, but:
Yincognito wrote: October 10th, 2024, 6:58 pmThis can be applied even to the case where meters have different heights (except that instead of LineH * LineCount you'll have something like Meter1H + Meter2H + ... MeterLineCountH), of course, assuming that GapH is the same.

RicardoTM wrote: October 10th, 2024, 7:45 pmI changed the [#MeterHeight] part to [[#CurrentSection]:H] but sadly it doesn't work as expected.
Of course it doesn't, see the above. Doing this change you assumed that all meters have the current meter's height, which is obviously not the case in your last code.

RicardoTM wrote: October 10th, 2024, 7:45 pmAlso change the first and last strings to "This is the first string" and "This is the last string".

Edit. Also changed the mouse action to change the height of the container instead of the number of meters.
Yep, that's more naturally appropriate indeed.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
Yincognito
Rainmeter Sage
Posts: 8471
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Meters Auto-Adjust to container's height (?)

Post by Yincognito »

RicardoTM wrote: October 10th, 2024, 7:45 pmIt has to work even if the meters are different Heights.
For example:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1

[Text]
Container=Container
FontColor=255,255,255
FontSize=12
StringAlign=Center
X=([Container:W]/2)
Y=(([Container:H]-[&Text1:H]-[&Text2:H]-[&Text3:H]-[&Text4:H]-[&Text5:H]-[&Text6:H]-[&Text7:H]-[&Text8:H]-[&Text9:H]-[&Text10:H]-[&Text11:H]-[&Text12:H]-[&Text13:H]-[&Text14:H]-[&Text15:H]-[&Text16:H]-[&Text17:H]-[&Text18:H]-[&Text19:H]-[&Text20:H])/([#NumberOfMeters]-1))R
DynamicVariables=1
SolidColor=255,0,0,255

[Variables]
NumberOfMeters=20
FGW=400
FGH=500
MeterHeight=18

[Background]
Meter=Image
SolidColor=0,0,0
W=500
H=600

[Foreground]
Meter=Image
SolidColor=10,10,10
W=[#FGW]
H=[#FGH]
Y=50
X=([Background:W]-[Container:W])/2
DynamicVariables=1

[Container]
Meter=Image
SolidColor=10,10,10
W=[Foreground:W]
H=[Foreground:H]
Y=50
X=([Background:W]-[Container:W])/2
MouseScrollUpAction=[!SetVariable FGH (Clamp([#FGH]+1,1,600))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable FGH (Clamp([#FGH]-1,1,600))][!UpdateMeter *][!Redraw]
DynamicVariables=1

[Text1]
Meter=String
MeterStyle=Text
Text=THIS IS THE FIRSTSTRING.
FontSize=25
Y=r

[Text2]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=12

[Text3]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=13

[Text4]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=7

[Text5]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=18

[Text6]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=35

[Text7]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=2

[Text8]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=19

[Text9]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=6

[Text10]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=5

[Text11]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=8

[Text12]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=7

[Text13]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=10

[Text14]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=18

[Text15]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=26

[Text16]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=35

[Text17]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=18

[Text18]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=7

[Text19]
Meter=String
MeterStyle=Text
Text=This is a test string.
FontSize=6

[Text20]
Meter=String
MeterStyle=Text
Text=This is the last string.
FontSize=5
The fact that the last meter is not always at the bottom has to do with the round-ing / trunc-ing inconsistencies I mentioned earlier.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
RicardoTM
Posts: 366
Joined: December 28th, 2022, 9:30 pm
Location: México

Re: Meters Auto-Adjust to container's height (?)

Post by RicardoTM »

Yincognito wrote: October 10th, 2024, 8:03 pm It will, but:



Of course it doesn't, see the above. Doing this change you assumed that all meters have the current meter's height, which is obviously not the case in your last code.



Yep, that's more naturally appropriate indeed.
Got you, I forgot to re-read your answer and focused on the given code lol, this works as expected.

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1

[Text]
Container=Container
FontColor=255,255,255
FontSize=12
StringAlign=Center
X=([Container:W]/2)
Y=(([Container:H]-([Text1:H]+[Text2:H]+[Text3:H]+[Text4:H]+[Text5:H]+[Text6:H]+[Text7:H]+[Text8:H]+[Text9:H]+[Text10:H]))/([#NumberOfMeters]-1))R
DynamicVariables=1
SolidColor=255,0,0,255

[Variables]
NumberOfMeters=10
FGW=400
FGH=500
MeterHeight=12

[Background]
Meter=Image
SolidColor=0,0,0
W=500
H=600

[Foreground]
Meter=Image
SolidColor=10,10,10
W=[#FGW]
H=[#FGH]
Y=50
X=([Background:W]-[Container:W])/2
DynamicVariables=1

[Container]
Meter=Image
SolidColor=10,10,10
W=[Foreground:W]
H=[Foreground:H]
Y=50
X=([Background:W]-[Container:W])/2
MouseScrollUpAction=[!SetVariable FGH (Clamp([#FGH]+5,1,500))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable FGH (Clamp([#FGH]-5,1,500))][!UpdateMeter *][!Redraw]
DynamicVariables=1

[Text1]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
Y=r
FontSize=25

[Text2]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=8

[Text3]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=13

[Text4]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=10

[Text5]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=5

[Text6]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=12

[Text7]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=28

[Text8]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=13

[Text9]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=18

[Text10]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=5
I reduced the number of meters just because I was too lazy to keep the formula going.

Which that's the downside of this take, a long ass formula lol.

Guess this is the winning solution, until someone comes up with something better (for the sake of laziness).

Edit. didn't see you answer above, but yeah, is basically the same code I posted here.

A question though, you used [&Text:H], there's a reason for that? (It works fine with [Text:H])
Edited to keep as final answer.

Answer:

Y=(round(([&Container:H]-([Meter1:H]+[Meter2:H]+[Meter3:H] ... [Meter10:H]))/([#NumberOfMeters]-1)))R

For width is the same but using it on X and changing all H for W.

Example code: (Scroll on skin to change container's height)

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1

[Text]
Container=Container
FontColor=255,255,255
FontSize=12
StringAlign=Center
X=([Container:W]/2)
Y=(round(([Container:H]-([Text1:H]+[Text2:H]+[Text3:H]+[Text4:H]+[Text5:H]+[Text6:H]+[Text7:H]+[Text8:H]+[Text9:H]+[Text10:H]))/([#NumberOfMeters]-1)))R
DynamicVariables=1
SolidColor=255,0,0,255

[Variables]
NumberOfMeters=10
FGW=400
FGH=500
MeterHeight=12

[Background]
Meter=Image
SolidColor=0,0,0
W=500
H=600

[Foreground]
Meter=Image
SolidColor=10,10,10
W=[#FGW]
H=[#FGH]
Y=50
X=([Background:W]-[Container:W])/2
DynamicVariables=1

[Container]
Meter=Image
SolidColor=10,10,10
W=[Foreground:W]
H=[Foreground:H]
Y=50
X=([Background:W]-[Container:W])/2
MouseScrollUpAction=[!SetVariable FGH (Clamp([#FGH]+5,1,500))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable FGH (Clamp([#FGH]-5,1,500))][!UpdateMeter *][!Redraw]
DynamicVariables=1

[Text1]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
Y=r
FontSize=25

[Text2]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=8

[Text3]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=13

[Text4]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=10

[Text5]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=5

[Text6]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=12

[Text7]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=28

[Text8]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=13

[Text9]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=18

[Text10]
Meter=String
MeterStyle=Text
Text=THIS IS A TEST STRING.
FontSize=5
Last edited by RicardoTM on October 12th, 2024, 9:36 pm, edited 3 times in total.