Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
my button class is tha beast :-) - Gideros Forum

my button class is tha beast :-)

MoKaLuxMoKaLux Member
edited March 30 in Game & application design
how are you all doing?
My button class is the best :) ? It has:
- text, pixels, textures, up/down/disabled states, automatic nine patch
- all params are optional
Can you tell me if you spot any errors/improvement?
PS: I wanted to add tool tips in the hover function but I leave it for now.
	local mybtn02 = ButtonTextUDDP.new({
		imgup="gfx/ui/btn_03.png",
		text="B\nU\nT\nT\nO\nN", font=g_font1, fontsize=32, textcolorup=mytextcolorup, textcolordown=mytextcolordown,
		imagepaddingx=64, imagepaddingy=32
	})

Likes: pie, antix

my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
Tagged:
+1 -1 (+2 / -0 ) Share on Facebook

Comments

  • MoKaLuxMoKaLux Member
    edited March 30
    Excerpt:
    	-- the params
    	self.params = xparams or {}
    	-- textures?
    	self.params.imgup = xparams.imgup or nil -- img up path
    	self.params.imgdown = xparams.imgdown or self.params.imgup -- img down path
    	self.params.imgdisabled = xparams.imgdisabled or self.params.imgup -- img disabled path
    	self.params.imagealpha = xparams.imagealpha or 1 -- number
    	self.params.imgscalex = xparams.imgscalex or 1 -- number
    	self.params.imgscaley = xparams.imgscaley or 1 -- number
    	self.params.imagepaddingx = xparams.imagepaddingx or nil -- number (nil = auto)
    	self.params.imagepaddingy = xparams.imagepaddingy or nil -- number (nil = auto)
    	-- pixel?
    	self.params.pixelcolorup = xparams.pixelcolorup or nil -- color
    	self.params.pixelcolordown = xparams.pixelcolordown or self.params.pixelcolorup -- color
    	self.params.pixelcolordisabled = xparams.pixelcolordisabled or 0x555555 -- color
    	self.params.pixelalpha = xparams.pixelalpha or 1 -- number
    	self.params.pixelscalex = xparams.pixelscalex or 1 -- number
    	self.params.pixelscaley = xparams.pixelscaley or 1 -- number
    	self.params.pixelpaddingx = xparams.pixelpaddingx or 12 -- number
    	self.params.pixelpaddingy = xparams.pixelpaddingy or 12 -- number
    	-- text?
    	self.params.text = xparams.text or nil -- string
    	self.params.font = xparams.font or nil -- ttf font path
    	self.params.fontsize = xparams.fontsize or 16 -- number
    	self.params.textcolorup = xparams.textcolorup or 0x0 -- color
    	self.params.textcolordown = xparams.textcolordown or self.params.textcolorup -- color
    	self.params.textcolordisabled = xparams.textcolordisabled or 0x777777 -- color
    	self.params.textscalex = xparams.textscalex or 1 -- number
    	self.params.textscaley = xparams.textscaley or self.params.textscalex -- number
    	-- EXTRAS
    	self.params.isautoscale = xparams.isautoscale or 1 -- number (default 1 = true)
    	self.params.hover = xparams.hover or 1 -- number (default 1 = true)
    	self.params.defaultpadding = xparams.defaultpadding or 12 -- number
    PS: it's on the wiki and it's called UDDP https://wiki.giderosmobile.com/index.php/UI_Buttons
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    added tooltips.
    https://wiki.giderosmobile.com/index.php/UI_Buttons#Button_with_Text.2C_Pixel.2C_Images_UDD.2C_9_Patch.2C_Tooltip

    PS: one problem though, if you move the mouse too quickly the tooltip will remain on screen, the same on mobiles!
    PS2: I have removed the TOUCH event listeners as they seem not necessary

    Any improvements would be much appreciated ;)
    mybuttont.png
    224 x 210 - 11K
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
Sign In or Register to comment.