Author Topic: CalGUI -- A GUI library by flyingfisch  (Read 30961 times)

0 Members and 3 Guests are viewing this topic.

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
CalGUI -- A GUI library by flyingfisch
« on: January 05, 2012, 10:16:28 am »
NOTE: I am posting this in PRIZM projects, but since there is no LuaFX for PRIZM yet, it would be nice to have a LuaFX/AFX projects section ;)

I have been meaning to make a GUI library for a while and have only now found the time, so here it is in alpha-of-an-alpha :D

Available functions:

* Lua Classes (thanks to adriweb for code)
* Input text (missing in the originl luaFX)

Planned functions to be included:

* Buttons
* Window Manager
* EZ Menus
* Dialog boxes
* Radio Buttons
* Check Boxes
* More :D

Since this project is free and open source, and you are free to fork it if you want, here is the code: ;)

EDIT: Added a GitHub repo

Code: [Select]
-- locals
local line = graydraw.line
local wait = misc.wait
local setcolor = graydraw.setcolor
local text = graydraw.text
local exitprog = misc.exit
local print = nbdraw.print
local find = string.find
local setCursor = nbdraw.setcursor
local strsub = string.sub
local strlen = string.len

--[[--
CalGUI (Pronounced Cal-gew-ey), a GUI library for LuaFX
By flyingfisch
Last Updated 1/05/2012
This project is free and open source.
--]]--

--[[--
Class definition system
Borrowed from LuaNspire
Thanks to adriweb for code
--]]--
class = function(prototype)
    local derived = {}
    local derivedMT = {
        __index = prototype,
        __call  = function(proto, ...)
            local instance = {}
            local instanceMT = {
                __index = derived,
                __call = function()
                    return nil, "ERROR: Attempt to invoke an instance of a class"
                end,
            }
            setmetatable(instance, instanceMT)
            if instance.init then
                instance:init(...)
            end
            return instance
        end,
    }
    setmetatable(derived, derivedMT)
    return derived
end

--[[--
Input text system
--]]--
function input()
setcolor(false) --set 5-color mode "false"
i = 1
parse = ""
print(parse .. "_")
--keystrokes
while not key(5) do
repeat
--non-alpha:
if alpha == 0 then
if key(1) then parse = parse .. "0" end
if key(2) then parse = parse .. "." end
if key(4) then parse = parse .. "-" end
if key(6) then parse = parse .. "1" end
if key(7) then parse = parse .. "2" end
if key(8) then parse = parse .. "3" end
if key(9) then parse = parse .. "+" end
if key(10) then parse = parse .. "-" end
if key(11) then parse = parse .. "4" end
if key(12) then parse = parse .. "5" end
if key(13) then parse = parse .. "6" end
if key(14) then parse = parse .. "*" end
if key(15) then parse = parse .. "/" end
if key(16) then parse = parse .. "7" end
if key(17) then parse = parse .. "8" end
if key(18) then parse = parse .. "9" end
if key(19) then parse = strsub(parse,1,#parse-1) end
if key(33) then alpha = 1 end
--alpha:
else
if key(1) then parse = parse .. "z" end
if key(2) then parse = parse .. " " end
if key(3) then parse = parse .. [["]] end
if key(6) then parse = parse .. "u" end
if key(7) then parse = parse .. "v" end
if key(8) then parse = parse .. "w" end
if key(9) then parse = parse .. "x" end
if key(10) then parse = parse .. "y" end
if key(11) then parse = parse .. "p" end
if key(12) then parse = parse .. "q" end
if key(13) then parse = parse .. "r" end
if key(14) then parse = parse .. "s" end
if key(15) then parse = parse .. "t" end
if key(16) then parse = parse .. "m" end
if key(17) then parse = parse .. "n" end
if key(18) then parse = parse .. "o" end
if key(19) then parse = strsub(parse,1,#parse-1) end
if key(21) then parse = parse .. "g" end
if key(22) then parse = parse .. "h" end
if key(23) then parse = parse .. "i" end
if key(24) then parse = parse .. "j" end
if key(25) then parse = parse .. "k" end
if key(26) then parse = parse .. "l" end
if key(27) then parse = parse .. "a" end
if key(28) then parse = parse .. "b" end
if key(29) then parse = parse .. "c" end
if key(30) then parse = parse .. "d" end
if key(31) then parse = parse .. "e" end
if key(32) then parse = parse .. "f" end
if key(34) then parse = parse .. "r" end
if key(33) then alpha = 0 end
end
wait(2) --interrupt
until key(0)

clear nil
setCursor(1,1)
print(parse .. "_")

refresh

if key(5) then break end --check for EXE
wait(3)
end
end
« Last Edit: January 05, 2012, 11:12:36 am by flyingfisch »



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: CalGUI -- A GUI library by flyingfisch
« Reply #1 on: January 05, 2012, 11:10:17 am »
does it work with the classes now? sounds great, now you're sort of the inventor of classes for casio lol

looks good, and it might be alpha-of-alpha, but you have to start somewhere.. i wish you good luck with it (not sarcastic or ironically meant xp )

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: CalGUI -- A GUI library by flyingfisch
« Reply #2 on: January 05, 2012, 11:14:29 am »
does it work with the classes now? sounds great, now you're sort of the inventor of classes for casio lol

looks good, and it might be alpha-of-alpha, but you have to start somewhere.. i wish you good luck with it (not sarcastic or ironically meant xp )

I understand how its meant :)

Yep, It does work with classes.

I added a repo on GitHub for this project: https://github.com/flyingfisch/CalGUI



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: CalGUI -- A GUI library by flyingfisch
« Reply #3 on: January 05, 2012, 11:22:44 am »
ooh, i just took a look at it, and can't you remake that
Code: [Select]
if key(1) then parse = parse .. "0" end
if key(2) then parse = parse .. "." end
if key(4) then parse = parse .. "-" end
etc etc
to a table like this:
Code: [Select]
parsetable = {
["1"]="0",
["2"]=".",
etc..
}

or isn't that possible in luaFX? it would be a lot smaller than now, so you don't need all those statements, just
Code: [Select]
parse..parsetable[tostring(key)]
« Last Edit: January 05, 2012, 11:24:30 am by Nick »

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: CalGUI -- A GUI library by flyingfisch
« Reply #4 on: January 05, 2012, 11:26:58 am »
does it work with the classes now? sounds great, now you're sort of the inventor of classes for casio lol

Just for LuaFX! :p

OW, 208 posts already?
« Last Edit: January 05, 2012, 11:27:11 am by Eiyeron »

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: CalGUI -- A GUI library by flyingfisch
« Reply #5 on: January 05, 2012, 11:29:22 am »
ooh, i just took a look at it, and can't you remake that
Code: [Select]
if key(1) then parse = parse .. "0" end
if key(2) then parse = parse .. "." end
if key(4) then parse = parse .. "-" end
etc etc
to a table like this:
Code: [Select]
parsetable = {
["1"]="0",
["2"]=".",
etc..
}

or isn't that possible in luaFX? it would be a lot smaller than now, so you don't need all those statements, just
Code: [Select]
parse..parsetable[tostring(key)]

Ok, so this is using classes?

does it work with the classes now? sounds great, now you're sort of the inventor of classes for casio lol

Just for LuaFX! :p

OW, 208 posts already?
What do you mean by "Just for LuaFX"?



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: CalGUI -- A GUI library by flyingfisch
« Reply #6 on: January 05, 2012, 11:31:22 am »
no flyingfisch, that's not classes, that's just a table and the reference to it..

i only don't know if that ["0"]= is possible in lua, it would make the work much easier

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: CalGUI -- A GUI library by flyingfisch
« Reply #7 on: January 05, 2012, 11:35:38 am »
does it work with the classes now? sounds great, now you're sort of the inventor of classes for casio lol

Just for LuaFX! :p

OW, 208 posts already?
What do you mean by "Just for LuaFX"?

C/C++ and classes could be already compiled with GCC or Casio's SDK (if the first option is better than second). But Very good job for making classes :)

and just {"0","1","2"...} is enough, nah?
« Last Edit: January 05, 2012, 11:36:22 am by Eiyeron »

Offline flyingfisch

  • I'm 1337 now!
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1620
  • Rating: +94/-17
  • Testing, testing, 1...2...3...4...5...6...7...8..9
    • View Profile
    • Top Page Website Design
Re: CalGUI -- A GUI library by flyingfisch
« Reply #8 on: January 05, 2012, 11:36:41 am »
key(0) returns true if one or more keys are pressed.



Quote from: my dad
"welcome to the world of computers, where everything seems to be based on random number generators"



The Game V. 2.0

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: CalGUI -- A GUI library by flyingfisch
« Reply #9 on: January 05, 2012, 11:38:52 am »
I know that! I'm the guy who forc'd Veb to make that! :p
and with table = {"a" = 5}, we can make table.a = 5, I saw that with trying to make a tilemapper engine...

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: CalGUI -- A GUI library by flyingfisch
« Reply #10 on: January 05, 2012, 11:55:58 am »
you should go look at my lib i have made for the nspire. it offers all of those things you mentioned plus more. its bieng updated and their are pictures on this site in another topic it might give you some ideas...:
http://ourl.ca/14633/276223;topicseen#new
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: CalGUI -- A GUI library by flyingfisch
« Reply #11 on: January 05, 2012, 11:56:53 am »
What does mean "EZ menus"?

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: CalGUI -- A GUI library by flyingfisch
« Reply #12 on: January 05, 2012, 11:57:30 am »
is there a big difference between luaFX and Nspire lua? otherwise this gui from jwalker could be really useful

Offline Eiyeron

  • Urist McEiyolobster
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1430
  • Rating: +130/-10
  • (-_(//));
    • View Profile
    • Rétro-Actif : Rétro/Prog/Blog
Re: CalGUI -- A GUI library by flyingfisch
« Reply #13 on: January 05, 2012, 12:02:06 pm »
Not many graphics functions!

Offline jwalker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 660
  • Rating: +13/-0
  • Almost everything I have released includes a 'WZ'
    • View Profile
Re: CalGUI -- A GUI library by flyingfisch
« Reply #14 on: January 05, 2012, 12:05:01 pm »
what functions are there?
basicly if it supports lines, arcs, text, and the abiliy to fill polygons like rectangles, thats prety much all you need
<a href="http://www.nerdtests.com/ft_cg.php?im">
<img src="http://www.nerdtests.com/images/ft/cg.php?val=9612" alt="My computer geek score is greater than 41% of all people in the world! How do you compare? Click here to find out!"> </a>

Support Casio-Scene against the attacks of matt @ matpac.co.uk ! For more information: Casio-Scene shuts down & Matt actions threads