Jump to content
  • Advertisement
Sign in to follow this  
Toadhead

GUI for SFML

This topic is 2538 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

Hello,

I am trying to write a GUI for my game. I am using SFML for graphics.
I have already created some simple widgets, such as buttons. However, I'd like to have some more advanced widgets as well.
One of them includes "tabs", where I can click on like 4 different tabs, each with its own layout of widgets. And I want windows/dialog boxes that can be dragges, closed and perhaps minimized.

So, I came up with a design strategy and I was wondering whether people think it's ok to do it like this or if someone has a better idea.
Basicly, I will create a new class called GUIArea. This GUIArea can contain several widgets by composition. This GUIArea is a widget itself like any other widget with an Update() and Draw() function called by my GUIManager every frame. However, the widgets inside GUIArea are handled by this class itself and are only Updated and Drawed if the GUIArea IsVisible() returns true. This way, I can "switch on/off" the widgets by GUIArea as a group. GUITab is composed of several GUIArea's and that enable/disable them based on on which tab (basicly a radio button) is being active. GUIWindow works in the same way, it also contains one GUIArea that is enabled/disabled based on if the window is currently visible. The GUIWindow's draw function simple draws a rectangle and places a [x] button on the top right for closure, next it draws the widgets on top of it. The Update() function works in the same way. Whenever the window is being dragged, it will call the UpdatePosition(x,y) function that updates the position of all widgets in the window by the relative position in which the window has been dragged.

So, what about this design? Would this be fine or would it cause errors/performance problems?


Greetings,
Rob

Share this post


Link to post
Share on other sites
Advertisement
I don't know a lot about GUI's, but if you goal is to just get a GUI working with SFML, maybe take a look at SFGUI:
http://sfgui.sfml-dev.de/

It's a GUI written specifically for SFML.

If you want to write a GUI for the exercise, then disregard (or, you can check the site for ideas too).

Good Luck!

Share this post


Link to post
Share on other sites

I don't know a lot about GUI's, but if you goal is to just get a GUI working with SFML, maybe take a look at SFGUI:
http://sfgui.sfml-dev.de/

It's a GUI written specifically for SFML.

If you want to write a GUI for the exercise, then disregard (or, you can check the site for ideas too).

Good Luck!


Thanks for the info, but I already checked it out as well as some others, but they all don't seem to support windows/dialog boxes and more features I need.
They also look outdated as it has not been updated for over 2-3 years.

I might check or use them later, for now I think it'll be some good experience to write my own. I already have buttons, radioboxes, scrollbars and checkboxes, however the textboxes, tabs and windows are a little bit more difficult to write, performance-wise that is.

Share this post


Link to post
Share on other sites

[quote name='BeerNutts' timestamp='1325625304' post='4899389']
I don't know a lot about GUI's, but if you goal is to just get a GUI working with SFML, maybe take a look at SFGUI:
http://sfgui.sfml-dev.de/

It's a GUI written specifically for SFML.

If you want to write a GUI for the exercise, then disregard (or, you can check the site for ideas too).

Good Luck!


Thanks for the info, but I already checked it out as well as some others, but they all don't seem to support windows/dialog boxes and more features I need.
They also look outdated as it has not been updated for over 2-3 years.

I might check or use them later, for now I think it'll be some good experience to write my own. I already have buttons, radioboxes, scrollbars and checkboxes, however the textboxes, tabs and windows are a little bit more difficult to write, performance-wise that is.
[/quote]

sfgui was last updated a few days ago. It is actively being updated. I don't know why you think it's been over 2-3 years. Check their github.

Good luck

Share this post


Link to post
Share on other sites

Basicly, I will create a new class called GUIArea. This GUIArea can contain several widgets by composition. This GUIArea is a widget itself like any other widget with an Update() and Draw() function called by my GUIManager every frame. However, the widgets inside GUIArea are handled by this class itself and are only Updated and Drawed if the GUIArea IsVisible() returns true. This way, I can "switch on/off" the widgets by GUIArea as a group. GUITab is composed of several GUIArea's and that enable/disable them based on on which tab (basicly a radio button) is being active.

That's basically the same method I used when I wrote Simplui, and it seems to work pretty well. I can't offhand think of a better way to structure things...

Share this post


Link to post
Share on other sites

[quote name='vleugel' timestamp='1325531970' post='4899044']
Basicly, I will create a new class called GUIArea. This GUIArea can contain several widgets by composition. This GUIArea is a widget itself like any other widget with an Update() and Draw() function called by my GUIManager every frame. However, the widgets inside GUIArea are handled by this class itself and are only Updated and Drawed if the GUIArea IsVisible() returns true. This way, I can "switch on/off" the widgets by GUIArea as a group. GUITab is composed of several GUIArea's and that enable/disable them based on on which tab (basicly a radio button) is being active.

That's basically the same method I used when I wrote Simplui, and it seems to work pretty well. I can't offhand think of a better way to structure things...
[/quote]

Haha nice, I have absolutely no idea how this is normaly done.
I guess I was looking at a very old website, as I just see SFGUI recently supports windows as well :)
I'm going to check it out, thanks!

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.

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!