Page 3 of 3

Re: loveui 0.7 (just started)

Posted: Fri Aug 26, 2011 10:03 pm
by chrism
Can you change the style elements of a widget without having to create whole new style and applying it? For example, is it possible to move a widget just by changing it's "left" and "top" style elements?

Re: loveui 0.7 (just started)

Posted: Sun Aug 28, 2011 3:55 am
by appleide
You create a new style that only specifies left and top, and apply it to the element.

The following code adds a button to the context, and set it to location (10, 10), without modifying the buttons' default style.

Code: Select all

local context = ui.context()
st_b1, button_b1 = 
context:add(
  ui.style("b1", {left=10,top=10}),
  ui.button("b1", {value = "Menu"})
    :onclick(function(self, x, y, button)
      print("click", x, y, button)
    end))
EDIT: If you want to move the widget every frame... remove the style that describes the location and add a new style that describes the updated location.

Code: Select all

function love.update(dt)
  context:update(dt)
  context:remove(st_b1)
  st_b1.styles.left = st_b1.styles.left + 1
  context:add(st_b1)
end

Re: loveui 0.7 (just started)

Posted: Sun Aug 28, 2011 4:56 pm
by chrism
Excellent, thanks for the examples.

Re: loveui 0.7 (just started)

Posted: Mon Sep 05, 2011 10:46 am
by appleide
Added label and checkbox. See github download link in first post to download newest version.

Re: loveui 0.7 (just started)

Posted: Mon Sep 05, 2011 12:38 pm
by T-Bone
Pics?

Re: loveui 0.7 (just started)

Posted: Mon Sep 05, 2011 1:02 pm
by appleide
T-Bone wrote:Pics?
Here :)

Re: loveui 0.7 (just started)

Posted: Mon Sep 05, 2011 3:33 pm
by T-Bone
appleide wrote:
T-Bone wrote:Pics?
Here :)
Looks good! Put some pics in the first post, that's where people look for them!