Jump to content

  • Log In with Google      Sign In   
  • Create Account

GUI for SFML


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 vleugel   Members   -  Reputation: 252

Like
0Likes
Like

Posted 02 January 2012 - 01:19 PM

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

Sponsor:

#2 BeerNutts   Crossbones+   -  Reputation: 3000

Like
1Likes
Like

Posted 03 January 2012 - 03:15 PM

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!
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#3 vleugel   Members   -  Reputation: 252

Like
0Likes
Like

Posted 04 January 2012 - 04:05 PM

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.

#4 BeerNutts   Crossbones+   -  Reputation: 3000

Like
1Likes
Like

Posted 04 January 2012 - 10:35 PM


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.


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
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#5 swiftcoder   Senior Moderators   -  Reputation: 10367

Like
0Likes
Like

Posted 04 January 2012 - 11:35 PM

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...

Tristam MacDonald - Software Engineer @Amazon - [swiftcoding]


#6 vleugel   Members   -  Reputation: 252

Like
0Likes
Like

Posted 05 January 2012 - 12:44 PM


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...


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!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS