Author Topic: Hyena: a simple (Lua) GUI library for the TI-Nspire  (Read 12227 times)

0 Members and 1 Guest are viewing this topic.

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Hyena: a simple (Lua) GUI library for the TI-Nspire
« 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:



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
« Last Edit: January 29, 2013, 10:55:52 am by hoffa »

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #1 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.

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #2 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 :)
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #3 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.
« Last Edit: August 17, 2011, 03:15:01 pm by hoffa »

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #4 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

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #5 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
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #6 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
That's great, didn't know about that. Thanks!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #7 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

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #8 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):
« Last Edit: January 29, 2013, 10:57:08 am by hoffa »

Offline pianoman

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 426
  • Rating: +24/-0
  • ♪♫ ♪♫ ♪♫ ♪♫ ♪♫ ♪♫ ♪♫
    • View Profile
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #9 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

Offline NecroBumpist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 130
  • Rating: +14/-5
  • Master of Lua
    • View Profile
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #10 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
Developing Lua scripts for the NSpire ?
Check out the Necrotorium
Need a few routines to run faster ? Checkout the MODS Lua Assembly Toolkit.
Need to save space for your scripts ? Checkout LuaSrcDiet

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #11 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:

Offline pianoman

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 426
  • Rating: +24/-0
  • ♪♫ ♪♫ ♪♫ ♪♫ ♪♫ ♪♫ ♪♫
    • View Profile
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #12 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

Offline hoffa

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 322
  • Rating: +131/-13
    • View Profile
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #13 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.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Hyena: a simple (Lua) GUI library for the TI-Nspire
« Reply #14 on: August 31, 2011, 02:58:01 pm »
Wow nice Hoffa!