It is currently July 4th, 2022, 6:40 am

Integrating dynamically changing font size code into app volume control

Get help with creating, editing & fixing problems with skins
meowbox
Posts: 1
Joined: June 23rd, 2022, 11:16 pm

Integrating dynamically changing font size code into app volume control

Post by meowbox »

Hello there! I'm a new user here, and newish to Rainmeter as well.

I'm working on a skin right now that displays the audio levels of applications and allows you to adjust them. It's a variation of a volume control skin I found at: https://github.com/khanhas/AppVolumePlugin/releases (the example skin). It took me a while but I was successful in understanding the weird format of incrementing index to alter it and make it look like I want in regard to the 2 dynamic bars and the name of the apps. The issue comes when I try to use a dynamic font-changing code to fit long titles into a specific width. I also found one for this online https://forum.rainmeter.net/viewtopic.php?t=31547 (basically copied and edited Yincognito's code from the 2nd comment, it's the first code below). Once I got that to work by itself, I put it into the app volume control (second code below) and tested it for a long time, but it only worked when I didn't use the indexing system (%% after each variable/meter). I feel like I'm incorrectly using DynamicVariables, the Bangs, or am misunderstanding the indexing. If anyone is able to help with understanding the indexing system and the bangs/actions, that would be much appreciated!

edit: oh yeah, and the [MeterTextVol%%] meter is supposed to display the volume of the app, but I have no idea how to get the value from [AppVol%%], as it always returns 0 (do I use AppVol%% , [AppVol%%] , or [AppVol%%:] ?).

Dynamicaly changing font size code:

Code: Select all


[Rainmeter]
Update=1000
AccurateText=1

[Variables]
Width=85
Height=36
Adjusted=0
TSize=14
TText=hyperlight

[MeasureTextWidth]
Measure=Calc
UpdateDivider=-1
Formula=([MeterText:W])
IfCondition=(([MeasureTextWidth]>=#Width#) && (#Adjusted#=0))
IfTrueAction=[!SetVariable TSize (#TSize#-1)][!UpdateMeter "MeterText"][!Redraw]
IfCondition2=(([MeasureTextWidth]<#Width#) && (#Adjusted#=0))
IfTrueAction2=[!SetVariable Adjusted 1][!SetVariable TSize (#TSize#+1)][!SetOption MeterText FontColor "255,255,255,255"][!UpdateMeter "MeterText"][!Redraw]
IfConditionMode=1
DynamicVariables=1

[Background]
Meter=Image
SolidColor=00000033
W=#Width#
H=#Height#
DynamicVariables=1

[MeterText]
Meter=String
Text=#TText#
AntiAlias=1
ClipString=0
X=[Background:X]
Y=[Background:Y]
FontColor=255,255,255,0
FontSize=#TSize#
FontFace=Source Sans Pro
OnUpdateAction=[!UpdateMeasure "MeasureTextWidth"]
DynamicVariables=1
SolidColor=0,255,0,200

[textwidth]
Meter=String
Text=[MeterText:W]
X=[Background:X]
Y=[Background:Y]
DynamicVariables=1



app volume control code:

Code: Select all


[Rainmeter]
Update=25
AccurateText=1

[Variables]
;Set by script, do not change.
MaxMeter=0
Adjusted1=0
Adjusted2=0
Adjusted3=0
Adjusted4=0
Adjusted5=0
TSize1=14
TSize2=0
TSize3=0
TSize4=0
TSize5=0


[AppVolumeParent]
Measure = Plugin
Plugin = AppVolume
IgnoreSystemSound = 1
ExcludeApp = rainmeter.exe;AMDRSServ.exe;steam.exe;steamwebhelper.exe

;Generate child measures/meters.
;@Options:
; IncFile:	Directory to file that contains measures/meters.
; MeasureName:	Name of measure to get number value and re-generate same amount
;              of measures/meters everytime that value changes.
; AutoRefresh:	Automatically refresh when file is re-generated. 0 or 1
; S[n]:	Section name. [n] can be from 1 to infinity.
; S[n]K[m]:	Key and value of section [n]. [m] can be from 1 to infinity.
;
;You can use %% to replace it with index number.
;You can also use math formula by putting it inside {}.

[GeneratorScript]
Measure=Script
ScriptFile  = GeneratorScript.lua
IncFile     = MeasuresAndMeters.inc
MeasureName = AppVolumeParent
AutoRefresh = 1
S1   = AppVol%%
S1K1 = Measure = Plugin
S1K2 = Plugin = AppVolume
S1K3 = Parent = AppVolumeParent
S1K4 = Index = %%
S1K5 = Substitute = ".exe":""

S2   = AppPeak%%
S2K1 = Measure = Plugin
S2K2 = Plugin = AppVolume
S2K3 = Parent = AppVolumeParent
S2K4 = Index = %%
S2K5 = NumberType = Peak
S2K6 = StringType = FilePath

S3   = MeterBackground%%
S3K1 = Meter = Shape
S3K2 = MeterStyle = ShapeBackground
S3K3 = X = {(%% - 1) * 120 + 1035}
S3K4 = Y = 802

S4   = MeterShapeTop%%
S4K1 = Meter = Shape
S4K2 = MeterStyle = ShapeStyleTop
S4K3 = X = {(%% - 1) * 120 + 1035}
S4K4 = Y = 802
;Scale is scaleX,scaleY,anchorX,anchorY
;volwidth scaleX gives dynamic volume percent
S4K5 = VolWidth = Scale ([AppVol%%:] > 0 ? [AppVol%%:] : 0), 1, 0, 0
S4K6 = LeftMouseUpAction = !CommandMeasure AppVol%% "ToggleMute"
S4K7 = MouseScrollUpAction = !CommandMeasure AppVol%% "SetVolume +5"
S4K8 = MouseScrollDownAction = !CommandMeasure AppVol%% "SetVolume -5"

S5   = MeterShapeBottom%%
S5K1 = Meter = Shape
S5K2 = MeterStyle = ShapeStyleBottom
S5K3 = X = 16r
S5K4 = Y = 3R
;peakwidth scaleX gives dynamic blue bar
S5K5 = PeakWidth = Scale 1, ([AppPeak%%:] > 0 ? [AppPeak%%:] : 0), 0, 64

S6   = MeterBorder%%
S6K1 = Meter = Shape
S6K2 = X = {(%% - 1) * 120 + 1035}
S6K3 = Y = 802
S6K4 = Shape = Path WhiteBorder | StrokeWidth 2 | Stroke Color 255,255,255 | Fill Color 0,0,0,0
S6K5 = WhiteBorder = 0,18 | LineTo 10,0 | LineTo 104,0 | LineTo 114,18 | LineTo 104,36 | LineTo 10,36 | ClosePath 1
S6K6 = Shape2 = Path WhiteBorder2 | StrokeWidth 2 | Stroke Color 255,255,255 | Fill Color 0,0,0,0
S6K7 = WhiteBorder2 = 16,40 | LineTo 98,40 | LineTo 98,80 | LineTo 57,104 | LineTo 16,80 | ClosePath 1

S7   = MeasureTextWidth%%
S7K1 = Measure=Calc
S7K2 = UpdateDivider=-1
S7K3 = Formula={[MeterTextApp%%:W]}
S7K4 = IfCondition=([MeasureTextWidth%%]>94} && {#Adjusted%%#=0)
S7K5 = IfTrueAction=[!SetVariable TSize%% {#TSize%%#-1}][!UpdateMeter "MeterTextApp%%"][!Redraw]
S7K6 = IfCondition2=([MeasureTextWidth%%]<=94} && {#Adjusted%%#=0)
S7K7 = IfTrueAction2=[!SetVariable Adjusted%% 1][!SetVariable TSize%% {#TSize%%#+1}][!SetOption "MeterTextApp%%" FontColor "255,255,255,255"][!UpdateMeter "MeterTextApp%%"][!Redraw]
S7K8 = IfConditionMode=1
S7K9 = DynamicVariables=1

S8   = MeterTextApp%%
S8K1 = Meter = String
S8K2 = MeterStyle = TextStyle
S8K3 = MeasureName = AppVol%%
S8K4 = X = {(%% - 1) * 120 + 1035 + 114/2}
S8K5 = Y = {802+36/2-2}
S8K6 = W = 94
S8K7 = H = 36
S8K8 = FontSize = #TSize%%#
S8K9 = FontColor=255,255,255
S8K10= OnUpdateAction=[!UpdateMeasure "MeasureTextWidth%%"]

S9   = MeasureVol%%
S9K1 = Meter = Calc
S9K2 = Formula = {[AppVol%%:] * 100}
S9K3 = DynamicVariables = 1

S10   = MeterTextVol%%
S10K1 = Meter = String
S10K2 = MeterStyle = TextStyle
S10K3 = MeasureName = MeasureVol%%
S10K4 = X = {(%% - 1) * 120 + 1035 + 114/2}
S10K5 = Y = {802+72}
S10K6 = FontSize = 14
S10K7 = FontColor=255,255,255
S10K8 = Text = {%1*100}
;S10K9 = DynamicVariables=1


[ShapeBackground]
Shape = Path Background | StrokeWidth 2 | Stroke Color 255,255,255 | Fill Color 0,0,0
Background = 16,-4 | LineTo 6,18 | LineTo 16,40 | LineTo 98,40 | LineTo 112,18 | LineTo 98,-4 | ClosePath 1


[ShapeStyleTop]
;wide hexagon background shape
Shape = Path BackgroundBarTop | StrokeWidth 2 | Stroke Color 255,255,255 | Fill Color 0,0,0
BackgroundBarTop = 0,18 | LineTo 10,0 | LineTo 104,0 | LineTo 114,18 | LineTo 104,36 | LineTo 10,36 | ClosePath 1
;red app audio percentage bar
Shape2 = Rectangle 0, 0, 114, 36 | StrokeWidth 0 | Fill Color 255,0,0 | Extend VolWidth
;tapers the dynamic bar
Shape3 = Path BackgroundBarTop | StrokeWidth 2 | Stroke Color 255,255,255 | Fill Color 0,0,0
BackgroundBarTop = 0,18 | LineTo 10,0 | LineTo 104,0 | LineTo 114,18 | LineTo 104,36 | LineTo 10,36 | ClosePath 1
Shape4 = Combine Shape2 | Intersect Shape3
DynamicVariables = 1


[ShapeStyleBottom]
;pentagon background shape
Shape = Path BackgroundBarBottom | StrokeWidth 2 | Stroke Color 255,255,255 | Fill Color 0,0,0
BackgroundBarBottom = 0,0 | LineTo 82,0 | LineTo 82,40 | LineTo 41,64 | LineTo 0,40 | ClosePath 1
;blue instantaneous audio level bar
Shape2 = Rectangle 0, 0, 82, 64 | StrokeWidth 0 | Fill Color 0,0,255 | Extend PeakWidth
;tapers the dynamic bar
Shape3 = Path BackgroundBarBottom | StrokeWidth 2 | Stroke Color 255,255,255 | Fill Color 0,0,0
BackgroundBarBottom = 0,0 | LineTo 82,0 | LineTo 82,40 | LineTo 41,64 | LineTo 0,40 | ClosePath 1
Shape4 = Combine Shape2 | Intersect Shape3
DynamicVariables = 1


[TextStyle]
FontFace   = Cabliri
StringAlign= CenterCenter
StringCase = Upper
AntiAlias  = 1


[DummyMeter]
Meter=String
X=0

@include=MeasuresAndMeters.inc