Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Poll: Allegro 5 GUI in C or C++?

Credits go to AMCerasoli, Andrei Ellman, bamccaig, Dizzy Egg, Edgar Reynaldo, Elias, Evert, GullRaDriel, ImLeftFooted, jhuuskon, Johan Halmén, Karadoc ~~, kenmasters1976, Mark Oates, Matthew Leverton, Michael Faerber, Neil Walker, Peter Wang, Ron Novy, SiegeLord, Thomas Fjellstrom, Tobias Dammers, Trezker, and type568 for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2   3   4 
Poll: Allegro 5 GUI in C or C++?
Mark Oates
Member #1,146
March 2001
avatar

An Allegro 5 GUI has the added complication of integrating multiple displays. It's a serious challenge.

bamccaig said:

You just go right after the data. It's bad practice to though because it's error prone and limits code reuse. In C, accepting a void * is a very common way to pass any arbitrary data into an API. Not using it is your fault; not the API. :P Again, it's not easier, but it's more correct, less error prone, and overall cleaner than using a global. If you want easier then you shouldn't be using C (nor C++) in the first place. :P Any kind of messaging or event system will pretty much need to resort to the same thing to pass arbitrary data around; unless it doesn't pass any data around and just assumes the message or event loop already has that data, but then that could require globals for some applications. :P

BamBam... bambam... you need to try using more globals. All this void* cast with struct type identifier overhead workaround is more error prone than a single global.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Bamccaig said:

Any kind of messaging or event system will pretty much need to resort to the same thing to pass arbitrary data around; unless it doesn't pass any data around and just assumes the message or event loop already has that data, but then that could require globals for some applications.

A widget messaging system has no need to pass any data around at all. You get the message from the widget, decide what to do based on which widget and what message it is, and then you do it. It makes it far easier to deal with an action locally as opposed to globally or wasting your time binding a 1000 different sets of data into 1000 different structs and having a custom callback function for each of your 1000 different structs. :P:P:P

Bamccaig said:

In C, accepting a void * is a very common way to pass any arbitrary data into an API. Not being forced to use it should be a valid choice.

If you want easier then you shouldn't be using C (nor C++) in the first place.

Fixed X 2.

Thomas Fjellstrom
Member #476
June 2000
avatar

An Allegro 5 GUI has the added complication of integrating multiple displays. It's a serious challenge.

What would probably make the most sense, is not having any fancyness in the api at all. You would be required to call the event pump function for the gui, as well as the drawing function, every loop, and pass in the display to draw to, etc.

--
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

Evert
Member #794
November 2000
avatar

Taking the time to bind all the necessary information to that struct takes more time and takes more work to access than using global data in the first place.

Possibly. Depends on whether you intend to re-use that function or not. If you do, best not to touch global data!

Quote:

A4's gui encourages use of global data. Sure you can get around it, but it's easier not to.

That's again debatable, but it's not what you said earlier where you claimed you "have to use global data".

It's ok, you don't like the A4 GUI. You don't have to either, and you don't have to rationalise it as far as I'm concerned. If you do though, at least keep your arguments consistent. :P

Quote:

All of that behaviour could have been easily prevented by making a slider widget that queues a value_changed message.

That piece of code looks pretty obscure to me though!

Quote:

If someone does decide to make a C GUI for Allegro 5, please don't base it off of A4's gui, for the sake of your users.

Not even for the sake of those who like the A4 GUI? But don't worry, I'm sure that eventually different people will make different GUI addons since there's clearly room for different approaches here.
As I already said earlier, using A5's event system to interact with the GUI makes the most sense to me if you're designing the GUI from scratch. That's actually not orthogonal to basing the GUI on Allegro 4's GUI though.
Also, to get back to an earlier point in the discussion, it doesn't require C++ either (Allegro 5's event system is C, afterall).

axilmar
Member #1,204
April 2001

An Allegro 5 GUI has the added complication of integrating multiple displays. It's a serious challenge.

My approach is very simple (already implemented): the GUI does not have a global state; all the state of the GUI is kept into the widgets, so one can run many widget trees at the same time and in parallel.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Evert said:

That's again debatable, but it's not what you said earlier where you claimed you "have to use global data".

Fair enough.

Evert said:

Also, to get back to an earlier point in the discussion, it doesn't require C++ either (Allegro 5's event system is C, afterall).

Yeah well, consider me proven wrong. SiegeLord's and Matthew Leverton's designs seem reasonable enough to me. Still, using a this pointer seems rather archaic now that I use C++.

Evert
Member #794
November 2000
avatar

EDIT: seem to have somehow double posted with half an hour in between...

GullRaDriel
Member #3,861
September 2003
avatar

That's because you're travelling quicker than the light, Evert. ;)

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

axilmar
Member #1,204
April 2001

I've added a gui project to github, if anyone is interested.

bamccaig
Member #7,536
July 2006
avatar

The example program doesn't actually seem to show me any GUI widgets. :-/ I don't know if it's because my Makefile is doing something wrong or if I'm just not using the program properly. Should it be drawing something? :-/ What platform(s) have you tried it on? Or is it just an empty shell right now that needs to be filled in?

SiegeLord
Member #7,827
October 2006
avatar

bamccaig said:

The example program doesn't actually seem to show me any GUI widgets. :-/ I don't know if it's because my Makefile is doing something wrong or if I'm just not using the program properly. Should it be drawing something? :-/ What platform(s) have you tried it on? Or is it just an empty shell right now that needs to be filled in?

Try pressing keys 1, 2 or 3.

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

bamccaig
Member #7,536
July 2006
avatar

Matthew Leverton
Supreme Loser
January 1999
avatar

For what it's worth, my GUI also uses the algui_ prefix. I don't really care at all if you use the same, but I won't be changing mine if I ever do release it.

bamccaig
Member #7,536
July 2006
avatar

Ron Novy
Member #6,982
March 2006
avatar

Matthew Leverton, release it. Set it free. Let it roam free and be with it's own kind... Let it go. Let it grow.

And some day it will use Allegro mind control to take over the world...

Just realized that Matthew Leverton must also be his porn name... Lever-Ton ;D

Arg! Why do I think up these things!

----
Oh... Bieber! I thought everyone was chanting Beaver... Now it doesn't make any sense at all. :-/

Mark Oates
Member #1,146
March 2001
avatar

Because you watch too much porn, Ron. Because you watch too much porn.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Ron Novy
Member #6,982
March 2006
avatar

That's just not true... I don't watch porn. I make it! 8-)

Stunt double! Where are you? ;D

----
Oh... Bieber! I thought everyone was chanting Beaver... Now it doesn't make any sense at all. :-/

Trezker
Member #1,739
December 2001
avatar

I'm making a C++ GUI lib with the following features.
Editor, save and load XML layouts.
Skinning, code your own rendering routines or customize data for existing routines.
Event queue, widgets put events in a queue and lets you handle them where you want.
Layout, container widgets that handle size and position of their children.
Clipboard, copy text between your application and the rest of your OS.

And possibly more coming. Of course, even this basic list of features are under rather slow development since I have a full time coding jorb and is very tired in the evenings.

I named the project SWAG.

type568
Member #8,381
March 2007
avatar

And during the process of making, you're not looking?

axilmar
Member #1,204
April 2001

bamccaig said:

The example program doesn't actually seem to show me any GUI widgets

For now, the example program is the testing ground for the new features. It currently tests drawing, widget tree management, focus and layout management.

For what it's worth, my GUI also uses the algui_ prefix. I don't really care at all if you use the same, but I won't be changing mine if I ever do release it.

I will change it then, but in the future.

Johan Halmén
Member #1,550
September 2001

type568 said:

And during the process of making, you're not looking?

A Finnish stand-up commedian pointed out that in Finland you're allowed to have sex at 16. And you're allowed to look at hard core porn at 18. So if a couple of 16 year olds are filming their act, they're allowed to look at the film only after two years.

<edit>
I nominate this thread for the derail category of Allegro '11 Awards.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Ron Novy
Member #6,982
March 2006
avatar

It would be nice to have a few official A5 GUI libraries to choose from...
But I guess GUI libraries is just another 'touchy' topic. :P

----
Oh... Bieber! I thought everyone was chanting Beaver... Now it doesn't make any sense at all. :-/

Johan Halmén
Member #1,550
September 2001

It's not important that a GUI lib has a good set of gadgets. It's important that it's easy to write your own gadgets. If they are easy to create, then there will anyway automatically be a set of them in the first place, made by the creator of the GUI.

And a good C++ lib is better than a lousy C lib, whereas a good C lib is better than a lousy C++ lib.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

type568
Member #8,381
March 2007
avatar

A Finnish stand-up commedian pointed out that in Finland you're allowed to have sex at 16. And you're allowed to look at hard core porn at 18. So if a couple of 16 year olds are filming their act, they're allowed to look at the film only after two years.

Killed me.. So true, in Israel and many many other countries- it's the same.. However, I wonder how it goes if they film it, if they're allowed to and, or.. ? Kinda it's obvious that port would not be allowed to be sold cos' the actors have to be over 18 as well, but if they shot it(didn't look at it for 2 years), why the hell can't they sell it afterwards?!

P.S:
I add me "+1" to the nomination of this thread to Allegro '11 derail rewards..

AMCerasoli
Member #11,955
May 2010
avatar

So now we have four candidates working to create the best GUI for Allegro!

Which are:

axilmar: from Athens, Greece, 10 Years in the community. His web page has 50.000 visits per day.

Edgar Reynaldo: from Vermont, United States 4 Years in the community. Very well known by his game on the depot entitled: "This member has no projects listed".

Matthew Leverton: from Illinois, United States 12 years in the community. Many people say he was the original inventor of Tetris.

Trezker: from Sweden, 10 Years in the community. Very well known for selling his "Map and terrain generator" to Google to create, Google Earth.

So who you think is going to come up with the best GUI lib for this beautiful librarie? do your bets now!

 1   2   3   4 


Go to: