It is currently October 13th, 2024, 8:43 am

My First Skin Help

Get help with creating, editing & fixing problems with skins
User avatar
MourningStar
Posts: 300
Joined: June 12th, 2016, 2:40 am

Re: My First Skin Help

Post by MourningStar »

Yincognito wrote: July 29th, 2021, 7:59 pm Yeah, that too. Well, you could just leave the Program/Parameter no. 0 uncommented but with the values from no. 1, and comment no. 1 instead which would have no. 0 values. That would solve the refresh problem, but the middle click one would remain - if that bothers you, that is.
Instead I left the Program/Parameter no. 0 commented but changed the Program/Parameter no. '1' to '0'. A refresh now preserves the skin size, font and location. However, there is a 'momentary' display of the 'system' font. Is this preventable if I follow your original "...you could just leave the Program/Parameter no. 0 uncommented but with the values from no. 1, and comment no. 1 instead which would have no. 0 values." instruction?

Also, because the skin/font are 'remembered' from previous session the middle clik no longer required.

thx!!
User avatar
Yincognito
Rainmeter Sage
Posts: 8442
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: My First Skin Help

Post by Yincognito »

MourningStar wrote: July 29th, 2021, 8:38 pm Instead I left the Program/Parameter no. 0 commented but changed the Program/Parameter no. '1' to '0'. A refresh now preserves the skin size, font and location.
That works too - very well, now you know how to manipulate it, since you've done it yourself. :great:

MourningStar wrote: July 29th, 2021, 8:38 pmHowever, there is a 'momentary' display of the 'system' font. Is this preventable if I follow your original "...you could just leave the Program/Parameter no. 0 uncommented but with the values from no. 1, and comment no. 1 instead which would have no. 0 values." instruction?
I don't believe it's preventable, at least not in this form. What happens is that at skin refresh, Rainmeter looks to use some font to display the text; since the RunCommand measure (and PowerShell as well!) take some time to run and produce the result from the folder fonts, until the result is available, Rainmeter will use its default font (which is a "system" one). It's like waiting for the car engine to start before you can accelerate.

One solution would be to write the chosen font's actual name as a variable in Variables.inc (and not just its "index" in the folder font list), and use that name until the RunCommand/Powershell do their thing and come up with a valid list/index. While the first part is easier and I believe you could do it, this would probably require some !SetOption on the meter to change its FontFace from that newly created font name variable to an indexed font from the PS provided list, and I'm not sure you'd correctly do that. If you want, you can pack the current state of the skin and I'll do it for you.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
MourningStar
Posts: 300
Joined: June 12th, 2016, 2:40 am

Re: My First Skin Help

Post by MourningStar »

Yincognito wrote: July 29th, 2021, 9:18 pm That works too - very well, now you know how to manipulate it, since you've done it yourself. :great:
thank you.
Yincognito wrote: July 29th, 2021, 9:18 pm I don't believe it's preventable, ...
Good to know it's 'normal' behavior and not something induced 3rd party (us). The transition happens very quickly and does not really bother me at all. Thank you for the offer.

Another observation in the ini file. I notice that the [Variables} section is at top/the first lines of code. In other skins it is farther down. Originally I thought first was metadata then rainmeter then ... iow it seemed to me there was 'an order to things'. When I did the rearranging the skin broke so I quickly put Humpty back together again. It just weirded me out.

Anyways, it seems this train has reached journey's end (it was a long but fun ride, is it really over, have I missed any scheduled stops?).

Grateful to you and 'the crew' that have helped me with this, ...

:bow: Image :bow:
User avatar
Yincognito
Rainmeter Sage
Posts: 8442
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: My First Skin Help

Post by Yincognito »

MourningStar wrote: July 29th, 2021, 10:16 pmAnother observation in the ini file. I notice that the [Variables} section is at top/the first lines of code. In other skins it is farther down. Originally I thought first was metadata then rainmeter then ... iow it seemed to me there was 'an order to things'. When I did the rearranging the skin broke so I quickly put Humpty back together again. It just weirded me out.
Yes, I know in other skins is farther down, but personally I don't do things just because everybody else does it or someone else says or recommends it that way - I prefer to follow the logic of things. I like to put [Variables] at the top because all the other sections - including [Rainmeter] and why not, [Metadata] in some cases - use the data there and depend on it (so, from that POV, the variables come "first"), while the section and its contents doesn't depend on any other section, only through "back-reference", so to speak. So, when you set a variable to 3 in [Variables], it's at first 3 and only then other sections can alter it.

That being said, I'm not sure why things "broke" when you attempted rearranging that - maybe because of the @Includes, whose place actually matters (just like for meters). Since we're at it, the place for @Include2=#@#WeatherComJSONMeasures.inc should have been just before any measure and not necessarily in [Variables], but then, if it didn't produce any side effects, I skipped that.

Regarding the order of things in a skin, Rainmeter is pretty forgiving at that, but there are some elements where the order actually matters. As far as I know (hopefully I'm not mistaken), there isn't a specific order for the main sections in a skin, the whole order of things is logically more about dependencies, with stuff that depend on others in the workflow preferably (but not necessarily) coming last. A developer might be more on point regarding these things, since I never really tried another order than what I use (helping folks doesn't count here, because apart from some special cases, my focus was more on a solution than ordering their code).

Oh, and you're welcome - I'm glad you enjoyed the ride, hopefully it will serve you well for future Rainmeter coding. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
MourningStar
Posts: 300
Joined: June 12th, 2016, 2:40 am

Re: My First Skin Help

Post by MourningStar »

Yincognito wrote: July 29th, 2021, 11:47 pm ... I'm not sure why things "broke" ...
Not actually broke (wrong term, sorry), but got weird? After refresh the skin reappears in the default state. Size scroll works but font scroll does not. Perhaps, as you speculate, the @includes must be first - :confused:

The order I re-arranged was

[Metadata]

[Rainmeter]

[Variables]

...
User avatar
Yincognito
Rainmeter Sage
Posts: 8442
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: My First Skin Help

Post by Yincognito »

MourningStar wrote: July 30th, 2021, 12:37 am Not actually broke (wrong term, sorry), but got weird? After refresh the skin reappears in the default state. Size scroll works but font scroll does not. Perhaps, as you speculate, the @includes must be first - :confused:

The order I re-arranged was

[Metadata]

[Rainmeter]

[Variables]

...
If it's the font scroll not working, then it's not the @Includes, but rather the fact that the RunCommand measure executed at skin refresh needs to know the value of the variables it uses. Can't test it now as I'm on mobile, but I'll try to see if it happens in my version if the skin when I'm back on my laptop.

EDIT: Just tested it out on the skin code that I have (after following what you said you did regarding variables and the main section order), and it's not causing any issues for me, I can scroll the folder fonts properly...

...\BasicDualTemperature\@Resources\Variables.inc:

Code: Select all

[Variables]
; Used in regexp substitutes
Cleaner="(?:^[^[\x200B]].*|.*[^[\x200B]]$)":"","(?:^[\x200B]|[\x200B]$)":"","(?:^\\\d+|\\\d+$)":""
; RunCommand options for font list 0 = system fonts
;Program0=
;Parameter0=reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /s
; RunCommand options for font list 1 = @Resources\Fonts folder fonts; replace the '#@#Fonts' part to scan another folder for fonts below
Program0=powershell
Parameter0=Add-Type -AssemblyName PresentationCore; Get-ChildItem '#@#Fonts\*.*' -Include *.otf,*.ttf | Foreach-Object {(New-Object -TypeName Windows.Media.GlyphTypeface -ArgumentList $_.FullName).Win32FamilyNames.Values}
; Font list and font indexes
FontListIndex=0
FontIndex=5

FontColor=5,199,252

;===================
;Translate Langauge
;===================

Low Tonight=Low Tonight
Feels Like=Feels Like
Humidity=Humidity
Sunrise=Sunrise
Sunset=Sunset
Visibility=Visibility
Wind=Wind
UV Index=UV Index
...\BasicDualTemperature\BasicDualTemperature.ini:

Code: Select all

[Metadata]
Name=BasicDualTemperature
Author=MourningStar
Co-Authors=zivallh, Yincognito, balala, eclectic-tech & Rainmeter Tutorial
Information=basic dual (C & F) text-only display temperature skin
Version=3.0.0
License=Creative Commons Attribution - Non - Commercial - Share Alike 3.0

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=0,0,0,1

; Got the font list data and started the endless animation below
OnRefreshAction=[!CommandMeasure FontList "Run"][!CommandMeasure Slider "Stop 1"][!CommandMeasure Slider "Stop 2"][!CommandMeasure Slider "Execute 2"]

RightMouseUpAction=[!SkinCustomMenu]
ContextTitle=Location: [@LocationName]
ContextAction=["https://weather.com/weather/today"]
ContextTitle2=Time: [@CurrentObservationTime] [@LocationTimezoneAbbreviation]
ContextAction2=[]
ContextTitle3=Edit Weather Variables
ContextAction3=["#@#WeatherComJSONVariables.inc"]
ContextTitle4="---"
ContextAction4=[]
ContextTitle5=Change Text Color
ContextAction5=["#@#Addons\RainRGB4.exe" "VarName=FontColor" "FileName=#@#Variables.inc"]
ContextTitle6="---"
ContextAction6=[]
ContextTitle7="More Actions >>"
ContextAction7=[!SkinMenu]

[Variables]
; Include weather settings and language variables 
@Include1=#@#WeatherComJSONVariables.inc
@Include2=#@#WeatherComJSONMeasures.inc
@Include3=#@#Variables.inc
; Added 'Scale' variable used in the new mouse action bangs below 
Scale=1
; Set the animation parameters (current frame, max frame, wait time) below
Index=1
Count=23
Wait=25

---Measures---

[FontList]
Measure=Plugin
Plugin=RunCommand
Program=[#Program[#FontListIndex]]
Parameter=[#Parameter[#FontListIndex]]
State=Hide
OutputType=ANSI
Timeout=5000
RegExpSubstitute=1
Substitute="(?si)(?:^.*\\Fonts(?=\R)|(?<=\n)\h*|(?: \(\S*Type\)|REG_SZ)\N*|(?<=\N)\R*$)":"","^(\N)":"#CRLF#\1"
FinishAction=[!UpdateMeasureGroup FontListGroup][!UpdateMeter FontChooser][!Redraw]
DynamicVariables=1

[FontCountFormula]
Group=FontListGroup
Measure=String
String="[FontList]"
UpdateDivider=-1
RegExpSubstitute=1
Substitute="\N":"","\R":"+1"
DynamicVariables=1

[FontCount]
Group=FontListGroup
Measure=Calc
Formula=[FontCountFormula]
UpdateDivider=-1
DynamicVariables=1

[FontFace]
Group=FontListGroup
Measure=String
String="[FontList]"
UpdateDivider=-1
RegExpSubstitute=1
Substitute="(?si)^(?:\R\N*){[#FontIndex]}\R(\N*).*$":"[\x200B]\1[\x200B]","#Cleaner#"
DynamicVariables=1

[CurrentTemperatureF]
; Added to 'Times' group so it is enabled when the webparser finishes
Group=Times
Measure=Calc
Formula=(([@CurrentTemperature]*9/5)+32)
DynamicVariables=1
Disabled=1

[Slider]
; Controlled the animation and the frame index iteration below (action 1 = on demand animation; action 2 = endless animation)
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat Slide, #Wait#, #Count# | Wait #Wait#
ActionList2=Repeat Slide, #Wait#, #Count# | Wait #Wait# | Rerun | Wait #Wait#
Slide=[!SetVariable Index (Clamp(#Index#+1,1,#Count#))][!UpdateMeasure Slider][!UpdateMeter *][!Redraw]
Rerun=[!SetVariable Index 0][!UpdateMeasure Slider][!CommandMeasure Slider "Stop 1"][!CommandMeasure Slider "Stop 2"][!CommandMeasure Slider "Execute 2"]
UpdateDivider=-1
DynamicVariables=1

---Meters---

; [FontChooser]
; Meter=String
; X=(5)
; Y=(5)
; FontFace=Consolas
; FontColor=#FontColor#
; StringEffect=Shadow
; FontEffectColor=0,0,0,50
; SolidColor=0,0,0,255
; FontSize=16
; AntiAlias=1
; Text=*
; UpdateDivider=-1
; MouseScrollUpAction=[!SetVariable FontIndex (([FontCount]+#FontIndex#+1)%[FontCount])][!WriteKeyValue Variables FontIndex "[#FontIndex]" "#@#Variables.inc"][!UpdateMeasure FontFace][!UpdateMeter *][!Redraw]
; MouseScrollDownAction=[!SetVariable FontIndex (([FontCount]+#FontIndex#-1)%[FontCount])][!WriteKeyValue Variables FontIndex "[#FontIndex]" "#@#Variables.inc"][!UpdateMeasure FontFace][!UpdateMeter *][!Redraw]
; DynamicVariables=1

[FontChooser]
; Started/stopped the on demand animation on mouse hover/leave, chose the font (index) on mouse scroll, chose the font list (index) on middle click below
Meter=Image
*** LeftTop: FontChooser; RightTop: Temperature
X=(5)
Y=(5)
*** CenterTop: FontChooser; LeftBottom: Temperature
; X=([Temperature:W]/2-[FontChooser:W]/2)
; Y=(5)
W=(90*#Scale#)
H=(90*#Scale#)
ImageName=#@#Images\camera.png
ImageCrop=(160*(#Index#-1)),0,160,160,1
UpdateDivider=-1
MouseOverAction=[!CommandMeasure Slider "Stop 1"][!CommandMeasure Slider "Stop 2"][!CommandMeasure Slider "Execute 1"]
MouseLeaveAction=[!CommandMeasure Slider "Stop 1"][!CommandMeasure Slider "Stop 2"][!SetVariable Index 1][!UpdateMeasure Slider][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetVariable FontIndex (([FontCount]+#FontIndex#+1)%[FontCount])][!WriteKeyValue Variables FontIndex "[#FontIndex]" "#@#Variables.inc"][!UpdateMeasure FontFace][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable FontIndex (([FontCount]+#FontIndex#-1)%[FontCount])][!WriteKeyValue Variables FontIndex "[#FontIndex]" "#@#Variables.inc"][!UpdateMeasure FontFace][!UpdateMeter *][!Redraw]
MiddleMouseUpAction=[!SetVariable FontListIndex (1-#FontListIndex#)][!SetVariable FontIndex 0][!UpdateMeasure FontList][!CommandMeasure FontList "Run"]
DynamicVariables=1

[Temperature]
Meter=String
*** LeftTop: FontChooser; RightTop: Temperature
X=(10*#Scale#)R
Y=(5*#Scale#)r
*** CenterTop: FontChooser; LeftBottom: Temperature
; X=(0*#Scale#)
; Y=(5*#Scale#)R
FontFace=[FontFace]
FontSize=(55*#Scale#)
FontColor=#FontColor#
StringStyle=Normal
StringAlign=Left
StringEffect=Shadow
FontEffectColor=0,0,0,50
SolidColor=0,0,0,1
Antialias=1
MeasureName=@CurrentTemperature
MeasureName2=CurrentTemperatureF
Text=%1°C / %2°F
; Added to change the text size by scrolling the mouse wheel up or down
MiddleMouseUpAction=[!ToggleMeter FontChooser][!Redraw]
MouseScrollUpAction=[!SetVariable Scale (Clamp(#Scale#+0.05,0.1,3))][!WriteKeyValue Variables Scale (Clamp(#Scale#+0.05,0.1,3))][!UpdateMeter *][!Redraw]
MouseScrollDownAction=[!SetVariable Scale (Clamp(#Scale#-0.05,0.1,3))][!WriteKeyValue Variables Scale (Clamp(#Scale#-0.05,0.1,3))][!UpdateMeter *][!Redraw]
DynamicVariables=1
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
MourningStar
Posts: 300
Joined: June 12th, 2016, 2:40 am

Re: My First Skin Help

Post by MourningStar »

Yincognito wrote: July 30th, 2021, 10:48 am (after following what you said you did regarding variables and the main section order), a...
no, your inc file does not show the variables after rainmeter as i have shown. Unless the context stuff is a a part of rainmeter which I now suspect was my stumbling again. thx for reply
User avatar
Yincognito
Rainmeter Sage
Posts: 8442
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: My First Skin Help

Post by Yincognito »

MourningStar wrote: July 30th, 2021, 3:31 pmUnless the context stuff is a a part of rainmeter which I now suspect was my stumbling again. thx for reply
Precisely. ;-) The current section continues until Rainmeter encounters an [AnotherSection] part, which is where the "another section" begins. New lines, comments and basically anything other than [SomeSection] or the end of file don't count as "section separators". I only placed those comments and new / blank lines to make it easier to view what was going on and where was going on. Functionally, they serve no purpose.

Also, a more to the point discussion regarding the order of the main sections in a skin here.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
MourningStar
Posts: 300
Joined: June 12th, 2016, 2:40 am

Re: My First Skin Help

Post by MourningStar »

Yincognito wrote: July 30th, 2021, 3:48 pm Precisely. ;-) ...
yeah, thank you for posting the file.
Image
I understand this now.
User avatar
Yincognito
Rainmeter Sage
Posts: 8442
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: My First Skin Help

Post by Yincognito »

MourningStar wrote: July 30th, 2021, 6:12 pm yeah, thank you for posting the file.
Image
I understand this now.
Image
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth