Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » GWEN - GUI toolkit

This thread is locked; no one can reply to it. rss feed Print
 1   2 
GWEN - GUI toolkit
Garry Newman
Member #13,614
October 2011

Allegro is now officially supported by GWEN. ( http://code.google.com/p/gwen/ ) Big thanks to chinbillybilbo for their work on the renderer.

{"name":"604918","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/7\/57f6d4291d52c9346c7f722ccd285e3c.png","w":1040,"h":806,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/7\/57f6d4291d52c9346c7f722ccd285e3c"}604918 {"name":"604919","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/c\/0c2ab57e8773f371b8bfa89fa8a28321.png","w":1040,"h":806,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/c\/0c2ab57e8773f371b8bfa89fa8a28321"}604919 {"name":"604920","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/3\/230a2d2ba00c773443acd56766016dcd.png","w":1040,"h":806,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/3\/230a2d2ba00c773443acd56766016dcd"}604920

You can download the sample (for windows) here:

http://code.google.com/p/gwen/downloads/detail?name=GWEN-WinSamples-4.zip

I threw the sample and input class together from other examples I'd downloaded.. and I'm hoping they're fully cross platform. I was hoping someone would take a look at it to make sure I'm not doing something stupid.

Sample: http://code.google.com/p/gwen/source/browse/trunk/trunk/gwen/Samples/Allegro/AllegroSample.cpp

Renderer: http://code.google.com/p/gwen/source/browse/trunk/trunk/gwen/Renderers/Allegro/Allegro.cpp

Input: http://code.google.com/p/gwen/source/browse/trunk/trunk/gwen/include/Gwen/Input/Allegro.h

Also, sorry if this looks like a repost. The other GWEN related thread seemed to get a bit off topic - and wasn't really announcing support for it.

Let me know if you have any questions :D

Johan Halmén
Member #1,550
September 2001

I see awfully little images in your post. Is this about some GUI toolkit?

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

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Garry Newman
Member #13,614
October 2011

Here's some screenshots showing a few of the widgets. The list of widgets down the left shows the majority of the available widgets.

GullRaDriel
Member #3,861
September 2003
avatar

Use the img tags with <>, not []

Like that:
{"name":"604915","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/7\/57f6d4291d52c9346c7f722ccd285e3c.png","w":1040,"h":806,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/7\/57f6d4291d52c9346c7f722ccd285e3c"}604915{"name":"604916","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/c\/0c2ab57e8773f371b8bfa89fa8a28321.png","w":1040,"h":806,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/0\/c\/0c2ab57e8773f371b8bfa89fa8a28321"}604916
{"name":"604915","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/7\/57f6d4291d52c9346c7f722ccd285e3c.png","w":1040,"h":806,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/5\/7\/57f6d4291d52c9346c7f722ccd285e3c"}604915

Looks nice BTW. A pity it's C++ only, I only use C ^^

Edit: and you forgot to add a / at the end of the url, after the closing "

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

Garry Newman
Member #13,614
October 2011

Thanks!

billyquith
Member #13,534
September 2011

Thanks for the UI Garry. ;D It was quite easy to add Allegro support due to your good design, and to Allegro (5!) being a very practical library. A happy marriage. :D

Cheers!

http://chinbilly.blogspot.com/

axilmar
Member #1,204
April 2001

Congratulations for this library. Some questions:

1) when documentation will be available.
2) when layout management will be available.

Garry Newman
Member #13,614
October 2011

What kind of layout management do you want? Here's how it's done right now:

http://garry.tv/post/9338161524/docking

axilmar
Member #1,204
April 2001

What kind of layout management do you want? Here's how it's done right now:

How about laying widgets in rows, in columns, in a grid, etc.

Garry Newman
Member #13,614
October 2011

If you want to lay widgets in a row you'd just dock them all left (or right) in a child panel. To lay in a row vertically you'd dock top.

You can lay them out manually in a child panel, by overriding the Layout function. In there you'd set the position and size manually, using whatever you want.

We have a few layout controls to make your life easier, but this is something that could definitely be expanded upon. I'm trying to keep things as simple as I can right now.

Here's the layout controls:

http://code.google.com/p/gwen/source/browse/#svn%2Ftrunk%2Ftrunk%2Fgwen%2Finclude%2FGwen%2FControls%2FLayout

axilmar
Member #1,204
April 2001

Garry, what is your plan regarding documentation? it is hard to browse the source code, just to learn the basics.

Garry Newman
Member #13,614
October 2011

I'm planning to document some of the simple things that people have pointed out (laying out, widget list, margin vs padding).

But I want to produce a few heavily commented samples to show how things are meant to work in the wild rather than relying on just docs. I prefer this method as docs can go out of date - but the samples will be updated along with any changes to the codebase.

I'm thinking a couple of simple things, like a calculator/model viewer just to help people understand how it all fits together.

axilmar
Member #1,204
April 2001

Some other questions:

1) how does focus work.
2) how does modality work.
3) how do menus work.

Garry Newman
Member #13,614
October 2011

There's two types of focus, keyboard and mouse. Mouse focus is simply the control you're hovering over. Keyboard focus is similar to windows focus - in that you press tab to go to the next control.

Modal panels are simply just screen sized panels that block out input to everything else - because you can't click through them. The modalled control is a child of that control - so you can still interact with it.

I don't understand what you want to know about menus?

axilmar
Member #1,204
April 2001

I don't understand what you want to know about menus?

Win32 popup menus block the main event queue. Does this happen with your GUI? I think not, but I'd like a confirmation.

Furthermore, how do you handle events, when a menu is closed and when a menu is opened? a menu is a modal structure, but it consists of many top-level widgets. In Win32, if a menu is open, windows receive mouse movement events, and mouse click events, but Win32 knows if a menu is open and closes the menu before the window receives the mouse click event.

Garry Newman
Member #13,614
October 2011

No the menu is just a control that floats above everything else. When you click on something that isn't derived from a menu it closes all open menus.

You can see examples of all the controls usage here: http://code.google.com/p/gwen/source/browse/#svn%2Ftrunk%2Ftrunk%2Fgwen%2FUnitTest

This is the menu one:

http://code.google.com/p/gwen/source/browse/trunk/trunk/gwen/UnitTest/MenuStrip.cpp

which creates this menu

{"name":"230a2d2ba00c773443acd56766016dcd-1024.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/b\/2b5bfc8ce131ea9c64373cc4c1bb1f7a.jpg","w":1024,"h":793,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/2\/b\/2b5bfc8ce131ea9c64373cc4c1bb1f7a"}230a2d2ba00c773443acd56766016dcd-1024.jpg

kenmasters1976
Member #8,794
July 2007

Looks really nice!. I'm definitely giving it a try.

axilmar
Member #1,204
April 2001

No the menu is just a control that floats above everything else. When you click on something that isn't derived from a menu it closes all open menus.

Does the menu have a parent widget, i.e. is it a child of the root widget, or it is a standalone widget?

And how do you close the menu when the user clicks outside of it? do you have an 'if menu is open then close it' statement somewhere in the event handling code?

Garry Newman
Member #13,614
October 2011

Basically yes. The menu is a child of the canvas (the root panel).

bool Gwen::Input::OnMouseClicked( Controls::Base* pCanvas, int iMouseButton, bool bDown )
{
        // If we click on a control that isn't a menu we want to close
        // all the open menus. Menus are children of the canvas.
        if ( bDown && (!Gwen::HoveredControl || !Gwen::HoveredControl->IsMenuComponent()) )
        {
                pCanvas->CloseMenus();
        }

And

bool Base::IsMenuComponent()
{
        if ( !m_Parent ) return false;
        return m_Parent->IsMenuComponent();
}

void Base::CloseMenus()
{
        for ( Base::List::iterator it = Children.begin(); it != Children.end(); ++it )
        {
                (*it)->CloseMenus();
        }
}

axilmar
Member #1,204
April 2001

Ok, thank you for the replies.

Peter Wang
Member #23
April 2000

There's something wrong with the build system on Linux:

% make Sample-Allegro verbose=1   
==== Building Renderer-Allegro (release) ====

Creating obj/Release/Renderer-Allegro
mkdir -p obj/Release/Renderer-Allegro
Allegro.cpp
g++ -MMD -MP -DNDEBUG -I../../../include x86_64 -g -O2 -ffast-math -fno-rtti -o "obj/Release/Renderer-Allegro/Allegro.o" -c "../../../Renderers/Allegro/Allegro.cpp"
g++: x86_64: No such file or directory
make[1]: *** [obj/Release/Renderer-Allegro/Allegro.o] Error 1
make: *** [Renderer-Allegro] Error 2

Where is that x86_64 coming from?

edit: the ARCH variable. I can suppress it by running make ARCH=

Linking with -lalleg won't work. That's for Allegro 4. The sample program requires at least: -lallegro -lallegro_image -lallegro_font -lallegro_ttf -lallegro_primitives. It would be best to use pkg-config to pull in the libraries; I don't know if that's possible with premake.

edit See the patch. Dunno about pkg-config.

The Allegro sample pegs the CPU unnecessarily. It should use al_wait_for_event instead of al_get_next_event so that it blocks.

edit see patch.

The patch also passes through mouse wheel events.

axilmar
Member #1,204
April 2001

Garry, one last question: how do you handle menu bars? menu bars are not children of the root panel, obviously.

Garry Newman
Member #13,614
October 2011

Thanks for the patch!

The menu bar (menu strip) is just a control - like a button. You can put it anywhere you want.

axilmar
Member #1,204
April 2001

The menu bar (menu strip) is just a control - like a button. You can put it anywhere you want.

It is, but how do you handle the modality of it, since menu bars have sub menus which are pop ups?

Is a menu bar positioned above the panel that closes a menu?

And if so, does this happen automatically, or does the programmer has to do so manually?

 1   2 


Go to: