Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » GUI present in Allegro 5?

This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
GUI present in Allegro 5?
Matt Smith
Member #783
November 2000

Not really. GEM + TOS on the AtariST came to 192KiB. The only extra bits needed are the hierarchy tree (each object has parent, sibling and child pointers) and the dirty rectangle system (which subdivides the whole screen into paint areas).

Neither of these are particularly difficult to implement. If I hadn't tried so hard to avoid making a whole new incompatible GUI, I would have implemented these by now . I regret my decision to persevere so long with Allegro 4 GUI which has so many flaws for complex programs.

Martin Kalbfuß
Member #9,131
October 2007
avatar

In my opinion the minimum requirements for creating a game are:

graphics
sound
user input
structuring

The structuring part is often kept aside. The game libs themes to be made for games able to run in a single while loop in the main function.

When your game is getting bigger, you need to structure it. You will have different scenes. Main menu, editor, configuration, game view etc. So a minimum of structuring support would be good.

The widgets are definitely not core. But the DIALOG structures are.

If the there would be a d_dialog_proc to embed dialogs in dialogs, you could build a structure for your game, and activate or disable the different parts, when needed.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

Thomas Harte
Member #33
April 2000
avatar

Quote:

Allegro is a game lib, not a multimedia lib.

There has to be a dividing line between providing every single piece of code that any game may ever need and providing just the bits that every game will definitely need. Allegro traditionally steers a pragmatic course between the two. New-fangled Allegro 5 makes things even better by pushing the core library back to the edge of the spectrum and supplying add-ons that make its exact positioning optional.

Quote:

Neither of these are particularly difficult to implement. If I hadn't tried so hard to avoid making a whole new incompatible GUI, I would have implemented these by now . I regret my decision to persevere so long with Allegro 4 GUI which has so many flaws for complex programs.

I did at one stage have a decent enough clone of most of the QuickDraw drawing operations, but including arbitrary clip areas (essentially software-based stencilling) basically means rejecting most of Allegro's built-in code so I wouldn't advocate it as either something that should be built into the library or should be considered an officially supported add-on.

Martin Kalbfuß
Member #9,131
October 2007
avatar

Every game, made for being played needs a core of gui functionality. I can't remember ever played a finished game without gui.

I still think the DIALOG structure (or someting similar) is core.

I don't think the A4 gui is the only or best solution. There are be better ones. I know the problems about it. I use it.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

Thomas Harte
Member #33
April 2000
avatar

Quote:

Every game, made for being played needs a core of gui functionality. I can't remember ever played a finished game without gui.

I still think the DIALOG structure (or someting similar) is core.

But there are a million ways to implement GUI functionality that are entirely different to Allegro's model, and another part of Allegro has always been not forcing design decisions on the end user. That's why it is still a C based library with relatively low level operations.

For those two reasons, I respectfully disagree that DIALOG or a DIALOG variant should be a central part of the library.

However, as I said before, I'm not one of the Allegro developers, I'm just expressing an opinion. My judgments about the design goals for Allegro both now and in the past are my own and may be incorrect.

Martin Kalbfuß
Member #9,131
October 2007
avatar

You're right about these two points.

But I'm afraid of loosing one of the last C gui's. When it is exluded, it maybe wouldn't be maintained any longer. So if there isn't a C gui available for allegro this is more a limitation than to include it, because you have to use C++.

So, is there any cool C gui lib out here, integrating well with allegro?

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

Evert
Member #794
November 2000
avatar

Quote:

But I'm afraid of loosing one of the last C gui's. When it is exluded, it maybe wouldn't be maintained any longer.

I use C.
As long as I do that (and as long as I make games with Allegro, which is admittedly somewhat intermittent at the moment and likely to stay that way) I'll have a need for the equivalent of Allegro's GUI. If I can be bothered to clean it up enough to release it as an addon, I will. Someone can always ask for it if they want it.

Actually, why would you be afraid of losing it? It's not actually very hard to take Allegro 4's code, modify it, and add it to your own project.

Martin Kalbfuß
Member #9,131
October 2007
avatar

So i will do.

Can you please make an A4 gui add-on for all the C programmers. This would be really cool.

I could help, too.

I think copying code is not the best way of reusing code. Libraries are used for this task.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Thomas Harte said:

Edgar > good work on the avatar. Now you're talking my childhood. I might pull out some spoons and start doing a phoney Scottish accent.

Glad to be of service. ;)
Now all I need is a pretty girl on the forums who uses Ace as her avatar. :D

Martin Kalbfuß said:

The widgets are definitely not core. But the DIALOG structures are.

Part of the reason I don't like A4's gui is the inflexibility of the DIALOG struct and global gui functions that rely on them. They're nice to a certain degree but tend to force the user into using global data and scattered code. At least in C++ this can be more easily avoided, which is one reason to let the gui be created as an add on. Of course, it would always be nice if it was an officially supported add on.

Martin Kalbfuß
Member #9,131
October 2007
avatar

Definitely the DIALOG thing has to be reworked. Hopefully it is getting an official add-on.

a state mashine would be cool.

1 
2start(DIALOG);
3 
4 add_widget(d_box_proc, 0, 0, 100, 100, makecol(255, 255, 255), 0, 0, 0, 0, 0, NULL, NULL, NULL;
5 add_widget(d_ctext_proc, 50, 10, 0, 0, maecol(255, 255, 255), 0, 0, 0, 0, "An Example", NULL, NULL);
6 
7 
8 start(DIALOG);
9 
10 add_widget(d_button_proc, 20, 70, 60, 20, makecol(255, 255, 255), 0, 0, 0, 0, "Press me", NULL, NULL);
11 
12 end(DIALOG);
13 
14end(DIALOG);

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

KnightWhoSaysNi
Member #7,339
June 2006
avatar

I usually program my own buttons and text input because I don't like allegro's way of doing things. It isn't that hard.

Thomas Harte
Member #33
April 2000
avatar

Quote:

Now all I need is a pretty girl on the forums who uses Ace as her avatar.

Just do a forum search for "nitro 9" and "professor", I'm sure something will turn up. You'll be using baseball bats on Daleks before you know it.

Assuming this is turning into a brainstorming session for what may become an official GUI addons for Allegro 5, I'd prefer a system with full hardware compositing under which every widget maintains an input event queue for receiving messages and a list of queues that it will broadcast to whenever it needs to send a message. Beyond that, widgets will have no concept of any sort of hierarchy and program code will have no knowledge of internal memory structures. I guess you'll keep arbitrary collections of widgets, each collection being linked to a particular BITMAP (or the Allegro 5 equivalent) and in order not to steal control of your entire program, the rule would just be to call a GUI keepalive function every frame.

Obviously stuff like multiple overlapping windows or whatever is therefore left to the end user to implement if they really want to.

SiegeLord
Member #7,827
October 2006
avatar

Brainstorming sessions do not work. Whoever finishes a C GUI addon first, will be the one who decides what is good and what is not, and how to do things.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Thomas Harte
Member #33
April 2000
avatar

I don't think that's necessarily true in this case. My assumption is that if there are to be officially blessed add-ons then the main developers will do some degree of screening. They're not just going to endorse any old junk.

SiegeLord
Member #7,827
October 2006
avatar

I agree. Screening after the addon is done, not before. I for one think A4's GUI design and operation is near perfect as is, and any deviation from that proven formula is a very, very hard sell for me personally.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Thomas Fjellstrom
Member #476
June 2000
avatar

Its a better waste of time to screen before AND after. So people don't waste their time doing things they don't know won't be accepted.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

SiegeLord
Member #7,827
October 2006
avatar

I hardly think making a good C GUI would be a waste of time whether it is accepted or not, but point taken.

In that case, here's what a perfect gui would look like for me:

1AL_GUI_MANAGER *dlg = al_create_gui_manager();
2al_set_gui_dest_bmp(dlg, 0);//0 = 'screen'
3AL_GUI *button1 = al_create_button(dlg, 10, 10, 20, 20, "Exit");//manager, x,y,w,h, text
4AL_GUI *editbox = al_create_editbox(dlg, 10, 10, 20, 20, "Edit me!");//manager, x,y,w,h, default text
5 
6//in the game loop
7{
8 al_update_dialog(dlg);//update all of the dialogs
9
10 char* text = editbox->dp1;//dp1 stores the edit box managed string buffer
11 bool button_pressed = button1->d1 & AL_BUTTON_PRESSED;//d1 stores various button flags (hover, pressed etc)
12
13 //...
14
15 al_draw_dialog(dlg);//make them draw themselves
16}
17 
18//at the end of the program
19al_destroy_gui(dlg);//takes care of the attached gui's

Alternatively, for people who don't like the state based approach, the main loop could look like this:

1 
2al_wait_for_event(blah)
3{
4 case AL_GUI_EVENT:
5 {
6 int id = event->id;
7 if(id == button1->id)
8 {
9 switch(event->type)
10 {
11 case AL_BUTTON_PRESSED:
12 {
13 button_pressed = true;
14 }
15 break;
16 }
17 }
18 }
19 break;
20}
21al_draw_dialog(dlg);//make them draw themselves

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Trent Gamblin
Member #261
April 2000
avatar

I would at least give the fields proper names, not "dp1" and "d1".

axilmar
Member #1,204
April 2001

Quote:

sigh Here we go. What is so bad about using a third party GUI system? Why does it have to be part of "Allegro"? We could never write a system that satisfies everybody's needs, and if we did it would probably be so complex that nobody was satisfied.

A library can't have everything everyone desires. Furthermore, that's what libraries are for. If someone can't deal with linking to one more library, then they shouldn't be programming.

A proper GUI is a tremendous job, much larger than Allegro. You have to cater about how the screen is redrawn, if the redraw method is appropriate for games, about keystrokes, about data events (remember the recent discussion with Reynaldo about how to easily change data and notify the GUI at the same time).

You have to present decent default graphics, but also allow the user to change the style.

You have to cater for the input focus, and for data validation.

You have to have layout management.

So, under this light, it's better to have the GUI as an add-on.

Regarding the current GUI, it's a mess. It's appalling, both presentation-wise and coding-wise. It sucks big time. I don't object to a C gui only (C++ is better suited for guis though, but apparently many Allegro coders like to torture themselves :-)), but it has to be better than the current one.

Martin Kalbfuß
Member #9,131
October 2007
avatar

I think to say, if you can't link libraries it's your fault is to easy.
The problem is the cross platform compatibility. libraries could named different, and could be found in different places at different platforms. So linking is not that easy if the library does not support any helpers like pkg-config. If you release your sources, others want to compile them without setting the pathes to the libraries manually. There is such a tool for allegro, using autotools. But is there such a thing for the third party libs? Sometimes. But you cannot count on it.

Complex gui like CEGUI for example would be to much. But the discussion is about a core set of gui functionality.

Why not provide a configure switch --with-gui. So everyone could decide if he like to has an integrated gui.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

axilmar
Member #1,204
April 2001

Quote:

If you release your sources, others want to compile them without setting the pathes to the libraries manually.

The appropriate way to compile things is to put the common library paths into environment variables or tool settings and pass the variables to the make tool.

Personally, I am using Visual Studio, and I never had any problem with libraries and paths. When I download a library, I put the paths in the compiler settings. You can do that with any modern IDE.

Quote:

Complex gui like CEGUI for example would be to much. But the discussion is about a core set of gui functionality.

And what is core gui functionality?

For me, layout management and data events are 'core' to the gui.

Thomas Harte
Member #33
April 2000
avatar

Quote:

And what is core gui functionality?

For me, layout management and data events are 'core' to the gui.

I think the starting point for answering that question should be: where can you cleanly divide the code? For my money, data events would be trivially in because I understand that Allegro 5 is likely to have a user-tappable event system and it'd make most sense to build a GUI around that.

Layout management is clearly separable, so its inclusion would be arguable.

Martin Kalbfuß
Member #9,131
October 2007
avatar

Well that's 'core' to a GUI, except the drawing stuff

The A4 gui isn't the best piece of software. But it a good example for a small and basic set of structuring support. There are better solutions but the code is easy and small. So the components you are talking about are core, but aren't to big for including it as shown by the A4 gui. Things get even smaller for A5, because there will be an event queue or someting similar. So there is no need for an extra event system.

Throwing out the d_proc stuff would reduce size dramatically. It's the game programmers choice how his game elements look like and react to events. I say game elements here, because the structuring part is not gui specific. You can use it for everything.

As long as you act as an developer on the code, the way you described is OK. But when shipping your code, you need to use a build system. And these build systems try to locate the needed libraries(./configure, cmake ., etc.). But when there is no support by the used lib for the build system you are using, you has to set up things manually, which is in case of the many platforms available no trivial task.

http://remote-lisp.spdns.de -- my server side lisp interpreter
http://www.nongnu.org/gm2/ -- Modula-2 alias Pascal++

SiegeLord
Member #7,827
October 2006
avatar

See what I mean? You just can't please everyone. AllegroGUI is fine as is for what it does. If you want something more complex, get a 3rd party addon. Am I to stop doing my primitives addon because I can't do all that libcairo does? Should the audio addons be scrapped because they cannot do a full 3D sound refraction and handling like a good sound library would do? Clearly, you people are missing the point of Allegro (at least according to me). Allegro's point is to allow people to provide the basics, basics without which it would be impossible to make games. And GUI is a basic need. Layout is not necessary for a game, I pray you tell me where the layout engine for Quake's GUI system is located. Data events? If they fit in the general event queue method, then fine, but otherwise just use plain member access. Input focus? AllegroGUI of old did that. Data validation? Do it yourself.

A way to proceed would be just to reimplement A4 GUI given that there is a new event method system, but still allow for d1-3, dp1-3 to be used for people who don't want to interact with their GUI via events. Also, fix all of the blocking GUI bugs in A4. Perhaps make it a little more pretty by default. And that should be enough for 90% of games out there. For the 10% that want a Qt equivalent, let them make their own or use some sort of 3rd party lib.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

KnightWhoSaysNi
Member #7,339
June 2006
avatar

In allegro 4.2 there is a function called file_select_ex where you can look for files to save and load on the hard disk.

Instead of using a gui in allegro to do this is it possible to add the operating system's default save/open dialog? Or do all of the operating systems allegro is meant to work on not have one?

http://www.winprog.org/tutorial/app_two.html

I am looking at this but I don't know how to get the owner's window.

ofn.hwndOwner = hwnd;

It seems to work with that part commented out but does it need it set to avoid memory leaks?

 1   2   3 


Go to: