It is currently April 19th, 2024, 10:00 am

Dynamic width within a max width value

Get help with installing and using Rainmeter.
brokendrum
Posts: 2
Joined: November 12th, 2018, 12:34 pm

Dynamic width within a max width value

Post by brokendrum »

Hello from a newcomer/beginner,

I hope the title description fits the following problem I am trying to solve :

I am trying to design a music player rainmeter skin.
I have the cover of the album as a background set to W=288 and H=125
Within this area I load the text of the Artist, Tracktitle and Album on top of the cover, with a black solidcolor underneath it to
make the font visible on top of the cover background.
The width of the solidcolor area depends on the width of the text of the artist, tracktitle and album thus having a variable width.
Sometimes the artist name/track/album overflows the background/cover area (w=288), so when this happens I would like it to have a max width of lets say W=250 and clip the text when overflowing starts to occur.

Maybe I am making this way more difficult than it should be, hopefully somebody could point me in the right direction!
Thanks in advance!
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Dynamic width within a max width value

Post by jsmorley »

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeterExample]
Meter=String
ClipString=1
W=250
FontSize=14
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=My Uncle Used to Love Me but She Died

1.png

https://docs.rainmeter.net/manual/meters/string/#ClipString

That will create a fixed-width String meter of 250 pixels, which will clip the text when it exceeds that width.

Note that this will actually be 260 pixels wide, due to the Padding option I have on it. You can make the width 240 instead, to account for the Padding and end up with a fixed width of 250.

To have a variable width String meter, that still clips at 250 pixels, you might use:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeterExample]
Meter=String
ClipString=2
ClipStringW=250
H=22
FontSize=14
FontWeight=400
FontColor=255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=My Uncle Used to Love Me but She Died\
The key to that is to set a height with H, so it clips rather than wrapping.

https://docs.rainmeter.net/manual/meters/string/#ClipStringW

Note as well that clipping is done on "word boundaries" when possible, so depending on the text, it may be clipped sooner than the full 250 pixels.
You do not have the required permissions to view the files attached to this post.
brokendrum
Posts: 2
Joined: November 12th, 2018, 12:34 pm

Re: Dynamic width within a max width value

Post by brokendrum »

Thank u!, after going through the beta manual and forum the last couple of days trying to find the answer it seems I have overlooked this completely......bah. Well thanks again and also for making a wonderful program!
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Dynamic width within a max width value

Post by jsmorley »

brokendrum wrote: November 12th, 2018, 3:05 pm Thank u!, after going through the beta manual and forum the last couple of days trying to find the answer it seems I have overlooked this completely......bah. Well thanks again and also for making a wonderful program!
With 150+ pages of documentation, it's easy to do...

Glad to help.