It is currently May 1st, 2024, 2:20 am

Change size of skin on fly and reposition everything with it

Get help with creating, editing & fixing problems with skins
Lightz39
Posts: 98
Joined: August 1st, 2012, 12:48 am

Change size of skin on fly and reposition everything with it

Post by Lightz39 »

So for my media player I would like to have an option to change its size to whatever you'd like. So say you want a 200x200 album cover or 100x100 it will resize and move the rest of the meters (play buttons, progress bar etc..) with it. I got the sizing thats pretty easy. Just have a variable and +/- things with it. I thought using relative positioning would cause everything to move but it doesn't work as intended. They all stay where they originally are. Any ideas how to accomplish this? Easy rainmeter fix or lua needed?
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Change size of skin on fly and reposition everything wit

Post by Kaelri »

If you're changing the variable with !SetVariable, then you'll need to have DynamicVariables=1 set on all of the affected meters. If you change it with !WriteKeyValue - i.e. permanently changing it in the file - then you should only need to !Refresh the skin to apply the change. It's hard to say what else the problem could be without seeing your skin, but you definitely should not need Lua or any other advanced method for this.
Lightz39
Posts: 98
Joined: August 1st, 2012, 12:48 am

Re: Change size of skin on fly and reposition everything wit

Post by Lightz39 »

I'm using write key variable. I could have something messed up somewhere. This is just a quick get it done version. Haven't really gone over anything yet.

Code: Select all

[Rainmeter]
Author=Tyler LaCroix
Update=1000
DynamicWindowSize=#Yes#
BackgroundMode=2
SolidColor=0,0,0,1

[Metadata]
Name=Now Playing
Version=1.0
Description=A simple desktop widget that controls your favorite media player.
License=Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported.

[Variables]
@Include=#@#Variables.inc
MyPlayer=iTunes
Size=250
;==========================================================================
[mSize]
Measure=Plugin
Plugin=InputText
SolidColor=255,255,255
FontFace=#Font#
FontColor=#Black#
FontSize=10
AntiAlias=#Yes#
DefaultValue="#Size#"
FocusDismiss=1
Command1=!WriteKeyValue Variables Size "$UserInput$" "#CURRENTPATH##CURRENTFILE#"
Command2=!Refresh #CURRENTCONFIG#
W=50
H=20
X=93
Y=128

[mCoverArt]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#MyPlayer#
PlayerType=Cover

[mSong]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#MyPlayer#
PlayerType=Title

[mArtist]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#MyPlayer#
PlayerType=Artist

[mAlbum]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#MyPlayer#
PlayerType=Album

[mProgressScript]
Measure=Script
ScriptFile="Progress Bar Script.lua"
UpdatePeriod=1000
ResetInterval=10
SafetyRange=2
Adjustment=1.03

[mProgress]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#MyPlayer#
PlayerType=Progress

[mPosition]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#MyPlayer#
PlayerType=Position
DisableLeadingZero=1

[mDuration]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#MyPlayer#
PlayerType=Duration
DisableLeadingZero=1

[mState]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#MyPlayer#
PlayerType=State
IfAboveValue=1
IfAboveAction=[!HideMeter Pause][!ShowMeter Play]
IfEqualValue=1
IfEqualAction=[!HideMeter Play][!ShowMeter Pause]
IfBelowValue=1
IfBelowAction=[!HideMeter Pause][!ShowMeter Play]
;==========================================================================
[sSong]
FontFace=#Font#
FontColor=#White#
FontSize=10
StringAlign=CenterTop
AntiAlias=#Yes#
ClipString=#Yes#

[sArtist-Album]
FontFace=#Font#
FontColor=#White#
FontSize=10
StringAlign=CenterTop
AntiAlias=#Yes#
ClipString=#Yes#

[sPosition]
FontFace=#Font#
FontColor=#White#
FontSize=8
AntiAlias=#Yes#

[sDuration]
FontFace=#Font#
FontColor=#White#
FontSize=8
StringAlign=Right
AntiAlias=#Yes#

[sOptions]
FontFace=#Font#
FontColor=#White#
FontSize=10
AntiAlias=#Yes#
;==========================================================================
[Outline1]
Meter=Image
SolidColor=#White#
W=(#Size#+4)
H=(#Size#+4)
X=0
Y=39

[CoverArt]
Meter=Image
MeasureName=mCoverArt
W=#Size#
H=#Size#
X=2r
Y=2r
LeftMouseUpAction=[!CommandMeasure "mCoverArt OpenPlayer"]
RightMouseUpAction=[!ShowMeter Overlay][!ShowMeter Close][!ShowMeter Options][!ShowMeter MediaPlayer][!ShowMeter Size]

[Overlay]
Meter=Image
SolidColor=0,0,0,200
Hidden=#Yes#
W=#Size#
H=#Size#
X=r
Y=r

[Song]
Meter=String
MeterStyle=sSong
MeasureName=mSong
W=(#Size#-5)
H=20
X=125r
Y=-41r

[Artist-Album]
Meter=String
MeterStyle=sArtist-Album
MeasureName=mArtist
MeasureName2=mAlbum
Text="%1 - %2"
W=(#Size#-5)
H=20
X=r
Y=15r

[ProgressBG]
Meter=Image
SolidColor=255,255,255,100
W=(#Size#+4)
H=4
X=-127r
Y=288r

[Progress]
Meter=Bar
MeasureName=mProgressScript
BarColor=FFFFFF
BarOrientation=Horizontal
W=(#Size#+4)
H=4
X=r
Y=r

[Position]
Meter=String
MeterStyle=sPosition
MeasureName=mPosition
X=r
Y=12r

[Duration]
Meter=String
MeterStyle=sDuration
MeasureName=mDuration
X=254r
Y=r

[Previous]
Meter=Button
ButtonImage=#@#Previous
SolidColor=0,0,0,1
W=48
H=10
X=-174r
Y=2r
ButtonCommand=!CommandMeasure "mCoverArt Previous"

[Play]
Meter=Button
ButtonImage=#@#Play
SolidColor=0,0,0,1
W=24
H=10
X=31r
Y=r
ButtonCommand=!CommandMeasure "mCoverArt Play"

[Pause]
Meter=Button
ButtonImage=#@#Pause
SolidColor=0,0,0,1
W=24
H=10
X=r
Y=r
ButtonCommand=!CommandMeasure "mCoverArt Pause"

[Stop]
Meter=Button
ButtonImage=#@#Stop
SolidColor=0,0,0,1
W=30
H=10
X=23r
Y=r
ButtonCommand=!CommandMeasure "mCoverArt Stop"

[Next]
Meter=Button
ButtonImage=#@#Next
SolidColor=0,0,0,1
W=48
H=10
X=25r
Y=r
ButtonCommand=!CommandMeasure "mCoverArt Next"

[Close]
Meter=String
MeterStyle=sOptions
SolidColor=0,0,0,1
Text="x"
Hidden=#Yes#
X=80r
Y=-278r
LeftMouseUpAction=[!HideMeter Overlay][!HideMeter Close][!HideMeter Options][!HideMeter MediaPlayer][!HideMeter Size]

[Options]
Meter=String
MeterStyle=sOptions
Text="Options"
Hidden=#Yes#
X=-137r
Y=20r

[MediaPlayer]
Meter=String
MeterStyle=sOptions
Text="Media Player: #MyPlayer#"
Hidden=#Yes#
X=-39r
Y=50r

[Size]
Meter=String
MeterStyle=sOptions
Text="Size: #Size#"
Hidden=#Yes#
X=r
Y=20r
LeftMouseUpAction=!CommandMeasure "mSize" "ExecuteBatch 1-2"
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: Change size of skin on fly and reposition everything wit

Post by Kaelri »

Well, the issue is that none of your relative positions would be affected by the #Size# variable. Here's a stripped-down version of your skin, showing only your meters with their X/Y settings:

Code: Select all

[Outline1]
X=0
Y=39

[CoverArt]
X=2r
Y=2r

[Overlay]
X=r
Y=r

[Song]
X=125r
Y=-41r

[Artist-Album]
X=r
Y=15r

[ProgressBG]
X=-127r
Y=288r

[Progress]
X=r
Y=r

[Position]
X=r
Y=12r

[Duration]
X=254r
Y=r

[Previous]
X=-174r
Y=2r

[Play]
X=31r
Y=r

[Pause]
X=r
Y=r

[Stop]
X=23r
Y=r

[Next]
X=25r
Y=r

[Close]
X=80r
Y=-278r

[Options]
X=-137r
Y=20r

[MediaPlayer]
X=-39r
Y=50r

[Size]
X=r
Y=20r
Using "r" for relative X/Y positions, each meter is placed relative to the top-left corner of the previous meter. None of these values are impacted by the value of #Size# at all. (More about relative positions here.)

You'll need to use formulas to position at least some of your meters according to how you want them to be aligned to the album art. For example, if you want a meter to start at the exact center of the square, you might use:

Code: Select all

X=(#Size#/2)
Y=(#Size#/2)
Or, if you want a meter to start a number of pixels from the right edge of the square - say, 20:

Code: Select all

X=(#Size#-20)
I hope that will point you in the right direction.
Lightz39
Posts: 98
Joined: August 1st, 2012, 12:48 am

Re: Change size of skin on fly and reposition everything wit

Post by Lightz39 »

Yes, yes. That got the trick done. Thank you.