annotate Frames.lua @ 145:6a52272a0e5a

Added a craft button to the queue window. This is still very experimental.
author Zerotorescue
date Thu, 20 Jan 2011 00:07:47 +0100
parents 12a8ea5af671
children 5d13830e8b0d
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@145 403
Zerotorescue@145 404 -- Craft
Zerotorescue@145 405 local btnCraft = CreateFrame("Button", "$parentCraft", frame, "UIPanelButtonTemplate");
Zerotorescue@145 406 btnCraft:SetHeight(21);
Zerotorescue@145 407 --btnCraft:SetWidth(125);
Zerotorescue@145 408 btnCraft:SetPoint("TOPLEFT", btnProceed, "TOPRIGHT", 15, 0);
Zerotorescue@145 409 btnCraft:SetPoint("BOTTOMRIGHT", btnCancel, "BOTTOMLEFT", -15, 0);
Zerotorescue@145 410 btnCraft:SetScript("OnClick", function(this) this.OnClick(this); end);
Zerotorescue@145 411 btnCraft:SetScript("OnEnter", ShowTooltip);
Zerotorescue@145 412 btnCraft:SetScript("OnLeave", HideTooltip);
Zerotorescue@145 413
Zerotorescue@145 414 frame.btnCraft = btnCraft;
Zerotorescue@132 415
Zerotorescue@132 416 -- 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 417 local frmMeasureDummy = CreateFrame("Frame", nil, frame);
Zerotorescue@132 418 frmMeasureDummy:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18);
Zerotorescue@132 419 frmMeasureDummy:SetPoint("LEFT", frame, "LEFT", 15, 0);
Zerotorescue@132 420 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
Zerotorescue@132 421
Zerotorescue@132 422 frame.frmMeasureDummy = frmMeasureDummy;
Zerotorescue@132 423
Zerotorescue@132 424 -- Scrolling table with a list of items to be queued
Zerotorescue@132 425 local ScrollingTable = LibStub("ScrollingTable");
Zerotorescue@132 426 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings
Zerotorescue@132 427 scrollTable.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18);
Zerotorescue@132 428 scrollTable.frame:SetPoint("LEFT", frame, "LEFT", 15, 0);
Zerotorescue@132 429 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
Zerotorescue@132 430 -- When moving over a row, provide a tooltip for the item
Zerotorescue@132 431 scrollTable:RegisterEvents({
Zerotorescue@144 432 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column)
Zerotorescue@132 433 if row and realrow then
Zerotorescue@132 434 -- Data row
Zerotorescue@132 435
Zerotorescue@144 436 if cols[column].name == "X" then
Zerotorescue@144 437 cellFrame.tooltipTitle = "Remove";
Zerotorescue@144 438 cellFrame.tooltip = "Remove this item from the queue.";
Zerotorescue@144 439 cellFrame.tooltipLocation = "BOTTOM";
Zerotorescue@144 440
Zerotorescue@144 441 ShowTooltip(cellFrame);
Zerotorescue@144 442 elseif data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then
Zerotorescue@132 443 GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE");
Zerotorescue@132 444 GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT");
Zerotorescue@132 445 GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId));
Zerotorescue@132 446 GameTooltip:Show();
Zerotorescue@132 447 end
Zerotorescue@132 448 else
Zerotorescue@132 449 -- Header row
Zerotorescue@132 450
Zerotorescue@132 451 if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then
Zerotorescue@132 452 cellFrame.tooltipTitle = cols[column].tooltipTitle;
Zerotorescue@132 453 if cols[column].tooltip then
Zerotorescue@132 454 cellFrame.tooltip = cols[column].tooltip; -- Optional
Zerotorescue@132 455 else
Zerotorescue@132 456 cellFrame.tooltip = nil;
Zerotorescue@132 457 end
Zerotorescue@132 458
Zerotorescue@132 459 ShowTooltip(cellFrame);
Zerotorescue@132 460 end
Zerotorescue@132 461 end
Zerotorescue@132 462 end,
Zerotorescue@144 463 ["OnLeave"] = function()
Zerotorescue@132 464 HideTooltip();
Zerotorescue@132 465 end,
Zerotorescue@144 466 ["OnClick"] = function(rowFrame, cellFrame, data, cols, row, realrow, column)
Zerotorescue@144 467 if row and realrow then
Zerotorescue@144 468 -- Data row
Zerotorescue@144 469
Zerotorescue@144 470 if cols[column].name == "X" then
Zerotorescue@144 471 cols[column].onClick(data[realrow].rowData);
Zerotorescue@144 472
Zerotorescue@144 473 return true; -- cancel default event
Zerotorescue@144 474 end
Zerotorescue@144 475 end
Zerotorescue@144 476 end,
Zerotorescue@132 477 });
Zerotorescue@144 478 scrollTable:EnableSelection(true);
Zerotorescue@132 479
Zerotorescue@132 480 frame.scrollTable = scrollTable;
Zerotorescue@132 481
Zerotorescue@132 482 -- Change the amount of displayed rows based on the size of the frame
Zerotorescue@132 483 frame.AdjustScrollTableRows = function(this)
Zerotorescue@132 484 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15);
Zerotorescue@132 485 newRows = (newRows < 4 and 4) or newRows;
Zerotorescue@132 486
Zerotorescue@132 487 this.scrollTable:SetDisplayRows(newRows, 15);
Zerotorescue@132 488 end;
Zerotorescue@132 489 frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows);
Zerotorescue@132 490 end
Zerotorescue@132 491 do
Zerotorescue@132 492 local frameWidth = 300;
Zerotorescue@132 493
Zerotorescue@132 494 -- Main window
Zerotorescue@132 495 local frame = CreateFrame("Frame", "InventoriumQueuerUnqueueables", InventoriumQueuer);
Zerotorescue@132 496 -- Hide by default
Zerotorescue@132 497 frame:Hide();
Zerotorescue@132 498 -- Position the frame against the queuer window
Zerotorescue@132 499 frame:SetPoint("TOPLEFT", InventoriumQueuer, "TOPRIGHT", 0, 0);
Zerotorescue@132 500 frame:SetPoint("BOTTOMLEFT", InventoriumQueuer, "BOTTOMLEFT", 0, 0);
Zerotorescue@132 501 -- Put in front of other windows
Zerotorescue@132 502 frame:SetFrameStrata("FULLSCREEN_DIALOG");
Zerotorescue@132 503 frame:SetToplevel(true);
Zerotorescue@132 504 -- Give it a size
Zerotorescue@132 505 frame:SetWidth(frameWidth);
Zerotorescue@132 506 -- Background
Zerotorescue@132 507 frame:SetBackdrop({
Zerotorescue@132 508 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
Zerotorescue@132 509 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
Zerotorescue@132 510 edgeSize = 20,
Zerotorescue@132 511 insets = {
Zerotorescue@132 512 left = 5,
Zerotorescue@132 513 right = 5,
Zerotorescue@132 514 top = 5,
Zerotorescue@132 515 bottom = 5,
Zerotorescue@132 516 },
Zerotorescue@132 517 });
Zerotorescue@132 518 frame:SetBackdropColor(0, 0, 0, .8);
Zerotorescue@132 519 -- Mouse functions
Zerotorescue@132 520 frame:EnableMouse();
Zerotorescue@132 521 frame:SetMovable(true);
Zerotorescue@132 522 -- Set event handlers
Zerotorescue@132 523 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end);
Zerotorescue@132 524 frame:SetScript("OnShow", function(this)
Zerotorescue@132 525 this:AdjustScrollTableRows();
Zerotorescue@132 526 end);
Zerotorescue@132 527
Zerotorescue@132 528 -- Title (AceGUI frame-widget-title used as example)
Zerotorescue@132 529 local titleBackground = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 530 titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 531 titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63);
Zerotorescue@132 532 titleBackground:SetPoint("TOP", 0, 12);
Zerotorescue@132 533 titleBackground:SetWidth(90);
Zerotorescue@132 534 titleBackground:SetHeight(40);
Zerotorescue@132 535
Zerotorescue@132 536 frame.titleBackground = titleBackground;
Zerotorescue@132 537
Zerotorescue@132 538 local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 539 titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 540 titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63);
Zerotorescue@132 541 titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT");
Zerotorescue@132 542 titleBackgroundLeft:SetWidth(30);
Zerotorescue@132 543 titleBackgroundLeft:SetHeight(40);
Zerotorescue@132 544
Zerotorescue@132 545 local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY");
Zerotorescue@132 546 titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header");
Zerotorescue@132 547 titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63);
Zerotorescue@132 548 titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT");
Zerotorescue@132 549 titleBackgroundRight:SetWidth(30);
Zerotorescue@132 550 titleBackgroundRight:SetHeight(40);
Zerotorescue@132 551
Zerotorescue@132 552 local frmTitle = CreateFrame("Frame", nil, frame);
Zerotorescue@132 553 frmTitle:EnableMouse(true);
Zerotorescue@132 554 frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end);
Zerotorescue@132 555 frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end);
Zerotorescue@132 556 frmTitle:SetAllPoints(titleBackground);
Zerotorescue@132 557
Zerotorescue@132 558 local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal");
Zerotorescue@132 559 lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14);
Zerotorescue@132 560 lblTitle:SetText("Unqueueables");
Zerotorescue@132 561
Zerotorescue@132 562 -- 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 563 local frmMeasureDummy = CreateFrame("Frame", nil, frame);
Zerotorescue@132 564 frmMeasureDummy:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -42);
Zerotorescue@132 565 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 15);
Zerotorescue@132 566
Zerotorescue@132 567 frame.frmMeasureDummy = frmMeasureDummy;
Zerotorescue@132 568
Zerotorescue@132 569 -- Scrolling table with a list of items to be queued
Zerotorescue@132 570 local ScrollingTable = LibStub("ScrollingTable");
Zerotorescue@132 571 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings
Zerotorescue@132 572 scrollTable.frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -42);
Zerotorescue@132 573 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 15);
Zerotorescue@132 574 -- When moving over a row, provide a tooltip for the item
Zerotorescue@132 575 scrollTable:RegisterEvents({
Zerotorescue@132 576 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@132 577 if row and realrow then
Zerotorescue@132 578 -- Data row
Zerotorescue@132 579
Zerotorescue@132 580 if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then
Zerotorescue@132 581 if column == 1 then
Zerotorescue@132 582 GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE");
Zerotorescue@132 583 GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT");
Zerotorescue@132 584 GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId));
Zerotorescue@132 585 GameTooltip:Show();
Zerotorescue@132 586 else
Zerotorescue@132 587 GameTooltip:SetOwner(cellFrame, "ANCHOR_NONE");
Zerotorescue@132 588 GameTooltip:SetPoint("TOPLEFT", cellFrame, "BOTTOMLEFT");
Zerotorescue@132 589 GameTooltip:SetText(data[realrow].rowData.reason[1]);
Zerotorescue@132 590 GameTooltip:AddLine(data[realrow].rowData.reason[2], 1, 1, 1, 1);
Zerotorescue@132 591 GameTooltip:Show();
Zerotorescue@132 592 end
Zerotorescue@132 593 end
Zerotorescue@132 594 else
Zerotorescue@132 595 -- Header row
Zerotorescue@132 596
Zerotorescue@132 597 if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then
Zerotorescue@132 598 cellFrame.tooltipTitle = cols[column].tooltipTitle;
Zerotorescue@132 599 if cols[column].tooltip then
Zerotorescue@132 600 cellFrame.tooltip = cols[column].tooltip; -- Optional
Zerotorescue@132 601 else
Zerotorescue@132 602 cellFrame.tooltip = nil;
Zerotorescue@132 603 end
Zerotorescue@132 604
Zerotorescue@132 605 ShowTooltip(cellFrame);
Zerotorescue@132 606 end
Zerotorescue@132 607 end
Zerotorescue@132 608 end,
Zerotorescue@132 609 ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...)
Zerotorescue@132 610 HideTooltip();
Zerotorescue@132 611 end,
Zerotorescue@141 612 ["OnClick"] = function() end,
Zerotorescue@132 613 });
Zerotorescue@132 614
Zerotorescue@132 615 frame.scrollTable = scrollTable;
Zerotorescue@132 616
Zerotorescue@132 617 -- Change the amount of displayed rows based on the size of the frame
Zerotorescue@132 618 frame.AdjustScrollTableRows = function(this)
Zerotorescue@132 619 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15);
Zerotorescue@132 620 newRows = (newRows < 4 and 4) or newRows;
Zerotorescue@132 621
Zerotorescue@132 622 this.scrollTable:SetDisplayRows(newRows, 15);
Zerotorescue@132 623 end;
Zerotorescue@132 624 frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows);
Zerotorescue@132 625 end
Zerotorescue@132 626 end
Zerotorescue@132 627
Zerotorescue@132 628 function addon:SetQueueFrameData(queueable, unqueueables)
Zerotorescue@132 629 InventoriumQueuer.scrollTable:SetData(queueable);
Zerotorescue@132 630 InventoriumQueuerUnqueueables.scrollTable:SetData(unqueueables);
Zerotorescue@132 631
Zerotorescue@132 632 InventoriumQueuer:Show();
Zerotorescue@132 633 end
Zerotorescue@132 634
Zerotorescue@145 635 function addon:SetQueueFrameSettings(title, description, proceed, cancel, craft, headers, unqueueablesHeaders)
Zerotorescue@132 636 local frame = InventoriumQueuer;
Zerotorescue@132 637
Zerotorescue@132 638 frame.lblTitle:SetText(title);
Zerotorescue@132 639 -- Adjust size for the title background
Zerotorescue@132 640 frame.titleBackground:SetWidth((frame.lblTitle:GetWidth() or 0) + 10); -- 10 pixels margin
Zerotorescue@132 641
Zerotorescue@132 642 frame.lblDescription:SetText(description);
Zerotorescue@132 643
Zerotorescue@132 644 frame.btnProceed:SetText(proceed.text);
Zerotorescue@132 645 frame.btnProceed.tooltipTitle = proceed.tooltipTitle;
Zerotorescue@132 646 frame.btnProceed.tooltip = proceed.tooltip;
Zerotorescue@132 647 frame.btnProceed.OnClick = proceed.onClick;
Zerotorescue@132 648
Zerotorescue@132 649 frame.btnCancel:SetText(cancel.text);
Zerotorescue@132 650 frame.btnCancel.tooltipTitle = cancel.tooltipTitle;
Zerotorescue@132 651 frame.btnCancel.tooltip = cancel.tooltip;
Zerotorescue@132 652 frame.btnCancel.OnClick = cancel.onClick;
Zerotorescue@132 653
Zerotorescue@145 654 frame.btnCraft:SetText(craft.text);
Zerotorescue@145 655 frame.btnCraft.tooltipTitle = craft.tooltipTitle;
Zerotorescue@145 656 frame.btnCraft.tooltip = craft.tooltip;
Zerotorescue@145 657 frame.btnCraft.OnClick = craft.onClick;
Zerotorescue@145 658
Zerotorescue@132 659 frame.scrollTable:SetDisplayCols(headers);
Zerotorescue@132 660
Zerotorescue@132 661 InventoriumQueuerUnqueueables.scrollTable:SetDisplayCols(unqueueablesHeaders);
Zerotorescue@132 662 end