diff --git a/Titan/Titan.lua b/Titan/Titan.lua index 344d9f8..3530c98 100644 --- a/Titan/Titan.lua +++ b/Titan/Titan.lua @@ -711,7 +711,7 @@ local function handle_reset_cmds(cmd_list) elseif p1 == "panelscale" then if not InCombatLockdown() then TitanPanelSetVar("Scale", 1); - TitanPanel_InitPanelBarButton() + TitanPanel_InitPanelBarButton("/panelscale reset ") TitanPrint(L["TITAN_PANEL_SLASH_RESP3"], "info") else TitanPrint(L["TITAN_PANEL_MENU_IN_COMBAT_LOCKDOWN"], "warning") @@ -1282,6 +1282,7 @@ function TitanPanelBarButton_Show(frame) if display and TitanBarData[frame].name then local x, y, w = TitanVariables_GetBarPos(frame) + local tscale = TitanPanelGetVar("Scale") local show = TitanBarData[frame].show local bott = TitanBarData[frame].bott @@ -1313,9 +1314,10 @@ print(">>" --]===] if TitanBarData[frame].user_move then display:SetPoint(show.pt, show.rel_fr, show.rel_pt, x, y) + display:SetSize(w, TITAN_PANEL_BAR_HEIGHT) else display:SetPoint(show.pt, show.rel_fr, show.rel_pt, x, y) - local h = TITAN_PANEL_BAR_HEIGHT -- / UIParent:GetEffectiveScale() -- adjust scale so it is full height + local h = TITAN_PANEL_BAR_HEIGHT display:SetPoint(bott.pt, bott.rel_fr, bott.rel_pt, x, y - h) end TitanPanel_SetBarTexture(frame) @@ -2233,6 +2235,8 @@ local function CheckBarBounds(self, width) -- Assume all ok :) x_off = l_off y_off = b_off + result.ok = true + result.err = "" local show_errs = false if (width == 0) then -- drag and drop @@ -2250,11 +2254,15 @@ local show_errs = false err = "Off right side of screen, leaving on the edge." res = "Off R" end - if show_errs and err ~= "" then - TitanPrint(locale_name.." "..err.."!!!!" + if err ~= "" then + result.ok = false + result.err = err + if show_errs then + TitanPrint(locale_name.." "..err.."!!!!" .." ["..tostring(format("%0.1f", x_off)).."]" .." ["..tostring(format("%0.1f", y_off)).."]" , "warning") + end end err = "" if (t_off) > screen_top then @@ -2267,17 +2275,20 @@ local show_errs = false err = "Off bottom of screen, leaving on the edge." res = "Off B" end - if show_errs and err ~= "" then - TitanPrint(locale_name.." "..err.."!!!!" + if err ~= "" then + result.ok = false + result.err = result.err.."\n"..err + if show_errs then + TitanPrint(locale_name.." "..err.."!!!!" .." ["..tostring(format("%0.1f", x_off)).."]" .." ["..tostring(format("%0.1f", y_off)).."]" , "warning") + end end else -- width change local min_w, min_h, max_w, max_h = self:GetResizeBounds() -- Keep the X and Y w_new = orig_w + width - if w_new < min_w then -- do nothing - too small w_off = min_w @@ -2312,13 +2323,6 @@ local show_errs = false -- Controlled with anchor points; cannot move so no check is needed end - if err == "" then - -- all is good - result.ok = true - else - result.ok = false - end - return result end @@ -2364,10 +2368,12 @@ local function OnMovingStop(self) local res = CheckBarBounds(self, 0) if res.ok then + -- placement ok else + -- Need to 'snap' it to an edge + TitanPanel_InitPanelBarButton("OnMovingStop") end -- Seems overkill - this will recalc all bars... - TitanPanel_InitPanelBarButton("OnMovingStop") end --[[ local @@ -2383,7 +2389,13 @@ NOTE: local function OnMouseWheel(self, d) if IsShiftKeyDown() then local old_w = self:GetWidth() - local res = CheckBarBounds(self, d) + local delta = d + if IsControlKeyDown() then + delta = d * 10 + else + -- use 1 + end + local res = CheckBarBounds(self, delta) if res.ok then end --[[ @@ -2395,8 +2407,7 @@ print("wheel" .." ok: "..tostring(res.ok).."" ) --]] - -- Seems overkill - this will recalc all bars but recalc of textures could be needed... - TitanPanel_InitPanelBarButton("OnMouseWheel") +-- TitanPanel_InitPanelBarButton("OnMouseWheel") end end @@ -2512,7 +2523,7 @@ print("_Create hide bar" hide_bar:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) hide_bar:SetFrameStrata("BACKGROUND") - hide_bar:SetSize(screen.x / tscale, TITAN_PANEL_BAR_HEIGHT) + hide_bar:SetSize(screen.x, TITAN_PANEL_BAR_HEIGHT) else -- Not allowed for this bar end diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index 3eb9a77..99b2dec 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -604,7 +604,8 @@ local optionsUIScale = { get = function() return TitanPanelGetVar("Scale") end, set = function(_, a) TitanPanelSetVar("Scale", a) - TitanPanel_InitPanelBarButton("Config scale change "..a) + TitanPanel_SetScale() + --TitanPanel_InitPanelBarButton("Config scale change "..a) end, disabled = function() if InCombatLockdown() then @@ -1066,8 +1067,9 @@ help_text = "" .."- Short bars are independent. They may be used with or without the full width Titan bars.\n" .."- Enable and change options using Configuration > Bars.\n" .."- The default position is the top center under the full width bars. They will be stacked to not overlap.\n" - .."- Move : Use Alt + left mouse and dragging.\n" - .."- Change width : Use Alt + mouse wheel.\n" + .."- Move : Use Shift + left mouse and dragging.\n" + .."- Change width by 1 : Use Shift + mouse wheel.\n" + .."- Change width by 10: Use Shift + Ctrl + mouse wheel.\n" .."- When dragging, best to place your mouse over the left side padding before moving or changing width.\n" .."- When stop dragging, if the Short Bar is beyond the scrren the Short Bar should 'snap' to the edge.\n" .."- Skin : Can select Skin per Short bar BUT only the 'top' skin is used; some skins have a different top & bottom.\n" @@ -1422,12 +1424,13 @@ print("Color new:" name = BATTLEGROUND.." / "..ARENA, }, setarenauseglobal = { - name = HIDE, + name = HIDE.." "..L["TITAN_PANEL_MENU_TOP_BARS"] + .." - "..BATTLEGROUND.." / "..ARENA , desc = "Hide" .." "..TitanBarData[TitanVariables_GetFrameName("Bar")].locale_name .." and" .." "..TitanBarData[TitanVariables_GetFrameName("Bar2")].locale_name - .." in Battleground or Arena", + .." in "..BATTLEGROUND.." / "..ARENA, order = 205, type = "toggle", width = "full", get = function() return TitanPanelGetVar("HideBarsInPVP") end, set = function() diff --git a/Titan/TitanTemplate.lua b/Titan/TitanTemplate.lua index 3021b6d..a98a186 100644 --- a/Titan/TitanTemplate.lua +++ b/Titan/TitanTemplate.lua @@ -59,278 +59,6 @@ local _G = getfenv(0); local InCombatLockdown = _G.InCombatLockdown; local media = LibStub("LibSharedMedia-3.0") --- ---========================== --- Routines to handle moving and sizing of short bars --- - -local function CheckBarBounds(self, width) - local result = {} - local err = "" - local res = "" - - local f_name = self:GetName() - local bar_name = TitanBarData[f_name].name - local locale_name = TitanBarData[f_name].locale_name - local escale = UIParent:GetEffectiveScale() - - if TitanBarData[f_name].user_move - and TitanBarDataVars[f_name].show - then - local tscale = TitanPanelGetVar("Scale") --- local tscale = self:GetEffectiveScale() - local screen = TitanUtils_ScreenSize() - local screen_right_scaled = screen.scaled_x - local screen_top_scaled = screen.scaled_y - local screen_right = screen.x - local screen_top = screen.y ---[===[ -print("CheckBounds" -.." '"..tostring(bar_name).."'" -.." "..(width == 0 and "drag" or "width").."" -.." T "..tostring(format("%0.3f", tscale)).."" -.." UI "..tostring(format("%0.3f", UIParent:GetEffectiveScale())).."" -.."\n ["..tostring(format("%0.1f", screen_right_scaled)).."" -.." X "..tostring(format("%0.1f", screen_top_scaled)).."]" -.." u["..tostring(format("%0.1f", screen_right)).."" -.." X "..tostring(format("%0.1f", screen_top)).."]" -) ---]===] - -- Assumes BOTTOMLEFT of screen per Short bar defaults. - -- Top and right adjust an addition pixel, - -- if resolution is not 'pixel perfect' rounding could cause algorithm to think bar is off screen - - --- Back out the Titan scaling to get 'real' position within unscaled WoW window - -- Use floor to trunc decimal places where the side could be right on the edge of the screen. - local orig_w = self:GetWidth() - local l_off = math.floor(self:GetLeft() * tscale) - local r_off = math.floor(self:GetRight() * tscale) - local t_off = math.floor(self:GetTop() * tscale) - local b_off = math.floor(self:GetBottom() * tscale) - - local w = 0 - local x_off = 0 - local y_off = 0 - local w_off = 0 - - -- Assume all ok :) - x_off = l_off - y_off = b_off - -local show_errs = false - if (width == 0) then -- drag and drop - -- Keep the width - w_off = orig_w - res = "Ok" ---[===[ -print(">>CheckBounds" -.." '"..tostring(bar_name).."'" -.." L "..tostring(format("%0.1f", l_off)).."" -.." R "..tostring(format("%0.1f", r_off)).."" -.." T "..tostring(format("%0.1f", t_off)).."" -.." B "..tostring(format("%0.1f", b_off)).."" -.." W "..tostring(format("%0.1f", w_off)).."" -.."\n Tsdiff "..tostring(format("%0.3f", (screen_top - (t_off)))).."" -.." Rsdiff "..tostring(format("%0.3f", (screen_right - (r_off)))).."" -) ---TitanUtils_ScreenSize(true) ---]===] - if l_off < 0 then - x_off = 0 - err = "Off left of screen, leaving on the edge." - res = "Off L" - elseif (r_off) > screen_right then --- x_off = math.floor(l_off - math.abs((r_off - screen_right))) - x_off = math.floor(screen_right - (r_off - l_off)) - err = "Off right side of screen, leaving on the edge." - res = "Off R" - end - if show_errs and err ~= "" then - TitanPrint(locale_name.." "..err.."!!!!" - .." ["..tostring(format("%0.1f", x_off)).."]" - .." ["..tostring(format("%0.1f", y_off)).."]" - , "warning") - end - err = "" - if (t_off) > screen_top then --- y_off = math.floor(b_off - ((t_off) - screen_top)) - y_off = math.floor(screen_top - (t_off - b_off)) - err = "Off top of screen, leaving on the edge." - res = "Off T" - elseif b_off < 0 then - y_off = 0 - err = "Off bottom of screen, leaving on the edge." - res = "Off B" - end - if show_errs and err ~= "" then - TitanPrint(locale_name.." "..err.."!!!!" - .." ["..tostring(format("%0.1f", x_off)).."]" - .." ["..tostring(format("%0.1f", y_off)).."]" - , "warning") - end - else -- width change - local min_w, min_h, max_w, max_h = self:GetResizeBounds() - -- Keep the X and Y - w_new = orig_w + width - - if w_new < min_w then - -- do nothing - too small - w_off = min_w - err = "Width too small. Set to min width." - res = "Too small" - elseif w_new > max_w then - w_off = max_w - err = "Width too big. Set to max width." -- too wide - res = "Too big" - elseif x_off + w_new > screen_right then - w_off = orig_w - err = "Off right of screen, leaving on the edge." - res = "Off R" - else - w_off = w_new - res = "Ok" - end ---[===[ -print(">>CheckBounds" -.." '"..tostring(bar_name).."'" -.." L "..tostring(format("%0.1f", l_off)).."" -.." B "..tostring(format("%0.1f", b_off)).."" -.." oW "..tostring(format("%0.1f", orig_w)).."" -.." nw "..tostring(format("%0.1f", w_new)).."" -.." => "..tostring(format("%0.1f", w_off)).."" -.."\n min "..tostring(format("%0.1f", min_w)).."" -.." max "..tostring(format("%0.1f", max_w)).."" -) ---]===] - self:SetSize(w_off, TITAN_PANEL_BAR_HEIGHT) --- self:SetWidth(w_off) - if show_errs and err ~= "" then - TitanPrint(locale_name.." "..err.."!!!!" - .." ["..tostring(format("%0.1f", orig_w)).."]" - .." ["..tostring(format("%0.1f", w_off)).."]" - , "warning") - end - end - ---[===[ -print(">>CheckBounds" -.." '"..tostring(bar_name).."'" -.." '"..tostring(res).."'" -.."\n" -.." x "..tostring(format("%0.1f", l_off)).."" -.." => "..tostring(format("%0.1f", x_off)).."" -.."\n" -.." y "..tostring(format("%0.1f", b_off)).."" -.." => "..tostring(format("%0.1f", y_off)).."" ---.."\n" ---.." w "..tostring(format("%0.1f", orig_w)).."" ---.." + "..tostring(format("%0.1f", width)).."" ---.." = "..tostring(format("%0.1f", w_off)).."" ---.."\n" ---.." s "..tostring(format("%0.1f", screen_right_scaled)).."w" ---.." x "..tostring(format("%0.1f", screen_top_scaled)).."h" -) ---]===] - - -- Offsets are saved in without scale - TitanVariables_SetBarPos(self, false, x_off, y_off, w_off) - else - -- Controlled with anchor points; cannot move so no check is needed - end - - if err == "" then - -- all is good - result.ok = true - else - result.ok = false - end - ---[[ -print("CheckBounds" -.." '"..tostring(locale_name).."'" -.." w "..tostring(format("%0.1f", orig_w)).."" -.." + "..tostring(format("%0.1f", w)).."" -.." = "..tostring(format("%0.1f", self:GetWidth())).."" -) -print(">>" -.." x "..tostring(format("%0.1f", x_off)).."" -.." => "..tostring(format("%0.1f", result.x)).."" -) -print(">>" -.." y "..tostring(format("%0.1f", y_off)).."" -.." => "..tostring(format("%0.1f", result.y)).."" -) -print(">>" -.." w "..tostring(format("%0.1f", self:GetWidth())).."" -.." s "..tostring(format("%0.1f", screen_edge)).."" -) ---]] - return result -end - -local function OnMoveStart(self) - if IsShiftKeyDown() then - if self:IsMovable() then - self.isMoving = true ---[[ -print("OnMoveStart" -.." "..tostring(self:GetName()).."" -.." "..tostring(IsShiftKeyDown()).."" -.." "..tostring(IsAltKeyDown()).."" -.."\n" -.." x "..tostring(format("%0.1f", self:GetLeft())).."" -.." y "..tostring(format("%0.1f", self:GetTop())).."" -) ---]] - self:StartMoving() - _G.GameTooltip:Hide() - end - else - -- Do not move - end -end - -local function OnMovingStop(self) - - self:StopMovingOrSizing() - self.isMoving = nil - - local res = CheckBarBounds(self, 0) ---[[ -print("OnMovingStop" -.." "..tostring(self:GetName()).."" -.." x: "..tostring(res.x).."" -.." y: "..tostring(res.y).."" -.." ok: "..tostring(res.ok).."" -) ---]] - if res.ok then - else - end - -- Seems overkill - this will recalc all bars... - TitanPanel_InitPanelBarButton("OnMovingStop") -end - -local function OnMouseWheel(self, d) - if IsShiftKeyDown() then - local old_w = self:GetWidth() - local res = CheckBarBounds(self, d) - if res.ok then - end ---[[ -print("wheel" -.." "..tostring(self:GetName()).."" -.." "..tostring(d).."" -.." old: "..tostring(format("%0.1f", old_w)).."" -.." new: "..tostring(format("%0.1f", self:GetWidth())).."" -.." ok: "..tostring(res.ok).."" -) ---]] - -- Seems overkill - this will recalc all bars but recalc of textures could be needed... - TitanPanel_InitPanelBarButton("OnMouseWheel") - end -end - --========================== --[[ local @@ -1459,122 +1187,3 @@ function TitanOptionsSliderTemplate_OnLoad(self) edgeSize = 8, }) end - ---[[ Titan -NAME: TitanPanel_InitPanelBarButton -DESC: Set the scale, texture (graphic), and transparancy of all the Titan bars based on the user selection. -VAR: None -OUT: None ---]] -function TitanPanel_InitPanelBarButton() - -- Set initial Panel Scale - TitanPanel_SetScale(); - - for idx,v in pairs (TitanBarData) do - CheckBarBounds(_G[idx], 0) - TitanPanel_SetBarTexture(idx) - end - - TitanPanelBarButton_DisplayBarsWanted("InitPanelBarButton") -end - --- ---========================== --- Routines to handle creation of Titan bars --- ---[[ Titan -NAME: TitanPanelButton_CreateBar(frame_str) -DESC: Create a Titan bar that can show plugins. -VAR: frame_str - name of the frame -NOTE: -- This assumes ... -:NOTE ---]] -function TitanPanelButton_CreateBar(frame_str) - local this_bar = frame_str - local a_bar = CreateFrame("Button", this_bar, UIParent, "Titan_Bar__Display_Template") - - local bar_data = TitanBarData[this_bar] - - -- ====== - -- Scripts - a_bar:SetScript("OnEnter", function(self) TitanPanelBarButton_OnEnter(self) end) - a_bar:SetScript("OnLeave", function(self) TitanPanelBarButton_OnLeave(self) end) - a_bar:SetFrameStrata("DIALOG") - - local x, y, w = TitanVariables_GetBarPos(frame_str) - local tscale = TitanPanelGetVar("Scale") ---[[ -print("_Create bar" -.." "..tostring(bar_data.name).."" -.."\n " -.." "..tostring(bar_data.name).."" -.." "..tostring(bar_data.show.pt).."" -.." "..tostring(bar_data.show.rel_fr).."" -.." "..tostring(bar_data.show.rel_pt).."" -.."\n " -.." "..tostring(bar_data.name).."" -.." "..tostring(format("%0.1f", x)).."" -.." "..tostring(format("%0.1f", y)).."" -.." "..tostring(format("%0.1f", w)).."" -) ---]] - if bar_data.user_move then - a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y) - a_bar:SetMovable(true) - a_bar:SetResizable(true) - a_bar:EnableMouse(true) - a_bar:RegisterForDrag("LeftButton") - a_bar:SetScript("OnDragStart", OnMoveStart) - a_bar:SetScript("OnDragStop", OnMovingStop) - a_bar:SetScript("OnMouseWheel", OnMouseWheel) - a_bar:SetSize(w / tscale, TITAN_PANEL_BAR_HEIGHT) - else - -- Static full width bar - a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y) - a_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, y - TITAN_PANEL_BAR_HEIGHT) - end - - -- ====== - -- Bounds only effective on Short bars for now - -- Min : No smaller than the padding & one icon - -- Max : No wider than the screen - -- does not seem to work to restrict size automatically... - local screen = TitanUtils_ScreenSize() - a_bar:SetResizeBounds(TitanBarData[this_bar].plugin_x_offset + 16, TITAN_PANEL_BAR_HEIGHT, screen.x, TITAN_PANEL_BAR_HEIGHT) - - a_bar:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - a_bar:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) - - -- ====== - -- Frame for right clicks - f = CreateFrame("Frame", this_bar..TITAN_PANEL_CLICK_MENU_SUFFIX, UIParent, "UIDropDownMenuTemplate") - - -- ====== - -- Hider for auto hide feature - local hide_bar_name = TITAN_PANEL_HIDE_PREFIX..bar_data.name - if bar_data.hider then ---[[ -print("_Create hide bar" -.." "..tostring(bar_data.name).."" -.." "..tostring(hide_bar_name).."" -) ---]] - - local hide_bar = CreateFrame("Button", hide_bar_name, UIParent, "TitanPanelBarButtonHiderTemplate") - hide_bar:SetFrameStrata("DIALOG") - hide_bar:SetPoint(bar_data.show.pt, bar_data.show.rel_fr, bar_data.show.rel_pt, x, -y) - - -- Set script handlers for display - hide_bar:RegisterForClicks("LeftButtonUp", "RightButtonUp"); - hide_bar:SetScript("OnEnter", function(self) TitanPanelBarButtonHider_OnEnter(self) end) - hide_bar:SetScript("OnLeave", function(self) TitanPanelBarButtonHider_OnLeave(self) end) - hide_bar:SetScript("OnClick", function(self, button) TitanPanelBarButton_OnClick(self, button) end) - - hide_bar:SetFrameStrata("BACKGROUND") - hide_bar:SetSize(screen.x / tscale, TITAN_PANEL_BAR_HEIGHT) - else - -- Not allowed for this bar - end -end - diff --git a/Titan/TitanVariables.lua b/Titan/TitanVariables.lua index cad06b5..1162f2f 100644 --- a/Titan/TitanVariables.lua +++ b/Titan/TitanVariables.lua @@ -971,15 +971,12 @@ NOTE: function TitanVariables_SetBarPos(self, reset, x_off, y_off, w_off) -- Collect bar x & y and save so bar stays put. local bar_frame = self:GetName() --- local off_x = self:GetLeft() --- local off_y = self:GetBottom() --- local width = self:GetWidth() local force_reset = reset or false if TitanBarDataVars[bar_frame] then if reset then - -- Initial defaults calc on screen and scaling at that time - it could have changed! + -- Initial defaults calc to screen size and scaling at that time - it could have changed! TitanBarDataVars[bar_frame].off_x = Calc_X() TitanBarDataVars[bar_frame].off_y = Calc_Y(TitanBarData[bar_frame].order-2) TitanBarDataVars[bar_frame].off_w = SHORT_WIDTH @@ -1016,8 +1013,8 @@ print("_GetBarPos" ) --]] return - TitanBarDataVars[frame_str].off_x / tscale, - TitanBarDataVars[frame_str].off_y / tscale, + TitanBarDataVars[frame_str].off_x, -- / tscale, + TitanBarDataVars[frame_str].off_y, -- / tscale, TitanBarDataVars[frame_str].off_w -- / tscale end