It is currently March 28th, 2024, 9:40 am

Problems with BackgroundMode

Get help with creating, editing & fixing problems with skins
Post Reply
russdirks
Posts: 12
Joined: June 9th, 2016, 4:53 am

Problems with BackgroundMode

Post by russdirks »

I'm having problems getting BackgroundMode and BackgroundMargins working. They don't seem to behave as the documentation says they should, especially the scaling. I took the Illustro Disk gauge and used the SkinHeight option to force the gauge to be higher, and noticed that the depth of the header increased. Shouldn't it stay the same? (see attached image)

Code: Select all

; this is from the illustro\disk gauge
[Rainmeter]
Update=1000
Background=#@#Background.png
BackgroundMode=3
BackgroundMargins=0,34,0,14
SkinHeight=147     ; I added this line
Capture.PNG
russdirks
Posts: 12
Joined: June 9th, 2016, 4:53 am

Re: Problems with BackgroundMode

Post by russdirks »

After more investigation, I have found that if you leave off the SkinHeight option, and just add more string meters to the skin, then the header stays the same height.

The reason I was trying to use the SkinHeight option is because I was investigating ways to keep a skin the same height vertically, even when there are more or less string meters being displayed. My application is hiding and displaying string meters dynamically from an external program. Any ideas how I could do that without using SkinHeight?
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Problems with BackgroundMode

Post by balala »

russdirks wrote:After more investigation, I have found that if you leave off the SkinHeight option, and just add more string meters to the skin, then the header stays the same height.

The reason I was trying to use the SkinHeight option is because I was investigating ways to keep a skin the same height vertically, even when there are more or less string meters being displayed. My application is hiding and displaying string meters dynamically from an external program. Any ideas how I could do that without using SkinHeight?
Not sure. Do you want to keep the height of the skin unchanged, regardless how many meters do you have? I better think you'd need to do this exactly vice-versa: changing the height of the skin depending on how many meters do you have shown, don't you?
If I'm right, the main problem is that even a hidden meter (no matter what type of them) is placed in the same position as when it's visible, just its width and height are set to 0. This means that if on your code you add an additional meter and set an absolute position to it, even if you hide it, the height of the skin won't decrease, because the meter is on the same position.
However there could be two different solutions:
  • In parallel with hiding the appropriate meters, move them upper. Eg I added a few measures and meters to the illusto's 1 Disk.ini skin, to can dynamically show / hide the meters associated with a second disk:

    Code: Select all

    [Rainmeter]
    Update=1000
    Background=#@#Background.png
    BackgroundMode=3
    BackgroundMargins=0,34,0,14
    
    [Metadata]
    Name=Disk
    Author=poiru
    Information=Displays disk usage.
    License=Creative Commons BY-NC-SA 3.0
    Version=1.0.0
    
    [Variables]
    fontName=Trebuchet MS
    textSize=8
    colorBar=235,170,0,255
    colorText=255,255,255,205
    disk1=C:
    disk2=D:
    Show=1
    
    ; ----------------------------------
    ; MEASURES return some kind of value
    ; ----------------------------------
    
    [measureTotalDisk1]
    Measure=FreeDiskSpace
    Drive=#disk1#
    Total=1
    UpdateDivider=120
    
    [measureUsedDisk1]
    Measure=FreeDiskSpace
    Drive=#disk1#
    InvertMeasure=1
    UpdateDivider=120
    
    [measureTotalDisk2]
    Measure=FreeDiskSpace
    Drive=#disk2#
    Total=1
    UpdateDivider=120
    
    [measureUsedDisk2]
    Measure=FreeDiskSpace
    Drive=#disk2#
    InvertMeasure=1
    UpdateDivider=120
    
    ; ----------------------------------
    ; STYLES are used to "centralize" options
    ; ----------------------------------
    
    [styleTitle]
    StringAlign=Center
    StringCase=Upper
    StringStyle=Bold
    StringEffect=Shadow
    FontEffectColor=0,0,0,50
    FontColor=#colorText#
    FontFace=#fontName#
    FontSize=10
    AntiAlias=1
    ClipString=1
    
    [styleLeftText]
    StringAlign=Left
    StringCase=None
    StringStyle=Bold
    StringEffect=Shadow
    FontEffectColor=0,0,0,20
    FontColor=#colorText#
    FontFace=#fontName#
    FontSize=#textSize#
    AntiAlias=1
    ClipString=1
    
    [styleRightText]
    StringAlign=Right
    StringCase=None
    StringStyle=Bold
    StringEffect=Shadow
    FontEffectColor=0,0,0,20
    FontColor=#colorText#
    FontFace=#fontName#
    FontSize=#textSize#
    AntiAlias=1
    ClipString=1
    
    [styleBar]
    BarColor=#colorBar#
    BarOrientation=HORIZONTAL
    SolidColor=255,255,255,15
    
    ; ----------------------------------
    ; METERS display images, text, bars, etc.
    ; ----------------------------------
    
    [meterTitle]
    Meter=String
    MeterStyle=styleTitle
    X=100
    Y=12
    W=190
    H=18
    Text=Disk
    LeftMouseUpAction=[!SetVariable Show "(1-#Show#)"][!UpdateMeterGroup "Disk2"][!Redraw]
    DynamicVariables=1
    
    [meterLabelDisk1]
    Meter=String
    MeterStyle=styleLeftText
    X=10
    Y=40
    W=190
    H=14
    Text=#disk1#\
    
    [meterValueDisk1]
    Meter=String
    MeterStyle=styleRightText
    MeasureName=measureUsedDisk1
    MeasureName2=measureTotalDisk1
    X=200
    Y=0r
    W=190
    H=14
    Text=%1B/%2B used
    NumOfDecimals=1
    AutoScale=1
    LeftMouseUpAction=["#disk1#\"]
    
    [meterBarDisk1]
    Meter=Bar
    MeterStyle=styleBar
    MeasureName=measureUsedDisk1
    X=10
    Y=52
    W=190
    H=1
    
    [meterLabelDisk2]
    Meter=String
    MeterStyle=styleLeftText
    X=10
    Y=(40+20*#Show#)
    W=190
    H=14
    Text=#disk2#\
    Group=Disk2
    Hidden=(1-#Show#)
    DynamicVariables=1
    
    [meterValueDisk2]
    Meter=String
    MeterStyle=styleRightText
    MeasureName=measureUsedDisk2
    MeasureName2=measureTotalDisk2
    X=200
    Y=0r
    W=190
    H=14
    Text=%1B/%2B used
    NumOfDecimals=1
    AutoScale=1
    LeftMouseUpAction=["#disk2#\"]
    Group=Disk2
    Hidden=(1-#Show#)
    DynamicVariables=1
    
    [meterBarDisk2]
    Meter=Bar
    MeterStyle=styleBar
    MeasureName=measureUsedDisk2
    X=10
    Y=(52+20*#Show#)
    W=190
    H=1
    Group=Disk2
    Hidden=(1-#Show#)
    DynamicVariables=1
    See that I introduced a Show variable, which will control if the meters of the second disk are visible or not. You can change its value clicking the DISK title of the skin. Initially the Show variable is set to 1, which means that the meters of the second disk are visible.
    Once you click the DISK title, the value of the Show variable become 0 (through the LeftMouseUpAction option of the [meterTitle] meter). This will hide the [meterLabelDisk2], [meterValueDisk2] and [meterBarDisk2] meters (which are belonging to the Disk2 group and have set a Hidden option). Also in this moment these meters are moved up, in the same position as the [meterLabelDisk1], [meterValueDisk1] and [meterBarDisk1] meters (the Y options of the meters of second disk are changing dynamically). Because the meters of the second disk are hidden, they won't disturb the meters of the first disk. On a newer click, the value of the Show variable is set back to 1, the meters are moved again down and shown.
  • A simpler solution wouldn't require to move the meters, but in this case you have to set relative positions of these meters, using the R parameter, not r:

    Code: Select all

    [Rainmeter]
    Update=1000
    Background=#@#Background.png
    BackgroundMode=3
    BackgroundMargins=0,34,0,14
    
    [Metadata]
    Name=Disk
    Author=poiru
    Information=Displays disk usage.
    License=Creative Commons BY-NC-SA 3.0
    Version=1.0.0
    
    [Variables]
    fontName=Trebuchet MS
    textSize=8
    colorBar=235,170,0,255
    colorText=255,255,255,205
    disk1=C:
    disk2=D:
    Show=1
    
    ; ----------------------------------
    ; MEASURES return some kind of value
    ; ----------------------------------
    
    [measureTotalDisk1]
    Measure=FreeDiskSpace
    Drive=#disk1#
    Total=1
    UpdateDivider=120
    
    [measureUsedDisk1]
    Measure=FreeDiskSpace
    Drive=#disk1#
    InvertMeasure=1
    UpdateDivider=120
    
    [measureTotalDisk2]
    Measure=FreeDiskSpace
    Drive=#disk2#
    Total=1
    UpdateDivider=120
    
    [measureUsedDisk2]
    Measure=FreeDiskSpace
    Drive=#disk2#
    InvertMeasure=1
    UpdateDivider=120
    
    ; ----------------------------------
    ; STYLES are used to "centralize" options
    ; ----------------------------------
    
    [styleTitle]
    StringAlign=Center
    StringCase=Upper
    StringStyle=Bold
    StringEffect=Shadow
    FontEffectColor=0,0,0,50
    FontColor=#colorText#
    FontFace=#fontName#
    FontSize=10
    AntiAlias=1
    ClipString=1
    
    [styleLeftText]
    StringAlign=Left
    StringCase=None
    StringStyle=Bold
    StringEffect=Shadow
    FontEffectColor=0,0,0,20
    FontColor=#colorText#
    FontFace=#fontName#
    FontSize=#textSize#
    AntiAlias=1
    ClipString=1
    
    [styleRightText]
    StringAlign=Right
    StringCase=None
    StringStyle=Bold
    StringEffect=Shadow
    FontEffectColor=0,0,0,20
    FontColor=#colorText#
    FontFace=#fontName#
    FontSize=#textSize#
    AntiAlias=1
    ClipString=1
    
    [styleBar]
    BarColor=#colorBar#
    BarOrientation=HORIZONTAL
    SolidColor=255,255,255,15
    
    ; ----------------------------------
    ; METERS display images, text, bars, etc.
    ; ----------------------------------
    
    [meterTitle]
    Meter=String
    MeterStyle=styleTitle
    X=100
    Y=12
    W=190
    H=18
    Text=Disk
    LeftMouseUpAction=[!SetVariable Show "(1-#Show#)"][!UpdateMeterGroup "Disk2"][!Redraw]
    DynamicVariables=1
    
    [meterLabelDisk1]
    Meter=String
    MeterStyle=styleLeftText
    X=10
    Y=40
    W=190
    H=14
    Text=#disk1#\
    
    [meterValueDisk1]
    Meter=String
    MeterStyle=styleRightText
    MeasureName=measureUsedDisk1
    MeasureName2=measureTotalDisk1
    X=200
    Y=0r
    W=190
    H=14
    Text=%1B/%2B used
    NumOfDecimals=1
    AutoScale=1
    LeftMouseUpAction=["#disk1#\"]
    
    [meterBarDisk1]
    Meter=Bar
    MeterStyle=styleBar
    MeasureName=measureUsedDisk1
    X=10
    Y=52
    W=190
    H=1
    
    [meterLabelDisk2]
    Meter=String
    MeterStyle=styleLeftText
    X=10
    Y=0R
    W=190
    H=14
    Text=#disk2#\
    Group=Disk2
    Hidden=(1-#Show#)
    DynamicVariables=1
    
    [meterValueDisk2]
    Meter=String
    MeterStyle=styleRightText
    MeasureName=measureUsedDisk2
    MeasureName2=measureTotalDisk2
    X=200
    Y=0r
    W=190
    H=14
    Text=%1B/%2B used
    NumOfDecimals=1
    AutoScale=1
    LeftMouseUpAction=["#disk2#\"]
    Group=Disk2
    Hidden=(1-#Show#)
    DynamicVariables=1
    
    [meterBarDisk2]
    Meter=Bar
    MeterStyle=styleBar
    MeasureName=measureUsedDisk2
    X=10
    Y=0R
    W=190
    H=1
    Group=Disk2
    Hidden=(1-#Show#)
    In this case the problem is that you can't position the meters of the second disk anywhere, their positions are fixed.
russdirks
Posts: 12
Joined: June 9th, 2016, 4:53 am

Re: Problems with BackgroundMode

Post by russdirks »

Not sure. Do you want to keep the height of the skin unchanged, regardless how many meters do you have?
Yes that is correct. I have an application that I've written that displays a number of lines of data. Each line is positioned relative to the one above it, for easy modifications. When my application is not running, I want to hide the lines of data and simply display "The application is offline", and not have the skin shrink vertically.

Your response gave me an idea though ... I can put a hidden, absolutely positioned meter after the last line, which will keep the vertical height from changing. I tried it and it works good. And if I ever change fonts or sizes, I only have to change one item instead of 4 or 5.

It's not a big concern for me now, but what about that that SkinHeight and BackgroundMargins issue? Is it supposed to be that way or is that a bug?
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Problems with BackgroundMode

Post by balala »

russdirks wrote:It's not a big concern for me now, but what about that that SkinHeight and BackgroundMargins issue? Is it supposed to be that way or is that a bug?
The BackgroundMode=3 option (set in the [Rainmeter] section) tells Rainmeter to scale the image used as background. If you add a SkinHeight option, the background will be scaled to the specified height and it seems the header will be scaled proportionally, ignoring the BackgroundMargins. However I'm not very sure.
Post Reply