It is currently October 18th, 2019, 7:09 am

Trouble with moving author line dependant on quote length

Help with creating, editing & fixing problems with skins
magnusvn
Posts: 2
Joined: May 8th, 2019, 3:36 pm

Trouble with moving author line dependant on quote length

magnusvn » May 8th, 2019, 3:46 pm

What i'm trying to do is have the text where the authors name is displayed automatically move further down if the quote text wraps down to a second (or even third) line.

So i was wondering if there was a way to change the "Y" variable in [MeasureAuthor] depending on if the text in [MeasureQuote] clips down to another line.

Code: Select all

[Rainmeter] 
Update=1000 

[Metadata] 
Name=Quotes

[Variables] 
TextColor=255,255,255,255
TextColor2=56,222,218,255
LabelColor=255,255,255,90
LineHeight=20
RSS=http://www.quotationspage.com/data/qotd.rss 
Substitute="":"...","&amp;":"&","&quot;":"'","<![CDATA[":"","]]>":"" 

[MeasureAuthor] 
Measure=Plugin 
Plugin=Plugins\WebParser.dll 
URL=http://www.quotationspage.com/data/qotd.rss
RegExp="(?siU)<title>(.*)</title>.*<link>(.*)</link>.*<item>.*<title>(.*)</title>.*<link>(.*)</link>.*<item>.*<title>(.*)</title>.*<link>(.*)</link>.*<item>.*<title>(.*)</title>.*<link>(.*)</link>.*<item>.*<title>(.*)</title>.*<link>(.*)</link>.*<item>.*<title>(.*)</title>.*<link>(.*)</link>" 
Substitute=#Substitute# 
StringIndex=3

[MeasureQuote] 
Measure=Plugin 
Plugin=Plugins\WebParser.dll 
URL=http://www.quotationspage.com/data/qotd.rss
RegExp="(?siU)<description>(.*)</description>.*<link>(.*)</link>.*<item>.*<description>(.*)</description>.*<link>(.*)</link>.*<item>.*<description>(.*)</description>.*<link>(.*)</link>.*<item>.*<description>(.*)</description>.*<link>(.*)</link>.*<item>.*<description>(.*)</description>.*<link>(.*)</link>.*<item>.*<description>(.*)</description>.*<link>(.*)</link>" 
Substitute=#Substitute# 
StringIndex=3

[MeterAuthor] 
Meter=String 
MeasureName=MeasureAuthor
X=170
Y=105 
W=290 
H=#LineHeight# 
ClipString=1 
FontColor=#TextColor2#
FontFace=Raleway Light
FontSize=12
StringAlign=RIGHT
StringStyle=NORMAL
AntiAlias=1
MouseOverAction=!Execute [!RainmeterShowMeter MeterHover1][!RainmeterRedraw] MouseLeaveAction=!Execute [!RainmeterHideMeter MeterHover1][!RainmeterRedraw] LeftMouseDownAction=[MeasureRSS1Link] 

[MeterQuote] 
Meter=String 
MeasureName=MeasureQuote
X=5 
Y=60
W=500
H=69
ClipString=1 
FontColor=#TextColor#
FontFace=Raleway Light
FontSize=12
StringAlign=LEFT
StringStyle=NORMAL
AntiAlias=1
MouseOverAction=!Execute [!RainmeterShowMeter MeterHover1][!RainmeterRedraw] MouseLeaveAction=!Execute [!RainmeterHideMeter MeterHover1][!RainmeterRedraw] LeftMouseDownAction=[MeasureRSS1Link] 

[MeterLineSeparator]
Meter=Image
X=0
Y=50
W=1
H=80
SolidColor=255,255,255,155
UpdateDivider=-1
User avatar
balala
Rainmeter Sage
Posts: 8852
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trouble with moving author line dependant on quote length

balala » May 8th, 2019, 6:12 pm

magnusvn wrote:
May 8th, 2019, 3:46 pm
So i was wondering if there was a way to change the "Y" variable in [MeasureAuthor] depending on if the text in [MeasureQuote] clips down to another line.
Although a relative positioning of the [MeterAuthor] meter could be used, this isn't a viable way, because if you set a size for the [MeterQuote] meter (having a W, a H and a ClipString option set, as you have), the meter(s) positioned relatively to this one will always have the same position.
So, you have to follow another way to achieve what you want. Here is my idea.
Add a second, practically invisible String meter, which shows the same string as [MeterQuote]. You'll need this meter, to can measure the size of the string needed to be shown. So add the following meter anywhere in your code:

Code: Select all

[MeterQuote1]
Meter=String
MeasureName=MeasureQuote
X=5
Y=60
FontColor=255,255,255,1
FontFace=Raleway Light
FontSize=12
StringAlign=LEFT
StringStyle=NORMAL
AntiAlias=1
Text=%1
See that this meter has the same settings as [MeterQuote], excepting the practically transparent color (due to the last parameter, which in this case is 1) and the missing MouseOverAction option.
Now this meter although not visible, can be used to measure the width of the shown string.
Now you have to modify the Y option of the [MeterAuthor] meter, to use the previously measured width and calculate the appropriate position of the meter, based on this width. Modify the Y option of the [MeterAuthor] meter, as it follows: Y=([MeterQuote:Y]+[MeterQuote1:H]*Ceil([MeterQuote1:W]/[MeterQuote:W])).Take care that using this position requires to set the dynamic variables on the meter. Don't forget to add the appropriate option to the same [MeterAuthor] meter (DynamicVariables=1).

And take care not to use nor the !Execute bang, nor the !Rainmeter... bang prefix, because both are deprecated.
magnusvn
Posts: 2
Joined: May 8th, 2019, 3:36 pm

Re: Trouble with moving author line dependant on quote length

magnusvn » May 8th, 2019, 8:20 pm

Thank you very much, it worked exactly as i had in mind :)
User avatar
balala
Rainmeter Sage
Posts: 8852
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Trouble with moving author line dependant on quote length

balala » May 8th, 2019, 8:32 pm

magnusvn wrote:
May 8th, 2019, 8:20 pm
Thank you very much, it worked exactly as i had in mind :)
Did it? I'm glad in this case.