comparison Frames.lua @ 104:8502f02bf543

Increased edge size to make them more visible. Item mover window is no longer setting point to itself. Lowered description position so it doesn?t overlap the title.
author Zerotorescue
date Tue, 11 Jan 2011 23:13:40 +0100
parents 6ae44d372360
children d3fbb5676a5e
comparison
equal deleted inserted replaced
103:f49060d05d1c 104:8502f02bf543
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 GameTooltip:SetOwner(this, "ANCHOR_NONE"); 7 GameTooltip:SetOwner(this, "ANCHOR_NONE");
8 if this.tooltipLocation and this.tooltipLocation == "TOP" then 8 if this.tooltipLocation and this.tooltipLocation == "BOTTOM" then
9 GameTooltip:SetPoint("TOP", this, "TOP"); 9 GameTooltip:SetPoint("TOP", this, "BOTTOM");
10 else 10 else
11 GameTooltip:SetPoint("BOTTOM", this, "TOP"); 11 GameTooltip:SetPoint("BOTTOM", this, "TOP");
12 end 12 end
13 GameTooltip:SetText(this.tooltipTitle, 1, .82, 0, 1); 13 GameTooltip:SetText(this.tooltipTitle, 1, .82, 0, 1);
14 14
40 frame:SetHeight(175); 40 frame:SetHeight(175);
41 -- Background 41 -- Background
42 frame:SetBackdrop({ 42 frame:SetBackdrop({
43 bgFile = "Interface\\ChatFrame\\ChatFrameBackground", 43 bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
44 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border", 44 edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
45 edgeSize = 13, 45 edgeSize = 20,
46 insets = { 46 insets = {
47 left = 5, 47 left = 5,
48 right = 5, 48 right = 5,
49 top = 5, 49 top = 5,
50 bottom = 5, 50 bottom = 5,
57 frame:SetResizable(true); 57 frame:SetResizable(true);
58 frame:SetMinResize(300, 175); 58 frame:SetMinResize(300, 175);
59 -- Set event handlers 59 -- Set event handlers
60 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end); 60 frame:SetScript("OnMouseUp", function(this) this:StopMovingOrSizing(); end);
61 frame:SetScript("OnShow", function(this) 61 frame:SetScript("OnShow", function(this)
62 -- 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 62 if not tContains(StaticPopup_DisplayedFrames, this) then
63 local lastFrame = StaticPopup_DisplayedFrames[#StaticPopup_DisplayedFrames]; 63 -- 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
64 if lastFrame then 64 local lastFrame = StaticPopup_DisplayedFrames[#StaticPopup_DisplayedFrames];
65 this:SetPoint("TOP", lastFrame, "BOTTOM", 0, 0); 65 if lastFrame then
66 else 66 this:SetPoint("TOP", lastFrame, "BOTTOM", 0, 0);
67 this:SetPoint("TOP", UIParent, "TOP", 0, -135); 67 else
68 this:SetPoint("TOP", UIParent, "TOP", 0, -135);
69 end
70
71 -- Position other static popups below this
72 tinsert(StaticPopup_DisplayedFrames, this);
68 end 73 end
69
70 -- Position other static popups below this
71 tinsert(StaticPopup_DisplayedFrames, this);
72 74
73 this:AdjustScrollTableRows(); 75 this:AdjustScrollTableRows();
74 76
75 PlaySound("OrcExploration"); 77 PlaySound("OrcExploration");
76 end); 78 end);
116 frmResizer:SetScript("OnMouseDown", function(this) this:GetParent():StartSizing("BOTTOM"); end); 118 frmResizer:SetScript("OnMouseDown", function(this) this:GetParent():StartSizing("BOTTOM"); end);
117 frmResizer:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end); 119 frmResizer:SetScript("OnMouseUp", function(this) this:GetParent():StopMovingOrSizing(); end);
118 120
119 -- Description 121 -- Description
120 local lblDescription = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal"); 122 local lblDescription = frame:CreateFontString(nil, "OVERLAY", "GameFontNormal");
121 lblDescription:SetPoint("TOPLEFT", frame, "TOPLEFT", 10, -23); 123 lblDescription:SetPoint("TOPLEFT", frame, "TOPLEFT", 15, -25);
122 lblDescription:SetWidth(frameWidth - 10 - 10); -- 10 margin left & 10 margin right 124 lblDescription:SetWidth(frameWidth - 15 - 15); -- 10 margin left & 10 margin right
123 lblDescription:SetJustifyH("LEFT"); 125 lblDescription:SetJustifyH("LEFT");
124 lblDescription:SetJustifyV("TOP"); 126 lblDescription:SetJustifyV("TOP");
125 lblDescription:SetText("The items listed below can be refilled from this location, do you wish to move them to your bags?"); 127 lblDescription:SetText("The items listed below can be refilled from this location, do you wish to move them to your bags?");
126 128
127 frame.lblDescription = lblDescription; 129 frame.lblDescription = lblDescription;
129 -- Buttons 131 -- Buttons
130 -- Move (proceed) 132 -- Move (proceed)
131 local btnMove = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate"); 133 local btnMove = CreateFrame("Button", "$parentProceed", frame, "UIPanelButtonTemplate");
132 btnMove:SetHeight(21); 134 btnMove:SetHeight(21);
133 btnMove:SetWidth(125); 135 btnMove:SetWidth(125);
134 btnMove:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 10); 136 btnMove:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 15, 11);
135 btnMove:SetText("Move Items"); 137 btnMove:SetText("Move Items");
136 btnMove:SetScript("OnClick", onAccept); 138 btnMove:SetScript("OnClick", onAccept);
137 btnMove:SetScript("OnEnter", ShowTooltip); 139 btnMove:SetScript("OnEnter", ShowTooltip);
138 btnMove:SetScript("OnLeave", HideTooltip); 140 btnMove:SetScript("OnLeave", HideTooltip);
139 btnMove.tooltipTitle = "Move Items"; 141 btnMove.tooltipTitle = "Move Items";
143 145
144 -- Cancel 146 -- Cancel
145 local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate"); 147 local btnCancel = CreateFrame("Button", "$parentCancel", frame, "UIPanelButtonTemplate");
146 btnCancel:SetHeight(21); 148 btnCancel:SetHeight(21);
147 btnCancel:SetWidth(125); 149 btnCancel:SetWidth(125);
148 btnCancel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 10); 150 btnCancel:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 11);
149 btnCancel:SetText("Cancel"); 151 btnCancel:SetText("Cancel");
150 btnCancel:SetScript("OnClick", onCancel); 152 btnCancel:SetScript("OnClick", onCancel);
151 btnCancel:SetScript("OnEnter", ShowTooltip); 153 btnCancel:SetScript("OnEnter", ShowTooltip);
152 btnCancel:SetScript("OnLeave", HideTooltip); 154 btnCancel:SetScript("OnLeave", HideTooltip);
153 btnCancel.tooltipTitle = "Cancel"; 155 btnCancel.tooltipTitle = "Cancel";
156 frame.btnCancel = btnCancel; 158 frame.btnCancel = btnCancel;
157 159
158 -- 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 160 -- 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
159 local frmMeasureDummy = CreateFrame("Frame", nil, frame); 161 local frmMeasureDummy = CreateFrame("Frame", nil, frame);
160 frmMeasureDummy:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -20); 162 frmMeasureDummy:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -20);
161 frmMeasureDummy:SetPoint("LEFT", frame.lblDescription, "LEFT", 10, 0); 163 frmMeasureDummy:SetPoint("LEFT", frame.lblDescription, "LEFT", 15, 0);
162 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -10, 35); 164 frmMeasureDummy:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
163 165
164 frame.frmMeasureDummy = frmMeasureDummy; 166 frame.frmMeasureDummy = frmMeasureDummy;
165 167
166 -- Scrolling table with a list of items to be moved 168 -- Scrolling table with a list of items to be moved
167 local scrollTableWidth = ( frame.frmMeasureDummy:GetWidth() - 20 ); -- adjust width by the scrollbar size 169 local scrollTableWidth = ( frame.frmMeasureDummy:GetWidth() - 20 ); -- adjust width by the scrollbar size
220 end, 222 end,
221 }); 223 });
222 224
223 frame.scrollTable = table; 225 frame.scrollTable = table;
224 table.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -20); 226 table.frame:SetPoint("TOP", frame.lblDescription, "BOTTOM", 0, -20);
225 table.frame:SetPoint("LEFT", frame.lblDescription, "LEFT", 10, 0); 227 table.frame:SetPoint("LEFT", frame, "LEFT", 15, 0);
226 table.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -10, 35); 228 table.frame:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -15, 35);
227 229
228 -- Change the amount of displayed rows based on the size of the frame 230 -- Change the amount of displayed rows based on the size of the frame
229 frame.AdjustScrollTableRows = function(this) 231 frame.AdjustScrollTableRows = function(this)
230 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15); 232 local newRows = math.floor(( this.frmMeasureDummy:GetHeight() - 5 ) / 15);
231 newRows = (newRows < 3 and 3) or newRows; 233 newRows = (newRows < 3 and 3) or newRows;