It is currently November 26th, 2022, 7:22 pm

Scroll Text ~ Take#2

Skins that control functions in Windows or Rainmeter
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4878
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Scroll Text ~ Take#2

Post by eclectic-tech »

An update of the coding of an earlier post demonstrating scrolling text...

One of the main drawbacks of the first version was not being able to assign links to each text element because the strings were concatenated into 1 string meter.
This meant at the most, 3 links could be made :uhuh:

This second version eliminates that by only scrolling the top meter, and setting all subsequent meters relative to that one. This allows placing each text item in a separate meter with a corresponding link. 8-)

The position of the scrolling is calculated using [MeasureY]. In the original post, the scrolling text simply moved above the skin margin and disappeared. This prevented using any image under the text because the text would scroll OVER the top. :vomit:

Checking the output of [MeasureY] in Calc measures, allows showing or hiding meters based on their position in the skin. This allows hiding the text near the top and bottom edges so background images can be used.

Another change was using [MeasureY] in a Calc measure to determine when the scrolling reached the end, rather than using a timer to refresh. Taking that a bit further, a Calc is included which reverses the scroll direction when the text nears the bottom or top edge, instead of refreshing the skin. One unforeseen caveat is that a MouseOver action, while reversed, will reset the scroller measure to a forward scroll. If untouched, the scroll will continually flow up and down. Right now, only the scroll image skin demonstrates this Calc, but it can be applied to any skin.

I made other minor code changes for alignment and other situations, but getting individual links was my main achievement...

All variables are in the skins and comments are there to help you understand what I am doing and help you modify it.

Feel free to 'play' with this and use it or modify it for your use.
Plain Text Scroller Code

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=0
MouseOverAction=[!SetOption mScroller Enable "true"][!SetVariable NotPause 0][!SetVariable Speed 0][!ShowMeter Speed]
MouseLeaveAction=[!SetOption mScroller Enable "false"][!SetVariable NotPause 1][!SetVariable Speed [*mScroller*]][!HideMeter Speed]

; ============= CREDITS ===========================================
;Scroll window modified from Manci5 Lyrics Skin (manci5.deviantart.com)
;Scroll.dll by REDK (Rainmeter Forum)
; Version 2 changes the scroll control impact by only controlling the Title meter; all other meters are relatively positioned to that meter. This allows setting a unique link to any item. This also uses 'linespace' & 'maxitemlines' variables together with the 'fontsize' to vertically space and format the text. The horizontal positioning is done with a textalignnum variable; 0=left, 0.5-center, & 1-right. 
; ============= VARIABLES ===========================================

[Variables]
; FONT VARIABLES===================================================================
;
FontName=Trebuchet MS
; Font
ScrollFontHeight1=10
; Controls font and spacing of items... larger font will increase vertical spacing
TitleColor=4040CCFF
; Scroll Title Color
TextColor=C8C8C8FF
; Scroll Item Color
;
; PANEL VARIABLES===================================================================
;
PanelHeight=300
; Text Panel Height(Viewable area)... Actual skin height is calculated using number of items
PanelWidth=350
; Text Panel Width
Margin=(#PanelWidth#/8)
; Side Margin Width... Note enlarge this if an overlay image is used in order to keep text inside the graphic; For overlay below use #PanelWidth#/8
;
; SPACING VARIABLES===================================================================
;
ItemLines=2
; Sets the number of lines possible for items; will affect spacing, position, and clipping of items also when they will appear or disappear at the bottom of the skin
LineHeight=(#ScrollFontHeight1#*1.6)
LineSpace=(((#LineHeight#)*#ItemLines#)+(#LineHeight#))
; Sets the height of items based on font size and number of lines for items. Adding 'LineHeight' ensures at least 1 line between items
FirstLineOffSet=(-(#PanelHeight#)+#LineSpace#*4)
; Can be used to change where the title line appears in the skin
TextAlignNum=0
; Use to automatically align the text; 0=left, 1=Right, 0.5=Center
;
; OVERLAY/UNDERLAY VARIABLES===================================================================
;
UnderlayTopMargin=10
; Setting to determine when to hide top item; set to 0 when not using under/over~lays
UnderlayBottomMargin=(#PanelHeight#/2+#LineHeight#)
; Setting to determine when to show bottom item
HideUnderlay=1
; Option to display scroll under the text; Hint: Increase #Margin# variable when used! And minimum panel height should be 300
HideOverlay=1
; Option to display iPad overlay image; Hint: Increase #Margin# variable when used!
;
; SCROLL VARIABLES===================================================================
;
DefaultSpeed=6
; Scroll Default Speed (0=None)
StepRate=2
; MouseWheel Step Rate
Speed=0
; This is set dynamically by the Scroller plug-in
NotPause=1
; Used to pause the refresh counter
;
; ITEM VARIABLES===================================================================
;
Title=Bi-Directional Vertically Scrolling Text
T1=I have seen few skins that could scroll information vertically
T2=This skin demonstrate ways to scroll text either direction
T3=These demos utilize the Scroller Plug-in developed by REDK
T4=I also drew some coding from a lyric skin by Manci5
T5=A major change is the ability to set unique links for each item
T6=And the ability to hide/show items based on position; allows image backgrounds
T7=The number of lines per item can be used to control position and clipping
T8=The spacing will automatically adjust with font size & item line settings
T9=Text is aligned using 'TextAlignNum' variable which also sets correct margins
T10=MouseOver will pause scrolling ~ Mouse wheel controls speed and direction
T11=The display will automatically refresh when bottom line nears the top
T12=Please let me know if you have any issues or suggestions
T13=Thanks again to Manci5 and REDK for their ideas
;
Lines=13
; Number of lines; used to hide/show lines based on vertical position in skin. You will need to add or delete the text meters (below) to match the number of text line variables (above)

; ============== MEASURES ==============================================

[MeasureY]
Measure=Calc
Formula=((MeasureY)-(#Speed#))
Dynamicvariables=1
; Used to control Title meter; all other meters are positioned relative to this one and therefore will also scroll

[mScroller]
Measure=PLUGIN
Plugin=Scroller
DefaultValue=#DefaultSpeed#
MinValue=-64
MaxValue=64
Step=#StepRate#
DynamicVariables=1
; Set the minimum/maximum scroll values and the steprate the mouse scroll will add to the current value

[CheckScroll]
Measure=CALC
Formula=mScroller%2
IfEqualValue=0
IfEqualAction=[!SetVariable Speed [*mScroller*]][!Update]
IfAboveValue=0
IfAboveAction=[!SetVariable Speed [*mScroller*]][!Update]
DynamicVariables=1
; Increases/Decreases scroll speed

[mLastLinePosRefresh]
Measure=Calc
Formula=((#LineSpace#*#Lines#)+(#PanelHeight#/2+#FirstLineOffset#)+MeasureY>0)? 
IfBelowValue=1
IfBelowAction=!Refresh
; Checks the position of the last line and refreshes skin when it is near the top

[mTextAlign]
Measure=Calc
Formula=#TextAlignNum#
IfEqualValue=0.5
IfEqualAction=[!SetVariable TextAlign "Center"][!SetOptionGroup Text X (#PanelWidth#*#TextAlignNum#)]
IfBelowValue=0.5
IfBelowAction=[!SetVariable TextAlign "Left"][!SetOptionGroup Text X (#Margin#)]
IfAboveValue=0.5
IfAboveAction=[!SetVariable TextAlign "Right"][!SetOptionGroup Text X (#PanelWidth#-#Margin#)]
; Uses the alignment variable to set correct margins based on alignment

; ============== STYLE ===============================

[Style]
SolidColor=0,0,0,1
FontColor=#TextColor#
FontEffectColor=0,0,0,200
FontFace=#FontName#
FontSize=#ScrollFontHeight1#
StringAlign=#TextAlign#
StringEffect=shadow
StringStyle=BOLDItalic
AntiAlias=1
X=(#PanelWidth#*#TextAlignNum#)
Y=(#LineSpace#)r
W=((#PanelWidth#)-(#Margin#*2))
H=#LineSpace#
ClipString=2

; ============== METERS ===============================

[UnderlayImage]
Meter=image
ImageName=#@#Images\scroll
W=(#PanelWidth#)
H=(#PanelHeight#+#UnderlayBottomMargin#)
ScaleMargins=0,0,0,1
SolidColor=0,0,0,1
DynamicVariables=1
Hidden=#HideUnderlay#

[BackGround]
Meter=Image
SolidColor=0,0,0,1
W=#PanelWidth#
H=(#PanelHeight#+#LineSpace#)
DynamicVariables=1

[TextTitle]
Meter=string
MeterStyle=Style
FontColor=#TitleColor#
Y=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)
W=((#PanelWidth#)-(#Margin#*2))
H=#LineSpace#
Text=#Title#
Hidden=(((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>#PanelHeight#)? 1:([TextTitle:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://eclectic-tech.deviantart.com"]
ToolTipText=My DeviantArt Site
DynamicVariables=1
Group=Text
; HIDDEN checks the position of the based on the current MEASUREY and hides until it is in the Viewable Area; the second calc checks if the current Y value is less than top margin and hides the meter if it is above it

[Divider0]
Meter=Image
SolidColor=#TextColor#
; Use alternate settings for X to match Centered, Left, and Right string alignments
;Centered
;X=(#PanelWidth#/6)
;Left
X=(#Margin#)
;Right
;X=(#PanelWidth#-#Margin#)
Y=(#LineHeight#)r
W=(#PanelWidth#*0.75)
H=1
Hidden=(((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>#PanelHeight#)? 1:([Divider0:Y]<#UnderlayTopMargin#)?
DynamicVariables=1

[Text1]
Meter=string
MeterStyle=Style
Text=#T1#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#)? 1:([Text1:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://eclectic-tech.deviantart.com"]
ToolTipText=My DeviantArt Site
DynamicVariables=1
Group=Text

[Text2]
Meter=string
MeterStyle=Style
Text=#T2#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*2)? 1:([Text2:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["ScrollText2.ini"]
ToolTipText=See Skin Code
DynamicVariables=1
Group=Text

[Text3]
Meter=string
MeterStyle=Style
Text=#T3#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*3)? 1:([Text3:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://rainmeter.net/forum/"]
ToolTipText=Rainmeter Forum
DynamicVariables=1
Group=Text

[Text4]
Meter=string
MeterStyle=Style
Text=#T4#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*4)? 1:([Text4:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://manci5.deviantart.com"]
ToolTipText=Manci5 DeviantArt Site
DynamicVariables=1
Group=Text

[Text5]
Meter=string
MeterStyle=Style
Text=#T5#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*5)? 1:([Text5:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://www.bing.com"]
ToolTipText=Bing It
DynamicVariables=1
Group=Text

[Text6]
Meter=string
MeterStyle=Style
Text=#T6#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*6)? 1:([Text6:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["ScrollText2.ini"]
ToolTipText=See the code...
DynamicVariables=1
Group=Text

[Text7]
Meter=string
MeterStyle=Style
Text=#T7#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*7)? 1:([Text7:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://eclectic-tech.deviantart.com"]
ToolTipText=My DeviantArt Site
DynamicVariables=1
Group=Text

[Text8]
Meter=string
MeterStyle=Style
Text=#T8#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*8)? 1:([Text8:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://trends.google.com"]
ToolTipText=Trends
DynamicVariables=1
Group=Text

[Text9]
Meter=string
MeterStyle=Style
Text=#T9#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*9)? 1:([Text9:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://eclectic-tech.deviantart.com"]
ToolTipText=My DeviantArt Site
DynamicVariables=1
Group=Text

[Text10]
Meter=string
MeterStyle=Style
Text=#T10#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*10)? 1:([Text10:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://eclectic-tech.deviantart.com"]
ToolTipText=My DeviantArt Site
DynamicVariables=1
Group=Text

[Text11]
Meter=string
MeterStyle=Style
Text=#T11#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*11)? 1:([Text11:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://eclectic-tech.deviantart.com"]
ToolTipText=My DeviantArt Site
DynamicVariables=1
Group=Text

[Text12]
Meter=string
MeterStyle=Style
Text=#T12#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*12)? 1:([Text12:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://eclectic-tech.deviantart.com"]
ToolTipText=My DeviantArt Site
DynamicVariables=1
Group=Text

[Text13]
Meter=string
MeterStyle=Style
Text=#T13#
Hidden=((#PanelHeight#-#LineSpace#)+([MeasureY])+#FirstLineOffSet#)>(#PanelHeight#-#LineSpace#*13)? 1:([Text13:Y]<#UnderlayTopMargin#)?
LeftMouseUpAction=["http://eclectic-tech.deviantart.com"]
ToolTipText=My DeviantArt Site
DynamicVariables=1
Group=Text

[Overlay]
Meter=image
X=
W=#PanelWidth#
H=(#PanelHeight#+#LineSpace#+#LineHeight#)
ImageName=#@#Images\ipadVBX.png
SolidColor=0,0,0,1
DynamicVariables=1
Hidden=#HideOverlay#

; [OpenSetting]
; Meter=BUTTON
; ButtonImage=#@#Images\Open.png
; X=(#PanelWidth#-30)
; Y=-1r
; ButtonCommand=!Execute ["#@#Options\Config.exe"]
; ToolTipText="Edit Options"
; Dynamicvariables=1

[Speed]
Meter=String
MeterStyle=Style
MeasureName=mScroller
Y=(#PanelHeight#+#LineSpace#)
W=(#PanelWidth#/2)
H=#LineSpace#
SolidColor=40,40,40,192
PreFix="*Paused* Scroll Step: "
Hidden=1
DynamicVariables=1
Group=Text