diff --git a/Docs/ConfigurationDialog.png b/Docs/ConfigurationDialog.png deleted file mode 100644 index be67c7f..0000000 Binary files a/Docs/ConfigurationDialog.png and /dev/null differ diff --git a/Docs/ConfigurationDialog1.png b/Docs/ConfigurationDialog1.png new file mode 100644 index 0000000..2d8759e Binary files /dev/null and b/Docs/ConfigurationDialog1.png differ diff --git a/Docs/ConfigurationDialog2.png b/Docs/ConfigurationDialog2.png new file mode 100644 index 0000000..74dbcde Binary files /dev/null and b/Docs/ConfigurationDialog2.png differ diff --git a/Docs/ConfigurationDialog3.png b/Docs/ConfigurationDialog3.png new file mode 100644 index 0000000..1ad1644 Binary files /dev/null and b/Docs/ConfigurationDialog3.png differ diff --git a/Docs/ConfigurationDialog4.png b/Docs/ConfigurationDialog4.png new file mode 100644 index 0000000..6585a9f Binary files /dev/null and b/Docs/ConfigurationDialog4.png differ diff --git a/Docs/releasenotes.md b/Docs/releasenotes.md index 14c40ed..ca94104 100644 --- a/Docs/releasenotes.md +++ b/Docs/releasenotes.md @@ -1,5 +1,10 @@ # Release Notes +## v1.6.2 - 2020-01-05 + +- Redesigned Configuration dialog to tabbed dialog +- Reformatted user options data file to have values in appropriate sections + ## v1.6.1 - 2020-01-04 - Fixed issue with Restore Window Positions which would position Windows Settings screen when it wasn't visible before diff --git a/Docs/todo.md b/Docs/todo.md index f7b6ba2..99fc2fb 100644 --- a/Docs/todo.md +++ b/Docs/todo.md @@ -3,7 +3,6 @@ - History list of Saved Window Positions - History list of Saved Desktop Icon Positions - Add icons to other context menu items -- Convert Configuration dialog to use Tabbed controls - Auto-Save Window Positions on a schedule - Auto-Save Desktop Icons on a schedule diff --git a/GuiSpike.ahk b/GuiSpike.ahk new file mode 100644 index 0000000..cc5f32d --- /dev/null +++ b/GuiSpike.ahk @@ -0,0 +1,173 @@ +cascadeGutterSize := 25 +columnGutterSize := 10 +gridGutterSize := 15 +spanMonitorGutterSize := 20 +restoreDesktopIconsOnStartup := true +restoreWindowPositionsOnStartup := true +windowPositionsIncludeOffScreenWindows := false +windowPositionsFilesToKeep := 19 +desktopIconsFilesToKeep := 21 + +shit := "This.iscrap" + +crap := Instr(shit, ".") ? StrSplit(shit, ".")[2] : shit + +MsgBox,,, %crap% + + +ShowConfigGui() + +return + +BuildGui() +{ + global cascadeGutterSize + global columnGutterSize + global gridGutterSize + global spanMonitorGutterSize + global restoreDesktopIconsOnStartup + global restoreWindowPositionsOnStartup + global MenuLocationValues + global windowPositionsIncludeOffScreenWindows + global windowPositionsFilesToKeep + global desktopIconsFilesToKeep + + menuLocationItemsText := "None|Window Menu|Tray Menu|Both" + + col1 := 20 + col2 := 220 + tabHeight := 40 + rowHeight := 30 + textOffSet := 3 + + row1 := tabHeight + (rowHeight * 0) + row2 := tabHeight + (rowHeight * 1) + row3 := tabHeight + (rowHeight * 2) + row4 := tabHeight + (rowHeight * 3) + + row1t := row1 + textOffset + row2t := row2 + textOffset + row3t := row3 + textOffset + row4t := row4 + textOffset + + Gui, Config:New, -SysMenu, Configuration + Gui, Config:Margin, 5, 5 + Gui, Config:Add, Tab3, -Wrap w370 h230, General|Startup|Menu Control|Window Positions|Desktop Icons + + ; Tab 1 - General + Gui, Config:Tab, 1 + ; Row 1 + Gui, Config:Add, Text, x%col1% y%row1t%, C&ascade Gutter Size: + Gui, Config:Add, Edit, x%col2% y%row1% w80 x%col2% + Gui, Config:Add, UpDown, vcascadeGutterSize Range0-100, %cascadeGutterSize% + ; Row 2 + Gui, Config:Add, Text, x%col1% y%row2t%, C&olumn Gutter Size: + Gui, Config:Add, Edit, w80 x%col2% y%row2% + Gui, Config:Add, UpDown, vcolumnGutterSize Range0-100, %columnGutterSize% + ; Row 3 + Gui, Config:Add, Text, x%col1% y%row3t%, &Grid Gutter Size: + Gui, Config:Add, Edit, w80 x%col2% y%row3% + Gui, Config:Add, UpDown, vgridGutterSize Range0-100, %gridGutterSize% + ; Row 4 + Gui, Config:Add, Text, x%col1% y%row4t%, Span &Monitor Gutter Size: + Gui, Config:Add, Edit, w80 x%col2% y%row4% + Gui, Config:Add, UpDown, vspanMonitorGutterSize Range0-100, %spanMonitorGutterSize% + + ; Tab 2 - Startup + Gui, Config:Tab, 2 + ; Row 1 + Gui, Config:Add, Checkbox, x%col1% y%row1t% vrestoreWindowPositionsOnStartup Checked%restoreWindowPositionsOnStartup%, Restore Window &Positions on Startup + ; Row 2 + Gui, Config:Add, Checkbox, x%col1% y%row2t% vrestoreDesktopIconsOnStartup Checked%restoreDesktopIconsOnStartup%, Restore Desktop &Icons on Startup + + ; Tab 3 - Menu Control + Gui, Config:Tab, 3 + ; Row 1 + Gui, Config:Add, Text, x%col1% y%row1t%, Window &Positions Menu Location: + Gui, Config:Add, DropDownList, x%col2% y%row1% vwindowPositionsMenuLocation AltSubmit Choose%windowPositionsMenuLocationChoice%, %menuLocationItemsText% + ; Row 2 + Gui, Config:Add, Text, x%col1% y%row2t%, Desktop &Icons Menu Location: + Gui, Config:Add, DropDownList, x%col2% y%row2% vdesktopIconsMenuLocation AltSubmit Choose%desktopIconsMenuLocationChoice%, %menuLocationItemsText% + + ; Tab 4 - Window Positions + Gui, Config:Tab, 4 + ; Row 1 + Gui, Config:Add, Text, x%col1% y%row1t%, Number of saved files to &keep : + Gui, Config:Add, Edit, w80 x%col2% y%row1% + Gui, Config:Add, UpDown, vwindowPositionsFilesToKeep Range0-100, %windowPositionsFilesToKeep% + ; Row 2 + Gui, Config:Add, Checkbox, x%col1% y%row2t% vwindowPositionsIncludeOffScreenWindows Checked%windowPositionsIncludeOffScreenWindows%, Include Off-Screen Windows + + ; Tab 5 - Desktop Icons + Gui, Config:Tab, 5 + ; Row 1 + Gui, Config:Add, Text, x%col1% y%row1t%, Number of saved files to &keep : + Gui, Config:Add, Edit, w80 x%col2% y%row1% + Gui, Config:Add, UpDown, vdesktopIconsFilesToKeep Range0-100, %desktopIconsFilesToKeep% + + ; Button Bar + Gui, Config:Tab + Gui, Config:Add, Button, default x205 y240 w80, OK ; The label ButtonOK (if it exists) will be run when the button is pressed. + Gui, Config:Add, Button, x295 y240 w80, Cancel ; The label ButtonCancel (if it exists) will be run when the button is pressed. +} + +DestroyUserConfigGui() +{ + Gui, Config:Destroy +} + +ShowConfigGui() +{ + global G_UserConfig + + BuildGui() + + Gui, Config:Show +} + +ConfigGuiEscape: +{ + DestroyUserConfigGui() + ExitApp +} + +ConfigGuiClose: +{ + DestroyUserConfigGui() + ExitApp +} + +ConfigButtonCancel: +{ + DestroyUserConfigGui() + ExitApp +} + +ConfigButtonOK: +{ + global cascadeGutterSize + global columnGutterSize + global gridGutterSize + global spanMonitorGutterSize + global restoreDesktopIconsOnStartup + global restoreWindowPositionsOnStartup + global MenuLocationValues + global windowPositionsIncludeOffScreenWindows + + Gui, Config:Submit + + G_UserConfig.CascadeGutterSize := cascadeGutterSize + G_UserConfig.ColumnGutterSize := columnGutterSize + G_UserConfig.GridGutterSize := gridGutterSize + G_UserConfig.SpanMonitorGutterSize := spanMonitorGutterSize + G_UserConfig.RestoreDesktopIconsOnStartup := restoreDesktopIconsOnStartup + G_UserConfig.RestoreWindowPositionsOnStartup := restoreWindowPositionsOnStartup + G_UserConfig.DesktopIconsMenuLocation := MenuLocationValues[desktopIconsMenuLocation] + G_UserConfig.WindowPositionsMenuLocation := MenuLocationValues[windowPositionsMenuLocation] + G_UserConfig.WindowPositions_IncludeOffScreenWindows := windowPositionsIncludeOffScreenWindows + G_UserConfig.Save() + + DestroyUserConfigGui() + + ExitApp +} diff --git a/Lib/UserConfig.ahk b/Lib/UserConfig.ahk index 6bc0074..0f9a8e7 100644 --- a/Lib/UserConfig.ahk +++ b/Lib/UserConfig.ahk @@ -1,5 +1,5 @@ -#Include Lib\UserDataUtils.ahk #Include Lib\Logging.ahk +#Include Lib\UserDataUtils.ahk #Include Lib\WindowPositions.ahk ;-------------------------------------------------------------------------------- @@ -13,8 +13,9 @@ UserConfig_OnInit() ; UserConfig base class class UserConfig { - Properties := [] DataFileName := + Properties := [] + ObsoleteProperties := [] __New(fileName) { @@ -60,9 +61,7 @@ class UserConfig GetSectionNameFromFunc(func, defaultName := "General") { - bits := StrSplit(func, ".") - - sectionName := bits[2] + sectionName := Instr(func, ".") ? StrSplit(func, ".")[2] : func if (sectionName =) sectionName := func @@ -78,9 +77,7 @@ class UserConfig GetPropertyNameFromFunc(func) { - bits := StrSplit(func, ".") - - propertyName := bits[2] + propertyName := Instr(func, ".") ? StrSplit(func, ".")[2] : func if (propertyName =) propertyName := func @@ -92,6 +89,14 @@ class UserConfig return propertyName } + RemoveProperty(section, propertyName) + { + dataFileName := this.DataFileName + + LogText("Removing: [" . section . "]." . propertyName) + IniDelete, %dataFileName%, %section%, %propertyName% + } + Save() { for index, propertyName in this.Properties @@ -99,5 +104,9 @@ class UserConfig value := this[propertyName] this[propertyName] := value } + for index, propertyName in this.ObsoleteProperties + { + this.RemoveProperty(this.GetSectionNameFromFunc(propertyName), this.GetPropertyNameFromFunc(propertyName)) + } } } diff --git a/README.md b/README.md index a12e9bf..8f0f959 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,13 @@ Selecting any of the entries applies to the target window, shown at the top of t A Configuration dialog, available from the tray icon, allows controlling some aspects of the functionality. -![Configuration Dialog](Docs/ConfigurationDialog.png) +![Configuration Dialog Tab 1](Docs/ConfigurationDialog1.png) + +![Configuration Dialog Tab 2](Docs/ConfigurationDialog2.png) + +![Configuration Dialog Tab 3](Docs/ConfigurationDialog3.png) + +![Configuration Dialog Tab 4](Docs/ConfigurationDialog4.png) ## Features diff --git a/Setup/WindowMenu_Setup.iss b/Setup/WindowMenu_Setup.iss index 7055823..1988916 100644 --- a/Setup/WindowMenu_Setup.iss +++ b/Setup/WindowMenu_Setup.iss @@ -1,6 +1,6 @@ #define AppName "WindowExtensions" #define AppTitle "Window Extensions" -#define AppVersion "1.6.1" +#define AppVersion "1.6.2" [Setup] AppName={#AppName} diff --git a/TrayMenu.ahk b/TrayMenu.ahk index dfb71b2..6eb7d1d 100644 --- a/TrayMenu.ahk +++ b/TrayMenu.ahk @@ -43,7 +43,7 @@ BuildTrayMenu() menuIndex := AddMenuItemWithIcon(TrayMenuName, "Con&figure...", "TrayConfigureHandler", A_ScriptFullPath, 0, menuIndex) ; Window Positions - if (ContainsFlag(G_UserConfig.WindowPositionsMenuLocation, MenuLocationTrayMenu)) + if (ContainsFlag(G_UserConfig.MenuControl_WindowPositionsMenuLocation, MenuLocationTrayMenu)) { menuIndex := AddMenuItemSeparator(TrayMenuName, menuIndex) @@ -58,7 +58,7 @@ BuildTrayMenu() } ; Desktop Icons - if (ContainsFlag(G_UserConfig.DesktopIconsMenuLocation, MenuLocationTrayMenu)) + if (ContainsFlag(G_UserConfig.MenuControl_DesktopIconsMenuLocation, MenuLocationTrayMenu)) { menuIndex := AddMenuItemSeparator(TrayMenuName, menuIndex) @@ -81,7 +81,7 @@ BuildTrayMenu() ;-------------------------------------------------------------------------------- TrayConfigureHandler: -ShowUserConfigGui() +ShowConfigGui() return ;-------------------------------------------------------------------------------- diff --git a/WindowExtensions.ahk b/WindowExtensions.ahk index 48e2222..513bd22 100644 --- a/WindowExtensions.ahk +++ b/WindowExtensions.ahk @@ -15,7 +15,7 @@ AppDescription := "Window Extensions Menu and HotKeys" AppCopyright := "Copyright © 2020 Martin Smith" AppNotes := "Concise and consistent control over Window Positions. Right-click right half of Window Caption bar to invoke, or hit WinKey-W" AppURL := "https://github.com/martinsmith1968/WindowExtensions" -AppVersion := "1.6.1.0" +AppVersion := "1.6.2.0" ;-------------------------------------------------------------------------------- ; Includes @@ -54,7 +54,7 @@ OnExit, ExitHandler ;-------------------------------------------------------------------------------- ; Auto-Execute section -OnInit() ; Perform module initialisation - not reliant on other modules +OnInit() ; Perform module initialisation - not reliant on other modules or globals InitGlobals() ; OnStartup() ; Perform module startup - may rely on other modules Init @@ -64,7 +64,9 @@ return ; End of script's auto-execute section. ;-------------------------------------------------------------------------------- ; Exit Handler ExitHandler: +LogText("Raising OnExit...") OnExit() +LogText("Exiting...") ; Must do this for the OnExit subroutine to actually Exit the script. ExitApp diff --git a/WindowExtensionsUserConfig.ahk b/WindowExtensionsUserConfig.ahk index 2b52073..6719d6f 100644 --- a/WindowExtensionsUserConfig.ahk +++ b/WindowExtensionsUserConfig.ahk @@ -47,34 +47,37 @@ WindowExtensionsUserConfig_OnStartup() { global G_UserConfig - if (G_UserConfig.RestoreDesktopIconsOnStartup) + if (G_UserConfig.Startup_RestoreDesktopIcons) { - RestoreDesktopIcons() + RestoreDesktopIcons() } - if (G_UserConfig.RestoreWindowPositionsOnStartup) + if (G_UserConfig.Startup_RestoreWindowPositions) { - RestoreWindowPositions(G_UserConfig.WindowPositions_IncludeOffScreenWindows) + RestoreWindowPositions(G_UserConfig.WindowPositions_IncludeOffScreenWindows) } } class WindowExtensionsUserConfig extends UserConfig { -DefaultCascadeGutterSize := 30 -DefaultColumnGutterSize := 5 -DefaultGridGutterSize := 5 -DefaultSpanMonitorGutterSize := 5 -DefaultRestoreDesktopIconsOnStartup := false -DefaultRestoreWindowPositionsOnStartup := false -DefaultWindowPositionsMenuLocation := 2 -DefaultDesktopIconsMenuLocation := 2 -DefaultWindowPositions_IncludeOffScreenWindows := false +Default_About_Version := "" +Default_General_CascadeGutterSize := 30 +Default_General_ColumnGutterSize := 5 +Default_General_GridGutterSize := 5 +Default_General_SpanMonitorGutterSize := 5 +Default_Startup_RestoreDesktopIcons := false +Default_Startup_RestoreWindowPositions := false +Default_MenuControl_WindowPositionsMenuLocation := 0 +Default_MenuControl_DesktopIconsMenuLocation := 0 +Default_WindowPositions_IncludeOffScreenWindows := false InitDefaults() { + global AppVersion global MenuLocationTrayMenu - this.DefaultWindowPositionsMenuLocation := MenuLocationTrayMenu - this.DefaultDesktopIconsMenuLocation := MenuLocationTrayMenu + this.Default_About_Version := AppVersion + this.Default_MenuControl_WindowPositionsMenuLocation := MenuLocationTrayMenu + this.Default_MenuControl_DesktopIconsMenuLocation := MenuLocationTrayMenu } __New() @@ -87,22 +90,40 @@ DefaultWindowPositions_IncludeOffScreenWindows := false base.__New(fileName) - this.Properties.push("CascadeGutterSize") - this.Properties.push("ColumnGutterSize") - this.Properties.push("GridGutterSize") - this.Properties.push("SpanMonitorGutterSize") - this.Properties.push("RestoreDesktopIconsOnStartup") - this.Properties.push("RestoreWindowPositionsOnStartup") - this.Properties.push("WindowPositionsMenuLocation") - this.Properties.push("DesktopIconsMenuLocation") + this.Properties.push("About_Version") + this.Properties.push("General_CascadeGutterSize") + this.Properties.push("General_ColumnGutterSize") + this.Properties.push("General_GridGutterSize") + this.Properties.push("General_SpanMonitorGutterSize") + this.Properties.push("Startup_RestoreDesktopIcons") + this.Properties.push("Startup_RestoreWindowPositions") + this.Properties.push("MenuControl_WindowPositionsMenuLocation") + this.Properties.push("MenuControl_DesktopIconsMenuLocation") this.Properties.push("WindowPositions_IncludeOffScreenWindows") + + this.ObsoleteProperties.push("General_RestoreDesktopIconsOnStartup") + this.ObsoleteProperties.push("General_RestoreWindowPositionsOnStartup") + this.ObsoleteProperties.push("General_DesktopIconsMenuLocation") + this.ObsoleteProperties.push("General_WindowPositionsMenuLocation") + } + + About_Version + { + get + { + return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_General_CascadeGutterSize, "string") + } + set + { + base.SetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_About_Version) + } } - CascadeGutterSize + General_CascadeGutterSize { get { - return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.DefaultCascadeGutterSize, "integer") + return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_General_CascadeGutterSize, "integer") } set { @@ -110,11 +131,11 @@ DefaultWindowPositions_IncludeOffScreenWindows := false } } - ColumnGutterSize + General_ColumnGutterSize { get { - return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.DefaultColumnGutterSize, "integer") + return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_General_ColumnGutterSize, "integer") } set { @@ -122,11 +143,11 @@ DefaultWindowPositions_IncludeOffScreenWindows := false } } - GridGutterSize + General_GridGutterSize { get { - return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.DefaultGridGutterSize, "integer") + return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_General_GridGutterSize, "integer") } set { @@ -134,11 +155,11 @@ DefaultWindowPositions_IncludeOffScreenWindows := false } } - SpanMonitorGutterSize + General_SpanMonitorGutterSize { get { - return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.DefaultSpanMonitorGutterSize, "integer") + return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_General_SpanMonitorGutterSize, "integer") } set { @@ -146,11 +167,13 @@ DefaultWindowPositions_IncludeOffScreenWindows := false } } - RestoreDesktopIconsOnStartup + Startup_RestoreDesktopIcons { get { - return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.DefaultRestoreDesktopIconsOnStartup, "boolean") + oldValue1 := base.GetValue("General", "RestoreDesktopIconsOnStartup", this.Default_Startup_RestoreDesktopIcons, "boolean") + + return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), oldValue1, "boolean") } set { @@ -158,11 +181,13 @@ DefaultWindowPositions_IncludeOffScreenWindows := false } } - RestoreWindowPositionsOnStartup + Startup_RestoreWindowPositions { get { - return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.DefaultRestoreWindowPositionsOnStartup, "boolean") + oldValue1 := base.GetValue("General", "RestoreWindowPositionsOnStartup", this.Default_Startup_RestoreWindowPositions, "boolean") + + return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), oldValue1, "boolean") } set { @@ -170,11 +195,13 @@ DefaultWindowPositions_IncludeOffScreenWindows := false } } - WindowPositionsMenuLocation + MenuControl_WindowPositionsMenuLocation { get { - return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.DefaultWindowPositionsMenuLocation, "integer") + oldValue1 := base.GetValue("General", "WindowPositionsMenuLocation", this.Default_MenuControl_WindowPositionsMenuLocation, "integer") + + return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), oldValue1, "integer") } set { @@ -182,11 +209,13 @@ DefaultWindowPositions_IncludeOffScreenWindows := false } } - DesktopIconsMenuLocation + MenuControl_DesktopIconsMenuLocation { get { - return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.DefaultDesktopIconsMenuLocation, "integer") + oldValue1 := base.GetValue("General", "DesktopIconsMenuLocation", this.Default_MenuControl_WindowPositionsMenuLocation, "integer") + + return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), oldValue1, "integer") } set { @@ -198,7 +227,7 @@ DefaultWindowPositions_IncludeOffScreenWindows := false { get { - return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.DefaultWindowPositions_IncludeOffScreenWindows, "boolean") + return base.GetValue(base.GetSectionNameFromFunc(A_ThisFunc), base.GetPropertyNameFromFunc(A_ThisFunc), this.Default_WindowPositions_IncludeOffScreenWindows, "boolean") } set { diff --git a/WindowExtensionsUserConfigGui.ahk b/WindowExtensionsUserConfigGui.ahk index 24e2c3f..68d482d 100644 --- a/WindowExtensionsUserConfigGui.ahk +++ b/WindowExtensionsUserConfigGui.ahk @@ -2,126 +2,240 @@ #Include Lib/ArrayUtils.ahk #Include WindowExtensionsUserConfig.ahk -cascadeGutterSize := 0 -columnGutterSize := 0 -gridGutterSize := 0 -spanMonitorGutterSize := 0 +;-------------------------------------------------------------------------------- +; Config Gui Values +general_cascadeGutterSize := 0 +general_columnGutterSize := 0 +general_gridGutterSize := 0 +general_spanMonitorGutterSize := 0 +startup_restoreWindowPositions := false +startup_restoreDesktopIcons := false +menuControl_windowPositionsMenuLocation := 0 +menuControl_desktopIconsMenuLocation := 0 +menuControl_desktopIconsMenuLocationChoice := 0 +menuControl_windowPositionsMenuLocationChoice := 0 +windowPositions_NumberOfFilesToKeep := 20 +windowPositions_IncludeOffScreenWindows := false +desktopIcons_NumberOfFilesToKeep := 20 -BuildUserConfigGui(windowExtensionsUserConfig) +;-------------------------------------------------------------------------------- +; LoadConfigGuiValues - Populate gui variables with values from User Config +LoadConfigGuiValues(userConfig) { - global cascadeGutterSize - global columnGutterSize - global gridGutterSize - global spanMonitorGutterSize - global restoreDesktopIconsOnStartup - global restoreWindowPositionsOnStartup - global desktopIconsMenuLocation - global windowPositionsMenuLocation - global windowPositionsIncludeOffScreenWindows + global general_cascadeGutterSize + global general_columnGutterSize + global general_gridGutterSize + global general_spanMonitorGutterSize + global startup_restoreWindowPositions + global startup_restoreDesktopIcons + global menuControl_windowPositionsMenuLocation + global menuControl_windowPositionsMenuLocationChoice + global menuControl_desktopIconsMenuLocation + global menuControl_desktopIconsMenuLocationChoice + global windowPositions_IncludeOffScreenWindows global MenuLocationValues global MenuLocationItems - cascadeGutterSize := windowExtensionsUserConfig.CascadeGutterSize - columnGutterSize := windowExtensionsUserConfig.ColumnGutterSize - gridGutterSize := windowExtensionsUserConfig.GridGutterSize - spanMonitorGutterSize := windowExtensionsUserConfig.SpanMonitorGutterSize - restoreDesktopIconsOnStartup := windowExtensionsUserConfig.RestoreDesktopIconsOnStartup ? 1 : 0 - restoreWindowPositionsOnStartup := windowExtensionsUserConfig.RestoreWindowPositionsOnStartup ? 1 : 0 - desktopIconsMenuLocation := windowExtensionsUserConfig.DesktopIconsMenuLocation - windowPositionsMenuLocation := windowExtensionsUserConfig.WindowPositionsMenuLocation - windowPositionsIncludeOffScreenWindows := windowExtensionsUserConfig.WindowPositions_IncludeOffScreenWindows ? 1 : 0 + if (!userConfig) + return + + general_cascadeGutterSize := userConfig.General_CascadeGutterSize + general_columnGutterSize := userConfig.General_ColumnGutterSize + general_gridGutterSize := userConfig.General_GridGutterSize + general_spanMonitorGutterSize := userConfig.General_SpanMonitorGutterSize + startup_restoreWindowPositions := userConfig.Startup_RestoreWindowPositions ? 1 : 0 + startup_restoreDesktopIcons := userConfig.Startup_RestoreDesktopIcons ? 1 : 0 + menuControl_windowPositionsMenuLocation := userConfig.MenuControl_WindowPositionsMenuLocation + menuControl_windowPositionsMenuLocationChoice := IndexOf(MenuLocationValues, menuControl_windowPositionsMenuLocation) + menuControl_desktopIconsMenuLocation := userConfig.MenuControl_DesktopIconsMenuLocation + menuControl_desktopIconsMenuLocationChoice := IndexOf(MenuLocationValues, menuControl_desktopIconsMenuLocation) + windowPositions_IncludeOffScreenWindows := userConfig.WindowPositions_IncludeOffScreenWindows ? 1 : 0 +} + +;-------------------------------------------------------------------------------- +; SaveConfigGuiValues +SaveConfigGuiValues(userConfig) +{ + global general_cascadeGutterSize + global general_columnGutterSize + global general_gridGutterSize + global general_spanMonitorGutterSize + global startup_restoreWindowPositions + global startup_restoreDesktopIcons + global menuControl_windowPositionsMenuLocation + global menuControl_windowPositionsMenuLocationChoice + global menuControl_desktopIconsMenuLocation + global menuControl_desktopIconsMenuLocationChoice + global windowPositions_IncludeOffScreenWindows - desktopIconsMenuLocationChoice := IndexOf(MenuLocationValues, desktopIconsMenuLocation) - windowPositionsMenuLocationChoice := IndexOf(MenuLocationValues, windowPositionsMenuLocation) + global MenuLocationValues + + if (!userConfig) + return + userConfig.General_CascadeGutterSize := general_cascadeGutterSize + userConfig.General_ColumnGutterSize := general_columnGutterSize + userConfig.General_GridGutterSize := general_gridGutterSize + userConfig.General_SpanMonitorGutterSize := general_spanMonitorGutterSize + userConfig.Startup_RestoreWindowPositions := startup_restoreWindowPositions + userConfig.Startup_RestoreDesktopIcons := startup_restoreDesktopIcons + userConfig.MenuControl_WindowPositionsMenuLocation := MenuLocationValues[menuControl_windowPositionsMenuLocation] + userConfig.MenuControl_DesktopIconsMenuLocation := MenuLocationValues[menuControl_desktopIconsMenuLocation] + userConfig.WindowPositions_IncludeOffScreenWindows := windowPositions_IncludeOffScreenWindows + + userConfig.Save() + + OnUserConfigUpdated() +} + +;-------------------------------------------------------------------------------- +; BuildConfigGui - Build the Config Gui +BuildConfigGui() +{ + global AppName + global MenuLocationItems + + global general_cascadeGutterSize + global general_columnGutterSize + global general_gridGutterSize + global general_spanMonitorGutterSize + global startup_restoreWindowPositions + global startup_restoreDesktopIcons + global menuControl_windowPositionsMenuLocation + global menuControl_windowPositionsMenuLocationChoice + global menuControl_desktopIconsMenuLocation + global menuControl_desktopIconsMenuLocationChoice + global windowPositions_IncludeOffScreenWindows + menuLocationItemsText := JoinItems("|", MenuLocationItems) - Gui, Config:New, -SysMenu - Gui, Config:Add, Text,, Cascade Gutter Size: - Gui, Config:Add, Text,, Column Gutter Size: - Gui, Config:Add, Text,, Grid Gutter Size: - Gui, Config:Add, Text,, Span Monitor Gutter Size: - Gui, Config:Add, Text,, Restore Desktop Icons on Startup: - Gui, Config:Add, Text,, Restore Window Positions on Startup: - Gui, Config:Add, Text,, Save / Restore Window Positions Menu Location: - Gui, Config:Add, Text,, Save / Restore Desktop Icons Menu Location: - Gui, Config:Add, Text,, Include Off-Screen Windows on Save / Restore: - Gui, Config:Add, Edit, ym w80 - Gui, Config:Add, UpDown, vcascadeGutterSize Range0-100, %cascadeGutterSize% - Gui, Config:Add, Edit, w80 - Gui, Config:Add, UpDown, vcolumnGutterSize Range0-100, %columnGutterSize% - Gui, Config:Add, Edit, w80 - Gui, Config:Add, UpDown, vgridGutterSize Range0-100, %gridGutterSize% - Gui, Config:Add, Edit, w80 - Gui, Config:Add, UpDown, vspanMonitorGutterSize Range0-100, %spanMonitorGutterSize% - Gui, Config:Add, Checkbox, vrestoreDesktopIconsOnStartup Checked%restoreDesktopIconsOnStartup% - Gui, Config:Add, Checkbox, vrestoreWindowPositionsOnStartup Checked%restoreWindowPositionsOnStartup%, `n - Gui, Config:Add, DropDownList, vwindowPositionsMenuLocation AltSubmit Choose%windowPositionsMenuLocationChoice%, %menuLocationItemsText% - Gui, Config:Add, DropDownList, vdesktopIconsMenuLocation AltSubmit Choose%desktopIconsMenuLocationChoice%, %menuLocationItemsText% - Gui, Config:Add, Checkbox, vwindowPositionsIncludeOffScreenWindows x257 y223 Checked%windowPositionsIncludeOffScreenWindows% - Gui, Config:Add, Button, default x245 y245 w80, OK ; The label ButtonOK (if it exists) will be run when the button is pressed. - Gui, Config:Add, Button, x330 y245 w80, Cancel ; The label ButtonCancel (if it exists) will be run when the button is pressed. + marginSize := 5 + col1 := 20 + col2 := 220 + tabHeight := 40 + rowHeight := 30 + textOffSet := 3 + + row1 := tabHeight + (rowHeight * 0) + row2 := tabHeight + (rowHeight * 1) + row3 := tabHeight + (rowHeight * 2) + row4 := tabHeight + (rowHeight * 3) + + row1t := row1 + textOffset + row2t := row2 + textOffset + row3t := row3 + textOffset + row4t := row4 + textOffset + + ; Start Gui + Gui, Config:New, -SysMenu, %AppName% Configuration + Gui, Config:Margin, %marginSize%, %marginSize% + ;Gui, Config:Add, Tab3, -Wrap w370 h230, General|Startup|Menu Control|Window Positions|Desktop Icons + Gui, Config:Add, Tab3, -Wrap w370 h230, General|Startup|Menu Control|Window Positions + + ; Tab 1 - General + Gui, Config:Tab, 1 + ; Row 1 + Gui, Config:Add, Text, x%col1% y%row1t%, C&ascade Gutter Size: + Gui, Config:Add, Edit, x%col2% y%row1% w80 x%col2% + Gui, Config:Add, UpDown, vgeneral_cascadeGutterSize Range0-100, %general_cascadeGutterSize% + ; Row 2 + Gui, Config:Add, Text, x%col1% y%row2t%, C&olumn Gutter Size: + Gui, Config:Add, Edit, w80 x%col2% y%row2% + Gui, Config:Add, UpDown, vgeneral_columnGutterSize Range0-100, %general_columnGutterSize% + ; Row 3 + Gui, Config:Add, Text, x%col1% y%row3t%, &Grid Gutter Size: + Gui, Config:Add, Edit, w80 x%col2% y%row3% + Gui, Config:Add, UpDown, vgeneral_gridGutterSize Range0-100, %general_gridGutterSize% + ; Row 4 + Gui, Config:Add, Text, x%col1% y%row4t%, Span &Monitor Gutter Size: + Gui, Config:Add, Edit, w80 x%col2% y%row4% + Gui, Config:Add, UpDown, vgeneral_spanMonitorGutterSize Range0-100, %general_spanMonitorGutterSize% + + ; Tab 2 - Startup + Gui, Config:Tab, 2 + ; Row 1 + Gui, Config:Add, Checkbox, x%col1% y%row1t% vstartup_restoreWindowPositions Checked%startup_restoreWindowPositions%, Restore Window &Positions on Startup + ; Row 2 + Gui, Config:Add, Checkbox, x%col1% y%row2t% vstartup_restoreDesktopIcons Checked%startup_restoreDesktopIcons%, Restore Desktop &Icons on Startup + + ; Tab 3 - Menu Control + Gui, Config:Tab, 3 + ; Row 1 + Gui, Config:Add, Text, x%col1% y%row1t%, Window &Positions Menu Location: + Gui, Config:Add, DropDownList, x%col2% y%row1% vmenuControl_windowPositionsMenuLocation AltSubmit Choose%menuControl_windowPositionsMenuLocationChoice%, %menuLocationItemsText% + ; Row 2 + Gui, Config:Add, Text, x%col1% y%row2t%, Desktop &Icons Menu Location: + Gui, Config:Add, DropDownList, x%col2% y%row2% vmenuControl_desktopIconsMenuLocation AltSubmit Choose%menuControl_desktopIconsMenuLocationChoice%, %menuLocationItemsText% + + ; Tab 4 - Window Positions + Gui, Config:Tab, 4 + ; Row 1 + ;Gui, Config:Add, Text, x%col1% y%row1t%, Number of saved files to &keep : + ;Gui, Config:Add, Edit, w80 x%col2% y%row1% + ;Gui, Config:Add, UpDown, vwindowPositions_NumberOfFilesToKeep Range0-100, %windowPositions_NumberOfFilesToKeep% + ; Row 2 + Gui, Config:Add, Checkbox, x%col1% y%row1t% vwindowPositions_IncludeOffScreenWindows Checked%windowPositions_IncludeOffScreenWindows%, Include Off-Screen Windows + + ; Tab 5 - Desktop Icons + ;Gui, Config:Tab, 5 + ; Row 1 + ;Gui, Config:Add, Text, x%col1% y%row1t%, Number of saved files to &keep : + ;Gui, Config:Add, Edit, w80 x%col2% y%row1% + ;Gui, Config:Add, UpDown, vdesktopIcons_NumberOfFilesToKeep Range0-100, %desktopIcons_NumberOfFilesToKeep% + + ; Button Bar + Gui, Config:Tab + Gui, Config:Add, Button, default x205 y240 w80, OK ; The label ButtonOK (if it exists) will be run when the button is pressed. + Gui, Config:Add, Button, x295 y240 w80, Cancel ; The label ButtonCancel (if it exists) will be run when the button is pressed. } -DestroyUserConfigGui() +;-------------------------------------------------------------------------------- +; DestroyConfigGui - Destroy the Config Gui +DestroyConfigGui() { Gui, Config:Destroy } -ShowUserConfigGui() +;-------------------------------------------------------------------------------- +; ShowUserConfigGui - Build, Populate and Show the Config Gui +ShowConfigGui() { global G_UserConfig - BuildUserConfigGui(G_UserConfig) + LoadConfigGuiValues(G_UserConfig) + + BuildConfigGui() - Gui, Config:Show,,%AppName% Configuration + Gui, Config:Show } ConfigGuiEscape: { - DestroyUserConfigGui() + DestroyConfigGui() return } ConfigGuiClose: { - DestroyUserConfigGui() + DestroyConfigGui() return } ConfigButtonCancel: { - DestroyUserConfigGui() + DestroyConfigGui() return } ConfigButtonOK: { - global cascadeGutterSize - global columnGutterSize - global gridGutterSize - global spanMonitorGutterSize - global restoreDesktopIconsOnStartup - global restoreWindowPositionsOnStartup - global MenuLocationValues - global windowPositionsIncludeOffScreenWindows + global G_UserConfig Gui, Config:Submit - G_UserConfig.CascadeGutterSize := cascadeGutterSize - G_UserConfig.ColumnGutterSize := columnGutterSize - G_UserConfig.GridGutterSize := gridGutterSize - G_UserConfig.SpanMonitorGutterSize := spanMonitorGutterSize - G_UserConfig.RestoreDesktopIconsOnStartup := restoreDesktopIconsOnStartup - G_UserConfig.RestoreWindowPositionsOnStartup := restoreWindowPositionsOnStartup - G_UserConfig.DesktopIconsMenuLocation := MenuLocationValues[desktopIconsMenuLocation] - G_UserConfig.WindowPositionsMenuLocation := MenuLocationValues[windowPositionsMenuLocation] - G_UserConfig.WindowPositions_IncludeOffScreenWindows := windowPositionsIncludeOffScreenWindows - G_UserConfig.Save() - - OnUserConfigUpdated() - - DestroyUserConfigGui() + SaveConfigGuiValues(G_UserConfig) + + DestroyConfigGui() return } diff --git a/WindowMenu.ahk b/WindowMenu.ahk index 0f04824..a2ec729 100644 --- a/WindowMenu.ahk +++ b/WindowMenu.ahk @@ -83,7 +83,7 @@ BuildWindowMenu() } ; Window Positions - if (ContainsFlag(G_UserConfig.WindowPositionsMenuLocation, MenuLocationWindowMenu)) + if (ContainsFlag(G_UserConfig.MenuControl_WindowPositionsMenuLocation, MenuLocationWindowMenu)) { menuIndex := AddMenuItemSeparator(WindowMenuName, menuIndex) @@ -127,7 +127,7 @@ BuildWindowMenu() menuIndex := AddMenuItemWithIcon(WindowMenuName, "Send to Bac&k", "SendToBackHandler", IconLibraryFileName, GetIconLibraryIndex("POSITION_ZORDER_SENDTOBACK"), menuIndex) ; Desktop Icons - if (ContainsFlag(G_UserConfig.DesktopIconsMenuLocation, MenuLocationWindowMenu)) + if (ContainsFlag(G_UserConfig.MenuControl_DesktopIconsMenuLocation, MenuLocationWindowMenu)) { menuIndex := AddMenuItemSeparator(WindowMenuName, menuIndex) @@ -201,59 +201,59 @@ GetIconLibraryIndex(iconName) ;-------------------------------------------------------------------------------- OptimumSizeHandler: -SetWindowByGutter(G_ActiveWindow, (G_UserConfig.CascadeGutterSize * 1)) +SetWindowByGutter(G_ActiveWindow, (G_UserConfig.General_CascadeGutterSize * 1)) return SubOptimumSizeHandler: -SetWindowByGutter(G_ActiveWindow, (G_UserConfig.CascadeGutterSize * 2)) +SetWindowByGutter(G_ActiveWindow, (G_UserConfig.General_CascadeGutterSize * 2)) return MediumSizeHandler: -SetWindowByGutter(G_ActiveWindow, (G_UserConfig.CascadeGutterSize * 3)) +SetWindowByGutter(G_ActiveWindow, (G_UserConfig.General_CascadeGutterSize * 3)) return SmallSizeHandler: -SetWindowByGutter(G_ActiveWindow, (G_UserConfig.CascadeGutterSize * 4)) +SetWindowByGutter(G_ActiveWindow, (G_UserConfig.General_CascadeGutterSize * 4)) return TinySizeHandler: -SetWindowByGutter(G_ActiveWindow, (G_UserConfig.CascadeGutterSize * 5)) +SetWindowByGutter(G_ActiveWindow, (G_UserConfig.General_CascadeGutterSize * 5)) return ;-------------------------------------------------------------------------------- MoveColumnLeftHandler: -SetWindowByColumn(G_ActiveWindow, 1, 3, G_UserConfig.ColumnGutterSize) +SetWindowByColumn(G_ActiveWindow, 1, 3, G_UserConfig.General_ColumnGutterSize) return MoveColumnCentreHandler: -SetWindowByColumn(G_ActiveWindow, 2, 3, G_UserConfig.ColumnGutterSize) +SetWindowByColumn(G_ActiveWindow, 2, 3, G_UserConfig.General_ColumnGutterSize) return MoveColumnRightHandler: -SetWindowByColumn(G_ActiveWindow, 3, 3, G_UserConfig.ColumnGutterSize) +SetWindowByColumn(G_ActiveWindow, 3, 3, G_UserConfig.General_ColumnGutterSize) return ;-------------------------------------------------------------------------------- SpanCurrentMonitorHandler: monitor := new Monitor(G_ActiveWindow.MonitorIndex) monitorWorkArea := monitor.WorkArea -SetWindowSpanMonitors(G_ActiveWindow, monitorWorkArea.Left, monitorWorkArea.Top, monitorWorkArea.Right, monitorWorkArea.Bottom, G_UserConfig.SpanMonitorGutterSize) +SetWindowSpanMonitors(G_ActiveWindow, monitorWorkArea.Left, monitorWorkArea.Top, monitorWorkArea.Right, monitorWorkArea.Bottom, G_UserConfig.General_SpanMonitorGutterSize) return SpanMonitorWidthHandler: monitor := new Monitor(G_ActiveWindow.MonitorIndex) monitorWorkArea := monitor.WorkArea -SetWindowSpanMonitors(G_ActiveWindow, "", monitorWorkArea.Top, "", monitorWorkArea.Bottom, G_UserConfig.SpanMonitorGutterSize) +SetWindowSpanMonitors(G_ActiveWindow, "", monitorWorkArea.Top, "", monitorWorkArea.Bottom, G_UserConfig.General_SpanMonitorGutterSize) return SpanMonitorHeightHandler: monitor := new Monitor(G_ActiveWindow.MonitorIndex) monitorWorkArea := monitor.WorkArea -SetWindowSpanMonitors(G_ActiveWindow, monitorWorkArea.Left, "", monitorWorkArea.Right, "", G_UserConfig.SpanMonitorGutterSize) +SetWindowSpanMonitors(G_ActiveWindow, monitorWorkArea.Left, "", monitorWorkArea.Right, "", G_UserConfig.General_SpanMonitorGutterSize) return SpanAllMonitorsHandler: -SetWindowSpanMonitors(G_ActiveWindow, "", "", "", "", G_UserConfig.SpanMonitorGutterSize) +SetWindowSpanMonitors(G_ActiveWindow, "", "", "", "", G_UserConfig.General_SpanMonitorGutterSize) return ;-------------------------------------------------------------------------------- @@ -271,19 +271,19 @@ SetWindowToCentre(G_ActiveWindow) return MoveTopLeftHandler: -SetWindowByGrid(G_ActiveWindow, 1, 1, 2, 2, G_UserConfig.GridGutterSize) +SetWindowByGrid(G_ActiveWindow, 1, 1, 2, 2, G_UserConfig.General_GridGutterSize) return MoveTopRightHandler: -SetWindowByGrid(G_ActiveWindow, 1, 2, 2, 2, G_UserConfig.GridGutterSize) +SetWindowByGrid(G_ActiveWindow, 1, 2, 2, 2, G_UserConfig.General_GridGutterSize) return MoveBottomLeftHandler: -SetWindowByGrid(G_ActiveWindow, 2, 1, 2, 2, G_UserConfig.GridGutterSize) +SetWindowByGrid(G_ActiveWindow, 2, 1, 2, 2, G_UserConfig.General_GridGutterSize) return MoveBottomRightHandler: -SetWindowByGrid(G_ActiveWindow, 2, 2, 2, 2, G_UserConfig.GridGutterSize) +SetWindowByGrid(G_ActiveWindow, 2, 2, 2, 2, G_UserConfig.General_GridGutterSize) return ;--------------------------------------------------------------------------------