Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / TopGUI - Open source immediate mode GUI

Author
Message
Chris Tate
DBPro Master
10
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 4th Jan 2012 01:24 Edited at: 4th Jan 2012 01:26
Ok, I'm starting to work on some projects and wanted to share the extra controls as I create them. The controls I make will reside in seperate source files that can be added to any up-to-date TopGUI project.

To start with I have added a button with rounded edge and a button that is bevelled.

If Diggsey or anyone good with graphics programming knowledge can give some tips on the rounded edge buttons, please do so, because they do not look perfect; and they look worse when you use a large radius.


Button Source File

Button Snippet (v0.1) - (Excuse my browser for adding double tabs)


Tester Demo


GlenNU
7
Years of Service
User Offline
Joined: 10th Oct 2011
Location:
Posted: 6th Feb 2012 07:55
i am having a problem with sprites and topgui:

with topgui - white sprite:


without topgui:


-
GlenNU
7
Years of Service
User Offline
Joined: 10th Oct 2011
Location:
Posted: 13th Feb 2012 04:28
I already fixed the above post..

is it possible to implement an imagebox in topgui?

-
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 13th Feb 2012 13:06 Edited at: 13th Feb 2012 13:07
Sorry I must have missed your first post, what was the problem in the end?

Also, TopGUI already supports an imagebox. For normal or tiled images you can use a normal panel or a scroll panel (guiPanel(), guiScrollPanel()). For other effects such as scaling, you can just draw the image yourself using "a2DrawImage" when inside the window you want it to appear in.

guiAdjustX(localx) and guiAdjustY(localy) will convert local coordinates inside the current control into screen coordinates for you.

[b]
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 17th Feb 2012 01:29 Edited at: 17th Feb 2012 01:41
First of all i have to say: Awesome Project! Allready using it in my project(s). Keep on it!

You could add a Text button like i'm doing.



(Code was just a test, maybe theres a better way.)



best regards.

edit: Gridboxes would be awesome too! Need that for my Server Browser
Lost Dragon
8
Years of Service
User Offline
Joined: 22nd Aug 2010
Location:
Posted: 17th Feb 2012 05:42
This is really cool.

I'm plowing through it now. Is there any help file or instructions?

I noticed that the scroll bar's "bar" (whatever that is called) will eventually get so small that it becomes really hard to grab if there are enough items in a window. It should probably have a minimum size set.

Does this have any sort of drag and drop functionality built in? Say like I wanted to drag an icon from one window and drop it in another?

It's really good work. I also use your Advanced2D functions. Thanks!
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 17th Feb 2012 19:26 Edited at: 17th Feb 2012 19:30
How can i readout the ItemIndex or ItemText of the selected item in a combo box?

Got it, guiComboboxEnd()
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 17th Feb 2012 22:58
@Gunslinger
Nice idea, I'll add that for the next update. I'll see what I can do about gridboxes, but they're alot more complicated.

@Lost Dragon
Not really any help files, sorry. I'll see if I can make at least some sort of document explaining how to use it at some point.

Good point about the scrollbar, will work on fixing that.

Drag and drop is not built in. It's fairly easy to emulate, but I'll see if I can add some stuff to make it easier.

[b]
Lost Dragon
8
Years of Service
User Offline
Joined: 22nd Aug 2010
Location:
Posted: 17th Feb 2012 23:17
Can someone show me how to use guiTextarea properly?

I want to put some strings in a box (that can scroll) and have them word wrap when appropriate. I thought guiTextarea would be good for that but I don't understand how to use it.

I need a simple example without a parser or anything fancy.

I got buttons to work okay.
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Feb 2012 00:32 Edited at: 18th Feb 2012 15:23
Ok, it's actually not too bad:


The stuff after the "do" should go in your main loop where you actually want the text to appear.

You can't not have a parser, since it needs to know how it should display the text, but top-gui comes with a default one which just says to use the default text style for everything.

edit:
If all you want to do is display multi-line word-wrapped text with no selection or editing, you'd be better off just using a label

[b]
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 18th Feb 2012 01:57
Found a small bug.
If you draw the windows (with a picbutton) with

guiWindowListNames(get arrayptr(windowFuncPtrs()), 1)

at a first part of the game (like the menu), and then clean the memory (deleting all images for example)

and then draw it again (ingame, after the menu) it will crash at removing the cached images (even if a new image is loaded with the same image number)



can be fixed with



I think.

And, i have no clue why, if you load an image to a button, and delete it later, it cant be loaded again.

Like

load image "xxx", 2
draw a image button with image 2 at the game menu
delete all images
load image "yyy", 2

that image can't be displayed.
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Feb 2012 02:34 Edited at: 18th Feb 2012 02:35
You shouldn't just delete all images. TopGUI has its own resource management, so you should only delete images that you have created. The simplest way of doing this is just add all image IDs you use to an array and then use that array for deleting images, but you should normally have some way of keeping track of things anyway.

[b]
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 18th Feb 2012 02:46
Ye i put that into arrays. But i just wanted a "lazy" solution for getting from the menu into the game, and back
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Feb 2012 03:16
Just updated the first post with a new version

- Text button is now supported
- Scrollbar thumbs won't get too small
- Drag-drop is now supported
- Altered test program to include new features

[b]
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 18th Feb 2012 23:47
Another update with some features I think alot of people will find useful:
- Message dialog
- Open file dialog
- Save file dialog

These are very easy to use, just call the relevent function (see TopGui_Dialog.dba) and pass in a pointer to a function to call.

When the dialog is closed the function you specified will be called and the result of the dialog passed in.

The dialogs support filters and optionally selection of multiple files at once.

[b]
GlenNU
7
Years of Service
User Offline
Joined: 10th Oct 2011
Location:
Posted: 20th Feb 2012 14:17
How can I make TopGUI to appear on top of sprites?



-
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th Feb 2012 18:03
The only thing that can appear on top of sprites is another sprite. The easiest thing to do would be to hide the sprite and use "paste sprite" to draw it instead. As long as the "paste sprite" command appears before that part of the GUI is drawn it will appear underneath it.

[b]
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 20th Feb 2012 20:19
Just a question, but why do you use topgui to draw that bars?
GlenNU
7
Years of Service
User Offline
Joined: 10th Oct 2011
Location:
Posted: 21st Feb 2012 14:24
I'm a newbie..
I use TopGUI for HP Bars and menu buttons..

-
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 21st Feb 2012 16:20
Nah, it's okay. Just asking
Gunslinger
12
Years of Service
User Offline
Joined: 29th May 2007
Location:
Posted: 2nd Mar 2012 20:21 Edited at: 2nd Mar 2012 21:32
Is there a way to return the selected item text of a combo box?
Did not see it in the combobox file.

e// Okay, created my own function for that.

edit again: For dialogs are no returns done too, are they? Or am i just too stupid to find that?
Jimmy
15
Years of Service
User Offline
Joined: 20th Aug 2003
Location: Back in the USA
Posted: 3rd Mar 2012 00:24 Edited at: 3rd Mar 2012 00:25
guiComboboxEnd() returns the index of the selected item

And it looks like, with the dialogs, you have to pass the pointer to a callback function that takes 3 parameters: param As Integer, path As String, and result As String.

Example:



Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 3rd Mar 2012 04:39
Dialogs don't return a result immediately because while the user is interacting with them the program must keep running, so instead you pass in a function which will be called when the dialog is closed such as in Jimmy's example.

[b]
NQC
10
Years of Service
User Offline
Joined: 14th Mar 2009
Location:
Posted: 6th May 2012 00:06
What function use for remove gui?

I am a newbie. ^ ^

NQC
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th May 2012 21:05
There's no function to remove the gui, because the gui isn't a persistant thing. As soon as you stop calling the functions to draw the gui it will no longer exist.

[b]
NQC
10
Years of Service
User Offline
Joined: 14th Mar 2009
Location:
Posted: 6th May 2012 21:38
Thank you for answer. I'll re-coding and test again.

NQC
Duffer
16
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 7th May 2012 13:12 Edited at: 7th May 2012 13:12
@ Diggsey,

Any chance of a TopGUI design utility exporting to dba code?

[edit]

I'm being lazy - could code one myself - but wouldn't be fantastic...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
NQC
10
Years of Service
User Offline
Joined: 14th Mar 2009
Location:
Posted: 8th May 2012 07:52
I've tested, it ok ^ ^. And i have some question. Can Topgui make item inventory gui like an online game?.

NQC
basjak
9
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 22nd May 2012 03:34
@diggsey:
I already started with bbb gui by brendy boy. however, I left it for a while as i've been busy with couple of AppGameKit projects.

now I want to comeback to gui things.

which one is better bbb gui or top gui. or both are the same. however, I didn't see those coloring frames in bbb gui.

Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 22nd May 2012 05:48
BBB gui uses the windows API to create the gui, this draws it all itself, it depends on your requirements which one you should use. If you need it to look like a standard windows application UI then use BBB gui. For something like a game, or an application where you need to do custom rendering on top of the gui I'd suggest that you use this.

[b]

Login to post a reply

Server time is: 2019-07-18 19:34:38
Your offset time is: 2019-07-18 19:34:38