Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: An simple immediate mode GUI with SFML  (Read 12945 times)

0 Members and 1 Guest are viewing this topic.

pamaury

  • Newbie
  • *
  • Posts: 31
    • View Profile
An simple immediate mode GUI with SFML
« on: June 28, 2008, 07:10:59 pm »
Hello,
I've discovered few months ago what an immediate mode gui was(see http://sol.gfxile.net/imgui/ for an introduction) and wondered how easy it really was to implement some basic controls. Here is the result of my try. I've coded a very simple gui using this paradigm entirely with SFML(I'm not using any Opengl code, only shapes and text) with the following controls:
    button: a push button which display some text
    scrollbar: a scrollbar(horizontal and vertical) which supports mouse and wheel movements
    textfield: a single line edit text field(can be read-only) which support mouse clicking(but no selection) and some useful shortcuts like end or home
    statictext: can display some text without any interaction
    checkbox: a two state checkbox which displays some text
    listbox: a list box with an automatic scrollbar if necessarywhich support mouse wheel and keyboard

All those controls except the static text have basic support for keyboard focus using the Tab and Alt-Tab combinasion and the Space key to action it(button and check box only) and arrows for movements(list and edit).
Furthermore, you can customize the colors of the controls even if it's not really explained in the code(see the source to understand how it works). I think the code is sufficiently commented to be understood(the header is commented for Doxygen even if there few places where its unfinished).

They are still some things that are not perfect(some come from the immediate mode paradigm) but I've tried to make it as usable as possible. I don't really have time to maintain it because so I post the as-is, feel free to copy and modify it if you want.
Here is a screenshort:

And here is the code(the header is 400 lines long and the code is 1200 lines long)
http://amaury.pouly.free.fr/Public/SfmlIMGui.zip

I would also appreciate some feedbacks.

Xylankant

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • http://xylankant.xy.funpic.de
An simple immediate mode GUI with SFML
« Reply #1 on: June 28, 2008, 08:39:10 pm »
hey pamaury,

this project seems interesting to me, however, if I try compiling the code (I'm using Code::Blocks as well), it says "cannot find -lfreetype"

What is that library?
is it from the freetype2-project?
would I have to install the whole freetype2 windows binaries?

hope you know, what I mean ^^

pamaury

  • Newbie
  • *
  • Posts: 31
    • View Profile
An simple immediate mode GUI with SFML
« Reply #2 on: June 28, 2008, 09:42:05 pm »
Well, SFML uses freetype to render some text so if you using the dll version of SFMl, just suppress this line. However, if you using the static version of SFMl, you need the binary but I think it is included in the SDK in the external dependencies folder.

Xylankant

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • http://xylankant.xy.funpic.de
An simple immediate mode GUI with SFML
« Reply #3 on: June 28, 2008, 09:57:24 pm »
ok, thx, I've tried it.

works fine here!

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
An simple immediate mode GUI with SFML
« Reply #4 on: June 29, 2008, 12:14:45 am »
Great job, I'm gonna check it out.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
An simple immediate mode GUI with SFML
« Reply #5 on: June 29, 2008, 07:09:16 am »
Very nice job :)

Why don't you put it on the wiki ? There's a project category for this kind of contributions.
Laurent Gomila - SFML developer

pamaury

  • Newbie
  • *
  • Posts: 31
    • View Profile
An simple immediate mode GUI with SFML
« Reply #6 on: June 29, 2008, 07:44:40 am »
Thx,
I'll perhaps do it later, I'm going to Paris for 3 weeks and I'm not sure to have an internet access so I will put it on the wiki in 3 weeks.

eleinvisible

  • Newbie
  • *
  • Posts: 47
    • View Profile
An simple immediate mode GUI with SFML
« Reply #7 on: July 01, 2008, 10:32:19 pm »
Very impressive... I suppose I'll just copy and paste this into the wiki then for you? Alright added it under Projects -> Extensions -> simple_imgui

Andershizzle

  • Newbie
  • *
  • Posts: 16
    • View Profile
An simple immediate mode GUI with SFML
« Reply #8 on: September 05, 2009, 08:02:52 am »
Any idea why setting the RenderWindow to fullscreen breaks this? Well it works but hangs and crashes on exit.

wallytsx

  • Newbie
  • *
  • Posts: 3
    • View Profile
An simple immediate mode GUI with SFML
« Reply #9 on: February 11, 2011, 10:36:14 pm »
Hello, can anybody post again the code of this gui please.
thanks

 

anything