Ace3

310 - Patch for AceGUI Button auto-resize

This patch adds an optional feature to automatically resize an AceGUI Button widget to match the size of the text it contains. This feature is disabled by default to maintain compatibility and is enabled by calling widget:SetAutoWidth(true).

--- AceGUIWidget-Button.lua  2012-09-08 12:29:29.136833200 -0700
+++ AceGUIWidget-Button.lua.new  2012-09-09 17:11:32.100568700 -0700
@@ -45,6 +45,7 @@
         self:SetHeight(24)
         self:SetWidth(200)
         self:SetDisabled(false)
+         self:SetAutoWidth(false)
         self:SetText()
     end,
 
@@ -52,6 +53,16 @@
 
     ["SetText"] = function(self, text)
         self.text:SetText(text)
+        if self.autoWidth then
+            self:SetWidth(self.text:GetStringWidth() + 30)
+        end
+    end,
+
+    ["SetAutoWidth"] = function(self, autoWidth)
+        self.autoWidth = autoWidth
+        if self.autoWidth then
+            self:SetWidth(self.text:GetStringWidth() + 30)
+        end
     end,
 
     ["SetDisabled"] = function(self, disabled)

User When Change
Nevcairiel Sep 13, 2013 at 14:50 UTC
Nevcairiel Dec 04, 2012 at 08:20 UTC
Realfriend Sep 10, 2012 at 00:24 UTC Changed description:
  This patch adds an optional feature to automatically resize an AceGUI Button widget to match the size of the text it contains. This feature is disabled by default to maintain compatibility and is enabled by calling widget:SetAutoWidth(true).
+
+ --- AceGUIWidget-Button.lua	2012-09-08 12:29:29.136833200 -0700
+ +++ AceGUIWidget-Button.lua.new	2012-09-09 17:11:32.100568700 -0700
+ @@ -45,6 +45,7 @@
+  		self:SetHeight(24)
+  		self:SetWidth(200)
+  		self:SetDisabled(false)
+ + 		self:SetAutoWidth(false)
+  		self:SetText()
+  	end,
+
+ @@ -52,6 +53,16 @@
+
+  	["SetText"] = function(self, text)
+  		self.text:SetText(text)
+ +		if self.autoWidth then
+ +			self:SetWidth(self.text:GetStringWidth() + 30)
+ +		end
+ +	end,
+ +
+ +	["SetAutoWidth"] = function(self, autoWidth)
+ +		self.autoWidth = autoWidth
+ +		if self.autoWidth then
+ +			self:SetWidth(self.text:GetStringWidth() + 30)
+ +		end
+  	end,
+
+  	["SetDisabled"] = function(self, disabled)
Realfriend Sep 10, 2012 at 00:23 UTC

Deleted attachment AceGUI-button-autowidth.patch: I found a bug in my patch

Realfriend Sep 08, 2012 at 19:52 UTC

Added attachment AceGUI-button-autowidth.patch

Realfriend Sep 08, 2012 at 19:52 UTC Create

You must login to post a comment. Don't have an account? Register to get one!

Facts

Last updated
Sep 13, 2013
Reported
Sep 08, 2012
Status
Fixed - Developer made requested changes. QA should verify.
Type
Patch - Source code patch for review
Priority
Medium - Normal priority.
Votes
0
Component
AceGUI-3.0

Reported by

Possible assignees