It is currently October 26th, 2021, 12:20 pm

Need Help with Mouse control on Shapes.

Help with creating, editing & fixing problems with skins
User avatar
KryptOnyx
Posts: 19
Joined: July 28th, 2021, 10:18 am

Re: Need Help with Mouse control on Shapes.

Post by KryptOnyx »

Hi Death.Crafter, HexLattice needs Rainmeter 4.4 (beta) to install, but I had a look inside rmskin...I did a similar thing to your LUA script but with ActionTimer.
This is a portion of the Test Skin that 'saves' the Tile Configuration, so wont work on its own.

Code: Select all

; --==>> Generate the Grid <<==--
[mHexTileTimer]
; This Section is to generate the HexGridTiles.inc file and create the Hex Tiles Stack.
Measure=Plugin
Plugin=ActionTimer
DynamicVariables=1
ActionList1=Repeat SetTilePosition, 5, 500
SetTilePosition=[!WriteKeyValue Hex_Tile_#TileCount# Meter "Shape" "#@#HexGridTiles.inc"][!WriteKeyValue Hex_Tile_#TileCount# X -100 "#@#HexGridTiles.inc"][!WriteKeyValue Hex_Tile_#TileCount# Y -100" "#@#HexGridTiles.inc"][!WriteKeyValue Hex_Tile_#TileCount# MeterStyle "HEX_UNSET | HEX_COMMON" "#@#HexGridTiles.inc"][!SetVariable TileCount (#TileCount#+1)][!UpdateMeasure #CurrentSection#]

[mHexLabelTimer]
; This Section is to generate the HexGridLabels.inc file and create the Hex Labels Stack.
Measure=Plugin
Plugin=ActionTimer
DynamicVariables=1
ActionList1=Repeat SetLabelPosition, 5, 500
SetLabelPosition=[!WriteKeyValue Hex_Label_#LabelCount# Meter "String" "#@#HexGridLabels.inc"][!WriteKeyValue Hex_Label_#LabelCount# X -100 "#@#HexGridLabels.inc"][!WriteKeyValue Hex_Label_#LabelCount# Y -100 "#@#HexGridLabels.inc"][!WriteKeyValue Hex_Label_#LabelCount# MeterStyle "HEX_LABEL" "#@#HexGridLabels.inc"][!WriteKeyValue Hex_Label_#LabelCount# Text #LabelCount# "#@#HexGridLabels.inc"][!SetVariable LabelCount (#LabelCount#+1)][!UpdateMeasure #CurrentSection#]

I had thought of the problem of 'deselecting' a mid-sequence Tile and opted to simply remove the last placed Tile.
I suspect the issue has something to do with Timing and the Update cycle.
The basic process is simple and native Rainmeter should be able to handle it...
All Tiles start off-screen (-100,-100). Sequence = 0.
Click on the Canvas -> Move Tile #Sequence to XY (calculated Hex Cell coord) -> increase Sequence by 1.
Click again on Canvas -> Move Tile #Sequence (now = 1) to XY (calculated Hex Cell cord) -> increase Sequence by 1 (now = 2).
Click on Tile (doesn't matter which one) -> decrease Sequence by 1 (because Canvas Click increased it in preparation of another Tile placement), now it equals (1) the last placed Tile # -> move Tile #Sequence to -100,-100.
Click the remaining Tile -> decrease Sequence by 1 (now = 0) -> move Tile #Sequence to -100,-100.
No more Tiles, Sequence = 0, Click Canvas and we begin again.

This should apply to however many Tiles in the Stack off-screen as there is no need to track which Tile is Clicked.
Obviously there are no Range limitations or checks as they will be added when the basic process works...only it doesn't.
There are three outcomes when Canvas is Clicked... the Clicks do what is expected, or a Click is ignored (no visible Action), or the Action is 'delayed' as the Tile appears in the previous Clicked location.
I will try using Update=-1 and see if the same thing happens.
Everything happens for a Reason, and could Not happen any other way.
User avatar
KryptOnyx
Posts: 19
Joined: July 28th, 2021, 10:18 am

Re: Need Help with Mouse control on Shapes.

Post by KryptOnyx »

Using Update=-1 seems to disable the About:Skins trace...no Measures or Variables change even though every second Canvas Click puts a Tile at Cell 0,0...
Time for some debug String Meters :D
Everything happens for a Reason, and could Not happen any other way.
User avatar
KryptOnyx
Posts: 19
Joined: July 28th, 2021, 10:18 am

Re: Need Help with Mouse control on Shapes.

Post by KryptOnyx »

Very strange...Variables are not changing in the Current Update cycle...
I modified the Canvas Click (untangled for easier reading) to put values into String Meters :
LeftMouseUpAction=
[!SetVariable MouseX "$MouseX$"]
[!SetVariable MouseY "$MouseY$"]
[UpdateMeasure Mouse_Cell_X]
[UpdateMeasure Mouse_Cell_Y]
[UpdateMeasure Tile_Center_X]
[UpdateMeasure Tile_Center_Y]
[!SetOption Hex_Tile_#Sequence# X [Tile_Center_X]]
[!SetOption Hex_Tile_#Sequence# Y [Tile_Center_Y]]
[!SetOption Debug_Label_0 Text "LMB X = $MouseX$ : LMB Y = $MouseY$"]
[!SetOption Debug_Label_1 Text "MouseX = #MouseX# : MouseY = #MouseY#"]
[!SetOption Debug_Label_2 Text "Cell X = [Mouse_Cell_X] : Cell Y = [Mouse_Cell_Y]"]
[!UpdateMeter *]
[!Redraw]
[!SetVariable Sequence (#Sequence#+1)]

Debug_Label_0 changes with every Mouse Click, as is expected, but Debug_Label_1 shows the PREVIOUS vales of $MouseX$ and $MouseY$ as if the MouseX and MouseY Variables are not set when the Debug_Labels are drawn.
And Mouse_Cell_X : Mouse_Cell_Y Measures are only returning 0, even with forced Update. :confused:
Everything happens for a Reason, and could Not happen any other way.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Need Help with Mouse control on Shapes.

Post by death.crafter »

I think you mistook beta for a unstable version. Well, I don't blame you for that, but beta is as stable as the final release. So you can install the latest version.

Also, if you are trying to make a launcher, you can do things in lua more easily than you can do in vanilla Rainmeter.

And HexLattice does exactly what you are trying to do in a more easy manner, and you don't have to go through a lot of trouble of updating measures and meters. With what you have, it is a little hard to follow and see where you are going wrong.

Here I packed it for 4.3. But you should get 4.4 beta.
HexLattice_1.0.1.rmskin
I added images to make the stepping back more clear.

Images from: https://www.deviantart.com/flickerywolf/art/Minimalist-gradiant-honeycomb-icons-730615311
You do not have the required permissions to view the files attached to this post.
from the Realm of Death
My Current Desktop
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Need Help with Mouse control on Shapes.

Post by Yincognito »

death.crafter wrote: August 10th, 2021, 11:56 pm Also I am pretty sure you can't in native Rainmeter. Simply because of the fact that you can't add or remove meters and store the options to go back from a certain index. I mean fall back or whatever it is.
In terms of dynamically creating measures or meters, I agree that you can't, as in native Rainmeter you have to have them all from the start. But then sometimes, like in this case, with a suitable meter style, it's just about pressing CTRL + V as many times as desired.

Regarding the indexes, it's entirely possible to cover the "gaps" when "hiding"/"invalidating" one of the hexes, you don't need to offset meter options for that. This is built on your initial code, so it has only 6 hexes (when it reaches the 7th it just moves the 6th instead of disabling mouse action, which creates an interesting, and not that bad, effect), and you can see how if you want to hide, say, the 3rd out of 5 hexes, when clicking to show hexes again it starts from the first in the list that's hidden, i.e. the 3rd:

Code: Select all

[Variables]
Cleaner="(?:^[^[\x200B]].*|.*[^[\x200B]]$)":"","(?:^[\x200B]|[\x200B]$)":"","(?:^\\\d+|\\\d+$)":""
Status=
Next=0

Radius=30
Width=3
StartAngle=0
MaxNext=5

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!AutoSelectScreen "1" "#CURRENTCONFIG#"]

---Measures---

[NextS]
Measure=String
String=#Status#
UpdateDivider=-1
RegExpSubstitute=1
Substitute="^$":"S0=0","^.*?S(\d+)=0.*$":"[\x200B]\1[\x200B]","#Cleaner#","^$":"#MaxNext#"
DynamicVariables=1

[Next]
Measure=Calc
Formula=[NextS]
UpdateDivider=-1
DynamicVariables=1

---Styles---

[Hex]
Group=SGroup
Hidden=1
Shape=Path HexPath | StrokeWidth #Width# | StrokeColor 255,0,0,255
HexPath=(#Radius#+#Width#/2+#Radius#*Cos(Rad(#StartAngle#+0))),(#Radius#+#Width#/2+#Radius#*Sin(Rad(#StartAngle#+0))) | LineTo (#Radius#+#Width#/2+#Radius#*Cos(Rad(#StartAngle#+60))),(#Radius#+#Width#/2+#Radius#*Sin(Rad(#StartAngle#+60))) | LineTo (#Radius#+#Width#/2+#Radius#*Cos(Rad(#StartAngle#+120))),(#Radius#+#Width#/2+#Radius#*Sin(Rad(#StartAngle#+120))) | LineTo (#Radius#+#Width#/2+#Radius#*Cos(Rad(#StartAngle#+180))),(#Radius#+#Width#/2+#Radius#*Sin(Rad(#StartAngle#+180))) | LineTo (#Radius#+#Width#/2+#Radius#*Cos(Rad(#StartAngle#+240))),(#Radius#+#Width#/2+#Radius#*Sin(Rad(#StartAngle#+240))) | LineTo (#Radius#+#Width#/2+#Radius#*Cos(Rad(#StartAngle#+300))),(#Radius#+#Width#/2+#Radius#*Sin(Rad(#StartAngle#+300))) | ClosePath 1
UpdateDivider=-1
OnUpdateAction=[!SetVariable Status "#Status##CURRENTSECTION#=[#CURRENTSECTION#:W],"]
LeftMouseUpAction=[!SetOption #CURRENTSECTION# Hidden 1][!SetVariable Status ""][!UpdateMeterGroup SGroup][!Redraw][!UpdateMeasure NextS][!UpdateMeasure Next][!SetVariable Next [Next:]][!UpdateMeter Background]
DynamicVariables=1

---Meters---

[Background]
Meter=Shape
Shape=Rectangle #WORKAREAX#,#WORKAREAY#,#WORKAREAWIDTH#,#WORKAREAHEIGHT# | Fill Color 255,255,255,100 | StrokeWidth 0
UpdateDivider=-1
LeftMouseUpAction=[!SetVariable Status ""][!SetOption S#Next# X (Clamp($MouseX$-#Radius#,0,[#CURRENTSECTION#:W]-#Radius#*2-#Width#))][!SetOption S#Next# Y (Clamp($MouseY$-#Radius#,0,[#CURRENTSECTION#:H]-#Radius#*2-#Width#))][!SetOption S#Next# Hidden 0][!UpdateMeterGroup SGroup][!Redraw][!UpdateMeasure NextS][!UpdateMeasure Next][!SetVariable Next [Next:]][!UpdateMeter Background]
DynamicVariables=1

[S0]
Meter=Shape
MeterStyle=Hex

[S1]
Meter=Shape
MeterStyle=Hex

[S2]
Meter=Shape
MeterStyle=Hex

[S3]
Meter=Shape
MeterStyle=Hex

[S4]
Meter=Shape
MeterStyle=Hex

[S5]
Meter=Shape
MeterStyle=Hex
For the above code, assuming you paste 300 or so [S..] and set MaxNext to that number (not that hard to do), only the positioning of the hexes in their mathematical "slots" is left to accomplish. And, like usually, it IS achievable (and you don't necessarily need loops, not that those are a problem).

I truly believe that in Rainmeter, formulas, regexes and Lua are the most powerful tools. You did a wonderful job in Lua, but in general, most folks find it easier to understand it if it's in vanilla Rainmeter, even though it might be more complicated ... simply because they feel they can tinker with the code. :confused:
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Need Help with Mouse control on Shapes.

Post by Yincognito »

KryptOnyx wrote: August 11th, 2021, 1:03 amI had thought of the problem of 'deselecting' a mid-sequence Tile and opted to simply remove the last placed Tile.
I suspect the issue has something to do with Timing and the Update cycle.
The basic process is simple and native Rainmeter should be able to handle it...
All Tiles start off-screen (-100,-100). Sequence = 0.
Click on the Canvas -> Move Tile #Sequence to XY (calculated Hex Cell coord) -> increase Sequence by 1.
Click again on Canvas -> Move Tile #Sequence (now = 1) to XY (calculated Hex Cell cord) -> increase Sequence by 1 (now = 2).
Click on Tile (doesn't matter which one) -> decrease Sequence by 1 (because Canvas Click increased it in preparation of another Tile placement), now it equals (1) the last placed Tile # -> move Tile #Sequence to -100,-100.
Click the remaining Tile -> decrease Sequence by 1 (now = 0) -> move Tile #Sequence to -100,-100.
No more Tiles, Sequence = 0, Click Canvas and we begin again.

This should apply to however many Tiles in the Stack off-screen as there is no need to track which Tile is Clicked.
Obviously there are no Range limitations or checks as they will be added when the basic process works...only it doesn't.
There are three outcomes when Canvas is Clicked... the Clicks do what is expected, or a Click is ignored (no visible Action), or the Action is 'delayed' as the Tile appears in the previous Clicked location.
I will try using Update=-1 and see if the same thing happens.
Moving hexes to -100,-100 is not absolutely required. You can simply hide them on whatever position. A hidden meter has its W and H set to 0, so it's just as identifiable or feasible for your purpose. Also, are you sure your Sequence is actually a "sequence"? What happens if you click the 3rd tile of 5 tiles to move it back to your stack? Is it the 3rd tile or the 5th tile that moves back to -100,-100? Because if it's the 5th according to you basing your approach on the #Sequence# number, then that's wrong...
KryptOnyx wrote: August 11th, 2021, 2:03 am Very strange...Variables are not changing in the Current Update cycle...
I modified the Canvas Click (untangled for easier reading) to put values into String Meters :
LeftMouseUpAction=
[!SetVariable MouseX "$MouseX$"]
[!SetVariable MouseY "$MouseY$"]
[UpdateMeasure Mouse_Cell_X]
[UpdateMeasure Mouse_Cell_Y]
[UpdateMeasure Tile_Center_X]
[UpdateMeasure Tile_Center_Y]
[!SetOption Hex_Tile_#Sequence# X [Tile_Center_X]]
[!SetOption Hex_Tile_#Sequence# Y [Tile_Center_Y]]
[!SetOption Debug_Label_0 Text "LMB X = $MouseX$ : LMB Y = $MouseY$"]
[!SetOption Debug_Label_1 Text "MouseX = #MouseX# : MouseY = #MouseY#"]
[!SetOption Debug_Label_2 Text "Cell X = [Mouse_Cell_X] : Cell Y = [Mouse_Cell_Y]"]
[!UpdateMeter *]
[!Redraw]
[!SetVariable Sequence (#Sequence#+1)]

Debug_Label_0 changes with every Mouse Click, as is expected, but Debug_Label_1 shows the PREVIOUS vales of $MouseX$ and $MouseY$ as if the MouseX and MouseY Variables are not set when the Debug_Labels are drawn.
And Mouse_Cell_X : Mouse_Cell_Y Measures are only returning 0, even with forced Update. :confused:
You need to use the nested syntax to get the CURRENT values of variables, especially when you modify them in the same option. Also, there are some quirks when trying to do it all in LeftMouseUpAction, sometimes you need to "spread" your operations so that everything can be properly updated. Not saying that's the case here, but just so you know.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Need Help with Mouse control on Shapes.

Post by death.crafter »

Yincognito wrote: August 11th, 2021, 11:49 am In terms of dynamically creating measures or meters, I agree that you can't, as in native Rainmeter you have to have them all from the start. But then sometimes, like in this case, with a suitable meter style, it's just about pressing CTRL + V as many times as desired.

Regarding the indexes, it's entirely possible to cover the "gaps" when "hiding"/"invalidating" one of the hexes, you don't need to offset meter options for that. This is built on your initial code, so it has only 6 hexes (when it reaches the 7th it just moves the 6th instead of disabling mouse action, which creates an interesting, and not that bad, effect), and you can see how if you want to hide, say, the 3rd out of 5 hexes, when clicking to show hexes again it starts from the first in the list that's hidden, i.e. the 3rd:
Even if you Ctrl+V them you have to position them yourself, doing all the required calculation for X and Y.

The OP here is looking for a settings menu that automatically creates or deletes does it. Well, not exactly looking, but the functionality is the same.

Actually I have got no idea how he wants to delete or hide them. He says he will hide any shape regardless of their index but still decrease the current index, leaving a index gap in between. This creates a hole in the logic.

Also, if he just wants to move it to place, he can do that by using the lua formula I use to get the X and Y, and then !SetOption ofc. That would be smooth but due to the logic hole explained above, which also you(Yincognito) mentioned earlier, it wouldn't work as expected.
from the Realm of Death
My Current Desktop
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Need Help with Mouse control on Shapes.

Post by Yincognito »

death.crafter wrote: August 11th, 2021, 12:10 pmEven if you Ctrl+V them you have to position them yourself, doing all the required calculation for X and Y.
I guess those kind of calculations are unavoidable, I mean even in Lua you do some of them, although the loop helps in avoiding the rest.
death.crafter wrote: August 11th, 2021, 12:10 pmThe OP here is looking for a settings menu that automatically creates or deletes does it. Well, not exactly looking, but the functionality is the same.
He might be looking for it indeed, he just doesn't know it yet, since he also starts with all the "tiles"/"hexes" already built (he just moves them into place on empty space click, moves them back on "tile"/"hex" click). :confused:
death.crafter wrote: August 11th, 2021, 12:10 pmActually I have got no idea how he wants to delete or hide them. He says he will hide any shape regardless of their index but still decrease the current index, leaving a index gap in between. This creates a hole in the logic.

Also, if he just wants to move it to place, he can do that by using the lua formula I use to get the X and Y, and then !SetOption ofc. That would be smooth but due to the logic hole explained above, which also you(Yincognito) mentioned earlier, it wouldn't work as expected.
Precisely. He seems set on a approach based on #Sequence# despite repeated warnings that it won't always work, and probably doesn't realize the logical flaw in doing things that way. I guess he always wants to know the number of "active" hexes, that's the only reason I can think of for persisting with that approach - but then, you can count them without using the count to hide/show them anyway.
User avatar
Yincognito
Rainmeter Sage
Posts: 4071
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Need Help with Mouse control on Shapes.

Post by Yincognito »

The later, the better: native Rainmeter approach to make a hexagonal lattice...

Code: Select all

[Variables]
Cleaner="(?:^[^[\x200B]].*|.*[^[\x200B]]$)":"","(?:^[\x200B]|[\x200B]$)":"","(?:^\\\d+|\\\d+$)":""
Status=
Next=0
RoundingRatio=1.1
Radius=30
Stroke=3
Gap=6
Angle=0
SlotW=(#Radius#*1.5+#Stroke#+#Gap#)
SlotH=(#Radius#*Sqrt(3)+#Stroke#+#Gap#)
SlotX="((#Gap#/2+#Stroke#/2+#Radius#-#SlotW#/2)+Trunc(([$*MouseX*]-(#Gap#/2+#Stroke#/2+#Radius#-#SlotW#/2))/#SlotW#)*#SlotW#)"
SlotY="((#SlotH#/2*((Trunc(([$*MouseX*]-(#Gap#/2+#Stroke#/2+#Radius#-#SlotW#/2))/#SlotW#))%2))+Trunc(([$*MouseY*]-(#SlotH#/2*((Trunc(([$*MouseX*]-(#Gap#/2+#Stroke#/2+#Radius#-#SlotW#/2))/#SlotW#))%2)))/#SlotH#)*#SlotH#)"
MaxNext=99
FontSize=10
FontColor=0,0,0,255
HexaStrokeColor=255,0,0,255
SlotStrokeColor=255,255,0,255
NearTransparentColor=0,0,0,1
BackgroundColor=255,0,255,100

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
OnRefreshAction=[!AutoSelectScreen "1" "#CURRENTCONFIG#"]

---Measures---

[Next]
Measure=String
String=#Status#
UpdateDivider=-1
RegExpSubstitute=1
Substitute="^$":"S0=0","^.*?S(\d+)=0.*$":"[\x200B]\1[\x200B]","#Cleaner#","^$":"#MaxNext#"
DynamicVariables=1

---Styles---

[Hex]
Group=SGroup
Hidden=1
Shape=Path HexaPath | StrokeWidth #Stroke# | StrokeColor #HexaStrokeColor#
HexaPath=(#SlotW#/2+#Radius#*Cos(Rad(#Angle#+0))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+0))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+60))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+60))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+120))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+120))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+180))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+180))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+240))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+240))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+300))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+300))) | ClosePath 1
Shape2=Path PaddingPath | StrokeWidth 0 | StrokeColor 0,0,0,0 | Fill Color #NearTransparentColor#
PaddingPath=(#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+0))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+0))) | LineTo (#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+60))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+60))) | LineTo (#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+120))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+120))) | LineTo (#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+180))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+180))) | LineTo (#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+240))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+240))) | LineTo (#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+300))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+300))) | ClosePath 1
;Shape3=Rectangle 0,0,#SlotW#,#SlotH# | StrokeWidth #Stroke# | StrokeColor #SlotStrokeColor# | Fill Color 0,0,0,0
UpdateDivider=-1
OnUpdateAction=[!SetVariable Status "#Status##CURRENTSECTION#=[#CURRENTSECTION#:W],"]
LeftMouseUpAction=[!SetOption #CURRENTSECTION# Hidden 1][!SetOption #CURRENTSECTION#T Hidden 1][!SetVariable Status ""][!UpdateMeterGroup SGroup][!Redraw][!UpdateMeasure Next][!UpdateMeter Background]
DynamicVariables=1

[Text]
Group=SGroup
Hidden=1
FontFace=Tahoma
FontWeight=700
FontSize=#FontSize#
FontColor=#FontColor#
StringAlign=CenterCenter
UpdateDivider=-1
DynamicVariables=1

---Meters---

[Background]
Meter=Shape
Shape=Rectangle #WORKAREAX#,#WORKAREAY#,#WORKAREAWIDTH#,#WORKAREAHEIGHT# | Fill Color #BackgroundColor# | StrokeWidth 0
UpdateDivider=-1
LeftMouseUpAction=[!SetVariable Status ""][!SetOption S[Next] X #SlotX#][!SetOption S[Next] Y #SlotY#][!SetOption S[Next] Hidden (((#SlotX#+#SlotW#+#Radius#*0.25>[Background:W])||(#SlotY#+#SlotH#>[Background:H]))?1:0)][!SetOption S[Next]T X (#SlotX#+#SlotW#/2)][!SetOption S[Next]T Y (#SlotY#+#SlotH#/2)][!SetOption S[Next]T Text "[Next]"][!SetOption S[Next]T Hidden (((#SlotX#+#SlotW#+#Radius#*0.25>[Background:W])||(#SlotY#+#SlotH#>[Background:H]))?1:0)][!UpdateMeterGroup SGroup][!Redraw][!UpdateMeasure Next][!UpdateMeter Background]
MiddleMouseUpAction=[!SetVariable Status ""][!SetOptionGroup SGroup Hidden 1][!UpdateMeterGroup SGroup][!Redraw][!UpdateMeasure Next][!UpdateMeter Background]
DynamicVariables=1

[S0]
Meter=Shape
MeterStyle=Hex

[S0T]
Meter=String
MeterStyle=Text

[S1]
Meter=Shape
MeterStyle=Hex

[S1T]
Meter=String
MeterStyle=Text

[S2]
Meter=Shape
MeterStyle=Hex

[S2T]
Meter=String
MeterStyle=Text

[S3]
Meter=Shape
MeterStyle=Hex

[S3T]
Meter=String
MeterStyle=Text

[S4]
Meter=Shape
MeterStyle=Hex

[S4T]
Meter=String
MeterStyle=Text

[S5]
Meter=Shape
MeterStyle=Hex

[S5T]
Meter=String
MeterStyle=Text

[S6]
Meter=Shape
MeterStyle=Hex

[S6T]
Meter=String
MeterStyle=Text

[S7]
Meter=Shape
MeterStyle=Hex

[S7T]
Meter=String
MeterStyle=Text

[S8]
Meter=Shape
MeterStyle=Hex

[S8T]
Meter=String
MeterStyle=Text

[S9]
Meter=Shape
MeterStyle=Hex

[S9T]
Meter=String
MeterStyle=Text

[S10]
Meter=Shape
MeterStyle=Hex

[S10T]
Meter=String
MeterStyle=Text

[S11]
Meter=Shape
MeterStyle=Hex

[S11T]
Meter=String
MeterStyle=Text

[S12]
Meter=Shape
MeterStyle=Hex

[S12T]
Meter=String
MeterStyle=Text

[S13]
Meter=Shape
MeterStyle=Hex

[S13T]
Meter=String
MeterStyle=Text

[S14]
Meter=Shape
MeterStyle=Hex

[S14T]
Meter=String
MeterStyle=Text

[S15]
Meter=Shape
MeterStyle=Hex

[S15T]
Meter=String
MeterStyle=Text

[S16]
Meter=Shape
MeterStyle=Hex

[S16T]
Meter=String
MeterStyle=Text

[S17]
Meter=Shape
MeterStyle=Hex

[S17T]
Meter=String
MeterStyle=Text

[S18]
Meter=Shape
MeterStyle=Hex

[S18T]
Meter=String
MeterStyle=Text

[S19]
Meter=Shape
MeterStyle=Hex

[S19T]
Meter=String
MeterStyle=Text

[S20]
Meter=Shape
MeterStyle=Hex

[S20T]
Meter=String
MeterStyle=Text

[S21]
Meter=Shape
MeterStyle=Hex

[S21T]
Meter=String
MeterStyle=Text

[S22]
Meter=Shape
MeterStyle=Hex

[S22T]
Meter=String
MeterStyle=Text

[S23]
Meter=Shape
MeterStyle=Hex

[S23T]
Meter=String
MeterStyle=Text

[S24]
Meter=Shape
MeterStyle=Hex

[S24T]
Meter=String
MeterStyle=Text

[S25]
Meter=Shape
MeterStyle=Hex

[S25T]
Meter=String
MeterStyle=Text

[S26]
Meter=Shape
MeterStyle=Hex

[S26T]
Meter=String
MeterStyle=Text

[S27]
Meter=Shape
MeterStyle=Hex

[S27T]
Meter=String
MeterStyle=Text

[S28]
Meter=Shape
MeterStyle=Hex

[S28T]
Meter=String
MeterStyle=Text

[S29]
Meter=Shape
MeterStyle=Hex

[S29T]
Meter=String
MeterStyle=Text

[S30]
Meter=Shape
MeterStyle=Hex

[S30T]
Meter=String
MeterStyle=Text

[S31]
Meter=Shape
MeterStyle=Hex

[S31T]
Meter=String
MeterStyle=Text

[S32]
Meter=Shape
MeterStyle=Hex

[S32T]
Meter=String
MeterStyle=Text

[S33]
Meter=Shape
MeterStyle=Hex

[S33T]
Meter=String
MeterStyle=Text

[S34]
Meter=Shape
MeterStyle=Hex

[S34T]
Meter=String
MeterStyle=Text

[S35]
Meter=Shape
MeterStyle=Hex

[S35T]
Meter=String
MeterStyle=Text

[S36]
Meter=Shape
MeterStyle=Hex

[S36T]
Meter=String
MeterStyle=Text

[S37]
Meter=Shape
MeterStyle=Hex

[S37T]
Meter=String
MeterStyle=Text

[S38]
Meter=Shape
MeterStyle=Hex

[S38T]
Meter=String
MeterStyle=Text

[S39]
Meter=Shape
MeterStyle=Hex

[S39T]
Meter=String
MeterStyle=Text

[S40]
Meter=Shape
MeterStyle=Hex

[S40T]
Meter=String
MeterStyle=Text

[S41]
Meter=Shape
MeterStyle=Hex

[S41T]
Meter=String
MeterStyle=Text

[S42]
Meter=Shape
MeterStyle=Hex

[S42T]
Meter=String
MeterStyle=Text

[S43]
Meter=Shape
MeterStyle=Hex

[S43T]
Meter=String
MeterStyle=Text

[S44]
Meter=Shape
MeterStyle=Hex

[S44T]
Meter=String
MeterStyle=Text

[S45]
Meter=Shape
MeterStyle=Hex

[S45T]
Meter=String
MeterStyle=Text

[S46]
Meter=Shape
MeterStyle=Hex

[S46T]
Meter=String
MeterStyle=Text

[S47]
Meter=Shape
MeterStyle=Hex

[S47T]
Meter=String
MeterStyle=Text

[S48]
Meter=Shape
MeterStyle=Hex

[S48T]
Meter=String
MeterStyle=Text

[S49]
Meter=Shape
MeterStyle=Hex

[S49T]
Meter=String
MeterStyle=Text

[S50]
Meter=Shape
MeterStyle=Hex

[S50T]
Meter=String
MeterStyle=Text

[S51]
Meter=Shape
MeterStyle=Hex

[S51T]
Meter=String
MeterStyle=Text

[S52]
Meter=Shape
MeterStyle=Hex

[S52T]
Meter=String
MeterStyle=Text

[S53]
Meter=Shape
MeterStyle=Hex

[S53T]
Meter=String
MeterStyle=Text

[S54]
Meter=Shape
MeterStyle=Hex

[S54T]
Meter=String
MeterStyle=Text

[S55]
Meter=Shape
MeterStyle=Hex

[S55T]
Meter=String
MeterStyle=Text

[S56]
Meter=Shape
MeterStyle=Hex

[S56T]
Meter=String
MeterStyle=Text

[S57]
Meter=Shape
MeterStyle=Hex

[S57T]
Meter=String
MeterStyle=Text

[S58]
Meter=Shape
MeterStyle=Hex

[S58T]
Meter=String
MeterStyle=Text

[S59]
Meter=Shape
MeterStyle=Hex

[S59T]
Meter=String
MeterStyle=Text

[S60]
Meter=Shape
MeterStyle=Hex

[S60T]
Meter=String
MeterStyle=Text

[S61]
Meter=Shape
MeterStyle=Hex

[S61T]
Meter=String
MeterStyle=Text

[S62]
Meter=Shape
MeterStyle=Hex

[S62T]
Meter=String
MeterStyle=Text

[S63]
Meter=Shape
MeterStyle=Hex

[S63T]
Meter=String
MeterStyle=Text

[S64]
Meter=Shape
MeterStyle=Hex

[S64T]
Meter=String
MeterStyle=Text

[S65]
Meter=Shape
MeterStyle=Hex

[S65T]
Meter=String
MeterStyle=Text

[S66]
Meter=Shape
MeterStyle=Hex

[S66T]
Meter=String
MeterStyle=Text

[S67]
Meter=Shape
MeterStyle=Hex

[S67T]
Meter=String
MeterStyle=Text

[S68]
Meter=Shape
MeterStyle=Hex

[S68T]
Meter=String
MeterStyle=Text

[S69]
Meter=Shape
MeterStyle=Hex

[S69T]
Meter=String
MeterStyle=Text

[S70]
Meter=Shape
MeterStyle=Hex

[S70T]
Meter=String
MeterStyle=Text

[S71]
Meter=Shape
MeterStyle=Hex

[S71T]
Meter=String
MeterStyle=Text

[S72]
Meter=Shape
MeterStyle=Hex

[S72T]
Meter=String
MeterStyle=Text

[S73]
Meter=Shape
MeterStyle=Hex

[S73T]
Meter=String
MeterStyle=Text

[S74]
Meter=Shape
MeterStyle=Hex

[S74T]
Meter=String
MeterStyle=Text

[S75]
Meter=Shape
MeterStyle=Hex

[S75T]
Meter=String
MeterStyle=Text

[S76]
Meter=Shape
MeterStyle=Hex

[S76T]
Meter=String
MeterStyle=Text

[S77]
Meter=Shape
MeterStyle=Hex

[S77T]
Meter=String
MeterStyle=Text

[S78]
Meter=Shape
MeterStyle=Hex

[S78T]
Meter=String
MeterStyle=Text

[S79]
Meter=Shape
MeterStyle=Hex

[S79T]
Meter=String
MeterStyle=Text

[S80]
Meter=Shape
MeterStyle=Hex

[S80T]
Meter=String
MeterStyle=Text

[S81]
Meter=Shape
MeterStyle=Hex

[S81T]
Meter=String
MeterStyle=Text

[S82]
Meter=Shape
MeterStyle=Hex

[S82T]
Meter=String
MeterStyle=Text

[S83]
Meter=Shape
MeterStyle=Hex

[S83T]
Meter=String
MeterStyle=Text

[S84]
Meter=Shape
MeterStyle=Hex

[S84T]
Meter=String
MeterStyle=Text

[S85]
Meter=Shape
MeterStyle=Hex

[S85T]
Meter=String
MeterStyle=Text

[S86]
Meter=Shape
MeterStyle=Hex

[S86T]
Meter=String
MeterStyle=Text

[S87]
Meter=Shape
MeterStyle=Hex

[S87T]
Meter=String
MeterStyle=Text

[S88]
Meter=Shape
MeterStyle=Hex

[S88T]
Meter=String
MeterStyle=Text

[S89]
Meter=Shape
MeterStyle=Hex

[S89T]
Meter=String
MeterStyle=Text

[S90]
Meter=Shape
MeterStyle=Hex

[S90T]
Meter=String
MeterStyle=Text

[S91]
Meter=Shape
MeterStyle=Hex

[S91T]
Meter=String
MeterStyle=Text

[S92]
Meter=Shape
MeterStyle=Hex

[S92T]
Meter=String
MeterStyle=Text

[S93]
Meter=Shape
MeterStyle=Hex

[S93T]
Meter=String
MeterStyle=Text

[S94]
Meter=Shape
MeterStyle=Hex

[S94T]
Meter=String
MeterStyle=Text

[S95]
Meter=Shape
MeterStyle=Hex

[S95T]
Meter=String
MeterStyle=Text

[S96]
Meter=Shape
MeterStyle=Hex

[S96T]
Meter=String
MeterStyle=Text

[S97]
Meter=Shape
MeterStyle=Hex

[S97T]
Meter=String
MeterStyle=Text

[S98]
Meter=Shape
MeterStyle=Hex

[S98T]
Meter=String
MeterStyle=Text

[S99]
Meter=Shape
MeterStyle=Hex

[S99T]
Meter=String
MeterStyle=Text
HexaLattice.jpg
Apart from one measure, two styles and one meter (plus the variables), the rest is just copy paste, for convenience (100 hexes included, thanks to some replacing in selection in Notepad++). The formulas are much shorter than the classical version, via breaking them into pieces stored in [Variables]. The "slots" for the hexes (i.e. the areas that show them on click, as opposed to their opaque pixels used in the hiding process) are described by the related variables in [Variables] and are visible if uncommenting the Shape3=... line from the Hex style. A string (i.e. Status) and some regex substitutions in [Next] store the hidden status of all the hexes, and the hex to be shown next, respectively, based on the 1st hidden hex. A "padding" (i.e. Shape2=... from the Hex style) and some rounding error procedure described by the RoundingRatio variable are used to correct unwanted effects like placing a hex on top of another hex when clicking in the space between them, as well as diagonal padding requiring further adjustment compared to the axis one. Left click on open space places/shows the hex, left click on a hex hides it, and middle click anywhere on the background hides/clears all the hexes, for convenience.

In the end, this turned out to be easier and more compact than expected, although it took some time to make it work and refine. Now the OP has all kinds of variants to choose from, or he can continue trying to place the hexes in a "sequence". :???:

P.S. I guess this could be adjusted to place hexes at -100,-100 if really really needed (although it would be a bit problematic when setting the position, as I use the hidden state as a "validator" of some sort as well, to make preventing placing a hex outside the background meter easier), but I very much doubt something will be gained out of it, since hiding stuff means more or less the same as the meter dimensions become 0 at that point. Also, this would probably work for a hex starting angle of 90 or 270 degrees if the proper X/Y/W/H related stuff are swapped between them - I didn't bother with that though as it didn't seem particularly important.
You do not have the required permissions to view the files attached to this post.
User avatar
death.crafter
Posts: 1070
Joined: April 24th, 2021, 8:13 pm

Re: Need Help with Mouse control on Shapes.

Post by death.crafter »

Yincognito wrote: August 12th, 2021, 1:06 am The later, the better: native Rainmeter approach to make a hexagonal lattice...

P.S. I guess this could be adjusted to place hexes at -100,-100 if really really needed (although it would be a bit problematic when setting the position, as I use the hidden state as a "validator" of some sort as well, to make preventing placing a hex outside the background meter easier), but I very much doubt something will be gained out of it, since hiding stuff means more or less the same as the meter dimensions become 0 at that point. Also, this would probably work for a hex starting angle of 90 or 270 degrees if the proper X/Y/W/H related stuff are swapped between them - I didn't bother with that though as it didn't seem particularly important.
Now that's Yincognito for you.
Yincognito wrote: August 12th, 2021, 1:06 am

Code: Select all

[Hex]
Group=SGroup
Hidden=1
Shape=Path HexaPath | StrokeWidth #Stroke# | StrokeColor #HexaStrokeColor#
HexaPath=(#SlotW#/2+#Radius#*Cos(Rad(#Angle#+0))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+0))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+60))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+60))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+120))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+120))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+180))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+180))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+240))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+240))) | LineTo (#SlotW#/2+#Radius#*Cos(Rad(#Angle#+300))),(#SlotH#/2+#Radius#*Sin(Rad(#Angle#+300))) | ClosePath 1
Shape2=Path PaddingPath | StrokeWidth 0 | StrokeColor 0,0,0,0 | Fill Color #NearTransparentColor#
PaddingPath=(#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+0))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+0))) | LineTo (#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+60))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+60))) | LineTo (#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+120))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+120))) | LineTo (#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+180))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+180))) | LineTo (#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+240))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+240))) | LineTo (#SlotW#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Cos(Rad(#Angle#+300))),(#SlotH#/2+(#Radius#+#Stroke#/2+#Gap#/2)*#RoundingRatio#*Sin(Rad(#Angle#+300))) | ClosePath 1
;Shape3=Rectangle 0,0,#SlotW#,#SlotH# | StrokeWidth #Stroke# | StrokeColor #SlotStrokeColor# | Fill Color 0,0,0,0
UpdateDivider=-1
OnUpdateAction=[!SetVariable Status "#Status##CURRENTSECTION#=[#CURRENTSECTION#:W],"]
LeftMouseUpAction=[!SetOption #CURRENTSECTION# Hidden 1][!SetOption #CURRENTSECTION#T Hidden 1][!SetVariable Status ""][!UpdateMeterGroup SGroup][!Redraw][!UpdateMeasure Next][!UpdateMeter Background]
DynamicVariables=1
[code]
[/quote]

But the shapes will probably contain images, so I wonder if including the padding was a good choice :???:
from the Realm of Death
My Current Desktop