Jump to content
Sign in to follow this  
  • entries
    88
  • comments
    117
  • views
    62405

UI programming fun

Sign in to follow this  
dcosborn

139 views

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  


0 Comments


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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!