annotate Frames.lua @ 141:5ed50feddeb0

Fixed sorting of all frames.
author Zerotorescue
date Tue, 18 Jan 2011 22:59:16 +0100
parents 8460855e3d90
children 12a8ea5af671
rev   line source
Zerotorescue@101 1 local addon = select(2, ...);
Zerotorescue@101 2
Zerotorescue@101 3 local function ShowTooltip(self)
Zerotorescue@101 4 -- If this function is called from a widget, self is the widget and self.frame the actual frame
Zerotorescue@101 5 local this = self.frame or self;
Zerotorescue@101 6
Zerotorescue@132 7 if not this.tooltipTitle or addon.db.profile.defaults.hideHelp then return; end
Zerotorescue@106 8
Zerotorescue@101 9 GameTooltip:SetOwner(this, "ANCHOR_NONE");
Zerotorescue@104 10 if this.tooltipLocation and this.tooltipLocation == "BOTTOM" then
Zerotorescue@104 11 GameTooltip:SetPoint("TOP", this, "BOTTOM");
Zerotorescue@101 12 else
Zerotorescue@101 13 GameTooltip:SetPoint("BOTTOM", this, "TOP");
Zerotorescue@101 14 end
Zerotorescue@101 15 GameTooltip:SetText(this.tooltipTitle, 1, .82, 0, 1);
Zerotorescue@101 16
Zerotorescue@101 17 if type(this.tooltip) == "string" then
Zerotorescue@101 18 GameTooltip:AddLine(this.tooltip, 1, 1, 1, 1);
Zerotorescue@101 19 end
Zerotorescue@101 20
Zerotorescue@101 21 GameTooltip:Show();
Zerotorescue@101 22 end
Zerotorescue@101 23
Zerotorescue@101 24 local function HideTooltip()
Zerotorescue@101 25 GameTooltip:Hide();
Zerotorescue@101 26 end
Zerotorescue@101 27
Zerotorescue@110 28 function addon:CreateMoverFrame()
Zerotorescue@132 29 if InventoriumItemMover then
Zerotorescue@132 30 return;
Zerotorescue@132 31 end
Zerotorescue@132 32
Zerotorescue@101 33 local frameWidth = 400;
Zerotorescue@101 34
Zerotorescue@101 35 -- Main window
Zerotorescue@101 36 local frame = CreateFrame("Frame", "InventoriumItemMover", UIParent);
Zerotorescue@101 37 -- Hide by default
Zerotorescue@101 38 frame:Hide();
Zerotorescue@101 39 -- Center the frame (will be adjusted later)
Zerotorescue@101 40 frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
Zerotorescue@101 41 -- Put in front of other windows
Zerotorescue@101 42 frame:SetFrameStrata("FULLSCREEN_DIALOG");
Zerotorescue@101 43 frame:SetToplevel(true);
Zerotorescue@101 44 -- Give it a size
Zerotorescue@101 45 frame:SetWidth(frameWidth);
Zerotorescue@101 46 frame:SetHeight(175);
Zerotorescue@101 47 -- Background
Zerotorescue@101 48 frame:SetBackdrop({
Zerotorescue@101 49 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
Zerotorescue@101 50 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
Zerotorescue@104 51 edgeSize = 20,
Zerotorescue@101 52 insets = {
Zerotorescue@101 53 left = 5,
Zerotorescue@101 54 right = 5,
Zerotorescue@101 55 top = 5,
Zerotorescue@101 56 bottom = 5,
Zerotorescue@101 57 },
Zerotorescue@101 58 });
Zerotorescue@101 59 frame:SetBackdropColor(0, 0, 0, .8);
Zerotorescue@101 60 -- Mouse functions
Zerotorescue@101 61 frame:EnableMouse();
Zerotorescue@101 62 frame:SetMovable(true);
Zerotorescue@101 63 frame:SetResizable(true);
Zerotorescue@101 64 frame:SetMinResize(300, 175);
Zerotorescue@101 65 -- Set event handlers
Zerotorescue@101 66 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end);
Zerotorescue@101 67 frame:SetScript("OnShow", function(this)
Zerotorescue@104 68 if not tContains(StaticPopup_DisplayedFrames, this) then
Zerotorescue@104 69 -- We wish to display our box at a similar position as the default interface's static popups, so we literally copied the code for these popups
Zerotorescue@104 70 local lastFrame = StaticPopup_DisplayedFrames[#StaticPopup_DisplayedFrames];
Zerotorescue@104 71 if lastFrame then
Zerotorescue@104 72 this:SetPoint("TOP", lastFrame, "BOTTOM", 0, 0);
Zerotorescue@104 73 else
Zerotorescue@104 74 this:SetPoint("TOP", UIParent, "TOP", 0, -135);
Zerotorescue@104 75 end
Zerotorescue@104 76
Zerotorescue@104 77 -- Position other static popups below this
Zerotorescue@104 78 tinsert(StaticPopup_DisplayedFrames, this);
Zerotorescue@101 79 end
Zerotorescue@101 80
Zerotorescue@101 81 this:AdjustScrollTableRows();
Zerotorescue@101 82
Zerotorescue@101 83 PlaySound("OrcExploration");
Zerotorescue@101 84 end);
Zerotorescue@110 85 frame:SetScript("OnHide", function(this)
Zerotorescue@110 86 StaticPopup_CollapseTable(this);
Zerotorescue@110 87 end);
Zerotorescue@101 88
Zerotorescue@101 89 -- Title (AceGUI frame-widget-title used as example)
Zerotorescue@101 90 local titleBackground = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@101 91 titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@101 92 titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63);
Zerotorescue@101 93 titleBackground:SetPoint("TOP", 0, 12);
Zerotorescue@101 94 titleBackground:SetWidth(150);
Zerotorescue@101 95 titleBackground:SetHeight(40);
Zerotorescue@119 96
Zerotorescue@119 97 frame.titleBackground = titleBackground;
Zerotorescue@119 98
Zerotorescue@101 99 local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@101 100 titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@101 101 titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63);
Zerotorescue@101 102 titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT");
Zerotorescue@101 103 titleBackgroundLeft:SetWidth(30);
Zerotorescue@101 104 titleBackgroundLeft:SetHeight(40);
Zerotorescue@101 105
Zerotorescue@101 106 local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@101 107 titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@101 108 titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63);
Zerotorescue@101 109 titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT");
Zerotorescue@101 110 titleBackgroundRight:SetWidth(30);
Zerotorescue@101 111 titleBackgroundRight:SetHeight(40);
Zerotorescue@101 112
Zerotorescue@101 113 local frmTitle = CreateFrame("Frame", nil, frame);
Zerotorescue@101 114 frmTitle:EnableMouse(true);
Zerotorescue@101 115 frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end);
Zerotorescue@101 116 frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end);
Zerotorescue@101 117 frmTitle:SetAllPoints(titleBackground);
Zerotorescue@101 118
Zerotorescue@101 119 local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@101 120 lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14);
Zerotorescue@110 121
Zerotorescue@110 122 frame.lblTitle = lblTitle;
Zerotorescue@101 123
Zerotorescue@101 124 -- Resizer (vertical only)
Zerotorescue@101 125 local frmResizer = CreateFrame("Frame", nil, frame);
Zerotorescue@101 126 frmResizer:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 0, -10);
Zerotorescue@101 127 frmResizer:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, -10);
Zerotorescue@101 128 frmResizer:SetHeight(20);
Zerotorescue@101 129 frmResizer:EnableMouse();
Zerotorescue@101 130 frmResizer:SetScript("OnMouseDown", function(this) this:GetParent():StartSizing("BOTTOM"); end);
Zerotorescue@101 131 frmResizer:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end);
Zerotorescue@101 132
Zerotorescue@101 133 -- Description
Zerotorescue@101 134 local lblDescription = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@106 135 lblDescription:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -27);
Zerotorescue@104 136 lblDescription:SetWidth(frameWidth - 15 - 15); -- 10 margin left & 10 margin right
Zerotorescue@101 137 lblDescription:SetJustifyH("LEFT");
Zerotorescue@101 138 lblDescription:SetJustifyV("TOP");
Zerotorescue@101 139
Zerotorescue@101 140 frame.lblDescription = lblDescription;
Zerotorescue@101 141
Zerotorescue@101 142 -- Buttons
Zerotorescue@132 143 -- Proceed
Zerotorescue@132 144 local btnProceed = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate");
Zerotorescue@132 145 btnProceed:SetHeight(21);
Zerotorescue@132 146 btnProceed:SetWidth(125);
Zerotorescue@132 147 btnProceed:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11);
Zerotorescue@132 148 btnProceed:SetScript("OnClick", function(this) this.OnClick(this); end);
Zerotorescue@132 149 btnProceed:SetScript("OnEnter", ShowTooltip);
Zerotorescue@132 150 btnProceed:SetScript("OnLeave", HideTooltip);
Zerotorescue@101 151
Zerotorescue@132 152 frame.btnProceed = btnProceed;
Zerotorescue@101 153
Zerotorescue@101 154 -- Cancel
Zerotorescue@101 155 local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate");
Zerotorescue@101 156 btnCancel:SetHeight(21);
Zerotorescue@101 157 btnCancel:SetWidth(125);
Zerotorescue@104 158 btnCancel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 11);
Zerotorescue@110 159 btnCancel:SetScript("OnClick", function(this) this.OnClick(this); end);
Zerotorescue@101 160 btnCancel:SetScript("OnEnter", ShowTooltip);
Zerotorescue@101 161 btnCancel:SetScript("OnLeave", HideTooltip);
Zerotorescue@101 162
Zerotorescue@101 163 frame.btnCancel = btnCancel;
Zerotorescue@101 164
Zerotorescue@101 165 -- Because the scrolling table code-behind will change this element's height, we can't rely on that. Make a dummy frame which we can measure
Zerotorescue@101 166 local frmMeasureDummy = CreateFrame("Frame", nil, frame);
Zerotorescue@106 167 frmMeasureDummy:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18);
Zerotorescue@106 168 frmMeasureDummy:SetPoint("LEFT", frame, "LEFT", 15, 0);
Zerotorescue@104 169 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
Zerotorescue@101 170
Zerotorescue@101 171 frame.frmMeasureDummy = frmMeasureDummy;
Zerotorescue@101 172
Zerotorescue@101 173 -- Scrolling table with a list of items to be moved
Zerotorescue@101 174 local ScrollingTable = LibStub("ScrollingTable");
Zerotorescue@132 175 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings
Zerotorescue@132 176 scrollTable.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18);
Zerotorescue@132 177 scrollTable.frame:SetPoint("LEFT", frame, "LEFT", 15, 0);
Zerotorescue@132 178 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
Zerotorescue@106 179 -- When moving over a row, provide a tooltip for the item
Zerotorescue@132 180 scrollTable:RegisterEvents({
Zerotorescue@101 181 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@106 182 if row and realrow then
Zerotorescue@106 183 -- Data row
Zerotorescue@106 184
Zerotorescue@112 185 if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then
Zerotorescue@106 186 GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE");
Zerotorescue@106 187 GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT");
Zerotorescue@112 188 GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId));
Zerotorescue@106 189 GameTooltip:Show();
Zerotorescue@106 190 end
Zerotorescue@106 191 else
Zerotorescue@106 192 -- Header row
Zerotorescue@106 193
Zerotorescue@106 194 if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then
Zerotorescue@106 195 cellFrame.tooltipTitle = cols[column].tooltipTitle;
Zerotorescue@106 196 if cols[column].tooltip then
Zerotorescue@106 197 cellFrame.tooltip = cols[column].tooltip; -- Optional
Zerotorescue@106 198 else
Zerotorescue@106 199 cellFrame.tooltip = nil;
Zerotorescue@106 200 end
Zerotorescue@106 201
Zerotorescue@106 202 ShowTooltip(cellFrame);
Zerotorescue@106 203 end
Zerotorescue@101 204 end
Zerotorescue@101 205 end,
Zerotorescue@101 206 ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@106 207 HideTooltip();
Zerotorescue@101 208 end,
Zerotorescue@141 209 ["OnClick"] = function() end,
Zerotorescue@101 210 });
Zerotorescue@101 211
Zerotorescue@132 212 frame.scrollTable = scrollTable;
Zerotorescue@110 213
Zerotorescue@106 214 -- Change the amount of displayed rows based on the size of the frame
Zerotorescue@106 215 frame.AdjustScrollTableRows = function(this)
Zerotorescue@106 216 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15);
Zerotorescue@110 217 newRows = (newRows < 4 and 4) or newRows;
Zerotorescue@106 218
Zerotorescue@106 219 this.scrollTable:SetDisplayRows(newRows, 15);
Zerotorescue@106 220 end;
Zerotorescue@106 221 frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows);
Zerotorescue@101 222 end
Zerotorescue@101 223
Zerotorescue@101 224 function addon:SetMoverFrameData(data)
Zerotorescue@101 225 InventoriumItemMover.scrollTable:SetData(data);
Zerotorescue@101 226
Zerotorescue@101 227 InventoriumItemMover:Show();
Zerotorescue@101 228 end
Zerotorescue@110 229
Zerotorescue@132 230 function addon:SetMoverFrameSettings(title, description, proceed, cancel, headers)
Zerotorescue@110 231 local frame = InventoriumItemMover;
Zerotorescue@110 232
Zerotorescue@110 233 frame.lblTitle:SetText(title);
Zerotorescue@119 234 -- Adjust size for the title background
Zerotorescue@119 235 frame.titleBackground:SetWidth((frame.lblTitle:GetWidth() or 0) + 10); -- 10 pixels margin
Zerotorescue@110 236
Zerotorescue@110 237 frame.lblDescription:SetText(description);
Zerotorescue@110 238
Zerotorescue@132 239 frame.btnProceed:SetText(proceed.text);
Zerotorescue@132 240 frame.btnProceed.tooltipTitle = proceed.tooltipTitle;
Zerotorescue@132 241 frame.btnProceed.tooltip = proceed.tooltip;
Zerotorescue@132 242 frame.btnProceed.OnClick = proceed.onClick;
Zerotorescue@110 243
Zerotorescue@110 244 frame.btnCancel:SetText(cancel.text);
Zerotorescue@110 245 frame.btnCancel.tooltipTitle = cancel.tooltipTitle;
Zerotorescue@110 246 frame.btnCancel.tooltip = cancel.tooltip;
Zerotorescue@110 247 frame.btnCancel.OnClick = cancel.onClick;
Zerotorescue@110 248
Zerotorescue@110 249 frame.scrollTable:SetDisplayCols(headers);
Zerotorescue@110 250 end
Zerotorescue@132 251
Zerotorescue@132 252 function addon:CreateQueueFrame()
Zerotorescue@132 253 if InventoriumQueuer then
Zerotorescue@132 254 return;
Zerotorescue@132 255 end
Zerotorescue@132 256
Zerotorescue@132 257 do
Zerotorescue@132 258 local frameWidth = 400;
Zerotorescue@132 259
Zerotorescue@132 260 -- Main window
Zerotorescue@132 261 local frame = CreateFrame("Frame", "InventoriumQueuer", UIParent);
Zerotorescue@132 262 -- Hide by default
Zerotorescue@132 263 frame:Hide();
Zerotorescue@132 264 -- Center the frame (will be adjusted later)
Zerotorescue@132 265 frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0);
Zerotorescue@132 266 -- Put in front of other windows
Zerotorescue@132 267 frame:SetFrameStrata("FULLSCREEN_DIALOG");
Zerotorescue@132 268 frame:SetToplevel(true);
Zerotorescue@132 269 -- Give it a size
Zerotorescue@132 270 frame:SetWidth(frameWidth);
Zerotorescue@132 271 frame:SetHeight(430);
Zerotorescue@132 272 -- Background
Zerotorescue@132 273 frame:SetBackdrop({
Zerotorescue@132 274 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
Zerotorescue@132 275 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
Zerotorescue@132 276 edgeSize = 20,
Zerotorescue@132 277 insets = {
Zerotorescue@132 278 left = 5,
Zerotorescue@132 279 right = 5,
Zerotorescue@132 280 top = 5,
Zerotorescue@132 281 bottom = 5,
Zerotorescue@132 282 },
Zerotorescue@132 283 });
Zerotorescue@132 284 frame:SetBackdropColor(0, 0, 0, .8);
Zerotorescue@132 285 -- Mouse functions
Zerotorescue@132 286 frame:EnableMouse();
Zerotorescue@132 287 frame:SetMovable(true);
Zerotorescue@132 288 -- Set event handlers
Zerotorescue@132 289 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end);
Zerotorescue@132 290 frame:SetScript("OnShow", function(this)
Zerotorescue@132 291 this:AdjustScrollTableRows();
Zerotorescue@132 292 end);
Zerotorescue@132 293
Zerotorescue@132 294 -- Title (AceGUI frame-widget-title used as example)
Zerotorescue@132 295 local titleBackground = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 296 titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 297 titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63);
Zerotorescue@132 298 titleBackground:SetPoint("TOP", 0, 12);
Zerotorescue@132 299 titleBackground:SetWidth(150);
Zerotorescue@132 300 titleBackground:SetHeight(40);
Zerotorescue@132 301
Zerotorescue@132 302 frame.titleBackground = titleBackground;
Zerotorescue@132 303
Zerotorescue@132 304 local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 305 titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 306 titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63);
Zerotorescue@132 307 titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT");
Zerotorescue@132 308 titleBackgroundLeft:SetWidth(30);
Zerotorescue@132 309 titleBackgroundLeft:SetHeight(40);
Zerotorescue@132 310
Zerotorescue@132 311 local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 312 titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 313 titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63);
Zerotorescue@132 314 titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT");
Zerotorescue@132 315 titleBackgroundRight:SetWidth(30);
Zerotorescue@132 316 titleBackgroundRight:SetHeight(40);
Zerotorescue@132 317
Zerotorescue@132 318 local frmTitle = CreateFrame("Frame", nil, frame);
Zerotorescue@132 319 frmTitle:EnableMouse(true);
Zerotorescue@132 320 frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end);
Zerotorescue@132 321 frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end);
Zerotorescue@132 322 frmTitle:SetAllPoints(titleBackground);
Zerotorescue@132 323
Zerotorescue@132 324 local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@132 325 lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14);
Zerotorescue@132 326
Zerotorescue@132 327 frame.lblTitle = lblTitle;
Zerotorescue@132 328
Zerotorescue@132 329 -- Expand button
Zerotorescue@132 330 local btnExpander = CreateFrame("Button", "$parentExpander", frame);
Zerotorescue@132 331 btnExpander:SetWidth(32);
Zerotorescue@132 332 btnExpander:SetHeight(32);
Zerotorescue@132 333 btnExpander:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -10, -10);
Zerotorescue@132 334 btnExpander:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up");
Zerotorescue@132 335 btnExpander:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down");
Zerotorescue@132 336 btnExpander:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled");
Zerotorescue@132 337 btnExpander:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight", "ADD");
Zerotorescue@132 338 btnExpander.tooltipTitle = "Show unqueueables";
Zerotorescue@132 339 btnExpander.tooltip = "Click to show a list of all unqueueable but tracked items.";
Zerotorescue@132 340 btnExpander:SetScript("OnEnter", ShowTooltip);
Zerotorescue@132 341 btnExpander:SetScript("OnLeave", HideTooltip);
Zerotorescue@132 342 btnExpander:SetScript("OnClick", function(this)
Zerotorescue@132 343 if this.Expanded then
Zerotorescue@132 344 -- Collapsing
Zerotorescue@132 345 this.Expanded = nil;
Zerotorescue@132 346 InventoriumQueuerUnqueueables:Hide();
Zerotorescue@132 347 PlaySound("igCharacterInfoClose");
Zerotorescue@132 348
Zerotorescue@132 349 -- Next is an expand
Zerotorescue@132 350 this:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up");
Zerotorescue@132 351 this:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down");
Zerotorescue@132 352 this:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled");
Zerotorescue@132 353 else
Zerotorescue@132 354 -- Expanding
Zerotorescue@132 355 this.Expanded = true;
Zerotorescue@132 356
Zerotorescue@132 357 -- Position the frame against the queuer window
Zerotorescue@132 358 InventoriumQueuerUnqueueables:ClearAllPoints();
Zerotorescue@132 359 InventoriumQueuerUnqueueables:SetPoint("TOPLEFT", this:GetParent(), "TOPRIGHT", 0, 0);
Zerotorescue@132 360 InventoriumQueuerUnqueueables:SetPoint("BOTTOMLEFT", this:GetParent(), "BOTTOMLEFT", 0, 0);
Zerotorescue@132 361 InventoriumQueuerUnqueueables:Show();
Zerotorescue@132 362 PlaySound("igCharacterInfoOpen");
Zerotorescue@132 363
Zerotorescue@132 364 -- Next is a collapse
Zerotorescue@132 365 this:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up");
Zerotorescue@132 366 this:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Down");
Zerotorescue@132 367 this:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled");
Zerotorescue@132 368 end
Zerotorescue@132 369 end);
Zerotorescue@132 370
Zerotorescue@132 371 -- Description
Zerotorescue@132 372 local lblDescription = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@132 373 lblDescription:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -27);
Zerotorescue@132 374 lblDescription:SetPoint("RIGHT", btnExpander, "LEFT", -15, 0);
Zerotorescue@132 375 lblDescription:SetJustifyH("LEFT");
Zerotorescue@132 376 lblDescription:SetJustifyV("TOP");
Zerotorescue@132 377 lblDescription:SetWidth(frameWidth - 70);
Zerotorescue@132 378
Zerotorescue@132 379 frame.lblDescription = lblDescription;
Zerotorescue@132 380
Zerotorescue@132 381 -- Buttons
Zerotorescue@132 382 -- Proceed
Zerotorescue@132 383 local btnProceed = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate");
Zerotorescue@132 384 btnProceed:SetHeight(21);
Zerotorescue@132 385 btnProceed:SetWidth(125);
Zerotorescue@132 386 btnProceed:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11);
Zerotorescue@132 387 btnProceed:SetScript("OnClick", function(this) this.OnClick(this); end);
Zerotorescue@132 388 btnProceed:SetScript("OnEnter", ShowTooltip);
Zerotorescue@132 389 btnProceed:SetScript("OnLeave", HideTooltip);
Zerotorescue@132 390
Zerotorescue@132 391 frame.btnProceed = btnProceed;
Zerotorescue@132 392
Zerotorescue@132 393 -- Cancel
Zerotorescue@132 394 local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate");
Zerotorescue@132 395 btnCancel:SetHeight(21);
Zerotorescue@132 396 btnCancel:SetWidth(125);
Zerotorescue@132 397 btnCancel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 11);
Zerotorescue@132 398 btnCancel:SetScript("OnClick", function(this) this.OnClick(this); end);
Zerotorescue@132 399 btnCancel:SetScript("OnEnter", ShowTooltip);
Zerotorescue@132 400 btnCancel:SetScript("OnLeave", HideTooltip);
Zerotorescue@132 401
Zerotorescue@132 402 frame.btnCancel = btnCancel;
Zerotorescue@132 403
Zerotorescue@132 404 -- Because the scrolling table code-behind will change the scrolltable element's height, we can't rely on that. Make a dummy frame which we can measure
Zerotorescue@132 405 local frmMeasureDummy = CreateFrame("Frame", nil, frame);
Zerotorescue@132 406 frmMeasureDummy:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18);
Zerotorescue@132 407 frmMeasureDummy:SetPoint("LEFT", frame, "LEFT", 15, 0);
Zerotorescue@132 408 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
Zerotorescue@132 409
Zerotorescue@132 410 frame.frmMeasureDummy = frmMeasureDummy;
Zerotorescue@132 411
Zerotorescue@132 412 -- Scrolling table with a list of items to be queued
Zerotorescue@132 413 local ScrollingTable = LibStub("ScrollingTable");
Zerotorescue@132 414 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings
Zerotorescue@132 415 scrollTable.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18);
Zerotorescue@132 416 scrollTable.frame:SetPoint("LEFT", frame, "LEFT", 15, 0);
Zerotorescue@132 417 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
Zerotorescue@132 418 -- When moving over a row, provide a tooltip for the item
Zerotorescue@132 419 scrollTable:RegisterEvents({
Zerotorescue@132 420 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@132 421 if row and realrow then
Zerotorescue@132 422 -- Data row
Zerotorescue@132 423
Zerotorescue@132 424 if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then
Zerotorescue@132 425 GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE");
Zerotorescue@132 426 GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT");
Zerotorescue@132 427 GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId));
Zerotorescue@132 428 GameTooltip:Show();
Zerotorescue@132 429 end
Zerotorescue@132 430 else
Zerotorescue@132 431 -- Header row
Zerotorescue@132 432
Zerotorescue@132 433 if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then
Zerotorescue@132 434 cellFrame.tooltipTitle = cols[column].tooltipTitle;
Zerotorescue@132 435 if cols[column].tooltip then
Zerotorescue@132 436 cellFrame.tooltip = cols[column].tooltip; -- Optional
Zerotorescue@132 437 else
Zerotorescue@132 438 cellFrame.tooltip = nil;
Zerotorescue@132 439 end
Zerotorescue@132 440
Zerotorescue@132 441 ShowTooltip(cellFrame);
Zerotorescue@132 442 end
Zerotorescue@132 443 end
Zerotorescue@132 444 end,
Zerotorescue@132 445 ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@132 446 HideTooltip();
Zerotorescue@132 447 end,
Zerotorescue@141 448 ["OnClick"] = function() end,
Zerotorescue@132 449 });
Zerotorescue@132 450
Zerotorescue@132 451 frame.scrollTable = scrollTable;
Zerotorescue@132 452
Zerotorescue@132 453 -- Change the amount of displayed rows based on the size of the frame
Zerotorescue@132 454 frame.AdjustScrollTableRows = function(this)
Zerotorescue@132 455 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15);
Zerotorescue@132 456 newRows = (newRows < 4 and 4) or newRows;
Zerotorescue@132 457
Zerotorescue@132 458 this.scrollTable:SetDisplayRows(newRows, 15);
Zerotorescue@132 459 end;
Zerotorescue@132 460 frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows);
Zerotorescue@132 461 end
Zerotorescue@132 462 do
Zerotorescue@132 463 local frameWidth = 300;
Zerotorescue@132 464
Zerotorescue@132 465 -- Main window
Zerotorescue@132 466 local frame = CreateFrame("Frame", "InventoriumQueuerUnqueueables", InventoriumQueuer);
Zerotorescue@132 467 -- Hide by default
Zerotorescue@132 468 frame:Hide();
Zerotorescue@132 469 -- Position the frame against the queuer window
Zerotorescue@132 470 frame:SetPoint("TOPLEFT", InventoriumQueuer, "TOPRIGHT", 0, 0);
Zerotorescue@132 471 frame:SetPoint("BOTTOMLEFT", InventoriumQueuer, "BOTTOMLEFT", 0, 0);
Zerotorescue@132 472 -- Put in front of other windows
Zerotorescue@132 473 frame:SetFrameStrata("FULLSCREEN_DIALOG");
Zerotorescue@132 474 frame:SetToplevel(true);
Zerotorescue@132 475 -- Give it a size
Zerotorescue@132 476 frame:SetWidth(frameWidth);
Zerotorescue@132 477 -- Background
Zerotorescue@132 478 frame:SetBackdrop({
Zerotorescue@132 479 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
Zerotorescue@132 480 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
Zerotorescue@132 481 edgeSize = 20,
Zerotorescue@132 482 insets = {
Zerotorescue@132 483 left = 5,
Zerotorescue@132 484 right = 5,
Zerotorescue@132 485 top = 5,
Zerotorescue@132 486 bottom = 5,
Zerotorescue@132 487 },
Zerotorescue@132 488 });
Zerotorescue@132 489 frame:SetBackdropColor(0, 0, 0, .8);
Zerotorescue@132 490 -- Mouse functions
Zerotorescue@132 491 frame:EnableMouse();
Zerotorescue@132 492 frame:SetMovable(true);
Zerotorescue@132 493 -- Set event handlers
Zerotorescue@132 494 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end);
Zerotorescue@132 495 frame:SetScript("OnShow", function(this)
Zerotorescue@132 496 this:AdjustScrollTableRows();
Zerotorescue@132 497 end);
Zerotorescue@132 498
Zerotorescue@132 499 -- Title (AceGUI frame-widget-title used as example)
Zerotorescue@132 500 local titleBackground = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 501 titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 502 titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63);
Zerotorescue@132 503 titleBackground:SetPoint("TOP", 0, 12);
Zerotorescue@132 504 titleBackground:SetWidth(90);
Zerotorescue@132 505 titleBackground:SetHeight(40);
Zerotorescue@132 506
Zerotorescue@132 507 frame.titleBackground = titleBackground;
Zerotorescue@132 508
Zerotorescue@132 509 local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 510 titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 511 titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63);
Zerotorescue@132 512 titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT");
Zerotorescue@132 513 titleBackgroundLeft:SetWidth(30);
Zerotorescue@132 514 titleBackgroundLeft:SetHeight(40);
Zerotorescue@132 515
Zerotorescue@132 516 local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 517 titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 518 titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63);
Zerotorescue@132 519 titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT");
Zerotorescue@132 520 titleBackgroundRight:SetWidth(30);
Zerotorescue@132 521 titleBackgroundRight:SetHeight(40);
Zerotorescue@132 522
Zerotorescue@132 523 local frmTitle = CreateFrame("Frame", nil, frame);
Zerotorescue@132 524 frmTitle:EnableMouse(true);
Zerotorescue@132 525 frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end);
Zerotorescue@132 526 frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end);
Zerotorescue@132 527 frmTitle:SetAllPoints(titleBackground);
Zerotorescue@132 528
Zerotorescue@132 529 local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@132 530 lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14);
Zerotorescue@132 531 lblTitle:SetText("Unqueueables");
Zerotorescue@132 532
Zerotorescue@132 533 -- Because the scrolling table code-behind will change this element's height, we can't rely on that. Make a dummy frame which we can measure
Zerotorescue@132 534 local frmMeasureDummy = CreateFrame("Frame", nil, frame);
Zerotorescue@132 535 frmMeasureDummy:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -42);
Zerotorescue@132 536 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 15);
Zerotorescue@132 537
Zerotorescue@132 538 frame.frmMeasureDummy = frmMeasureDummy;
Zerotorescue@132 539
Zerotorescue@132 540 -- Scrolling table with a list of items to be queued
Zerotorescue@132 541 local ScrollingTable = LibStub("ScrollingTable");
Zerotorescue@132 542 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings
Zerotorescue@132 543 scrollTable.frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -42);
Zerotorescue@132 544 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 15);
Zerotorescue@132 545 -- When moving over a row, provide a tooltip for the item
Zerotorescue@132 546 scrollTable:RegisterEvents({
Zerotorescue@132 547 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@132 548 if row and realrow then
Zerotorescue@132 549 -- Data row
Zerotorescue@132 550
Zerotorescue@132 551 if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then
Zerotorescue@132 552 if column == 1 then
Zerotorescue@132 553 GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE");
Zerotorescue@132 554 GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT");
Zerotorescue@132 555 GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId));
Zerotorescue@132 556 GameTooltip:Show();
Zerotorescue@132 557 else
Zerotorescue@132 558 GameTooltip:SetOwner(cellFrame, "ANCHOR_NONE");
Zerotorescue@132 559 GameTooltip:SetPoint("TOPLEFT", cellFrame, "BOTTOMLEFT");
Zerotorescue@132 560 GameTooltip:SetText(data[realrow].rowData.reason[1]);
Zerotorescue@132 561 GameTooltip:AddLine(data[realrow].rowData.reason[2], 1, 1, 1, 1);
Zerotorescue@132 562 GameTooltip:Show();
Zerotorescue@132 563 end
Zerotorescue@132 564 end
Zerotorescue@132 565 else
Zerotorescue@132 566 -- Header row
Zerotorescue@132 567
Zerotorescue@132 568 if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then
Zerotorescue@132 569 cellFrame.tooltipTitle = cols[column].tooltipTitle;
Zerotorescue@132 570 if cols[column].tooltip then
Zerotorescue@132 571 cellFrame.tooltip = cols[column].tooltip; -- Optional
Zerotorescue@132 572 else
Zerotorescue@132 573 cellFrame.tooltip = nil;
Zerotorescue@132 574 end
Zerotorescue@132 575
Zerotorescue@132 576 ShowTooltip(cellFrame);
Zerotorescue@132 577 end
Zerotorescue@132 578 end
Zerotorescue@132 579 end,
Zerotorescue@132 580 ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@132 581 HideTooltip();
Zerotorescue@132 582 end,
Zerotorescue@141 583 ["OnClick"] = function() end,
Zerotorescue@132 584 });
Zerotorescue@132 585
Zerotorescue@132 586 frame.scrollTable = scrollTable;
Zerotorescue@132 587
Zerotorescue@132 588 -- Change the amount of displayed rows based on the size of the frame
Zerotorescue@132 589 frame.AdjustScrollTableRows = function(this)
Zerotorescue@132 590 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15);
Zerotorescue@132 591 newRows = (newRows < 4 and 4) or newRows;
Zerotorescue@132 592
Zerotorescue@132 593 this.scrollTable:SetDisplayRows(newRows, 15);
Zerotorescue@132 594 end;
Zerotorescue@132 595 frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows);
Zerotorescue@132 596 end
Zerotorescue@132 597 end
Zerotorescue@132 598
Zerotorescue@132 599 function addon:SetQueueFrameData(queueable, unqueueables)
Zerotorescue@132 600 InventoriumQueuer.scrollTable:SetData(queueable);
Zerotorescue@132 601 InventoriumQueuerUnqueueables.scrollTable:SetData(unqueueables);
Zerotorescue@132 602
Zerotorescue@132 603 InventoriumQueuer:Show();
Zerotorescue@132 604 end
Zerotorescue@132 605
Zerotorescue@132 606 function addon:SetQueueFrameSettings(title, description, proceed, cancel, headers, unqueueablesHeaders)
Zerotorescue@132 607 local frame = InventoriumQueuer;
Zerotorescue@132 608
Zerotorescue@132 609 frame.lblTitle:SetText(title);
Zerotorescue@132 610 -- Adjust size for the title background
Zerotorescue@132 611 frame.titleBackground:SetWidth((frame.lblTitle:GetWidth() or 0) + 10); -- 10 pixels margin
Zerotorescue@132 612
Zerotorescue@132 613 frame.lblDescription:SetText(description);
Zerotorescue@132 614
Zerotorescue@132 615 frame.btnProceed:SetText(proceed.text);
Zerotorescue@132 616 frame.btnProceed.tooltipTitle = proceed.tooltipTitle;
Zerotorescue@132 617 frame.btnProceed.tooltip = proceed.tooltip;
Zerotorescue@132 618 frame.btnProceed.OnClick = proceed.onClick;
Zerotorescue@132 619
Zerotorescue@132 620 frame.btnCancel:SetText(cancel.text);
Zerotorescue@132 621 frame.btnCancel.tooltipTitle = cancel.tooltipTitle;
Zerotorescue@132 622 frame.btnCancel.tooltip = cancel.tooltip;
Zerotorescue@132 623 frame.btnCancel.OnClick = cancel.onClick;
Zerotorescue@132 624
Zerotorescue@132 625 frame.scrollTable:SetDisplayCols(headers);
Zerotorescue@132 626
Zerotorescue@132 627 InventoriumQueuerUnqueueables.scrollTable:SetDisplayCols(unqueueablesHeaders);
Zerotorescue@132 628 end