Omnimaga

Calculator Community => Other Calc-Related Projects and Ideas => TI-Nspire => Topic started by: hoffa on August 17, 2011, 08:10:29 am

Title: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: hoffa on August 17, 2011, 08:10:29 am
Hello,

I started a small project of writing in Lua a GUI library for the TI-Nspire. At the moment there's not much; the windows are clickable and the general floating windows thing works.
As everybody loves screenshots, I give you a screenshot:

(http://webgel.net/bf/5/hyena.png)

Also here's a very early video with some content in one of the windows. I can move windows around and close them also (forgot to show that, but it works).



I'm not even sure if it will actually be that useful when I eventually manage to make something usable, but we'll see about that later.
Well that's about it for the moment. :3
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: Munchor on August 17, 2011, 08:22:28 am
Looking great hoffa! I'd love some project like this, I have no idea of how you managed to make it too.
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: Adriweb on August 17, 2011, 08:23:52 am
Hey,

nice job, this looks like a nice library indeed.

@ephan : He used classes do get the windows, buttons, title etc.

It's quite long to do but not that hard :)
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: hoffa on August 17, 2011, 03:14:05 pm
I added a short video to show how it works and runs. I can now move and close the windows, and added some content to one of them.
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: DJ Omnimaga on August 17, 2011, 03:15:04 pm
Heya Hoffa where have you been? O.O I noticed you stopped posting for over a month recently. D: Nice to see you back now. Also this looks nice. :D
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: Adriweb on August 17, 2011, 03:15:49 pm
Great !

You know, you can use a cursor.set("grab") <-- or something like that, I don't remember exactly
when grabbing windows ...

it's all on http://wiki.inspired-lua.org/cursor.set (http://wiki.inspired-lua.org/cursor.set)
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: hoffa on August 17, 2011, 03:25:49 pm
Heya Hoffa where have you been? O.O I noticed you stopped posting for over a month recently. D: Nice to see you back now. Also this looks nice. :D
I was working for nearly two months in a landfill in Finland. I was doing the evening shift and spent nearly the whole day shoveling waste over there. Didn't have much nor did I spend much time on the computer during that time.

Great !

You know, you can use a cursor.set("grab") <-- or something like that, I don't remember exactly
when grabbing windows ...

it's all on http://wiki.inspired-lua.org/cursor.set (http://wiki.inspired-lua.org/cursor.set)
That's great, didn't know about that. Thanks!
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: DJ Omnimaga on August 17, 2011, 03:27:31 pm
Aaah ok I see. That explains why you were gone then. To be honest I noticed almost all our european users vanished for a while in Early july, though O.O
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: hoffa on August 19, 2011, 11:41:34 am
Alright so now I've rewritten a few parts and restructured my code and done other such things.

Here's a small example of a program, it should be pretty straightforward:
Code: [Select]
function win_1_f()
    hyena:drawImage(win_1, hyenaImage, 0, 0)
    hyena:drawString(win_1, "Hello, hyena!", 0, 50)
end

function win_2_f()
    hyena:drawString(win_2, "LOOK AT THESE GODDAMN ANTS", 0, 0)
end

function on.mouseDown(x, y)
    hyena:mouseDown(x, y)
end

function on.mouseUp(x, y)
    hyena:mouseUp(x, y)
end

function on.mouseMove(x, y)
    hyena:mouseMove(x, y)
end

function on.timer()
    timer.stop()
    platform.window:invalidate()
end

initialized = false
function on.paint(gc)
    if not initialized then
        hyena = Hyena(gc)
        win_1 = hyena:createWindow("First window, yay!", 0, 0, 128, 96)
        win_2 = hyena:createWindow("FEELS GOOD MAN", 80, 40, 100, 100)
        hyena:setWindowContentFunction(win_1, win_1_f)
        hyena:setWindowContentFunction(win_2, win_2_f)
        initialized = true
    end
    hyena:drawWindows()
    timer.start(0.01)
end

Which gives (it isn't rendered exactly like that on calc, there are a few very minor differences):
(http://webgel.net/bf/6/hyena.png)
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: pianoman on August 19, 2011, 11:47:36 am
Hmmm, I don't know how I missed this the first time.
Regardless, it looks really epic :)
Any chance you could upload your library code to pastebin or something like that and give us a link to that sometime soon, because, if it's alright with you, I would really love to implement this in Pacman :D
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: NecroBumpist on August 19, 2011, 11:58:03 am
Pretty cool, I might also try a basic window GUI library like this as well.
Also, dragging windows looks rather difficult on the touchpad, maybe you could change instead to holding a button like "ctrl", and pressing 4, 8, 6, or 2 will move the focused window left, up, right or down respectively ?
/suggestion
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: hoffa on August 19, 2011, 12:20:44 pm
Hmmm, I don't know how I missed this the first time.
Regardless, it looks really epic :)
Any chance you could upload your library code to pastebin or something like that and give us a link to that sometime soon, because, if it's alright with you, I would really love to implement this in Pacman :D
I'll post the current code in less than an hour, got to do some housekeeping and add a few functions. :)

Pretty cool, I might also try a basic window GUI library like this as well.
Also, dragging windows looks rather difficult on the touchpad, maybe you could change instead to holding a button like "ctrl", and pressing 4, 8, 6, or 2 will move the focused window left, up, right or down respectively ?
/suggestion
Actually it's not that difficult to move them around. It looked painful because I moved the window so slowly, and that was because of a small issue (if I moved the cursor too fast, it would ungrab the window). It's fixed now and works pretty well:
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: pianoman on August 19, 2011, 12:23:44 pm
Hmmm, I don't know how I missed this the first time.
Regardless, it looks really epic :)
Any chance you could upload your library code to pastebin or something like that and give us a link to that sometime soon, because, if it's alright with you, I would really love to implement this in Pacman :D
I'll post the current code in less than an hour, got to do some housekeeping and add a few functions. :)
Wonderful :)
Nice job on this :D
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: hoffa on August 19, 2011, 01:21:10 pm
Hmmm, I don't know how I missed this the first time.
Regardless, it looks really epic :)
Any chance you could upload your library code to pastebin or something like that and give us a link to that sometime soon, because, if it's alright with you, I would really love to implement this in Pacman :D
I'll post the current code in less than an hour, got to do some housekeeping and add a few functions. :)
Wonderful :)
Nice job on this :D
As promised, here's the current code: http://pastebin.com/4x53C9yk
It's everything but ready, there's still quite a bit of things to do. Codewise, I still need to find a nice way to take full advantage of Nspire Lua's magnificent object oriented programming.
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: DJ Omnimaga on August 31, 2011, 02:58:01 pm
Wow nice Hoffa!
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: Kjelddy on August 31, 2011, 03:28:47 pm
:O the calculators are more and more looking after pc OS's :)
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: Levak on August 31, 2011, 04:14:00 pm
hoffa : you should create a screen class. That way you don't have to do like that

Code: [Select]
        win_2 = hyena:createWindow("FEELS GOOD MAN", 80, 40, 100, 100)
        hyena:setWindowContentFunction(win_2, win_2_f)

but like that :
Code: [Select]
screen = class()
function screen:init()
...
end

function screen:paint(gc) --> here gc is hyena for more "confort"
...
end

...

textBox = class(screen)
function textBox:init(txt)
...
end

-- override screen:paint(gc) function
function screen:paint(gc) --> here gc is hyena for more "confort"
...
end

...

        win_2 = textBox("FEELS GOOD MAN")
        hyena:setWindowContentFunction(win_2)
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: renatose on December 01, 2011, 10:47:51 am
hoffa disappeared again...

this would be very useful for my project and maybe any other lua projects...

Anyway I've got to learn some object oriented programming... Which could be a problem when we are too much accustomed with TI-BASIC programming.
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: flyingfisch on December 01, 2011, 12:54:40 pm
I am thinking about doing something like this for casio LuaFX.
Title: Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
Post by: Jim Bauwens on December 02, 2011, 04:44:05 am
hoffa disappeared again...

this would be very useful for my project and maybe any other lua projects...

Anyway I've got to learn some object oriented programming... Which could be a problem when we are too much accustomed with TI-BASIC programming.

I'm making a gui library of EEPro, it will be open source so you will be able to use it :)