.
That works well for the structure of the windows, tabs, controls, but it leaves open the control system.
In my case things go up and down the chain. For example, the context menu can hide all the panels / buttons attached to it, but panels not attached are only hidden by some of the buttons, and some buttons hide everything including themselves regardless of whether or not the panel they are on is attached to the menu.
Some of the controls change the current tab. Some of the controls move the windows and panels.
Some of the buttons launch separate Overlays with there own programing that only exist while the button is pressed.
Second question. This one isn't that important but insights might be useful.
Looking at the code I will be adding below you will see that much of that construction has loops written all over it. The question is what is a good way to organize and collect the data that is used to populate the different panels and buttons?
Much of that is handled by the tab and button classes as defaults, but there are usually a large number of unique values that can't be defaulted and sometimes requires reading from a file or getting info from other sources. The place I can see as the clear dividing line is at the panel level. Panels act largely as independent windows that just happen to sometimes sit inside a tab in a menu. While the panels in this case are all roughly the same with mainly the number of buttons they have as the thing that separates them and the sub-routines they launch. Other panels have very different control layouts and may or may not detach from the menu.
I have setup the example code with most of the elements I am using except for the windows launched by the buttons ( I'll add them in later)
can be set to 1 or 2 manually but needs a system for the buttons to trigger the change.
If you have any comments on the example and the way I set it up please let me know.
Code: Select all
#SingleInstance, Force
return
GuiClose:
GuiContextMenu:
*ESC::ExitApp
class Main {
static init := Main._SetUp()
_Setup(){
local x
This.HiddenState := 0
This.Selected := {}
This.Selected.Tab := 2
This.Selected.Panel := 1
This.Selected.Button := 1
This.Index := 0
This.ContextMenu := New ContextMenuClass( ++This.Index , A_ScreenWidth - 600 , 100 , 550 , 500 )
This.ContextMenu.Tabs := []
This.ContextMenu.Buttons := []
;&&&&&&&&&&&&
;Buttons
x := 60
Loop, 4
This.ContextMenu.Buttons[ A_Index ] := New ButtonsClass( This.ContextMenu , ++This.Index , x += 45 , 5 , 30 , 30 , "42464a" , Method := "_SwitchTabs" )
;~ This.ContextMenu.Buttons[ 5 ] := { X: "" , Y: "" , W: "" , H: "" , Method: "_MoveContextMenu" }
;~ This.ContextMenu.Buttons[ 6 ] := { X: "" , Y: "" , W: "" , H: "" , Method: "_LaunchAll" }
;~ This.ContextMenu.Buttons[ 7 ] := { X: "" , Y: "" , W: "" , H: "" , Method: "_ReAttachAll" }
;***************************************************************************************************
;Tab 1
This.ContextMenu.Tabs[ 1 ] := New TabsClass( This.ContextMenu , ++This.Index , 50 , 50 , 450 , 400 )
This.ContextMenu.Tabs[ 1 ].Panels := []
;########################### ;Tab 1
;Panel 1
This.ContextMenu.Tabs[ 1 ].Panels[ 1 ] := New PanelsClass( This.ContextMenu.Tabs[ 1 ] , ++This.Index , 10 , 10 , 430 , 50 )
This.ContextMenu.Tabs[ 1 ].Panels[ 1 ].Buttons := []
;&&&&&&&&&&&& ;Tab 1 , Panel 1
;Buttons
x := 60
Loop, 6
This.ContextMenu.Tabs[ 1 ].Panels[ 1 ].Buttons[ A_Index ] := New ButtonsClass( This.ContextMenu.Tabs[ 1 ].Panels[ 1 ] , ++This.Index , x += 45 , 5 , 40 , 40 )
This.ContextMenu.Tabs[ 1 ].Panels[ 1 ].Buttons[ 7 ] := New ButtonsClass( This.ContextMenu.Tabs[ 1 ].Panels[ 1 ] , ++This.Index , This.ContextMenu.Tabs[ 1 ].Panels[ 1 ].W - 45 , 5 , 40 , 40 , "ff0000" )
;########################### ;Tab 1
;Panel 2
This.ContextMenu.Tabs[ 1 ].Panels[ 2 ] := New PanelsClass( This.ContextMenu.Tabs[ 1 ] , ++This.Index , 10 , 70 , 430 , 50 )
This.ContextMenu.Tabs[ 1 ].Panels[ 2 ].Buttons := []
;&&&&&&&&&&&& ;Tab 1 , Panel 2
;Buttons
x := 60
Loop, 4
This.ContextMenu.Tabs[ 1 ].Panels[ 2 ].Buttons[ A_Index ] := New ButtonsClass( This.ContextMenu.Tabs[ 1 ].Panels[ 2 ] , ++This.Index , x += 45 , 5 , 40 , 40 )
This.ContextMenu.Tabs[ 1 ].Panels[ 2 ].Buttons[ 5 ] := New ButtonsClass( This.ContextMenu.Tabs[ 1 ].Panels[ 2 ] , ++This.Index , This.ContextMenu.Tabs[ 1 ].Panels[ 2 ].W - 45 , 5 , 40 , 40 , "ff0000" )
;########################### ;Tab 1
;Panel 3
This.ContextMenu.Tabs[ 1 ].Panels[ 3 ] := New PanelsClass( This.ContextMenu.Tabs[ 1 ] , ++This.Index , 10 , 130 , 430 , 50 )
This.ContextMenu.Tabs[ 1 ].Panels[ 3 ].Buttons := []
;&&&&&&&&&&&& ;Tab 1 , Panel 3
;Buttons
x := 60
Loop, 3
This.ContextMenu.Tabs[ 1 ].Panels[ 3 ].Buttons[ A_Index ] := New ButtonsClass( This.ContextMenu.Tabs[ 1 ].Panels[ 3 ] , ++This.Index , x += 45 , 5 , 40 , 40 )
This.ContextMenu.Tabs[ 1 ].Panels[ 3 ].Buttons[ 4 ] := New ButtonsClass( This.ContextMenu.Tabs[ 1 ].Panels[ 3 ] , ++This.Index , This.ContextMenu.Tabs[ 1 ].Panels[ 3 ].W - 45 , 5 , 40 , 40 , "ff0000" )
;***************************************************************************************************
;Tab 2
This.ContextMenu.Tabs[ 2 ] := New TabsClass( This.ContextMenu , ++This.Index , 50 , 50 , 450 , 400 )
This.ContextMenu.Tabs[ 2 ].Panels := []
;########################### ;Tab 2
;Panel 1
This.ContextMenu.Tabs[ 2 ].Panels[ 1 ] := New PanelsClass( This.ContextMenu.Tabs[ 2 ] , ++This.Index , 10 , 10 , 430 , 50 )
This.ContextMenu.Tabs[ 2 ].Panels[ 1 ].Buttons := []
;&&&&&&&&&&&& ;Tab 2 , Panel 1
;Buttons
x := 60
Loop, 4
This.ContextMenu.Tabs[ 2 ].Panels[ 1 ].Buttons[ A_Index ] := New ButtonsClass( This.ContextMenu.Tabs[ 2 ].Panels[ 1 ] , ++This.Index , x += 45 , 5 , 40 , 40 )
This.ContextMenu.Tabs[ 2 ].Panels[ 1 ].Buttons[ 7 ] := New ButtonsClass( This.ContextMenu.Tabs[ 2 ].Panels[ 1 ] , ++This.Index , This.ContextMenu.Tabs[ 2 ].Panels[ 1 ].W - 45 , 5 , 40 , 40 , "ff0000" )
;########################### ;Tab 2
;Panel 2
This.ContextMenu.Tabs[ 2 ].Panels[ 2 ] := New PanelsClass( This.ContextMenu.Tabs[ 2 ] , ++This.Index , 10 , 70 , 430 , 50 )
This.ContextMenu.Tabs[ 2 ].Panels[ 2 ].Buttons := []
;&&&&&&&&&&&& ;Tab 2 , Panel 2
;Buttons
x := 60
Loop, 6
This.ContextMenu.Tabs[ 2 ].Panels[ 2 ].Buttons[ A_Index ] := New ButtonsClass( This.ContextMenu.Tabs[ 2 ].Panels[ 2 ] , ++This.Index , x += 45 , 5 , 40 , 40 )
This.ContextMenu.Tabs[ 2 ].Panels[ 2 ].Buttons[ 5 ] := New ButtonsClass( This.ContextMenu.Tabs[ 2 ].Panels[ 2 ] , ++This.Index , This.ContextMenu.Tabs[ 2 ].Panels[ 2 ].W - 45 , 5 , 40 , 40 , "ff0000" )
;########################### ;Tab 2
;Panel 3
This.ContextMenu.Tabs[ 2 ].Panels[ 3 ] := New PanelsClass( This.ContextMenu.Tabs[ 2 ] , ++This.Index , 10 , 130 , 430 , 50 )
This.ContextMenu.Tabs[ 2 ].Panels[ 3 ].Buttons := []
;&&&&&&&&&&&& ;Tab 2 , Panel 3
;Buttons
x := 60
Loop, 5
This.ContextMenu.Tabs[ 2 ].Panels[ 3 ].Buttons[ A_Index ] := New ButtonsClass( This.ContextMenu.Tabs[ 2 ].Panels[ 3 ] , ++This.Index , x += 45 , 5 , 40 , 40 )
This.ContextMenu.Tabs[ 2 ].Panels[ 3 ].Buttons[ 4 ] := New ButtonsClass( This.ContextMenu.Tabs[ 2 ].Panels[ 3 ] , ++This.Index , This.ContextMenu.Tabs[ 2 ].Panels[ 3 ].W - 45 , 5 , 40 , 40 , "ff0000" )
;########################### ;Tab 2
;Panel 4
This.ContextMenu.Tabs[ 2 ].Panels[ 4 ] := New PanelsClass( This.ContextMenu.Tabs[ 2 ] , ++This.Index , 10 , 190 , 430 , 50 )
This.ContextMenu.Tabs[ 2 ].Panels[ 4 ].Buttons := []
;&&&&&&&&&&&& ;Tab 2 , Panel 3
;Buttons
x := 60
Loop, 6
This.ContextMenu.Tabs[ 2 ].Panels[ 4 ].Buttons[ A_Index ] := New ButtonsClass( This.ContextMenu.Tabs[ 2 ].Panels[ 4 ] , ++This.Index , x += 45 , 5 , 40 , 40 )
This.ContextMenu.Tabs[ 2 ].Panels[ 4 ].Buttons[ 7 ] := New ButtonsClass( This.ContextMenu.Tabs[ 2 ].Panels[ 4 ] , ++This.Index , This.ContextMenu.Tabs[ 2 ].Panels[ 4 ].W - 45 , 5 , 40 , 40 , "ff0000" )
This.ContextMenu.Draw()
}
}
class ContextMenuClass {
Children := []
__New( Index , X , Y , W , H ){
Gui, New, +AlwaysOnTop +HwndHwnd
This.Hwnd := hwnd
This.Index := Index
This.X := X
This.Y := Y
This.W := W
This.H := H
}
Draw(){
Gui, % This.Hwnd ":Show", % "x" This.x " y" This.y " w" This.w " h" This.h " NA" , % "ContextMenu"
for k , v in This.Children {
if( Main.Selected.Tab = k - 4 || k < 5 )
This.Children[ k ].Draw()
}
}
}
class TabsClass {
Children := []
__New( Parent , Index , X , Y , W , H ){
This.Parent := Parent
Gui, New, % " +AlwaysOnTop +HwndHwnd -Caption +Parent" This.Parent.Hwnd
Gui, Color, 22262a
This.Hwnd := hwnd
This.Index := Index
This.X := X
This.Y := Y
This.W := W
This.H := H
This.Parent.Children.Push( This )
}
Draw(){
local k , v
Gui, % This.Hwnd ":Show", % "x" This.x " y" This.y " w" This.w " h" This.h " NA"
for k , v in This.Children
This.Children[ k ].Draw()
}
}
class PanelsClass {
Children := []
__New( Parent , Index , X , Y , W , H ){
This.Parent := Parent
Gui, New, % " +AlwaysOnTop +HwndHwnd -Caption +Parent" This.Parent.Hwnd
Gui, Color, 00ff00
This.Hwnd := hwnd
This.Index := Index
This.X := X
This.Y := Y
This.W := W
This.H := H
This.Parent.Children.Push( This )
}
Draw(){
Gui, % This.Hwnd ":Show", % "x" This.x " y" This.y " w" This.w " h" This.h " NA"
for k , v in This.Children
This.Children[ k ].Draw()
}
}
class ButtonsClass {
;~ Children := [] ? Spawns the new sub-windows
__New( Parent , Index , X , Y , W , H , Color := "FF00FF" , Method := "_SwitchTabs" ){
This.Parent := Parent
Gui, New, % " +AlwaysOnTop +HwndHwnd -Caption +Parent" This.Parent.Hwnd
Gui, Color, % Color
This.Hwnd := hwnd
This.Index := Index
This.Method := Method
This.X := X
This.Y := Y
This.W := W
This.H := H
This.Parent.Children.Push( This )
}
Draw(){
Gui, % This.Hwnd ":Show", % "x" This.x " y" This.y " w" This.w " h" This.h " NA"
}
}
I would say that I am decent at understanding code, so any examples don't need to be too elaborate or complete. Just something that gets the basic point across and perhaps a more technical example here and there.
Thanks again.