Commit 04b09c77 authored by nevcairiel's avatar nevcairiel
Browse files

AceGUI-3.0:

- Set a default width/height on all widgets in OnAcquire.
- Added the SetRelativeWidth API, allowing you to set the width relative to the container frame. 1.0 = 100%

git-svn-id: https://repos.wowace.com/wow/ace3/trunk@793 5debad98-a965-4143-8383-f471b3509dcf
parent c5a3f89c
......@@ -25,7 +25,7 @@
-- @class file
-- @name AceGUI-3.0
-- @release $Id$
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 20
local ACEGUI_MAJOR, ACEGUI_MINOR = "AceGUI-3.0", 21
local AceGUI, oldminor = LibStub:NewLibrary(ACEGUI_MAJOR, ACEGUI_MINOR)
if not AceGUI then return end -- No upgrade needed
......@@ -199,10 +199,14 @@ function AceGUI:Release(widget)
widget.events[k] = nil
end
widget.width = nil
--widget.frame:SetParent(nil)
widget.relWidth = nil
widget.height = nil
widget.relHeight = nil
widget.frame:ClearAllPoints()
widget.frame:Hide()
widget.frame:SetParent(nil)
widget.frame.width = nil
widget.frame.height = nil
if widget.content then
widget.content.width = nil
widget.content.height = nil
......@@ -312,6 +316,14 @@ do
end
end
WidgetBase.SetRelativeWidth = function(self, width)
if width <= 0 or width > 1 then
error(":SetRelativeWidth(width): Invalid relative width.", 2)
end
self.relWidth = width
self.width = "relative"
end
WidgetBase.SetHeight = function(self, height)
self.frame:SetHeight(height)
self.frame.height = height
......@@ -319,6 +331,14 @@ do
self:OnHeightSet(height)
end
end
--[[ WidgetBase.SetRelativeHeight = function(self, height)
if height <= 0 or height > 1 then
error(":SetRelativeHeight(height): Invalid relative height.", 2)
end
self.relHeight = height
self.height = "relative"
end ]]
WidgetBase.IsVisible = function(self)
return self.frame:IsVisible()
......@@ -633,6 +653,14 @@ AceGUI:RegisterLayout("List",
if child.DoLayout then
child:DoLayout()
end
elseif child.width == "relative" then
child:SetWidth(width * child.relWidth)
if child.OnWidthSet then
child:OnWidthSet(content.width or content:GetWidth())
end
if child.DoLayout then
child:DoLayout()
end
end
height = height + (frame.height or frame:GetHeight() or 0)
......@@ -684,6 +712,10 @@ AceGUI:RegisterLayout("Flow",
lastframeoffset = frameoffset
frameoffset = child.alignoffset or (frameheight / 2)
if child.width == "relative" then
framewidth = width * child.relWidth
end
frame:Show()
frame:ClearAllPoints()
if i == 1 then
......@@ -709,7 +741,7 @@ AceGUI:RegisterLayout("Flow",
rowstartoffset = frameoffset
rowheight = frameheight
rowoffset = frameoffset
usedwidth = frame.width or frame:GetWidth()
usedwidth = framewidth
if usedwidth > width then
oversize = true
end
......@@ -735,12 +767,25 @@ AceGUI:RegisterLayout("Flow",
rowstart = frame
rowstartoffset = frameoffset
if child.OnWidthSet then
child:OnWidthSet(width)
end
if child.DoLayout then
child:DoLayout()
end
rowheight = frame.height or frame:GetHeight() or 0
rowoffset = child.alignoffset or (rowheight / 2)
rowstartoffset = rowoffset
elseif child.width == "relative" then
child:SetWidth(width * child.relWidth)
if child.OnWidthSet then
child:OnWidthSet(width)
end
if child.DoLayout then
child:DoLayout()
end
elseif oversize then
if width > 1 then
frame:SetPoint("RIGHT",content,"RIGHT",0,0)
......
......@@ -5,9 +5,12 @@ local AceGUI = LibStub("AceGUI-3.0")
--------------------------
do
local Type = "Button"
local Version = 7
local Version = 8
local function OnAcquire(self)
-- restore default values
self:SetHeight(24)
self:SetWidth(200)
end
local function OnRelease(self)
......
......@@ -10,11 +10,13 @@ local AceGUI = LibStub("AceGUI-3.0")
]]
do
local Type = "CheckBox"
local Version = 4
local Version = 5
local function OnAcquire(self)
self:SetValue(false)
self.tristate = nil
self:SetHeight(24)
self:SetWidth(200)
end
local function OnRelease(self)
......
......@@ -5,11 +5,13 @@ local AceGUI = LibStub("AceGUI-3.0")
--------------------------
do
local Type = "ColorPicker"
local Version = 9
local Version = 10
local function OnAcquire(self)
self.HasAlpha = false
self:SetColor(0,0,0,1)
self:SetHeight(24)
self:SetWidth(200)
end
local function SetLabel(self, text)
......
......@@ -344,7 +344,7 @@ end
do
local widgetType = "Dropdown"
local widgetVersion = 18
local widgetVersion = 19
--[[ Static data ]]--
......@@ -444,6 +444,9 @@ do
pullout:SetCallback("OnOpen", OnPulloutOpen)
self.pullout.frame:SetFrameLevel(self.frame:GetFrameLevel() + 1)
fixlevels(self.pullout.frame, self.pullout.frame:GetChildren())
self:SetHeight(44)
self:SetWidth(200)
end
-- exported, AceGUI callback
......
......@@ -11,10 +11,13 @@ local AceGUI = LibStub("AceGUI-3.0")
]]
do
local Type = "EditBox"
local Version = 10
local Version = 11
local function OnAcquire(self)
self:SetHeight(26)
self:SetWidth(200)
self:SetDisabled(false)
self:SetLabel()
self.showbutton = true
end
......@@ -119,13 +122,13 @@ do
self.label:SetText(text)
self.label:Show()
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,-18)
self.frame:SetHeight(44)
self:SetHeight(44)
self.alignoffset = 30
else
self.label:SetText("")
self.label:Hide()
self.editbox:SetPoint("TOPLEFT",self.frame,"TOPLEFT",7,0)
self.frame:SetHeight(26)
self:SetHeight(26)
self.alignoffset = 12
end
end
......
......@@ -5,10 +5,12 @@ local AceGUI = LibStub("AceGUI-3.0")
--------------------------
do
local Type = "Heading"
local Version = 4
local Version = 5
local function OnAcquire(self)
self:SetText("")
self:SetFullWidth()
self:SetHeight(18)
end
local function OnRelease(self)
......
......@@ -5,9 +5,11 @@ local AceGUI = LibStub("AceGUI-3.0")
--------------------------
do
local Type = "Icon"
local Version = 8
local Version = 9
local function OnAcquire(self)
self:SetHeight(110)
self:SetWidth(110)
self:SetLabel("")
self:SetImage(nil)
self:SetImageSize(64, 64)
......
......@@ -5,9 +5,11 @@ local AceGUI = LibStub("AceGUI-3.0")
--------------------------
do
local Type = "InteractiveLabel"
local Version = 2
local Version = 3
local function OnAcquire(self)
self:SetHeight(18)
self:SetWidth(200)
self:SetText("")
self:SetImage(nil)
self:SetColor()
......
......@@ -6,7 +6,7 @@ local AceGUI = LibStub("AceGUI-3.0")
do
local Type = "Keybinding"
local Version = 11
local Version = 12
local ControlBackdrop = {
bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
......@@ -100,6 +100,8 @@ do
end
local function OnAcquire(self)
self:SetWidth(200)
self:SetHeight(44)
self:SetLabel("")
self:SetKey("")
end
......
......@@ -5,9 +5,11 @@ local AceGUI = LibStub("AceGUI-3.0")
--------------------------
do
local Type = "Label"
local Version = 9
local Version = 10
local function OnAcquire(self)
self:SetHeight(18)
self:SetWidth(200)
self:SetText("")
self:SetImage(nil)
self:SetColor()
......
......@@ -29,7 +29,7 @@ local _G = getfenv()
local AceGUI = LibStub("AceGUI-3.0")
local Version = 9
local Version = 10
---------------------
-- Common Elements --
---------------------
......@@ -106,6 +106,9 @@ do
end
function MultiLineEditBox:OnAcquire()
self:SetWidth(200)
self:SetHeight(116)
self:SetNumLines(4)
self:SetDisabled(false)
self:ShowButton(true)
end
......@@ -155,6 +158,11 @@ do
self.label:SetText(text)
end
end
function MultiLineEditBox:SetNumLines(number)
number = number or 4
self:SetHeight(60 + (14*number))
end
function MultiLineEditBox:GetText()
return self.editbox:GetText()
......
......@@ -5,9 +5,11 @@ local AceGUI = LibStub("AceGUI-3.0")
--------------------------
do
local Type = "Slider"
local Version = 6
local Version = 7
local function OnAcquire(self)
self:SetWidth(200)
self:SetHeight(44)
self:SetDisabled(false)
self:SetIsPercent(nil)
self:SetSliderValues(0,100,1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment