It is currently October 9th, 2024, 3:59 am

New Container meter option

Changes made during the Rainmeter 4.3 beta cycle.
User avatar
jsmorley
Developer
Posts: 22843
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

New Container meter option

Post by jsmorley »

Container=SomeMeter

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

The documentation and a bunch of examples for Container are at https://docs.rainmeter.net/manual-beta/meters/general-options/container/

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.

An existing discussion about this feature is at https://forum.rainmeter.net/viewtopic.php?f=123&t=30121#p155025.

The beauty of Container is the simplicity of the concept.

Visibility
  • Content meters are "constrained" by the W and H boundaries of the container.
    Content outside the container is not drawn, and in effect doesn't exist.
  • Content meters are only drawn on solid pixels of the container.
    Any transparency of both the container and the content are cumulative.
Relativity
  • The first content meter in a container is automatically relative to the top left of the container.
    "r" and "R" are ignored.
  • Subsequent content meters in a container are relative to each other.
    "r" and "R" are functional.
  • Meters that are not content are relative to the immediately preceding meter that isn't content.
  • Containers may not be "nested".
The combination of the simple visibility and relativity rules buys you both "viewport" and "masking".

As with all the best features, this is very simple in principle, and very easy to wrap your head around, while being VERY powerful and flexible, and allowing for a lot of creativity. Go nuts!
User avatar
jsmorley
Developer
Posts: 22843
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Container meter option

Post by jsmorley »

Here is what the various examples in the .rmskin at the bottom of the Container documentation look like:


Click to animate larger .gif files

HelloWorld.gif
BarMeter.gif
ClipString.gif
ImageInString.gif
IrisShape.gif
MaskImage.png
MaskShape.png
NiceWeather.jpg
RainyWeather.gif
Relative.png].png
RoundLineGradient.gif
ScaleShapeMask.gif
ScrollText.gif
SizeContainer.gif
Teleport.gif
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22843
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Container meter option

Post by jsmorley »

Here is another example. You can have as many "content" meters in a "container" as you want:

Code: Select all

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

[Variables]
ContainerH=48
U=[!UpdateMeasure Slider][!UpdateMeter *][!Redraw]

;[GATHER MEMORY]==================================

[MeasurePhysMemTotal]
Measure=PhysicalMemory
Total=1
UpdateDivider=-1

[MeasurePhysMemUsed]
Measure=PhysicalMemory
UpdateDivider=2

[MeasurePhysMemFree]
Measure=PhysicalMemory
InvertMeasure=1
UpdateDivider=2

[MeasureSwapMemTotal]
Measure=SwapMemory
Total=1
UpdateDivider=2

[MeasureSwapMemUsed]
Measure=SwapMemory
UpdateDivider=2

[MeasureSwapMemFree]
Measure=SwapMemory
InvertMeasure=1
UpdateDivider=2

[MeasurePageTotal]
Measure=Calc
Formula=MeasureSwapMemTotal - MeasurePhysMemTotal
UpdateDivider=2

[MeasurePageUsedPercent]
Measure=Plugin
Plugin=UsageMonitor
Category=Paging File
Counter=% Usage
UpdateDivider=2

[MeasurePageUsed]
Measure=Calc
Formula=MeasurePageTotal * (MeasurePageUsedPercent / 100)
UpdateDivider=2

[MeasurePageFree]
Measure=Calc
Formula=MeasurePageTotal - MeasurePageUsed
UpdateDivider=2

;[BACKGROUND CONTAINER]============================

[MeterBackVisible]
Meter=Shape
Shape=Rectangle 1,1,220,#ContainerH# | StrokeWidth 2 | Stroke Color 155,155,155,255 | Fill Color 47,47,47,255
DynamicVariables=1
MouseOverAction=[!CommandMeasure Slider "Stop 2"][!CommandMeasure Slider "Execute 1"]
MouseLeaveAction=[!CommandMeasure Slider "Stop 1"][!CommandMeasure Slider "Execute 2"]

[MeterBackContainer]
Meter=Shape
Shape=Rectangle 1,1,220,#ContainerH# | StrokeWidth 2
DynamicVariables=1

;[METERSTYLES]====================================

[AllStyle]
FontSize=11
FontWeight=600
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
AutoScale=1
NumOfDecimals=1
Container=MeterBackContainer

[LeftStyle]
StringAlign=Left

[RightStyle]
StringAlign=Right

;[ALWAYS DISPLAY]=================================

[MeterRAMTitle]
Meter=String
X=10
Y=10
FontSize=15
FontWeight=600
FontColor=255,255,255,255
SolidColor=0,0,0,1
StringAlign=Left
AntiAlias=1
Text=RAM

[MeterRAMValue]
Meter=String
MeasureName=MeasurePhysMemFree
X=210
Y=10
FontSize=15
FontWeight=600
FontColor=255,255,255,255
SolidColor=0,0,0,1
StringAlign=Right
AutoScale=1
AntiAlias=1
Text=%1B

[MeterPhysMemoryBar]
Meter=Bar
MeasureName=MeasurePhysMemUsed
BarOrientation=Horizontal
BarColor=0,255,0,255
SolidColor=80,80,80,255
X=10
Y=2R
W=200
H=2

;[SLIDE CONTAINER]===================================

[Slider]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat SlideDown,3,46
SlideDown=[!SetVariable ContainerH "(Clamp(#ContainerH#+4,48,230))"]#U#
ActionList2=Repeat SlideUp,3,46
SlideUp=[!SetVariable ContainerH "(Clamp(#ContainerH#-4,48,230))"]#U#
DynamicVariables=1

;[CONTAINER CONTENT]=================================

[MeterPhysTotalTitle]
Meter=String
MeterStyle=AllStyle | LeftStyle
; Note that this is 10 X  and 50 Y pixels relative to the starting X and Y of the
; Container meter, [MeterBackContainer].
X=10
Y=50
Text=Physical Total

[MeterPhysTotalValue]
Meter=String
MeterStyle=AllStyle | RightStyle
MeasureName=MeasurePhysMemTotal
; This "content" meter will be relative to the preceding content meter, [MeterPhysTotalTitle]. 
X=210
Y=0r
Text=%1B

[MeterPhysUsedTitle]
Meter=String
MeterStyle=AllStyle | LeftStyle
X=10
Y=2R
Text=Physical Used

[MeterPhysUsedValue]
Meter=String
MeterStyle=AllStyle | RightStyle
MeasureName=MeasurePhysMemUsed
X=210
Y=0r
Text=%1B

[MeterPhysFreeTitle]
Meter=String
MeterStyle=AllStyle | LeftStyle
X=10
Y=2R
Text=Physical Free

[MeterPhysFreeValue]
Meter=String
MeterStyle=AllStyle | RightStyle
MeasureName=MeasurePhysMemFree
X=210
Y=0r
Text=%1B

[MeterSwapTotalTitle]
Meter=String
MeterStyle=AllStyle | LeftStyle
X=10
Y=7R
Text=Swap Total

[MeterSwapTotalValue]
Meter=String
MeterStyle=AllStyle | RightStyle
MeasureName=MeasureSwapMemTotal
X=210
Y=0r
Text=%1B

[MeterSwapUsedTitle]
Meter=String
MeterStyle=AllStyle | LeftStyle
X=10
Y=2R
Text=Swap Used

[MeterSwapUsedValue]
Meter=String
MeterStyle=AllStyle | RightStyle
MeasureName=MeasureSwapMemUsed
X=210
Y=0r
Text=%1B

[MeterSwapFreeTitle]
Meter=String
MeterStyle=AllStyle | LeftStyle
X=10
Y=2R
Text=Swap Free

[MeterSwapFreeValue]
Meter=String
MeterStyle=AllStyle | RightStyle
MeasureName=MeasureSwapMemFree
X=210
Y=0r
Text=%1B

[MeterPageTotalTitle]
Meter=String
MeterStyle=AllStyle | LeftStyle
X=10
Y=7R
Text=Page Total

[MeterPageTotalValue]
Meter=String
MeterStyle=AllStyle | RightStyle
MeasureName=MeasurePageTotal
X=210
Y=0r
Text=%1B

[MeterPageUsedTitle]
Meter=String
MeterStyle=AllStyle | LeftStyle
X=10
Y=2R
Text=Page Used

[MeterPageUsedValue]
Meter=String
MeterStyle=AllStyle | RightStyle
MeasureName=MeasurePageUsed
X=210
Y=0r
Text=%1B

[MeterPageFreeTitle]
Meter=String
MeterStyle=AllStyle | LeftStyle
X=10
Y=2R
Text=Page Free

[MeterPageFreeValue]
Meter=String
MeterStyle=AllStyle | RightStyle
MeasureName=MeasurePageFree
X=210
Y=0r
Text=%1B
SlideMemory.gif
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22843
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Container meter option

Post by jsmorley »

You can slide the "content" around in and out of the "container", OR you can slide the "container" itself...

Code: Select all

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

[Variables]
Start=0
End=400

[MeasureLoop]
Measure=Loop
StartValue=#Start#
EndValue=#End#
Increment=6
LoopCount=1
IfCondition=MeasureLoop = #End#
IfTrueAction=[!Delay 1000][!SetOption MeasureLoop InvertMeasure 1][!UpdateMeasure MeasureLoop]
IfCondition2=MeasureLoop = #Start#
IfTrueAction2=[!Delay 1000][!SetOption MeasureLoop InvertMeasure 0][!UpdateMeasure MeasureLoop]

[MeterContainerVisible]
Meter=Shape
X=[MeasureLoop]
DynamicVariables=1
Shape=Rectangle 2,2,100,34 | StrokeWidth 4 | Stroke Color 160,160,160,255 | Fill Color 15,20,25,255

[MeterContainer]
Meter=Shape
X=[MeasureLoop]
DynamicVariables=1
Shape=Rectangle 4,4,96,30 | StrokeWidth 0

[MeterStringVisible]
Meter=String
X=10
Y=7
FontSize=16
FontWeight=400
FontColor=255,255,255,100
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
Text=If at first you don't succeed, skydiving is not for you.

[MeterStringContent]
Meter=String
; Since the content meter will be relative to the start of the container meter,
; we need to move the content meter "left" as the container meter moves "right".
; That will keep the contents in a static position, as the container moves.
X=(10 - [MeasureLoop])
Y=7
FontSize=16
FontWeight=400
FontColor=255,255,255,255
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
Container=MeterContainer
Text=If at first you don't succeed, skydiving is not for you.

Click to animate:
GIF.gif
You do not have the required permissions to view the files attached to this post.
jminternelia
Posts: 65
Joined: March 21st, 2017, 3:46 am

Re: New Container meter option

Post by jminternelia »

Is this broken with the new beta release? None of my metercontainers are working like they should
User avatar
jsmorley
Developer
Posts: 22843
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Container meter option

Post by jsmorley »

jminternelia wrote: December 19th, 2018, 2:56 pm Is this broken with the new beta release? None of my metercontainers are working like they should
Drat! Something got borked. We are on it...

You can roll back to r3266 here: https://builds.rainmeter.net.
User avatar
jsmorley
Developer
Posts: 22843
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: New Container meter option

Post by jsmorley »

Please get the r3271 beta version I just released, and let me know if this fixes Container for you.
jminternelia
Posts: 65
Joined: March 21st, 2017, 3:46 am

Re: New Container meter option

Post by jminternelia »

jsmorley wrote: December 19th, 2018, 3:45 pm Please get the r3271 beta version I just released, and let me know if this fixes Container for you.
It did.
User avatar
JosephB2000
Posts: 155
Joined: July 29th, 2014, 7:02 pm

Re: New Container meter option

Post by JosephB2000 »

The container option is a great addition to Rainmeter; being able to control the visibility of a multitude of meters from just one makes animations and the such much easier. I just have one possible bug or misunderstanding on my part with this new feature.

This test skin has a background (black), a container and its visible counterpart (red) and the container's contents (green). The container and its visible counterpart are both initially hidden and part of a group GroupContainer which, when you click on the background, should appear. They do appear, however,
if the container isn't updated and the skin isn't redrawn straight after, it takes a while for both the container AND the visible counterpart to appear. If the container is updated and the skin redrawn, then all appears fine and quickly...

Why does the container need to be updated whilst the visible counterpart doesn't? Also, when the container isn't updated, why does the visible counterpart also take a while?

Here is the skin. If you switch the LeftMouseUpAction for the one where the meter is updated, it works fine.
[Rainmeter]

[Background]
Meter=String
W=200
H=100
SolidColor=0,0,0
LeftMouseUpAction=[!ShowMeterGroup GroupContainer]
;LeftMouseUpAction=[!ShowMeterGroup GroupContainer][!UpdateMeter ContainerMeter][!Redraw]

[ContainerMeterVisible]
Meter=String
X=20
Y=10
W=160
H=80
SolidColor=255,0,0
Group=GroupContainer
Hidden=1

[ContainerMeter]
Meter=String
X=r
Y=r
W=160
H=80
SolidColor=0,0,0
Group=GroupContainer
Hidden=1

[ContainedString]
Meter=String
X=30
Y=10
W=100
H=60
SolidColor=0,255,0
Container=ContainerMeter
EDIT: Using Rainmeter 4.3 Final Release - r3298 on Windows 10, in case that is of any help.
[Insert Joke Here]
User avatar
balala
Rainmeter Sage
Posts: 16640
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: New Container meter option

Post by balala »

JosephB2000 wrote: April 8th, 2019, 6:31 pm Also, when the container isn't updated, why does the visible counterpart also take a while?
If you don't update a meter it is updated at next update cycle. In this case, because no Update option is set into the [Rainmeter] section, the skin is updated once per second. So, if you don't update the meter, it is updated after an interval of up to one second.
JosephB2000 wrote: April 8th, 2019, 6:31 pm Why does the container need to be updated whilst the visible counterpart doesn't?
When you update a container, it updates its content meters, as well.