loveui 0.7 (just started)

Showcase your libraries, tools and other projects that help your fellow love users.
chrism
Prole
Posts: 21
Joined: Wed May 25, 2011 6:17 pm

Re: loveui 0.7 (just started)

Post 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?
User avatar
appleide
Party member
Posts: 323
Joined: Fri Jun 27, 2008 2:50 pm

Re: loveui 0.7 (just started)

Post 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
chrism
Prole
Posts: 21
Joined: Wed May 25, 2011 6:17 pm

Re: loveui 0.7 (just started)

Post by chrism »

Excellent, thanks for the examples.
User avatar
appleide
Party member
Posts: 323
Joined: Fri Jun 27, 2008 2:50 pm

Re: loveui 0.7 (just started)

Post by appleide »

Added label and checkbox. See github download link in first post to download newest version.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: loveui 0.7 (just started)

Post by T-Bone »

Pics?
User avatar
appleide
Party member
Posts: 323
Joined: Fri Jun 27, 2008 2:50 pm

Re: loveui 0.7 (just started)

Post by appleide »

T-Bone wrote:Pics?
Here :)
Attachments
Picture 2.png
Picture 2.png (6.22 KiB) Viewed 6139 times
Picture 1.png
Picture 1.png (6.31 KiB) Viewed 6139 times
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: loveui 0.7 (just started)

Post 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!
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests