Container


Define a meter to be used as a "container" for the "contents" of this meter.

The intent of this is two-fold:

  • A meter that has a Container option will in effect be put "inside" the container meter. It will be positioned relative to the container, and will be visibly constrained by it. Only the part of the content that is "inside" the container will be drawn.

    Think sliding content, a menu or launcher for instance, into view without needing to start outside the entire skin.

  • The content will be "masked" into any solid pixels in the container meter. So only the part of the content that is masked into a solid pixel in the container will be drawn.

    Think masking an image into a String meter, or an image into a Shape meter.

Any "content" meter(s) will be positioned relative to the "container", and the content will only be drawn on solid pixels of the container. Any content that is positioned outside the container, or that is on a transparent pixel in the container, will not be drawn. Content outside the container is truncated, and in effect doesn't exist. It will not impact the size of the skin.

Any meter type can be a "container" and any meter type can be "content".

Container Any meter name

Name of a meter, of any type, to be used as a container for the content of this meter

Example: Container=SomeOtherMeter

Usage Notes

  • Meters that are "content" meters, that have the Container option on them, are positioned relative to the starting X and Y of the meter being used as a "container". Any X and Y on the first content meter in a container will in effect use the "r" relative positioning option, relative to their container. No actual "r" option is needed.
  • Meters that are "content" meters, and follow other content meters in a container, will be relative to each other. In this case, use the "r" and "R" options to position them relative to each other, as you normally would.
  • Meters that follow "content" meters, but are NOT content themselves, that have no Container option on them, will be relative to the last preceding meter that is not "content".

  • A meter being used as a "container" will NOT be drawn itself. In a sense, it is just the "shape" of its solid pixels that is being used. If you want the container meter itself to be visible, you will need to create a copy of the meter, not used as a container.
  • Any transparency on both the "container" and "content" meters will be taken into account. In effect they will both be "subtracted" from the opacity of the final result.

    Although container meters are not drawn, everything else about them plays a role. The position, size, and opacity of the container are all factors in how the "content" is treated when placed in the container. If a pixel in the container is fully transparent, any pixel from the "content" placed there will also be fully transparent. That is the key to how the "masking" is done.

  • A "content" meter may NOT also be a "container" meter. In other words, you cannot "nest" containers inside of containers.

Examples

While the example code here is for two simple skins that demonstrate using Container, you can download a suite of skins demonstrating several ways to use the funtionality.

Download the .rmskin.



Sliding a "content" meter in and out of a "container" meter.

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
OffSet=130
U=[!UpdateMeasure "MeasureSlideInOut"][!UpdateMeter *][!Redraw]

[MeterSkinBack]
Meter=Shape
Shape=Rectangle 0.5,0.5,169,103,12 | Fill Color 47,47,47,255 | StrokeWidth 1.5 | Stroke Color 150,150,150,255
X=0
Y=0
W=170
H=104

[MeterContainerVisible]
Meter=Shape
; A copy of the container meter, to provide visibility
Shape=Rectangle 0,0,130,84,12 | Fill Color 255,47,47,255 | StrokeWidth 0
X=20
Y=10

[MeterContainer]
Meter=Shape
; Meters used as a container will not be drawn. They are used as a "mask".
; Create a copy of them, as above, to make them visible.
Shape=Rectangle 0,0,130,84,12 | Fill Color 255,47,47,255 | StrokeWidth 0
X=20
Y=10
MouseOverAction=[!CommandMeasure MeasureSlideInOut "Stop 2"][!CommandMeasure MeasureSlideInOut "Execute 1"]
MouseLeaveAction=[!CommandMeasure MeasureSlideInOut "Stop 1"][!CommandMeasure MeasureSlideInOut "Execute 2"]

[MeterString]
Meter=String
; This meter will be relative to the starting X and Y of its container.
X=#OffSet#
Y=33
FontSize=13
FontColor=255,255,255,255
SolidColor=0,0,0,1
FontWeight=400
AntiAlias=1
Text=Hello World!
DynamicVariables=1
MouseOverAction=[!SetOption MeterString FontColor "0,0,0,255"][!UpdateMeter *][!Redraw]
MouseLeaveAction=[!SetOption MeterString FontColor "255,255,255,255"][!UpdateMeter *][!Redraw]
LeftMouseUpAction=[!Log "Clicked me!"]
Container=MeterContainer

[MeasureSlideInOut]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Reset | Wait 1 | Repeat SlideIn, 30, 11
SlideIn=[!SetVariable OffSet "(Clamp(#OffSet#-12,20,130))"]#U#
ActionList2=Repeat SlideOut, 30, 11 | Wait 1 | Reset
SlideOut=[!SetVariable OffSet "(Clamp(#OffSet#-12,-130,20))"]#U#
Reset=[!SetVariable OffSet 130]#U#
IgnoreWarnings=1
DynamicVariables=1



Masking an image "content" meter into a string "container" meter.

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]

[MeterWeatherVisible]
Meter=Image
; We want to display the entire image, as well as the part
; masked into the string, so we use this Image meter to
; display our slightly muted image as a background.
ImageName=#@#Images\NiceWeather.jpg
W=400
PreserveAspectRatio=1
ImageTint=180,180,180,255

[MeterTemperatureShadow]
Meter=String
; The actual text of this meter will be overlaid by the
; string we are using as mask, but the shadow will
; be displayed around it.
X=90
Y=50
FontSize=120
FontWeight=700
FontColor=255,255,255,255
InlineSetting=Shadow | 2 | 2 | 3.5 | 0,0,0,255
AntiAlias=1
Text=41°

[MeterTemperatureMask]
Meter=String
X=90
Y=50
FontSize=120
FontWeight=700
; Note that no FontColor is needed, as long as it is fully opaque,
; which the default FontColor for a String meter is.
AntiAlias=1
Text=41°

[MeterWeatherMasked]
Meter=Image
ImageName=#@#Images\NiceWeather.jpg
; Since we set an X and Y on the String meter, and this image
; content will be relative to the start of that, we need to
; move the image up and left so it aligns the result with
; the "visible" Image meter, and masks correctly into the
; String meter.
X=-90
Y=-50
W=400
PreserveAspectRatio=1
Container=MeterTemperatureMask