Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Extending Gosu / GGLib: A Gosu GUI Library
- By psadda Date 2009-01-28 21:05 Edited 2009-01-28 21:08
I can see that someone has already made a GUI library for Gosu. That just shows how long I have taken in packaging my library.
I started work on a Gosu project just over a year ago. As part of the project, I wrote a simple Ruby GUI Framework and decided that I would release it independently. (Which, once again, took an entire year...)

If you want to opt out before these copious amount of text, check out the download before you go: http://code.google.com/p/gglib/downloads/list

Unlike Rubygoo, GGLib does not provide a full fledged GUI library, but aims to make it very easy to write one's own widgets. And it is unbelievably easy to write widgets with GGLib. It's almost like using C# or VB with .NET to write Windows GUI apps. That said, GGLib does still provide a small assortment of predefined widgets. It has some interesting widgets, such as the DebugConsole and TracePanel which Rubygoo does not have. It also had the ability to fade in and out of menus, which Rubygoo does not have, and has an extensible window state mechanism. As of now, GGLib lacks a full set of widgets, but I will continue to add new widgets such as check boxes, radio buttons, and labels in the near future.

Unfortunately, many of the widgets which were previously part of this library have been removed because they are two heavily intertwined with the project I was previously working on. I will try to extract these widgets from the rest of the project so that they can be neatly distributed with the library. One of these widgets, the TextBar deserves a special mention. The TextBar is not a text editor like the TextBox, but a medium for conversation with in game characters. It is similar to the textbar in Gameboy games and many console games: that strip with text and response options that appears at the bottom of the screen. But the really cool thing about the TextBar is that it is fully scriptable: not from Ruby, but from a special custom language which the application parses passively rather than actively. (That is, the application pauses parsing the script to obtain a human response, rather than the other way around.)

Since this library is so old, some of it is a bit outdated. For example, before Gosu's text input was updated in 0.7.9, GGLib had it's own text input interface. With Gosu 0.7.9, GGLib's Widget#feedText and associated routines became redundant. This, and other legacy code, will be scrapped as soon as possible.

Currently supported widgets:
DebugConsole
GenericButton
SelectionBox
TextBox
ThemeButton
TracePanel

Finished widgets which must be cleaned up before release
TextBar
MenuBar
Menu
MenuItem
MiniMap

Planned widget additions:
RadioButton
CheckBox
Label
TextArea
HScroll
VScroll

Other planned additions:
Remove legacy code
Add audio hooks
Reintroduce serialization/deserialization
Reintroduce debugging/logging
Add layout mechanism
Add theme mechanism
Add support for drawn widgets as well as image-widgets.

Download:
http://code.google.com/p/gglib/downloads/list
- By wh1pl4sh Date 2009-01-29 00:30
First post on the forum =)

Let me say I really appreciated your lib. I'm creating a game here (actually my first game with Gosu) and it helped me alot to create great GUI so far. Just let me ask you (and, of course, all the other members) a kind of rethorical question, wouldn't be better if Gosu handle panels, instead of creating new windows? I mean, I created some games using Pygame, and  I  could use the pygame.sprite.Sprite class to create the panels for my GUI. Maybe because I'm newbie to Gosu I'm not considering problems that could arise from this idea.

psadda, keep up the nice work! if you need any help on further development, let me know =). Although my Ruby experience is kind of limited, I'm really enjoying Ruby and Gosu =P.
Cya, happy hacking
- By psadda Date 2009-01-29 21:37
If all you need is the ability to display a background image for your panel, you could use the GUIWindow#newImage function. If you need some slightly more advanced functionality, such as the ability to recieve input such as mouse clicks, you could implement a simple subclass of widget. (Actually, you could use widget itself, as it would provide all the necessary functionality, but it would be bad style to use something which should be considered an abstract base class.) If you need more advanced functionality such as panel based content layout, it isn't available yet, but I am working on it. I hope that answers your question.

Thanks for the input.

By the way, do you mind sharing your app, or screenshots of your GUI? I'm interested in seeing what kind of stuff people are doing with the library.
- By philomory Date 2009-01-30 08:27
Ok, I haven't had a chance to download this and play with it yet, but from readings your description I'm quite excited. I've been wishing for something like this for a while now.
- By ? Date 2009-01-30 15:00
Is there any gui library for guso c++? If not, any plans to extend gosu a little bit more to handle gui? (The text input abstract class is a great start, but not quite enough for a full gui some games would need).

Thanks
- By wh1pl4sh Date 2009-01-30 19:15
Not at all, I've being away from my pc for a couple of days, but I guess by Sunday I'll have the game finished (anyway, is a just a simple Space Invaders clone, but I'm working on to, who knows, do some great game in few weeks with Ruby =P).
I've actually extended some of your code, and modified some part of it too, but just some lines, not much.
I've gotta tell you, the fade effect is awesome! I really liked that. To simulate the kind-of panel behaviour I'm using this effect, it seems pretty nice actually (of course, fading too much just feels a bit awkward lol).
So, as soon as I'm done with the game, I can happily share it =).

Cya, happy hacking.
- By psadda Date 2009-02-01 03:35 Edited 2009-02-01 03:38
wh1pl4sh, I'm glad to hear that the library is working well for you. The FadeScreen was a short bit of inspiration. I was trying to figure out how to stop the transitions between menus from looking so choppy, and then I realized that most fullscreen apps/video games actually have a very quick fade in/fade out between screens. So, I felt it was pretty important to add the fade in class. Right know, I'm trying to see if I can use the new clip_to method to limit the fading to a single widget. What kind of modifications did you make? Maybe I should add them to the main library. ;)

About C++ libraries, there is no C++ GUI library specifically targeted at Gosu that I know of, but in C++, it is possible to directly access the components of the window, such as the Graphics class, use them with existing C++ or C toolkits such as wxWidgets, FLTK, GTK, ,etc.

philomory, I hope you like the library.

I've made some updates to the library. I'll post them along with more complete documentation on the Google Code site sometime tomorrow. I added support for themes to the library. Now, the same widgets can reused with different graphics. Themes can also be loaded from textfiles. The only problem is, there aren't any themes yet! There are two types of themes right now: drawn themes, drawn themes, which are drawn from code, and image based themes. Drawn themes can be easily reshaped and resized, but they don't look as good as image themes can. I've also added two new widgets: Label and CheckBox.