Mercurial > wow > inventory
comparison Frames.lua @ 132:8460855e3d90
Rewrote queueing module to insert a GUI.
Minor mover window changes.
author | Zerotorescue |
---|---|
date | Tue, 18 Jan 2011 00:30:15 +0100 |
parents | dc6f405c1a5d |
children | 5ed50feddeb0 |
comparison
equal
deleted
inserted
replaced
131:a27948591159 | 132:8460855e3d90 |
---|---|
2 | 2 |
3 local function ShowTooltip(self) | 3 local function ShowTooltip(self) |
4 -- If this function is called from a widget, self is the widget and self.frame the actual frame | 4 -- If this function is called from a widget, self is the widget and self.frame the actual frame |
5 local this = self.frame or self; | 5 local this = self.frame or self; |
6 | 6 |
7 if not this.tooltipTitle then return; end | 7 if not this.tooltipTitle or addon.db.profile.defaults.hideHelp then return; end |
8 | 8 |
9 GameTooltip:SetOwner(this, "ANCHOR_NONE"); | 9 GameTooltip:SetOwner(this, "ANCHOR_NONE"); |
10 if this.tooltipLocation and this.tooltipLocation == "BOTTOM" then | 10 if this.tooltipLocation and this.tooltipLocation == "BOTTOM" then |
11 GameTooltip:SetPoint("TOP", this, "BOTTOM"); | 11 GameTooltip:SetPoint("TOP", this, "BOTTOM"); |
12 else | 12 else |
24 local function HideTooltip() | 24 local function HideTooltip() |
25 GameTooltip:Hide(); | 25 GameTooltip:Hide(); |
26 end | 26 end |
27 | 27 |
28 function addon:CreateMoverFrame() | 28 function addon:CreateMoverFrame() |
29 if InventoriumItemMover then | |
30 return; | |
31 end | |
32 | |
29 local frameWidth = 400; | 33 local frameWidth = 400; |
30 | 34 |
31 -- Main window | 35 -- Main window |
32 local frame = CreateFrame("Frame", "InventoriumItemMover", UIParent); | 36 local frame = CreateFrame("Frame", "InventoriumItemMover", UIParent); |
33 -- Hide by default | 37 -- Hide by default |
134 lblDescription:SetJustifyV("TOP"); | 138 lblDescription:SetJustifyV("TOP"); |
135 | 139 |
136 frame.lblDescription = lblDescription; | 140 frame.lblDescription = lblDescription; |
137 | 141 |
138 -- Buttons | 142 -- Buttons |
139 -- Move (proceed) | 143 -- Proceed |
140 local btnMove = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate"); | 144 local btnProceed = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate"); |
141 btnMove:SetHeight(21); | 145 btnProceed:SetHeight(21); |
142 btnMove:SetWidth(125); | 146 btnProceed:SetWidth(125); |
143 btnMove:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11); | 147 btnProceed:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11); |
144 btnMove:SetText("Move Items"); | 148 btnProceed:SetScript("OnClick", function(this) this.OnClick(this); end); |
145 btnMove:SetScript("OnClick", function(this) this.OnClick(this); end); | 149 btnProceed:SetScript("OnEnter", ShowTooltip); |
146 btnMove:SetScript("OnEnter", ShowTooltip); | 150 btnProceed:SetScript("OnLeave", HideTooltip); |
147 btnMove:SetScript("OnLeave", HideTooltip); | 151 |
148 | 152 frame.btnProceed = btnProceed; |
149 frame.btnMove = btnMove; | |
150 | 153 |
151 -- Cancel | 154 -- Cancel |
152 local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate"); | 155 local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate"); |
153 btnCancel:SetHeight(21); | 156 btnCancel:SetHeight(21); |
154 btnCancel:SetWidth(125); | 157 btnCancel:SetWidth(125); |
167 | 170 |
168 frame.frmMeasureDummy = frmMeasureDummy; | 171 frame.frmMeasureDummy = frmMeasureDummy; |
169 | 172 |
170 -- Scrolling table with a list of items to be moved | 173 -- Scrolling table with a list of items to be moved |
171 local ScrollingTable = LibStub("ScrollingTable"); | 174 local ScrollingTable = LibStub("ScrollingTable"); |
172 local table = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings | 175 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings |
173 table.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18); | 176 scrollTable.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18); |
174 table.frame:SetPoint("LEFT", frame, "LEFT", 15, 0); | 177 scrollTable.frame:SetPoint("LEFT", frame, "LEFT", 15, 0); |
175 table.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35); | 178 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35); |
176 -- When moving over a row, provide a tooltip for the item | 179 -- When moving over a row, provide a tooltip for the item |
177 table:RegisterEvents({ | 180 scrollTable:RegisterEvents({ |
178 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) | 181 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) |
179 if row and realrow then | 182 if row and realrow then |
180 -- Data row | 183 -- Data row |
181 | 184 |
182 if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then | 185 if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then |
203 ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) | 206 ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) |
204 HideTooltip(); | 207 HideTooltip(); |
205 end, | 208 end, |
206 }); | 209 }); |
207 | 210 |
208 frame.scrollTable = table; | 211 frame.scrollTable = scrollTable; |
209 | 212 |
210 -- Change the amount of displayed rows based on the size of the frame | 213 -- Change the amount of displayed rows based on the size of the frame |
211 frame.AdjustScrollTableRows = function(this) | 214 frame.AdjustScrollTableRows = function(this) |
212 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15); | 215 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15); |
213 newRows = (newRows < 4 and 4) or newRows; | 216 newRows = (newRows < 4 and 4) or newRows; |
221 InventoriumItemMover.scrollTable:SetData(data); | 224 InventoriumItemMover.scrollTable:SetData(data); |
222 | 225 |
223 InventoriumItemMover:Show(); | 226 InventoriumItemMover:Show(); |
224 end | 227 end |
225 | 228 |
226 function addon:SetFrameSettings(title, description, proceed, cancel, headers) | 229 function addon:SetMoverFrameSettings(title, description, proceed, cancel, headers) |
227 local frame = InventoriumItemMover; | 230 local frame = InventoriumItemMover; |
228 | 231 |
229 frame.lblTitle:SetText(title); | 232 frame.lblTitle:SetText(title); |
230 -- Adjust size for the title background | 233 -- Adjust size for the title background |
231 frame.titleBackground:SetWidth((frame.lblTitle:GetWidth() or 0) + 10); -- 10 pixels margin | 234 frame.titleBackground:SetWidth((frame.lblTitle:GetWidth() or 0) + 10); -- 10 pixels margin |
232 | 235 |
233 frame.lblDescription:SetText(description); | 236 frame.lblDescription:SetText(description); |
234 | 237 |
235 frame.btnMove:SetText(proceed.text); | 238 frame.btnProceed:SetText(proceed.text); |
236 frame.btnMove.tooltipTitle = proceed.tooltipTitle; | 239 frame.btnProceed.tooltipTitle = proceed.tooltipTitle; |
237 frame.btnMove.tooltip = proceed.tooltip; | 240 frame.btnProceed.tooltip = proceed.tooltip; |
238 frame.btnMove.OnClick = proceed.onClick; | 241 frame.btnProceed.OnClick = proceed.onClick; |
239 | 242 |
240 frame.btnCancel:SetText(cancel.text); | 243 frame.btnCancel:SetText(cancel.text); |
241 frame.btnCancel.tooltipTitle = cancel.tooltipTitle; | 244 frame.btnCancel.tooltipTitle = cancel.tooltipTitle; |
242 frame.btnCancel.tooltip = cancel.tooltip; | 245 frame.btnCancel.tooltip = cancel.tooltip; |
243 frame.btnCancel.OnClick = cancel.onClick; | 246 frame.btnCancel.OnClick = cancel.onClick; |
244 | 247 |
245 frame.scrollTable:SetDisplayCols(headers); | 248 frame.scrollTable:SetDisplayCols(headers); |
246 end | 249 end |
250 | |
251 function addon:CreateQueueFrame() | |
252 if InventoriumQueuer then | |
253 return; | |
254 end | |
255 | |
256 do | |
257 local frameWidth = 400; | |
258 | |
259 -- Main window | |
260 local frame = CreateFrame("Frame", "InventoriumQueuer", UIParent); | |
261 -- Hide by default | |
262 frame:Hide(); | |
263 -- Center the frame (will be adjusted later) | |
264 frame:SetPoint("CENTER", UIParent, "CENTER", 0, 0); | |
265 -- Put in front of other windows | |
266 frame:SetFrameStrata("FULLSCREEN_DIALOG"); | |
267 frame:SetToplevel(true); | |
268 -- Give it a size | |
269 frame:SetWidth(frameWidth); | |
270 frame:SetHeight(430); | |
271 -- Background | |
272 frame:SetBackdrop({ | |
273 bgFile = "Interface\\ChatFrame\\ChatFrameBackground", | |
274 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", | |
275 edgeSize = 20, | |
276 insets = { | |
277 left = 5, | |
278 right = 5, | |
279 top = 5, | |
280 bottom = 5, | |
281 }, | |
282 }); | |
283 frame:SetBackdropColor(0, 0, 0, .8); | |
284 -- Mouse functions | |
285 frame:EnableMouse(); | |
286 frame:SetMovable(true); | |
287 -- Set event handlers | |
288 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end); | |
289 frame:SetScript("OnShow", function(this) | |
290 this:AdjustScrollTableRows(); | |
291 end); | |
292 | |
293 -- Title (AceGUI frame-widget-title used as example) | |
294 local titleBackground = frame:CreateTexture(nil, "OVERLAY"); | |
295 titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); | |
296 titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63); | |
297 titleBackground:SetPoint("TOP", 0, 12); | |
298 titleBackground:SetWidth(150); | |
299 titleBackground:SetHeight(40); | |
300 | |
301 frame.titleBackground = titleBackground; | |
302 | |
303 local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY"); | |
304 titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); | |
305 titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63); | |
306 titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT"); | |
307 titleBackgroundLeft:SetWidth(30); | |
308 titleBackgroundLeft:SetHeight(40); | |
309 | |
310 local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY"); | |
311 titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); | |
312 titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63); | |
313 titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT"); | |
314 titleBackgroundRight:SetWidth(30); | |
315 titleBackgroundRight:SetHeight(40); | |
316 | |
317 local frmTitle = CreateFrame("Frame", nil, frame); | |
318 frmTitle:EnableMouse(true); | |
319 frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end); | |
320 frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end); | |
321 frmTitle:SetAllPoints(titleBackground); | |
322 | |
323 local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal"); | |
324 lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14); | |
325 | |
326 frame.lblTitle = lblTitle; | |
327 | |
328 -- Expand button | |
329 local btnExpander = CreateFrame("Button", "$parentExpander", frame); | |
330 btnExpander:SetWidth(32); | |
331 btnExpander:SetHeight(32); | |
332 btnExpander:SetPoint("TOPRIGHT", frame, "TOPRIGHT", -10, -10); | |
333 btnExpander:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up"); | |
334 btnExpander:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down"); | |
335 btnExpander:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled"); | |
336 btnExpander:SetHighlightTexture("Interface\\Buttons\\UI-Common-MouseHilight", "ADD"); | |
337 btnExpander.tooltipTitle = "Show unqueueables"; | |
338 btnExpander.tooltip = "Click to show a list of all unqueueable but tracked items."; | |
339 btnExpander:SetScript("OnEnter", ShowTooltip); | |
340 btnExpander:SetScript("OnLeave", HideTooltip); | |
341 btnExpander:SetScript("OnClick", function(this) | |
342 if this.Expanded then | |
343 -- Collapsing | |
344 this.Expanded = nil; | |
345 InventoriumQueuerUnqueueables:Hide(); | |
346 PlaySound("igCharacterInfoClose"); | |
347 | |
348 -- Next is an expand | |
349 this:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Up"); | |
350 this:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Down"); | |
351 this:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-NextPage-Disabled"); | |
352 else | |
353 -- Expanding | |
354 this.Expanded = true; | |
355 | |
356 -- Position the frame against the queuer window | |
357 InventoriumQueuerUnqueueables:ClearAllPoints(); | |
358 InventoriumQueuerUnqueueables:SetPoint("TOPLEFT", this:GetParent(), "TOPRIGHT", 0, 0); | |
359 InventoriumQueuerUnqueueables:SetPoint("BOTTOMLEFT", this:GetParent(), "BOTTOMLEFT", 0, 0); | |
360 InventoriumQueuerUnqueueables:Show(); | |
361 PlaySound("igCharacterInfoOpen"); | |
362 | |
363 -- Next is a collapse | |
364 this:SetNormalTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Up"); | |
365 this:SetPushedTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Down"); | |
366 this:SetDisabledTexture("Interface\\Buttons\\UI-SpellbookIcon-PrevPage-Disabled"); | |
367 end | |
368 end); | |
369 | |
370 -- Description | |
371 local lblDescription = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal"); | |
372 lblDescription:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -27); | |
373 lblDescription:SetPoint("RIGHT", btnExpander, "LEFT", -15, 0); | |
374 lblDescription:SetJustifyH("LEFT"); | |
375 lblDescription:SetJustifyV("TOP"); | |
376 lblDescription:SetWidth(frameWidth - 70); | |
377 | |
378 frame.lblDescription = lblDescription; | |
379 | |
380 -- Buttons | |
381 -- Proceed | |
382 local btnProceed = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate"); | |
383 btnProceed:SetHeight(21); | |
384 btnProceed:SetWidth(125); | |
385 btnProceed:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11); | |
386 btnProceed:SetScript("OnClick", function(this) this.OnClick(this); end); | |
387 btnProceed:SetScript("OnEnter", ShowTooltip); | |
388 btnProceed:SetScript("OnLeave", HideTooltip); | |
389 | |
390 frame.btnProceed = btnProceed; | |
391 | |
392 -- Cancel | |
393 local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate"); | |
394 btnCancel:SetHeight(21); | |
395 btnCancel:SetWidth(125); | |
396 btnCancel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 11); | |
397 btnCancel:SetScript("OnClick", function(this) this.OnClick(this); end); | |
398 btnCancel:SetScript("OnEnter", ShowTooltip); | |
399 btnCancel:SetScript("OnLeave", HideTooltip); | |
400 | |
401 frame.btnCancel = btnCancel; | |
402 | |
403 -- 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 | |
404 local frmMeasureDummy = CreateFrame("Frame", nil, frame); | |
405 frmMeasureDummy:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18); | |
406 frmMeasureDummy:SetPoint("LEFT", frame, "LEFT", 15, 0); | |
407 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35); | |
408 | |
409 frame.frmMeasureDummy = frmMeasureDummy; | |
410 | |
411 -- Scrolling table with a list of items to be queued | |
412 local ScrollingTable = LibStub("ScrollingTable"); | |
413 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings | |
414 scrollTable.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -18); | |
415 scrollTable.frame:SetPoint("LEFT", frame, "LEFT", 15, 0); | |
416 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35); | |
417 -- When moving over a row, provide a tooltip for the item | |
418 scrollTable:RegisterEvents({ | |
419 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) | |
420 if row and realrow then | |
421 -- Data row | |
422 | |
423 if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then | |
424 GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE"); | |
425 GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT"); | |
426 GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId)); | |
427 GameTooltip:Show(); | |
428 end | |
429 else | |
430 -- Header row | |
431 | |
432 if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then | |
433 cellFrame.tooltipTitle = cols[column].tooltipTitle; | |
434 if cols[column].tooltip then | |
435 cellFrame.tooltip = cols[column].tooltip; -- Optional | |
436 else | |
437 cellFrame.tooltip = nil; | |
438 end | |
439 | |
440 ShowTooltip(cellFrame); | |
441 end | |
442 end | |
443 end, | |
444 ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) | |
445 HideTooltip(); | |
446 end, | |
447 }); | |
448 | |
449 frame.scrollTable = scrollTable; | |
450 | |
451 -- Change the amount of displayed rows based on the size of the frame | |
452 frame.AdjustScrollTableRows = function(this) | |
453 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15); | |
454 newRows = (newRows < 4 and 4) or newRows; | |
455 | |
456 this.scrollTable:SetDisplayRows(newRows, 15); | |
457 end; | |
458 frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows); | |
459 end | |
460 do | |
461 local frameWidth = 300; | |
462 | |
463 -- Main window | |
464 local frame = CreateFrame("Frame", "InventoriumQueuerUnqueueables", InventoriumQueuer); | |
465 -- Hide by default | |
466 frame:Hide(); | |
467 -- Position the frame against the queuer window | |
468 frame:SetPoint("TOPLEFT", InventoriumQueuer, "TOPRIGHT", 0, 0); | |
469 frame:SetPoint("BOTTOMLEFT", InventoriumQueuer, "BOTTOMLEFT", 0, 0); | |
470 -- Put in front of other windows | |
471 frame:SetFrameStrata("FULLSCREEN_DIALOG"); | |
472 frame:SetToplevel(true); | |
473 -- Give it a size | |
474 frame:SetWidth(frameWidth); | |
475 -- Background | |
476 frame:SetBackdrop({ | |
477 bgFile = "Interface\\ChatFrame\\ChatFrameBackground", | |
478 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", | |
479 edgeSize = 20, | |
480 insets = { | |
481 left = 5, | |
482 right = 5, | |
483 top = 5, | |
484 bottom = 5, | |
485 }, | |
486 }); | |
487 frame:SetBackdropColor(0, 0, 0, .8); | |
488 -- Mouse functions | |
489 frame:EnableMouse(); | |
490 frame:SetMovable(true); | |
491 -- Set event handlers | |
492 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end); | |
493 frame:SetScript("OnShow", function(this) | |
494 this:AdjustScrollTableRows(); | |
495 end); | |
496 | |
497 -- Title (AceGUI frame-widget-title used as example) | |
498 local titleBackground = frame:CreateTexture(nil, "OVERLAY"); | |
499 titleBackground:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); | |
500 titleBackground:SetTexCoord(0.31, 0.67, 0, 0.63); | |
501 titleBackground:SetPoint("TOP", 0, 12); | |
502 titleBackground:SetWidth(90); | |
503 titleBackground:SetHeight(40); | |
504 | |
505 frame.titleBackground = titleBackground; | |
506 | |
507 local titleBackgroundLeft = frame:CreateTexture(nil, "OVERLAY"); | |
508 titleBackgroundLeft:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); | |
509 titleBackgroundLeft:SetTexCoord(0.21, 0.31, 0, 0.63); | |
510 titleBackgroundLeft:SetPoint("RIGHT", titleBackground, "LEFT"); | |
511 titleBackgroundLeft:SetWidth(30); | |
512 titleBackgroundLeft:SetHeight(40); | |
513 | |
514 local titleBackgroundRight = frame:CreateTexture(nil, "OVERLAY"); | |
515 titleBackgroundRight:SetTexture("Interface\\DialogFrame\\UI-DialogBox-Header"); | |
516 titleBackgroundRight:SetTexCoord(0.67, 0.77, 0, 0.63); | |
517 titleBackgroundRight:SetPoint("LEFT", titleBackground, "RIGHT"); | |
518 titleBackgroundRight:SetWidth(30); | |
519 titleBackgroundRight:SetHeight(40); | |
520 | |
521 local frmTitle = CreateFrame("Frame", nil, frame); | |
522 frmTitle:EnableMouse(true); | |
523 frmTitle:SetScript("OnMouseDown", function(this) this:GetParent():StartMoving(); end); | |
524 frmTitle:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end); | |
525 frmTitle:SetAllPoints(titleBackground); | |
526 | |
527 local lblTitle = frmTitle:CreateFontString(nil, "OVERLAY", "GameFontNormal"); | |
528 lblTitle:SetPoint("TOP", titleBackground, "TOP", 0, -14); | |
529 lblTitle:SetText("Unqueueables"); | |
530 | |
531 -- 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 | |
532 local frmMeasureDummy = CreateFrame("Frame", nil, frame); | |
533 frmMeasureDummy:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -42); | |
534 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 15); | |
535 | |
536 frame.frmMeasureDummy = frmMeasureDummy; | |
537 | |
538 -- Scrolling table with a list of items to be queued | |
539 local ScrollingTable = LibStub("ScrollingTable"); | |
540 local scrollTable = ScrollingTable:CreateST({}, 4, 15, nil, frame); -- inserting a dummy cols, real cols to be set in SetFrameSettings | |
541 scrollTable.frame:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -42); | |
542 scrollTable.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 15); | |
543 -- When moving over a row, provide a tooltip for the item | |
544 scrollTable:RegisterEvents({ | |
545 ["OnEnter"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) | |
546 if row and realrow then | |
547 -- Data row | |
548 | |
549 if data[realrow] and data[realrow].rowData and data[realrow].rowData.itemId then | |
550 if column == 1 then | |
551 GameTooltip:SetOwner(rowFrame, "ANCHOR_NONE"); | |
552 GameTooltip:SetPoint("TOPLEFT", rowFrame, "BOTTOMLEFT"); | |
553 GameTooltip:SetHyperlink(("item:%d"):format(data[realrow].rowData.itemId)); | |
554 GameTooltip:Show(); | |
555 else | |
556 GameTooltip:SetOwner(cellFrame, "ANCHOR_NONE"); | |
557 GameTooltip:SetPoint("TOPLEFT", cellFrame, "BOTTOMLEFT"); | |
558 GameTooltip:SetText(data[realrow].rowData.reason[1]); | |
559 GameTooltip:AddLine(data[realrow].rowData.reason[2], 1, 1, 1, 1); | |
560 GameTooltip:Show(); | |
561 end | |
562 end | |
563 else | |
564 -- Header row | |
565 | |
566 if cols[column].tooltipTitle and type(cols[column].tooltipTitle) == "string" then | |
567 cellFrame.tooltipTitle = cols[column].tooltipTitle; | |
568 if cols[column].tooltip then | |
569 cellFrame.tooltip = cols[column].tooltip; -- Optional | |
570 else | |
571 cellFrame.tooltip = nil; | |
572 end | |
573 | |
574 ShowTooltip(cellFrame); | |
575 end | |
576 end | |
577 end, | |
578 ["OnLeave"] = function(rowFrame, cellFrame, data, cols, row, realrow, column, scrollingTable, ...) | |
579 HideTooltip(); | |
580 end, | |
581 }); | |
582 | |
583 frame.scrollTable = scrollTable; | |
584 | |
585 -- Change the amount of displayed rows based on the size of the frame | |
586 frame.AdjustScrollTableRows = function(this) | |
587 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15); | |
588 newRows = (newRows < 4 and 4) or newRows; | |
589 | |
590 this.scrollTable:SetDisplayRows(newRows, 15); | |
591 end; | |
592 frame:SetScript("OnSizeChanged", frame.AdjustScrollTableRows); | |
593 end | |
594 end | |
595 | |
596 function addon:SetQueueFrameData(queueable, unqueueables) | |
597 InventoriumQueuer.scrollTable:SetData(queueable); | |
598 InventoriumQueuerUnqueueables.scrollTable:SetData(unqueueables); | |
599 | |
600 InventoriumQueuer:Show(); | |
601 end | |
602 | |
603 function addon:SetQueueFrameSettings(title, description, proceed, cancel, headers, unqueueablesHeaders) | |
604 local frame = InventoriumQueuer; | |
605 | |
606 frame.lblTitle:SetText(title); | |
607 -- Adjust size for the title background | |
608 frame.titleBackground:SetWidth((frame.lblTitle:GetWidth() or 0) + 10); -- 10 pixels margin | |
609 | |
610 frame.lblDescription:SetText(description); | |
611 | |
612 frame.btnProceed:SetText(proceed.text); | |
613 frame.btnProceed.tooltipTitle = proceed.tooltipTitle; | |
614 frame.btnProceed.tooltip = proceed.tooltip; | |
615 frame.btnProceed.OnClick = proceed.onClick; | |
616 | |
617 frame.btnCancel:SetText(cancel.text); | |
618 frame.btnCancel.tooltipTitle = cancel.tooltipTitle; | |
619 frame.btnCancel.tooltip = cancel.tooltip; | |
620 frame.btnCancel.OnClick = cancel.onClick; | |
621 | |
622 frame.scrollTable:SetDisplayCols(headers); | |
623 | |
624 InventoriumQueuerUnqueueables.scrollTable:SetDisplayCols(unqueueablesHeaders); | |
625 end |