Tips for Programming a GUI

Started by
14 comments, last by JoshuaWaring 9 years, 11 months ago

While it's good to figure out class hierarchies and what features you need, don't lose sight of the purpose of the GUI - to allow the user to EASILY input whatever information the program you're writing needs. This is one of those things that some would dismiss as 'the easy part', but it's not (see: KDE vs Gnome). Incidentally, documentation is another thing that falls into this category - even Eric Raymond once wrote in an 'open letter' to open source developers saying, in effect, "We've done the hard part, now just do the easy stuff and write the manual." Sorry Eric, writing isn't easy - it's a craft that takes years of hard work, training, critques, and more practice to learn. Design is much the same: it's a separate skillset from what you use when you code the GUI elements.

IOW, your GUI code could be the most beautiful, elegant code ever seen, but your GUI could still suck bollocks from the user standpoint.

For inspiration, I'll refer you to what may be the most widely used and easily understood GUI ever created: The Denny's Menu.

"The multitudes see death as tragic. If this were true, so then would be birth"

- Pisha, Vampire the Maquerade: Bloodlines

Advertisement

Hi.

I'm on my 3rd or 4th UI now. Like HawkBlood said, edit boxes list boxes imageboxes, text, dropdowns and contain them all in a dialogbox type class, this is like your window.

Use a 3d model app to create and place buttons then export to your format and load it up.

some thing like this

Basemenu

load();

free();

render();

dokeyinput();

domouseover();

onleftclick();

ect.........

then create a menu say for load screen

class MenuLoadScreen :BaseMenu

{

doo stuff

};

basemenu *base = new MenuLoadScreen();

then you can have a list of them

vector<BaseMenu*> MenuSystem;

and define input elements for the location of the menu

#define LOADMENU_ID 0

MenuSystem[LOADMENU_ID]->render();

or use a CurrentMenuID to change menues.

This is what I've done so far. I hope it's a strong enough illustration.

One note unless GUIWindow is this I recommend a UIPanel class. This is pretty much just a group of components that has a size and can organize children relative to its position. It lets you anchor points and you will need a margin / anchor property to make sure everything lines up unless you are only wanting to support 1 resolution. Another convenient figure is if you allow it to clip children. Then you can create scroll views. Most gui utilities support panels, grids, and other organizational items but you can get by with just a panel to be honest. Also by supporting children to organizational objects you can build together different parts to make more complicated components. Also when you create your event system you can search through your items in a tree structure rather then a linear list. Also you NEED events / callbacks. If you are in c++ use FastDelegate as a base for your delegate system and build an event class. Most other languages have some sort of support for that otherwise.

Common components I use.

1. Textbox

2. Texture Button

3. Label

4. Progress Bar / Slider (these components internally will be very similar)

5. Scrollview

That is what the window is, although the idea with the window is to have a border (like a popup) but a Panel could be used as a border less window to go inside of a window.

The generated diagrams don't really show it, but they are working like a tree, also not really shown are the events, if something happens the entity will return a Event which contains a pointer to the entity, event type and the entity type.

Just an update on the progress

https://github.com/Joshhua5/Protheus-Engine/tree/master/scr/Engine

This topic is closed to new replies.

Advertisement