Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Gideros UI and layouts (WidgetKit) Thread - Page 2 — Gideros Forum

Gideros UI and layouts (WidgetKit) Thread

2»

Comments

  • MoKaLux said:

    at pie, I don't know if that would help but commenting out UI.Style will show the shapes beneath each UI.

    Thank you, the issue was not to see those shapes but to know exactly where were they placed, but I figured that out with @hgy29 help :)

    for the records, the error that was present in my drawRect function has been fixed here:
    local function drawRect(x1, y1, w,h, label, n)
     
    	local function getRdnCol(m)
    		local colors = {0xff0000, 0x0000ff, 0x00ff00, 0xdddddd, 0x000000}
    		return colors[m]
    	end
     
    	local x2=x1+w 
    	local y2=y1+h
     
    	local shape = Shape.new()
    	shape:setFillStyle(Shape.SOLID, getRdnCol(n), 0.2)
    	shape:beginPath()
    	shape:moveTo(x1, y1)
    	shape:lineTo(x2, y1)
    	shape:lineTo(x2,y2)
    	shape:lineTo(x1, y2)
    	shape:lineTo(x1, y1)
    	shape:endPath()
     
    	if label then
    		local txt = "\e[color=#f0f]"..label.."\e[color]"
    		local l = TextField.new(nil, txt)
    		l:setScale(4)
    		l:setAnchorPoint(.5,.5)
    		shape:addChild(l)
    		l:setPosition(x2*.5, y2*.5)
    	end
     
     
    	return shape
    end
    The only thing I am still struggling now about this matter, is that since my textfield is multiline and its length exceeds the size of the panel layout, getting its bounds leads to this:



    I am trying to understand if it's possible to query the boundaries of the visible area but had no luck so far. :)

  • hgy29hgy29 Maintainer
    I think getBounds() takes a Boolean as second arg for this purpose, but I don’t know if that will be enough

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29 said:

    I think getBounds() takes a Boolean as second arg for this purpose, but I don’t know if that will be enough

    You are always right, thank you! :)
    local fx, fy, fw, fh =  v[2]:getBounds(v[3],true)

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer

    Likes: pie

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29 said:
    Perfect, that event is a golden point to know when to trigger stuff, thanks :)

    for the records this is the updated code:
    startui.textfield:addEventListener(Event.LAYOUT_RESIZED, function(event)
    									for i,v in ipairs(testtab) do 
    										local fx, fy, fw, fh =  v[2]:getBounds(v[3],true)
    										print(v[1], "X", fx, "Y", fy, "W", fw, "H", fh)
    										local area = drawRect( fx, fy, fw, fh, v[1], i)
    										stage:addChild(area)
     
    									end 
     
    								end)


    Another question, if you still have patience :smiley:
    Can we set background images for UI.Panel elements?

    I've seen that UI.Panel has a setImage function and I've seen that I can call it in UI.Builder with
    Image = "myimage.png"
    or later as myElement:setImage (ie. on LAYOUT_RESIZED) but I can't see that image appear in my layout.


    Thank you

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    Yes, that’s because default color of Panel is transparent, and it acts like setColorTransform would. Set color to white and the image should appear

    Likes: MoKaLux, pie

    +1 -1 (+2 / -0 )Share on Facebook
Sign In or Register to comment.