Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

UI programming fun

Sign in to follow this  


So over the past few days I've been trying to figure out how to structure my GUI code so that its easy to use and extend. I'm working in C so when I talk in object-oriented terms, I'm talking figuratively. My lack of design pattern knowledge will probably show here.

My first approach yesterday was to make each widget an instantiation of a widget-specific object based on an abstract interface. This is similar to how my pipe/stream system is set up. I hit a roadblock when I started writing the interface for focus switching and realized that a widget couldn't take focus without removing focus from the widget that currently had it. Since one widget didn't know about any other widgets, there wasn't any good way to determine which widget was currently in focus.

So today I'm thinking I'll have all widget interactions go through the ui "manager". I'll have a set of global vid_ui_widget_* functions for everything you'd want to do with a widget and they'll delegate the widget-specific work through the widget's abstract interface. In the public header, I'll partially declare the widget struct such that its an incomplete type. This way, I can return a widget* on construction and the user can differentiate between widgets without being able to access their internals.

Just a side thought: Why doesn't google support regular expressions?
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!