Author Topic: Axe GUI Library  (Read 21508 times)

0 Members and 1 Guest are viewing this topic.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Axe GUI Library
« on: April 06, 2011, 09:51:19 am »
 

I was just in the mood to create an Axe GUI library and I thought "Why not?".

So it's not really a library since I use subroutines to create frames, buttons and dialogs.

So that you can have an idea of how this works, take a look at the code to draw the ABOUT button you can see in the demo:

Code: [Select]
sub(DB,40,42,30,10
Text(46,44,"ABOUT

As simple as that!

Let's take a look at its event when pressed:

Code: [Select]
If getKey(54)
[80C0E0F0F8F0B818->O
If X>40 and (X<70 and (Y>42 and (Y<52
sub(DD,"ABOUT","PROGRAM MADE","BY DAVID","GOMES"
Repeat getKey
End
End
...
End


So you have just learnt the two Drawing subroutines, DD (draw dialog) and DB (draw button).

There is not a DF (draw frame) yet, I am tidying it up to make it all a subroutine, but when finished it'll work like this:

Code: [Select]
sub(DF,"TITLE",1,0
The 1 (which could be a 0) is for X button or no X button to close the frame.
The 0 (which could be a 1) is for allow [CLEAR] to exit or don't allow [CLEAR] to exit.

This is just a demo, but I hope the library can have some uses :D I'll be making a few more Drawing Routines for other kinds of buttons, listboxes, etc. Not sure of how to make a textbox though.

Probably they can be in separate files (the routines) instead of being in the same program as the main program.

What do you think?
« Last Edit: April 06, 2011, 09:51:44 am by Scout »

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Axe GUI Library
« Reply #1 on: April 06, 2011, 11:16:43 am »
Looks pretty good! :D
Looks like DCS7 cursor thingy XD
Sig wipe!

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe GUI Library
« Reply #2 on: April 06, 2011, 01:00:44 pm »
Looks pretty good! :D
Looks like DCS7 cursor thingy XD

Thanks :D

I finished the Draw Frame subroutine and here's my code for drawing the GUI in the GUI demo now:

Code: [Select]
sub(DB,30,30,30,10
Text(34,32,"BUTTON
sub(DB,40,42,30,10
Text(46,44,"ABOUT
sub(DF,1,"TITLE

And that's all!!!

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Axe GUI Library
« Reply #3 on: April 06, 2011, 01:06:46 pm »
Looks nice, but you could optimize the location detection routine if you are willing to accept aligned buttons,
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe GUI Library
« Reply #4 on: April 06, 2011, 01:18:50 pm »
Wow great job scout!
I'm not a nerd but I pretend:

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe GUI Library
« Reply #5 on: April 06, 2011, 05:36:14 pm »
Wow great job scout!

Thanks.

I forgot how to explain how to use the three subroutines so far, here I go:
----------------------------------------------------------------------------------------------------
Code: [Select]
sub(DF,1,"TITLE
sub(DF,0,"NO CLOSE BUTTON

When you have 1 it draws a little X in the right upper corner, if you put 0 it won't.
----------------------------------------------------------------------------------------------------
Code: [Select]
sub(DB,30,30,30,10
Text(34,32,"BUTTON

This draws a button at coordinates (30,30) with width 30 and height 10.
----------------------------------------------------------------------------------------------------
Code: [Select]
sub(DD,"ABOUT","PROGRAM MADE","BY DAVID","GOMES"
Repeat getKey
End

This draws a message box (or dialog) with title 'ABOUT', and its text is the following:
Code: [Select]
PROGRAM MADE
BY DAVID
GOMES

Each argument is a line.


Hope you got it :D

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Axe GUI Library
« Reply #6 on: April 06, 2011, 06:00:40 pm »
That is really impressive. It looks almost exactly like the way you do Windows stuff, just way easier.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe GUI Library
« Reply #7 on: April 07, 2011, 09:11:46 am »
Looks pretty good! :D
Looks like DCS7 cursor thingy XD

Yeah, I used the same mouse sprite since I couldn't think of another way to do it.

Looks nice, but you could optimize the location detection routine if you are willing to accept aligned buttons,

What do you mean with that?


Also, I have added yet another GUI component, I'll show it to you later :)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe GUI Library
« Reply #8 on: April 07, 2011, 10:11:05 am »
Update



I added a status bar, very similar to Windows's, which can be created by writing:

Code: [Select]
sub(SB,X,"TEXT"

X is the X position of the text, for example, for the image above I wrote sub(SB,62,"GUI DEMO.

I optimized the subroutines and the main code (in the loop) is getting much shorter. The GUI DEMO is only 2000bytes for now :D (the compiled version).

Attached is the source code of the GUI. It works better if compiled with Axe 0.5.1 :D

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Axe GUI Library
« Reply #9 on: April 07, 2011, 12:02:27 pm »
That looks awesome :D

Maybe we could make an axiom with that?

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Axe GUI Library
« Reply #10 on: April 07, 2011, 01:07:56 pm »
Looks nice, but you could optimize the location detection routine if you are willing to accept aligned buttons,

What do you mean with that?

Currently you're using M>X and N<X to kind of "trap" the cursor and detect it. However, you can take advantage of the fact that Axe doesn't use decimal math to get the position of the cursor with two lines and half as many comparisons per button. The disadvantage is that you're forced to give up some accuracy and flexibility in where you can put your buttons. Here's a demonstration of what I mean:



As you can see, the buttons are all triggered by clicking on them when the cursor is inside of their "area." It's a simple matter to only define those areas that you want clicked and the size of each click area can be fully modified.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe GUI Library
« Reply #11 on: April 08, 2011, 10:01:03 am »
"Currently you're using M>X and N<X to kind of "trap" the cursor and detect it."

Exactly.

"However, you can take advantage of the fact that Axe doesn't use decimal math to get the position of the cursor with two lines and half as many comparisons per button."

No idea of what you mean.

Also, since this library is 200% open source, Ashbad is joining the team and will make a few changes to it, I hope he contributes :D

Offline z80man

  • Casio Traitor
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 977
  • Rating: +85/-3
    • View Profile
Re: Axe GUI Library
« Reply #12 on: April 08, 2011, 10:26:31 am »
I think what Qwerty means is that because the buttons are all located on a grid instead of randomly placed, you can add some optimizations. So correct me if I'm wrong, but you can find the cursor position on the grid by using x/width and y/height. Then using the 2 grid coordinates you can see if a button exists there.

List of stuff I need to do before September:
1. Finish the Emulator of the Casio Prizm (in active development)
2. Finish the the SH3 asm IDE/assembler/linker program (in active development)
3. Create a partial Java virtual machine  for the Prizm (not started)
4. Create Axe for the Prizm with an Axe legacy mode (in planning phase)
5. Develop a large set of C and asm libraries for the Prizm (some progress)
6. Create an emulator of the 83+ for the Prizm (not started)
7. Create a well polished game that showcases the ability of the Casio Prizm (not started)

Ashbad

  • Guest
Re: Axe GUI Library
« Reply #13 on: April 08, 2011, 11:54:25 am »
I used a system that qwerty would like, but also added:

-pic support
-scroll bars (working)
-input boxes
-scripting language

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Axe GUI Library
« Reply #14 on: April 08, 2011, 11:54:51 am »
I used a system that qwerty would like, but also added:

-pic support
-scroll bars (working)
-input boxes
-scripting language

Very nice Ashbad :D