It is currently May 1st, 2024, 4:51 am

struggling with new section variables for a rss feed

Get help with creating, editing & fixing problems with skins
dv-ent
Posts: 62
Joined: November 13th, 2011, 11:43 am

struggling with new section variables for a rss feed

Post by dv-ent »

basically how do i dynamically change the height of some of my rss feeds, so the next rss feed is always 25 underneath the last one - some feeds are much bigger and range from height 20 to 200. im kinda stumped :(

h= ???

Code: Select all


[Rainmeter]
Update=1000
Author=
DynamicWindowSize=1

[FeedTitle]
Meter=STRING
MeterStyle=1
MeasureName=RSS
X=50
Y=27

[Feed1]
Meter=STRING
MeasureName=MeasureRSS1
X=r
Y=([FeedTitle:Y] + 30)
H=20
W=950
MeterStyle=1
Clipstring=1
DynamicVariables=1
LeftMouseDownAction=["[MeasureLink1]"]
MouseOverAction=!Execute [!SetOption #CURRENTSECTION# FontColor 22a9ff][!Update]
MouseLeaveAction=!Execute [!SetOption #CURRENTSECTION# FontColor ffffff][!Update]


[Feed2]
Meter=STRING
MeasureName=MeasureRSS2
X=r
Y=([Feed1:Y] + 25)
H=20
W=950
MeterStyle=1
Clipstring=1
DynamicVariables=1
LeftMouseDownAction=["[MeasureLink2]"]
MouseOverAction=!Execute [!SetOption #CURRENTSECTION# FontColor 22a9ff][!Update]
MouseLeaveAction=!Execute [!SetOption #CURRENTSECTION# FontColor ffffff][!Update]

[Feed3]
Meter=STRING
MeasureName=MeasureRSS3
X=r
Y=([Feed2:Y] + 25)
H=20
W=950
MeterStyle=1
Clipstring=1
LeftMouseDownAction=["[MeasureLink3]"]
MouseOverAction=!Execute [!SetOption #CURRENTSECTION# FontColor 22a9ff][!Update]
MouseLeaveAction=!Execute [!SetOption #CURRENTSECTION# FontColor ffffff][!Update]

User avatar
AlC
Posts: 329
Joined: June 9th, 2011, 6:46 pm

Re: struggling with new section variables for a rss feed

Post by AlC »

Manual wrote:The Y-position of the meter inside the window. The coordinates can be made relative to the previous meter by adding 'r' to the end of the number (e.g. Y=-10r). You can also use capital R which makes the position relative to the bottom edge of the previous meter.
You know relative postions?

Y=25R should do it for you.

Or we make it complicated :)

Code: Select all


[FeedTitle]
Meter=STRING
MeterStyle=1
MeasureName=RSS
X=50
Y=27

[Feed1]
Meter=STRING
MeasureName=MeasureRSS1
X=r
Y=([FeedTitle:Y]+[FeedTitle:H] +25)
H=20
W=950
...

[Feed2]
Meter=STRING
MeasureName=MeasureRSS2
X=r
Y=([Feed1:Y]+[Feed1:H] +25)
H=20
W=950
...
Rainmeter - You are only limited by your imagination and creativity.
dv-ent
Posts: 62
Joined: November 13th, 2011, 11:43 am

Re: struggling with new section variables for a rss feed

Post by dv-ent »

i know y=25r !!

but some of my feeds text is larger than the 20 height ive clipstringed them to, but i want to display all of the text, then have y=25r for the next feed
... so what should h= ??

am i making sense ? its getting late here and im tired :(
User avatar
AlC
Posts: 329
Joined: June 9th, 2011, 6:46 pm

Re: struggling with new section variables for a rss feed

Post by AlC »

Ahh sorry I misread something in your post, it is also late here (00:14).
I will take a look tommorrow at this, sorry.
Rainmeter - You are only limited by your imagination and creativity.
dv-ent
Posts: 62
Joined: November 13th, 2011, 11:43 am

Re: struggling with new section variables for a rss feed

Post by dv-ent »

my reader would be something like this -

feed1 : text here

feed2 : text here
and here

feed3 : text here
and here
and here
and here

feed4 : text here

is it possible to dynamically alter the unknown height using the new section varaiables ?
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: struggling with new section variables for a rss feed

Post by KreAch3R »

I do what you want using Lua, counting the string's characters and use that to set an appropriate height for that meter. It's not perfect, because most fonts we use aren't monospace, but it works. Check the relevant code in my Reader skin:

Code: Select all

	-----------------------------------------------------------------------		
		-- STORY HEIGHT	
		
		if string.len(Titles) < 40 then
			SKIN:Bang('!SetOption "FeedStory'..j..'" H "20r"')
			elseif string.len(Titles) <80 then
			SKIN:Bang('!SetOption "FeedStory'..j..'" H "40r"')
			else
			SKIN:Bang('!SetOption "FeedStory'..j..'" H "60r"')
		end
If you want a living example, download the suite and play with it. :)
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
dv-ent
Posts: 62
Joined: November 13th, 2011, 11:43 am

Re: struggling with new section variables for a rss feed

Post by dv-ent »

thx kreacher - but i dont know lua at all :( maybe i'll have a play around later...

i tried this last night - and it kinda worked but went a bit crazy at the same time :

Code: Select all

[FeedTitle]
Meter=STRING
MeterStyle=1
MeasureName=RSS
X=50
Y=27


[Feed1]
Meter=STRING
MeasureName=MeasureRSS1
X=r
Y=([FeedTitle:Y] + 30)
H=([Feed1:H] + 10)
W=([Feed1:W] + 10)
MeterStyle=1
DynamicVariables=1
LeftMouseDownAction=["[MeasureLink1]"]

[Feed2]
Meter=STRING
MeasureName=MeasureRSS2
X=r
Y=([Feed1:Y] + 25)
H=([Feed2:H] + 10)
W=([Feed2:W] + 10)
MeterStyle=1
DynamicVariables=1
LeftMouseDownAction=["[MeasureLink2]"]

[Feed3]
Meter=STRING
MeasureName=MeasureRSS3
X=r
Y=([Feed2:Y] + 25)
H=([Feed3:H] + 10)
W=([Feed3:W] + 10)
MeterStyle=1
LeftMouseDownAction=["[MeasureLink3]"]

thats more what i was thinking of, but its not really usable. am i thinking along the right lines ??
User avatar
KreAch3R
Posts: 608
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: struggling with new section variables for a rss feed

Post by KreAch3R »

The problem with trying to make it work with section variables is ClipString=1. For that to work, you have to specify both W and H. If you try to specify a H based on the meter's H value, when ClipString=1, that will create a loop, like here:

Code: Select all

[Feed1]
H=([Feed1:H] + 10)
Where if you don't use ClipString=1, it will not get the proper height because all the string's content will be in the same line.

I just thought that we could use ClipString=1, take the meter's clipstring'ed height using section variables, and then disable DynamicVariables in the meter, so that it stops growing bigger. I haven't tried it, though, so if anyone wants to find something to test, please try that. :p

As for the way I currently use:
You don't need to know lua to start using it. :) This script should take your feeds' string lengths, try to produce a reasonable height and set it to your skin:

Code: Select all

function Initialize()

tRSS = {}

end --function Initialize

function Update()

	for i=1, 3 do
		tRSS[i] = SKIN:GetMeasure('MeasureRSS'..i)
		tRSS[i] = tRSS[i]:GetStringValue()

		if string.len(tRSS[i]) < 40 then
			SKIN:Bang('!SetOption', 'Feed'..i, 'H', '20')
		elseif string.len(tRSS[i]) <80 then
			SKIN:Bang('!SetOption', 'Feed'..i, 'H', '40')
		else
			SKIN:Bang('!SetOption', 'Feed'..i, 'H', '60')
		end
	end

end --function Update
You have to fiddle with the values above to get the look you want.

Include it in your skin:

Code: Select all

[MeasureScript]
Measure=SCRIPT
ScriptFile="Script.lua"
and remove all those H values from your feed meters. Keep ClipString=1, though. Note that I wrote all this from my head, because I couldn't test it (you haven't shared your whole code) so it is likely to produce errors.

Lua takes Rainmeter skins to another level. Read about it here and start messing with it. :)
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
thatsIch
Posts: 446
Joined: August 7th, 2012, 9:18 pm

Re: struggling with new section variables for a rss feed

Post by thatsIch »

I agree with KreAch3R.
Its the only way to predict the height of complete text.

Though there is a way to get what you want. It might sound silly and I don't know yet how to implement it, but in theory it works (tested it kinda)

I might post the "code" first for understanding:

Code: Select all


[Rainmeter]
Author = thatsIch
AppVersion= 201208130907
Update = 1000
MiddleMouseUPAction = !Refresh
DynamicWindowSize = 1

[MeterTest]
Meter = String
SolidColor = 0,0,0,1
FontColor = FFFFFF
Text = hallo das ist ein Test und weiter geht es hier

[MeterX]
Meter = String
MeterStyle = sameMeterStyleAsRealFeedTextMeter
Text = #CURRENTCONFIGWIDTH#
Y = 15r
DynamicVariables = 1
what you can do is having a String-Meter with your feedtext. With #CURRENTCONFIGWIDTH# you can get the total width of the printed string.
If you know 1 lineheight than just calculate the Area of the config (or use currcfgheight)

A = W * H

now in theory if you want to transform it into having more height, you just need the condition that A is the same

or easy said:
this config is 272px wide. So if you want 100px wide texts, then its

math.ceil(272/100) = 3

---
Though I'm not sure if its overkill :D


Another Solution could be (havent tested it yet)
if you input a text into a string-meter and the text is too long it will print the ... thingy right?
Can you re-read this string-meter if the end has the ...?
Then you know it needs a new line and then do it again:

- input 1 word into meter
- read meter
- test on ...

but this is far from a "good" solution
User avatar
MerlinTheRed
Rainmeter Sage
Posts: 889
Joined: September 6th, 2011, 6:34 am

Re: struggling with new section variables for a rss feed

Post by MerlinTheRed »

The area of a text meter in one line vs. wrapped is by no means constant, so dividing by the width will likely not work.

Also I don't think you can determine if a string meter is clipped (those three dots are only there when it's displayed, you can't parse them out of some string).
Have more fun creating skins with Sublime Text 2 and the Rainmeter Package!