Creating your own GUI library in C/C++

I wanted to make a GUI based program in C++ but i found everything too simple,non-standard C++ or i just didn't like it.I am also bored and need some huge project to work on.But thing is that i can't understand how GUI libraries work,i surfed on net and found nothing.Can anyone explain me simple algorithm for GUI library?
I wanted to make a GUI based program in C++ but i found everything too simple,non-standard C++ or i just didn't like it.
There are no standard GUI libraries.
Consider using 3rdParty Libraries like Qt, QtCreator even provides a GUI-Designer
You won't be able to make your own GUI library, at least you won't make a usable one in less than a few years (except you're REALLY motivated and have access to information on how to do it)
Last edited on
closed account (D80DSL3A)
For a slightly more encouraging reply:
It depends on the need. If you are ok with building basic functional elements, you can.

Start with a button class. It needs a hit() function and a draw() function. You can call hit at a framerate for a mouse over effect.
Coding for use can be simple:
1
2
3
4
5
// in event handling code for left mouse click
if( butt1.hit() )
{
    // code for what the button does
}


Next up is maybe a drop list. This may be just a managed array (or vector) of buttons.
I've built simple dialog boxes, alert boxes, menu lists, scroll bars, etc. as needed for my games. Develop incrementally.
Last edited on
To back this up, if you're familiar with using graphics libraries then you can make the basics in a couple of days. I just did in fact. All you need is three textures (normal, mouseOver and pressed), and update function to check for mouse clicks and check if they are in the area of the button. Then when it is drawn, if the use whether it is pressed and whether the mouse is over it to pick a texture. After this, all you need is an std::function callback to activate when the button is pressed. I'd suggest making an interface that defines what a button is and then making both containers to hold lots of buttons (such as a menu) and different types of buttons (press, slider etc).
I guess his biggest problem is how to draw something since he has got no 3rdParty library to use.
If you just want to have a GUI use Qt, if you really want to create your own GUI library you'll have to use a 2D-Graphics library as base where you can build upon that (eg. SDL or SFML).
Last edited on
Topic archived. No new replies allowed.