Jump to content
  • Advertisement
Sign in to follow this  

Programming a GUI

This topic is 4955 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have to make a GUI for my game and currently I already have the following classes for that (in C++): *GuiButton (returns values if you press it with the mouse or after releasing the mouse, on mouseover it changes to a different picture or different text) *GuiInputLine (allows you to enter text) *GuiMenu (a list that pops up that has different GuiButtons in it and returns which of those is pressed) And all of these classes have functions draw(), check() and handle(). However I also need a few more complex gui elements, such as scroll lists and windows that contain multiple GuiButtons, GuiInputLines, GuiMenus and other elements in them. What would be the best way to make such things?

Share this post


Link to post
Share on other sites
Advertisement
I don't have any concrete advices, but if you want to do it in a very clean oo way, take a look at the structure of the .net api, and take that as an example.

I think it will be a good idea to start with a Window/Widget/Form base class which has it's own events (functor objects are nice for that), and can have child windows, and then you build everything up from there.

Share this post


Link to post
Share on other sites
You can define basic windowed (abstract) control class and derive all controls from this. This window class will hold the list of all child controls so you can position them relative to parent and allow things like moving whole window in simple way.
For example you can create Button which will override only methods like OnClick, Draw() etc. You can also use messages (similar system to win32 api).
I used this method to write my own simple gui and it was prety easy to develop and simple to use. Each new control took about two hours to implement, so I wrote whole gui system in about a week.

Share this post


Link to post
Share on other sites
Quote:
Original post by b2b3
You can define basic windowed (abstract) control class and derive all controls from this. This window class will hold the list of all child controls so you can position them relative to parent and allow things like moving whole window in simple way.
For example you can create Button which will override only methods like OnClick, Draw() etc. You can also use messages (similar system to win32 api).
I used this method to write my own simple gui and it was prety easy to develop and simple to use. Each new control took about two hours to implement, so I wrote whole gui system in about a week.


What your essentially doing is implemenating the composite design pattern this is what Lode wants to be looking into.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!