Quantcast

- Add backdrop (hopefully last time!) to built-in plugin tooltips - Clock, Performace, Volume

urnati [11-14-21 - 16:04]
- Add backdrop (hopefully last time!) to built-in plugin tooltips - Clock, Performace, Volume
Filename
TitanClassic/TitanClassicUtils.lua
TitanClassicClock/TitanClassicClock.lua
TitanClassicPerformance/TitanClassicPerformance.lua
TitanClassicVolume/TitanClassicVolume.lua
diff --git a/TitanClassic/TitanClassicUtils.lua b/TitanClassic/TitanClassicUtils.lua
index 6793832..5859c41 100644
--- a/TitanClassic/TitanClassicUtils.lua
+++ b/TitanClassic/TitanClassicUtils.lua
@@ -988,29 +988,6 @@ function TitanPanelRightClickMenu_AddToggleColoredText(id, level)
 end

 --[[ API
-NAME: TitanPanelRightClickMenu_AddToggleRightSide
-DESC: Menu - add a toggle Right Side (localized) command at the given level in the form of a button. Titan will properly control the "DisplayOnRightSide"
-VAR: id - id of the plugin
-VAR: level - level to put the line
-OUT:  None
---]]
-function TitanPanelRightClickMenu_AddToggleRightSide(id, level)
-	-- copy of TitanPanelRightClickMenu_AddToggleVar adding a remove button
-	local info = {};
-	info.text = L["TITAN_CLOCK_MENU_DISPLAY_ON_RIGHT_SIDE"];
-	info.value = {id, "DisplayOnRightSide"};
-	info.func = function()
-		local bar = TitanUtils_GetWhichBar(id)
-		TitanPanelRightClickMenu_ToggleVar({id, "DisplayOnRightSide"})
-		TitanPanel_RemoveButton(id);
-		TitanUtils_AddButtonOnBar(bar, id)
-	end
-	info.checked = TitanGetVar(id, "DisplayOnRightSide");
-	info.keepShownOnClick = 1;
-	L_UIDropDownMenu_AddButton(info, level);
-end
-
---[[ API
 NAME: TitanPanelRightClickMenu_AddHide
 DESC: Menu - add a Hide (localized) command at the given level in the form of a button. When clicked this will remove the plugin from the Titan bar.
 VAR: id - id of the plugin
@@ -1086,6 +1063,34 @@ function TitanPanelRightClickMenu_ToggleColoredText(value)
 	TitanPanelButton_UpdateButton(value, 1);
 end

+--[[ API
+NAME: TitanPanelRightClickMenu_SetCustomBackdrop
+DESC: This will set the backdrop of the given button. This is used for custom created controls such as Clock offset or Volume sliders to give a consistent look.
+VAR: frame - the control frame of the plugin
+OUT:  None
+--]]
+function TitanPanelRightClickMenu_SetCustomBackdrop(frame)
+	frame:SetBackdrop({
+		bgFile="Interface\\Tooltips\\UI-Tooltip-Background",
+		edgeFile="Interface\\Tooltips\\UI-Tooltip-Border",
+		tile = true,
+		tileEdge = true,
+		insets = { left = 1, right = 1, top = 1, bottom = 1 },
+		tileSize = 8,
+		edgeSize = 8,
+	})
+
+	frame:SetBackdropBorderColor(
+		TOOLTIP_DEFAULT_COLOR.r,
+		TOOLTIP_DEFAULT_COLOR.g,
+		TOOLTIP_DEFAULT_COLOR.b);
+	frame:SetBackdropColor(
+		TOOLTIP_DEFAULT_BACKGROUND_COLOR.r,
+		TOOLTIP_DEFAULT_BACKGROUND_COLOR.g,
+		TOOLTIP_DEFAULT_BACKGROUND_COLOR.b
+		, 1);
+end
+
 --------------------------------------------------------------
 --
 -- Plugin manipulation routines
diff --git a/TitanClassicClock/TitanClassicClock.lua b/TitanClassicClock/TitanClassicClock.lua
index 24ae677..7b2a228 100644
--- a/TitanClassicClock/TitanClassicClock.lua
+++ b/TitanClassicClock/TitanClassicClock.lua
@@ -442,16 +442,7 @@ end
 -- **************************************************************************
 function TitanPanelClockControlFrame_OnLoad(self)
 	_G[self:GetName().."Title"]:SetText(L["TITAN_CLOCK_CONTROL_TITLE"]);
-	self:SetBackdrop({
-		bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark",
-		edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
-		tile = true,
-		tileSize = 32,
-		edgeSize = 32,
-		insets = { left = 11, right = 12, top = 12, bottom = 9, },
-	})
-	self:SetBackdropBorderColor(1, 1, 1);
-	self:SetBackdropColor(0, 0, 0, 1);
+	TitanPanelRightClickMenu_SetCustomBackdrop(self)
 end

 -- **************************************************************************
@@ -516,10 +507,14 @@ function TitanPanelRightClickMenu_PrepareClockMenu()
 	info.keepShownOnClick = 1;
 	L_UIDropDownMenu_AddButton(info);

-	TitanPanelRightClickMenu_AddSpacer();
+	info = {};
+	info.text = L["TITAN_CLOCK_MENU_DISPLAY_ON_RIGHT_SIDE"];
+	info.func = TitanPanelClockButton_ToggleRightSideDisplay;
+	info.checked = TitanGetVar(TITAN_CLOCK_ID, "DisplayOnRightSide");
+	L_UIDropDownMenu_AddButton(info);
+
 	TitanPanelRightClickMenu_AddToggleLabelText(TITAN_CLOCK_ID);
 	TitanPanelRightClickMenu_AddToggleColoredText(TITAN_CLOCK_ID);
-	TitanPanelRightClickMenu_AddToggleRightSide(TITAN_CLOCK_ID);

 	TitanPanelRightClickMenu_AddSpacer();
 	TitanPanelRightClickMenu_AddCommand(L["TITAN_PANEL_MENU_HIDE"], TITAN_CLOCK_ID, TITAN_PANEL_MENU_FUNC_HIDE);
diff --git a/TitanClassicPerformance/TitanClassicPerformance.lua b/TitanClassicPerformance/TitanClassicPerformance.lua
index 45ce4fb..260ec3d 100644
--- a/TitanClassicPerformance/TitanClassicPerformance.lua
+++ b/TitanClassicPerformance/TitanClassicPerformance.lua
@@ -68,7 +68,7 @@ function TitanPanelPerformanceButton_OnLoad(self)
 			ShowLabelText = true,
 			ShowRegularText = false,
 			ShowColoredText = true,
-			DisplayOnRightSide = true,
+			DisplayOnRightSide = false,
 		},
 		savedVariables = {
 			ShowFPS = 1,
@@ -82,7 +82,6 @@ function TitanPanelPerformanceButton_OnLoad(self)
 			ShowIcon = 1,
 			ShowLabelText = false,
 			ShowColoredText = 1,
-			DisplayOnRightSide = false,
 		}
 	};

@@ -372,9 +371,8 @@ function TitanPanelPerformanceButton_SetTooltip()
 	-- Tooltip title
 	GameTooltip:SetText(L["TITAN_PERFORMANCE_TOOLTIP"], HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);

--- Ticket 48 : Request to always show info in the tooltip. Does NOT include addon info as that is tooltip only
 	-- FPS tooltip
---	if ( showFPS ) then
+	if ( showFPS ) then
 		local fpsText = format(L["TITAN_FPS_FORMAT"], button.fps);
 		local avgFPSText = format(L["TITAN_FPS_FORMAT"], button.avgFPS);
 		local minFPSText = format(L["TITAN_FPS_FORMAT"], button.minFPS);
@@ -386,10 +384,10 @@ function TitanPanelPerformanceButton_SetTooltip()
 		GameTooltip:AddDoubleLine(L["TITAN_FPS_TOOLTIP_AVG_FPS"], TitanUtils_GetHighlightText(avgFPSText));
 		GameTooltip:AddDoubleLine(L["TITAN_FPS_TOOLTIP_MIN_FPS"], TitanUtils_GetHighlightText(minFPSText));
 		GameTooltip:AddDoubleLine(L["TITAN_FPS_TOOLTIP_MAX_FPS"], TitanUtils_GetHighlightText(maxFPSText));
---	end
+	end

 	-- Latency tooltip
---	if ( showLatency or showWorldLatency ) then
+	if ( showLatency or showWorldLatency ) then
 		local latencyText = format(L["TITAN_LATENCY_FORMAT"], button.latencyHome);
 		local latencyWorldText = format(L["TITAN_LATENCY_FORMAT"], button.latencyWorld);
 		local bandwidthInText = format(L["TITAN_LATENCY_BANDWIDTH_FORMAT"], button.bandwidthIn);
@@ -401,10 +399,10 @@ function TitanPanelPerformanceButton_SetTooltip()
 		if showWorldLatency then GameTooltip:AddDoubleLine(L["TITAN_LATENCY_TOOLTIP_LATENCY_WORLD"], TitanUtils_GetHighlightText(latencyWorldText)); end
 		GameTooltip:AddDoubleLine(L["TITAN_LATENCY_TOOLTIP_BANDWIDTH_IN"], TitanUtils_GetHighlightText(bandwidthInText));
 		GameTooltip:AddDoubleLine(L["TITAN_LATENCY_TOOLTIP_BANDWIDTH_OUT"], TitanUtils_GetHighlightText(bandwidthOutText));
---	end
+	end

 	-- Memory tooltip
---	if ( showMemory ) then
+	if ( showMemory ) then
 		local memoryText = format(L["TITAN_MEMORY_FORMAT"], button.memory/1024);
 		local initialMemoryText = format(L["TITAN_MEMORY_FORMAT"], button.initialMemory/1024);
 		local sessionTime = time() - button.startSessionTime;
@@ -425,7 +423,7 @@ function TitanPanelPerformanceButton_SetTooltip()
 		GameTooltip:AddDoubleLine(L["TITAN_MEMORY_TOOLTIP_CURRENT_MEMORY"], TitanUtils_GetHighlightText(memoryText));
 		GameTooltip:AddDoubleLine(L["TITAN_MEMORY_TOOLTIP_INITIAL_MEMORY"], TitanUtils_GetHighlightText(initialMemoryText));
 		GameTooltip:AddDoubleLine(L["TITAN_MEMORY_TOOLTIP_INCREASING_RATE"], rateRichText);
---	end
+	end

 	if ( showAddonMemory == 1 ) then
 		for _,i in pairs(topAddOns) do
@@ -603,7 +601,6 @@ function TitanPanelRightClickMenu_PreparePerformanceMenu()
 	TitanPanelRightClickMenu_AddToggleIcon(TITAN_PERFORMANCE_ID);
 	TitanPanelRightClickMenu_AddToggleLabelText(TITAN_PERFORMANCE_ID);
 	TitanPanelRightClickMenu_AddToggleColoredText(TITAN_PERFORMANCE_ID);
-	TitanPanelRightClickMenu_AddToggleRightSide(TITAN_PERFORMANCE_ID);
 	TitanPanelRightClickMenu_AddSpacer();
 	TitanPanelRightClickMenu_AddCommand(L["TITAN_PANEL_MENU_HIDE"], TITAN_PERFORMANCE_ID, TITAN_PANEL_MENU_FUNC_HIDE);
 end
@@ -621,7 +618,7 @@ function TitanPanelPerformanceButton_UpdateData()
 	local showAddonMemory = TitanGetVar(TITAN_PERFORMANCE_ID, "ShowAddonMemory");

 	-- FPS Data
---	if ( showFPS ) then
+	if ( showFPS ) then
 		button.fps = GetFramerate();
 		button.fpsSampleCount = button.fpsSampleCount + 1;
 		if (button.fpsSampleCount == 1) then
@@ -636,13 +633,13 @@ function TitanPanelPerformanceButton_UpdateData()
 			end
 			button.avgFPS = (button.avgFPS * (button.fpsSampleCount - 1) + button.fps) / button.fpsSampleCount;
 		end
---	end
+	end

 	-- Latency Data
---	if ( showLatency or showWorldLatency ) then
+	if ( showLatency or showWorldLatency ) then
 		-- bandwidthIn, bandwidthOut, latencyHome, latencyWorld = GetNetStats();
 		button.bandwidthIn, button.bandwidthOut, button.latencyHome, button.latencyWorld = GetNetStats();
---	end
+	end

 	-- Memory data
 	if ( showMemory ) or (showAddonMemory == 1) then
@@ -727,7 +724,7 @@ function TitanPanelPerfControlSlider_OnShow(self)
 	self:SetValueStep(1);
 	self:SetValue(CalcAppNum(TitanGetVar(TITAN_PERFORMANCE_ID, "NumOfAddons")));
 --	self:SetValue((TitanGetVar(TITAN_PERFORMANCE_ID, "NumOfAddons")));
-	TitanPanelPerfControlFrame:SetBackdropColor(0, 0, 0, 1)
+--	TitanPanelPerfControlFrame:SetBackdropColor(0, 0, 0, 1)

 	local scale = _G[drop_down.."1"]:GetScale()
 	local drop_arrow = drop_down.."2Button4ExpandArrow"
@@ -798,16 +795,7 @@ end
 -- **************************************************************************
 function TitanPanelPerfControlFrame_OnLoad(self)
 	_G[self:GetName().."Title"]:SetText(L["TITAN_PERFORMANCE_CONTROL_TITLE"]);
-	self:SetBackdrop({
-		bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark",
-		edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
-		tile = true,
-		tileSize = 32,
-		edgeSize = 32,
-		insets = { left = 11, right = 12, top = 12, bottom = 9, },
-	})
-	self:SetBackdropBorderColor(1, 1, 1);
-	self:SetBackdropColor(0, 0, 0, 1);
+	TitanPanelRightClickMenu_SetCustomBackdrop(self)
 end

 -- **************************************************************************
diff --git a/TitanClassicVolume/TitanClassicVolume.lua b/TitanClassicVolume/TitanClassicVolume.lua
index 394b3b0..e3a7ce8 100644
--- a/TitanClassicVolume/TitanClassicVolume.lua
+++ b/TitanClassicVolume/TitanClassicVolume.lua
@@ -357,16 +357,7 @@ function TitanPanelVolumeControlFrame_OnLoad(self)
 	_G[self:GetName().."DialogTitle"]:SetText(L["TITAN_VOLUME_DIALOG_CONTROL_TITLE"]);
 --	_G[self:GetName().."MicrophoneTitle"]:SetText(L["TITAN_VOLUME_MICROPHONE_CONTROL_TITLE"]);
 --	_G[self:GetName().."SpeakerTitle"]:SetText(L["TITAN_VOLUME_SPEAKER_CONTROL_TITLE"]);
-	self:SetBackdrop({
-		bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background-Dark",
-		edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
-		tile = true,
-		tileSize = 32,
-		edgeSize = 32,
-		insets = { left = 11, right = 12, top = 12, bottom = 9, },
-	})
-	self:SetBackdropBorderColor(1, 1, 1);
-	self:SetBackdropColor(0, 0, 0, 1);
+	TitanPanelRightClickMenu_SetCustomBackdrop(self)
 end

 function TitanPanelVolumeControlFrame_OnUpdate(self, elapsed)