Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
106 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

  Contents

 Introduction
 GUI Controls
 We'll Need

 Breaking It Down
 Static Controls
 Pushbuttons
 Carets and The
 Textbox Control

 Progress Bars
 Sliders and
 Scrollbars

 Listbox Control
 Conclusion

 Printable version

 


  The Series

 Part I
 Part II
 Part III
 Part IV

 

Breaking It Down: Complex Controls As Combinations of Simple Ones

The list becomes much more manageable when we realize that the more complex controls are just clever combinations of other, more simple controls. For example, a scrollbar is basically just two buttons and a slider control. A checkbox is a static control and two buttons (one "off" button, and one "on" button). A plain old button could be implemented using three static icon controls (just show/hide the appropriate ones to get the button to "press"), so that you can reuse your drawing code. If you were really strapped for time, you could even implement a progress bar as a slider that's moved by the computer, though I prefer having a separate control for this.

There are, however, disadvantages to this - namely, your GUI controls are going to take up more system resources than they really need. Think about it - each control is a window. Let's say you've gone with the reuse philosophy, and have created a button control that's really just three different statics. That's three windows per button. Now, you build a scrollbar control, using two button controls. That's six windows per scrollbar control. Build a List control using horizontal and vertical scrollbars, and you're sitting at twelve windows per list. It adds up quickly.

So it's really just another example of the classic tradeoff between "how fast can I develop it" and "how little resources can I get it to use?" If you need a very high performance, no-waste GUI, implement each control from the ground up. If you would instead a quick implementation, and don't mind the performance hit, you might choose to implement your controls so that the only control that would actually draw to the screen would be the static, and all other controls would be made up of combinations of statics.

When building my GUI, I tried to create a good balance between these two extremes.

Now, let's dive into the actual implementation of each control, starting with everyone's favorite, the static label.


Next : The Static Controls