It is currently May 23rd, 2024, 1:48 am
Use of "r" and "R" with right justified, dynamic string
-
- Posts: 17
- Joined: July 16th, 2010, 2:04 pm
Use of "r" and "R" with right justified, dynamic string
I'm trying to maintain a meter-image a couple of pixels to the left of a dynamic, right-justified (expands to the left) meter-string (weather description). I can't seem to accomplish that with the use of either "r" or "R" - neither keeps the image a fixed distance from the expanding left-edge of the text. Any advice?
-
- Posts: 100
- Joined: April 18th, 2009, 11:31 am
- Location: Sweden
Re: Use of "r" and "R" with right justified, dynamic string
Maybe X=-5r will work??davidross wrote:I'm trying to maintain a meter-image a couple of pixels to the left of a dynamic, right-justified (expands to the left) meter-string (weather description). I can't seem to accomplish that with the use of either "r" or "R" - neither keeps the image a fixed distance from the expanding left-edge of the text. Any advice?
Livet är bara en period man ska överleva.
Som filosoferna säger: man föds, man lever och man dör ensam...
Som filosoferna säger: man föds, man lever och man dör ensam...
-
- Posts: 17
- Joined: July 16th, 2010, 2:04 pm
Re: Use of "r" and "R" with right justified, dynamic string
That was roughly the first thing I tried but it doesn't work. It seems that for both pos and neg values of r and R, the position is set with respect to the right edge of the string which doesn't change in this case. But thank you.
-
- Moderator
- Posts: 1931
- Joined: January 29th, 2010, 1:43 am
- Location: Willmar, MN
Re: Use of "r" and "R" with right justified, dynamic string
r will always be the X/Y value of the meter directly above it in the code. When you right justify a string the X coordinate defines where the right side of the string will be. Unless you move your string meter, the coordinate provided by r will always be the right side of the string.
If the above information does not help you, posting your skin code for us to look at might.
If the above information does not help you, posting your skin code for us to look at might.
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
-
- Posts: 17
- Joined: July 16th, 2010, 2:04 pm
Re: Use of "r" and "R" with right justified, dynamic string
Smurfier, based on what you wrote, r or R won't work in this case because I want the meter it's associated with to maintain a fixed distance from the left edge of the variable length, right-justified meter-string directly above it in the code. Can this be done some other way?
-
- Posts: 608
- Joined: February 7th, 2011, 7:27 pm
- Location: Thessaloniki, GR
Re: Use of "r" and "R" with right justified, dynamic string
You could use .lua and string.len to measure the length of the string and make it !bang the correct X value.
Something like this (part of my code for sth else):
Basically, you would have to insert the description measure inside .lua, use string.len to count the length, and then use a !bang with a length-relative X value.
I don't know if that's the easy or only way, though.
Something like this (part of my code for sth else):
Code: Select all
if string.len(tTitles[iCurrentItem]) < 60 then
SKIN:Bang('!SetVariable "Height" "25r"')
end
I don't know if that's the easy or only way, though.
-
- Posts: 78
- Joined: March 9th, 2012, 10:06 am
Re: Use of "r" and "R" with right justified, dynamic string
String.len will return the lenght in characters. As an I and a an M will have a different (pixel) size, that would only be a rough approximation unless the type used is monospace. Most of the time, they are not the best looking fonts.
Better than nothing i suppose.
Better than nothing i suppose.
-
- Developer
- Posts: 22634
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: Use of "r" and "R" with right justified, dynamic string
There is no way to get the length in pixels of a "string" in Rainmeter, however you can get the "width" in pixels of the entire meter displaying a string. Don't know if this is of any help, I have not been following this thread closely, but perhaps using some of this functionality can get you closer to what you want.
Code: Select all
function Initialize()
mtMeterOne = SKIN:GetMeter('MeterOne')
mtMeterTwo = SKIN:GetMeter('MeterTwo')
end -->Initialize
function Update()
local MeterOneW = mtMeterOne:GetW()
local MeterOneX = mtMeterOne:GetX()
mtMeterTwo:SetX(MeterOneX + MeterOneW)
return "Done"
end -->Update
-
- Posts: 17
- Joined: July 16th, 2010, 2:04 pm
Re: Use of "r" and "R" with right justified, dynamic string
Thank you all for your help with this. I'll try a .lua script.