Murga-Projects Forums

Full Version: FLU - FLTK Utility Widgets
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
FLU - FLTK UTILITY WIDGETS
I found the project on my hard drive and remembered that it looked handy.
Cool features!

Would adding this bloat murgaLua too much?  

If I didn't mention it now it might be another many
months before I find it on my hard drive.

iGame3D Wrote:
FLU - FLTK UTILITY WIDGETS
I found the project on my hard drive and remembered that it looked handy.
Cool features!

Would adding this bloat murgaLua too much?

If I didn't mention it now it might be another many
months before I find it on my hard drive.

Hi,

I did play around with this a while ago, it is very cool, but it presents two problems ...

It is VERY callback based, and would add a lot of complexity.

AND it adds more bloat to murgaLua than I'd like to have.

I prefer to have a solid FLTK integration, and small, clearly defined extensions where FLTK falls short.

Cheers
JohnM

I think a few of these could be done, with some effort, in murgaLua. They mostly look like combinations of existing widgets, which could be manipulated with Lua.
This is a simple (but probably not efficient) way to create a rollover button using a timer. I thought it might have been possible to use when() instead of a loop, but I guess not.

Code:
w=fltk:Fl_Window(200,100,"Rollover Test")
b=fltk:Fl_Button(10,10,180,30,"rollover")

bg=b:color()
fg=b:labelcolor()
function loop()
if Fl:event_inside(b)==1 then
b:color(fg); b:labelcolor(bg)
else
b:color(bg); b:labelcolor(fg)
end
b:redraw()
timer:doWait(0.05)
end

timer=murgaLua.createFltkTimer()
timer:callback(loop)
timer:do_callback()

w:show()
Fl:run()

I'm not even going to attempt to do the file chooser, although I'm betting it's possible without adding anything to murgaLua.

Flu_Toggle_Group:

Code:
w=fltk:Fl_Window(400,300,"Flu_Toggle_group")
g=fltk:Fl_Group(10,30,380,240)
g:box(fltk.FL_EMBOSSED_FRAME)
fltk:Fl_Button(40,80,180,30,"button")
fltk:Fl_Button(40,115,180,30,"button")
fltk:Fl_Button(40,150,180,30,"button")
fltk:Fl_End()
t=fltk:Fl_Check_Button(20,15,120,30,"Toggle_Group")
t:box(fltk.FL_FLAT_BOX)
t:callback(function()
  if g:active()==1 then g:deactivate() else g:activate() end
end
)
t:value(1)
w:show()
Fl:run()

Flu_Choice_Group:

Code:
page={}
w=fltk:Fl_Window(400,300,"Flu_Choice_Group")
g=fltk:Fl_Wizard(10,30,380,240)
g:box(fltk.FL_EMBOSSED_FRAME)
page[1]=fltk:Fl_Group(10,30,380,240)
fltk:Fl_Button(40,80,180,30,"button")
fltk:Fl_End() --1
page[2]=fltk:Fl_Group(10,30,380,240)
fltk:Fl_Button(40,80,180,30,"button")
fltk:Fl_Button(40,115,180,30,"button")
fltk:Fl_End() --2
page[3]=fltk:Fl_Group(10,30,380,240)
fltk:Fl_Button(40,80,180,30,"button")
fltk:Fl_Button(40,115,180,30,"button")
fltk:Fl_Button(40,150,180,30,"button")
fltk:Fl_End() --3
fltk:Fl_End() --main
c=fltk:Fl_Choice(20,15,180,30)
c:callback(function() g:value(page[c:value()]) end)

c:add("Choice_Group")
c:add("first tab")
c:add("second tab")
c:add("third tab")
c:value(0)
w:show()
Fl:run()

with a function:

Code:
function flu_choice_group(x,y,w,h,tabs,table,label)
local g=fltk:Fl_Wizard(x,y,w,h,label)
g:box(fltk.FL_EMBOSSED_FRAME)
fltk:Fl_End()
c=fltk:Fl_Choice(20,15,180,30)
c:callback(function() g:value(table[c:value()]) end)
if not tabs then local tabs=0 end
for i=0,tabs do
  table[i]=fltk:Fl_Group(x,y,w,h)
  fltk:Fl_End()
  g:add(table[i])
  c:add("tab "..i)
end
c:value(0)
end

page={}
w=fltk:Fl_Window(400,300,"Choice_Group Test")

g=flu_choice_group(10,30,380,240,3,page)

a1=fltk:Fl_Button(40,80,180,30,"button")
page[0]:add(a1)
b1=fltk:Fl_Button(40,80,180,30,"button")
b2=fltk:Fl_Button(40,115,180,30,"button")
page[1]:add(b1)
page[1]:add(b2)
c1=fltk:Fl_Button(40,80,180,30,"button")
c2=fltk:Fl_Button(40,115,180,30,"button")
c3=fltk:Fl_Button(40,150,180,30,"button")
page[2]:add(c1)
page[2]:add(c2)
page[2]:add(c3)

w:show()
Fl:run()

Heh, and you say you are not a programmer.
Keep going :-)
Reference URL's