Quantcast

- Titan (edit mode vs Movable) in menu

urnati [03-11-26 - 12:25]
- Titan (edit mode vs Movable) in menu
- Titan Config back in menu
Filename
Titan/Titan.lua
Titan/TitanConfig.lua
Titan/TitanMenu.lua
diff --git a/Titan/Titan.lua b/Titan/Titan.lua
index b1b7c74..2333273 100644
--- a/Titan/Titan.lua
+++ b/Titan/Titan.lua
@@ -1,4 +1,3 @@
----@diagnostic disable: duplicate-set-field
 --[===[ File
 Contains the basic routines of Titan.
 All the event handler routines, initialization routines, Titan menu routines, and select plugin handler routines.
@@ -270,7 +269,8 @@ local function RegisterAddonCompartment()
 						local msg = ""
 							.. L["TITAN_PANEL"]
 							.. " " .. L["TITAN_PANEL_MENU_CONFIGURATION"]
-						tooltip:SetText(msg)
+---@diagnostic disable-next-line: missing-parameter
+						tooltip:SetText(msg) -- wants parameters for color...
 					end)
 				end,
 				funcOnLeave = function(button)
@@ -2123,7 +2123,7 @@ end
 local function GetLayout()
 	local res = ""

-	-- Defined in as part of the Edit Mode frame
+	-- Defined as part of the Edit Mode frame
 	--../Blizzard_EditMode/Shared/EditModeManager.lua
 	local EMM = EditModeManagerFrame
 	local layout = EMM:GetActiveLayoutInfo()
@@ -2145,12 +2145,15 @@ local function GeneratorFunction(owner, rootDescription)
 	local root = rootDescription -- menu widget to start with

 	Titan_Menu.AddText(root, L["TITAN_PANEL_MENU_PLUGINS"])
-	do
+	do -- plugins under category
+		-- Get virtual height in pixels
+		local scroll_hgt = math.floor(GetScreenHeight() * .6) -- virtual height in pixels
 		---@diagnostic disable-next-line: assign-type-mismatch, param-type-mismatch
 		for index, id in pairs(L["TITAN_PANEL_MENU_CATEGORIES"]) do
 			local cat = TITAN_PANEL_BUTTONS_PLUGIN_CATEGORY[index]
 			local cat_locale = L["TITAN_PANEL_MENU_CATEGORIES"][index]
 			local opts_plugins = Titan_Menu.AddButton(root, cat_locale)
+			opts_plugins:SetScrollMode(scroll_hgt) -- in case menu height is larger than screen / window
 			AddPlugin(opts_plugins, bar, cat) -- if same category
 		end
 	end
@@ -2187,8 +2190,17 @@ local function GeneratorFunction(owner, rootDescription)
 			)
 		end
 	end
+
 	Titan_Menu.AddDivider(root)
+	-- Config - just one button to open the first Titan option screen
+	Titan_Menu.AddCommand(root, id, L["TITAN_PANEL_MENU_CONFIGURATION"],
+		function()
+			TitanUpdateConfig("init")
+			AceConfigDialog:Open("Titan")
+		end
+	)

+	Titan_Menu.AddDivider(root)
 	if Titan_Global.switch.can_edit_ui then
 		local lay_out = GetLayout()
 		Titan_Menu.AddCommand(root, id, HUD_EDIT_MODE_MENU..": "..lay_out,
diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua
index 91a03d2..c4f31c3 100644
--- a/Titan/TitanConfig.lua
+++ b/Titan/TitanConfig.lua
@@ -274,7 +274,6 @@ local function TitanUpdateAdj(t, pos)
 	for idx = 1, #bar_list do
 		-- ======
 		-- Build the frame adjust list in order (left side)
-		-- NOTE: v.name is the 'group' name which is the table passed to callbacks : info[1]
 		local f_name = bar_list[idx].frame_name
 		local v = TitanAdjustSettings[f_name] -- process this frame
 		position = position + 1
@@ -422,7 +421,6 @@ local function TitanUpdateConfigBars(t, pos)
 	for idx = 1, #bar_list do
 		-- ======
 		-- Build the bar list in order (left side)
-		-- NOTE: v.name is the 'group' name which is the table passed to callbacks : info[1]
 		local v = bar_list[idx] -- process this bar
 		position = position + 1
 		args[v.name] = {
@@ -898,6 +896,16 @@ Bar:
 - The user can not move a plugin to a hidden bar to 'hide' it. The user should ensure "Show Plugin" is unchecked.
 --]]

+local function Getter(id, var)
+	local res = TitanGetVar(id, var)
+	return res
+end
+
+local function Setter(id, var, value)
+	TitanSetVar(id, var, value);
+	TitanPanelButton_UpdateButton(id)
+end
+
 ---Allow the user to control each plugin registered to Titan.
 local function UpdateConfigAddons()
 	local args = optionsAddons.args
@@ -913,6 +921,7 @@ local function UpdateConfigAddons()
 		plug_in = TitanUtils_GetPlugin(TitanPluginsIndex[idx])
 		if plug_in then
 			local header = (plug_in.menuText or "")
+			local plugin_id = plug_in.id -- set so each plugin gets the value appropriately
 			args[plug_in.id] = {
 				type = "group",
 				name = ColorVisible(plug_in.id, plug_in.menuText_NC or ""),
@@ -927,10 +936,11 @@ local function UpdateConfigAddons()
 						type = "toggle",
 						name = L["TITAN_PANEL_MENU_SHOW"],
 						order = 3,
-						get = function(info)
-							return (TitanPanel_IsPluginShown(info[1])) end,
+						get = function(info)
+							local name = plugin_id
+							return (TitanPanel_IsPluginShown(name)) end,
 						set = function(info, v)
-							local name = info[1]
+							local name = plugin_id
 							if v then -- Show / add
 								local bar = (TitanGetVar(name, "ForceBar") or TitanUtils_PickBar())
 								if type(bar) == 'string' then -- sanity and IDE
@@ -953,10 +963,11 @@ local function UpdateConfigAddons()
 					type = "toggle",
 					name = L["TITAN_PANEL_MENU_SHOW_ICON"],
 					order = 4,
-					get = function(info) return (TitanGetVar(info[1], "ShowIcon")) end,
+					get = function(info)
+						return Getter(plugin_id, "ShowIcon")
+					end,
 					set = function(info, v)
-						TitanToggleVar(info[1], "ShowIcon");
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "ShowIcon", v)
 					end,
 				}
 			end
@@ -967,10 +978,11 @@ local function UpdateConfigAddons()
 					type = "toggle",
 					name = L["TITAN_PANEL_MENU_SHOW_LABEL_TEXT"],
 					order = 5,
-					get = function(info) return (TitanGetVar(info[1], "ShowLabelText")) end,
+					get = function(info)
+						return Getter(plugin_id, "ShowLabelText")
+					end,
 					set = function(info, v)
-						TitanToggleVar(info[1], "ShowLabelText");
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "ShowLabelText", v)
 					end,
 				}
 			end
@@ -982,10 +994,11 @@ local function UpdateConfigAddons()
 					type = "toggle",
 					name = L["TITAN_PANEL_MENU_SHOW_PLUGIN_TEXT"],
 					order = 6,
-					get = function(info) return (TitanGetVar(info[1], "ShowRegularText")) end,
+					get = function(info)
+						return Getter(plugin_id, "ShowRegularText")
+					end,
 					set = function(info, v)
-						TitanToggleVar(info[1], "ShowRegularText");
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "ShowRegularText", v)
 					end,
 				}
 			end
@@ -996,10 +1009,11 @@ local function UpdateConfigAddons()
 					type = "toggle",
 					name = L["TITAN_PANEL_MENU_SHOW_COLORED_TEXT"],
 					order = 7,
-					get = function(info) return (TitanGetVar(info[1], "ShowColoredText")) end,
+					get = function(info)
+						return Getter(plugin_id, "ShowColoredText")
+					end,
 					set = function(info, v)
-						TitanToggleVar(info[1], "ShowColoredText");
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "ShowColoredText", v)
 					end,
 				}
 			end
@@ -1010,13 +1024,15 @@ local function UpdateConfigAddons()
 					type = "toggle",
 					name = L["TITAN_PANEL_MENU_LDB_SIDE"],
 					order = 8,
-					get = function(info) return (TitanGetVar(info[1], "DisplayOnRightSide")) end,
+					get = function(info)
+						local name = plugin_id
+						return (TitanGetVar(name, "DisplayOnRightSide")) end,
 					set = function(info, v)
-						local bar = TitanUtils_GetWhichBar(info[1])
-						TitanToggleVar(info[1], "DisplayOnRightSide");
-						TitanPanel_RemoveButton(info[1]);
-						TitanUtils_AddButtonOnBar(bar, info[1]);
-						TitanPanelButton_UpdateButton(info[1])
+						local bar = TitanUtils_GetWhichBar(plugin_id)
+						TitanToggleVar(plugin_id, "DisplayOnRightSide");
+						TitanPanel_RemoveButton(plugin_id);
+						TitanUtils_AddButtonOnBar(bar, plugin_id);
+						TitanPanelButton_UpdateButton(plugin_id)
 					end,
 				}
 			end
@@ -1031,7 +1047,7 @@ local function UpdateConfigAddons()
 				name = "< " .. L["TITAN_PANEL_SHIFT_LEFT"] .. "  ",
 				order = 51,
 				func = function(info, arg1)
-					local name = info[1]
+					local name = plugin_id
 					if TitanPanel_IsPluginShown(name) then
 						TitanUtils_ShiftButtonOnBarLeft(name)
 					end
@@ -1042,8 +1058,8 @@ local function UpdateConfigAddons()
 				name = "> " .. L["TITAN_PANEL_SHIFT_RIGHT"],
 				order = 52,
 				func = function(info, arg1)
-					local name = info[1]
-					if TitanPanel_IsPluginShown(info[1]) then
+					local name = plugin_id
+					if TitanPanel_IsPluginShown(name) then
 						TitanUtils_ShiftButtonOnBarRight(name)
 					end
 				end,
@@ -1060,20 +1076,18 @@ local function UpdateConfigAddons()
 					name = L["TITAN_PANEL_MENU_BAR"],
 					desc = L["TITAN_PANEL_MENU_DISPLAY_ON_BAR"],
 					get = function(info)
-						return TitanUtils_GetWhichBar(info[1])
+						return TitanUtils_GetWhichBar(plugin_id)
 					end,
 					set = function(info, v)
-						local name = info[1]
+						local name = plugin_id
 						if TitanPanel_IsPluginShown(name) then
 							TitanUtils_AddButtonOnBar(v, name)
 						end
 					end,
 					values = function()
 						local Locationlist = {}
-						local v
 						for idx, v in pairs(TitanBarData) do
 							if TitanBarDataVars[idx].show then
-								--							if TitanPanelGetVar(TitanBarData[idx].name.."_Show") then
 								Locationlist[TitanBarData[idx].name] = TitanBarData[idx].locale_name
 							end
 						end
@@ -1156,10 +1170,9 @@ local function UpdateConfigAddons()
 					type = "toggle",
 					name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"] .. " 1",
 					order = 71,
-					get = function(info) return (TitanGetVar(info[1], "CustomLabelTextShow") or false) end,
+					get = function(info) return (TitanGetVar(plugin_id, "CustomLabelTextShow") or false) end,
 					set = function(info, v)
-						TitanToggleVar(info[1], "CustomLabelTextShow");
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "CustomLabelTextShow", v)
 					end,
 				}
 				args[plug_in.id].args.custom_label_text = {
@@ -1168,10 +1181,9 @@ local function UpdateConfigAddons()
 					desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"],
 					type = "input",
 					width = "full",
-					get = function(info) return (TitanGetVar(info[1], "CustomLabelText") or "") end,
+					get = function(info) return (TitanGetVar(plugin_id, "CustomLabelText") or "") end,
 					set = function(info, v)
-						TitanSetVar(info[1], "CustomLabelText", v);
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "CustomLabelText", v)
 					end,
 				}
 			end
@@ -1180,10 +1192,9 @@ local function UpdateConfigAddons()
 					type = "toggle",
 					name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"] .. " 2",
 					order = 73,
-					get = function(info) return (TitanGetVar(info[1], "CustomLabel2TextShow") or false) end,
+					get = function(info) return (TitanGetVar(plugin_id, "CustomLabel2TextShow") or false) end,
 					set = function(info, v)
-						TitanToggleVar(info[1], "CustomLabel2TextShow");
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "CustomLabel2TextShow", v)
 					end,
 				}
 				args[plug_in.id].args.custom_label2_text = {
@@ -1192,10 +1203,9 @@ local function UpdateConfigAddons()
 					desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"],
 					type = "input",
 					width = "full",
-					get = function(info) return (TitanGetVar(info[1], "CustomLabel2Text") or "") end,
+					get = function(info) return (TitanGetVar(plugin_id, "CustomLabel2Text") or "") end,
 					set = function(info, v)
-						TitanSetVar(info[1], "CustomLabel2Text", v);
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "CustomLabel2Text", v)
 					end,
 				}
 			end
@@ -1204,10 +1214,9 @@ local function UpdateConfigAddons()
 					type = "toggle",
 					name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"] .. " 3",
 					order = 75,
-					get = function(info) return (TitanGetVar(info[1], "CustomLabel3TextShow") or false) end,
+					get = function(info) return (TitanGetVar(plugin_id, "CustomLabel3TextShow") or false) end,
 					set = function(info, v)
-						TitanToggleVar(info[1], "CustomLabel3TextShow");
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "CustomLabel3TextShow", v)
 					end,
 				}
 				args[plug_in.id].args.custom_label3_text = {
@@ -1216,10 +1225,9 @@ local function UpdateConfigAddons()
 					desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"],
 					type = "input",
 					width = "full",
-					get = function(info) return (TitanGetVar(info[1], "CustomLabel3Text") or "") end,
+					get = function(info) return (TitanGetVar(plugin_id, "CustomLabel3Text") or "") end,
 					set = function(info, v)
-						TitanSetVar(info[1], "CustomLabel3Text", v);
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "CustomLabel3Text", v)
 					end,
 				}
 			end
@@ -1228,10 +1236,9 @@ local function UpdateConfigAddons()
 					type = "toggle",
 					name = L["TITAN_PANEL_MENU_ADV_LABEL_SHOW"] .. " 4",
 					order = 77,
-					get = function(info) return (TitanGetVar(info[1], "CustomLabel4TextShow") or false) end,
+					get = function(info) return (TitanGetVar(plugin_id, "CustomLabel4TextShow") or false) end,
 					set = function(info, v)
-						TitanToggleVar(info[1], "CustomLabel4TextShow");
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "CustomLabel4TextShow", v)
 					end,
 				}
 				args[plug_in.id].args.custom_label4_text = {
@@ -1240,10 +1247,9 @@ local function UpdateConfigAddons()
 					desc = L["TITAN_PANEL_MENU_ADV_CUSTOM_DESC"],
 					type = "input",
 					width = "full",
-					get = function(info) return (TitanGetVar(info[1], "CustomLabel4Text") or "") end,
+					get = function(info) return (TitanGetVar(plugin_id, "CustomLabel4Text") or "") end,
 					set = function(info, v)
-						TitanSetVar(info[1], "CustomLabel4Text", v);
-						TitanPanelButton_UpdateButton(info[1])
+						Setter(plugin_id, "CustomLabel4Text", v)
 					end,
 				}
 			end
diff --git a/Titan/TitanMenu.lua b/Titan/TitanMenu.lua
index ff131be..9374dc2 100644
--- a/Titan/TitanMenu.lua
+++ b/Titan/TitanMenu.lua
@@ -891,10 +891,7 @@ function TitanPanelRightClickMenu_Close()
 	CloseAnyMenu()
 end

---[=====[ Implementation notes
---]=====]
-
---[=====[ NEW menu scheme Jan 2026
+--[=====[ New menu scheme being used Jan 2026
 Blizzard introduced a new menu scheme in 11.0.0 (July 2024) coded in Blizzard_Menu.
 The menu scheme is so different we use a new namespace for the new wrapper routines.

@@ -985,7 +982,7 @@ Wrapper notes:
 -- Most Blizzard_Menu 'create' routines return the resulting widget.

 - Blizzard_Menu create routines pass 'is selected' and 'set selected' as functions.
-The wrappers continue this and extends to other needed actions.
+-- The wrappers use this method and extends to other needed actions.
 - Adds 'update Titan button' where it makes sense, relieving the dev from including it 'all over'.
 - When a single selector is created, Titan uses a checkbox.
 - When multiple selectors are created, Titan uses a radio.
@@ -994,6 +991,13 @@ The wrappers continue this and extends to other needed actions.

 --]=====]

+--[=====[ Implementation notes and lessons
+- Once the menu 'generator' is called, the  menu is active. All set up and clean up must be already done.
+- If a scroll bar is needed, it must be added at that level. The setting does not apply to children menus!
+- CreateContextMenu will take other parameters (as ...) which are passed to GeneratorFunction.
+	A handy feature but not used in Titan.
+--]=====]
+
 --== menu helpers
 local nop = function(obj) end

@@ -1207,6 +1211,7 @@ local function MarkFromList(id, opt, list)
 		end
 	end
 end
+--== end menu helpers

 ---API Add divider (line) to owner
 ---@param owner table Menu widget object
@@ -1353,7 +1358,7 @@ function Titan_Menu.AddSelectorList(owner, id, label, opt, list, sel_func, ...)
 	end
 end

----API Add a button that, when pressed runs a command passing any given paramters
+---API Add a button that, when pressed runs a command passing any given parameters
 ---@param owner table Menu widget object
 ---@param id string Plugin ID
 ---@param label string Label of the  selector
@@ -1366,6 +1371,7 @@ function Titan_Menu.AddCommand(owner, id, label, function_name, ...)
 end

 ---Titan Add the desired control vars to the owner; this expected to end the menu!
+---Used in Titan menu to toggle plugin control vars.
 ---@param owner table Menu widget object
 ---@param id string Plugin ID
 function Titan_Menu.AddControlVars(owner, id)