How to get started on custom GUI widgets - c++

I would like to exercise programming software with non-standard graphical interfaces such as the ones in the following images. I know how to create a GUI using basic widgets, but I have no idea on how to create my own custom widgets. I am familiar with GTK 3.0 and Qt. The GTK tutorial, for instance, has a link on how to do custom drawing. I just don't know if this is the usual and correct way to create custom widgets. There's also things such as: selections, mouse handling, zoom, scrolling, animations and so on that tutorials do not teach.
So here is my question: what kind of documentation, keywords, tutorials and algorithms should I look for? For my first project, I would like to start with something similar to the first and second images below. My current knowledge is C/C++ and Qt and GTK, but I can learn new languages and tools if necessary.
http://hobby-electrons.sourceforge.net/tutorials/gEDA/simple-schematic-in-gschem.png
http://www.cburch.com/logisim/docs/2.7/pt/html/images/screen-shot.png
http://eeweb.poly.edu/labs/nanovlsi/tutorials/soctutorials/figures/ENCFinalDesign.gif
http://www.ccm.ece.vt.edu:8088/etextiles/projects/arch_images/simulation.jpg
http://j-algo.binaervarianz.de/images/avl_avltest.png

The Qt Graphics view Framework is what you should use if you go with Qt. There are several examples covering the basics of creating components.
To be able to mimic those samples, most of the work is going to be on implementing custom graphic view items. Like widgets it means providing a paint method, specialized event handlers and properties.

Related

Creating a simple window with simple controls in c++ and OpenGL

How do i just create a window with just some controls like menus , check button , radio button , scroll bar ..just with c++ and OpenGL?
It depends.
1) You can't use any external libraries.
In this case you would need to create whole framework for creating controls, handling events, hit tests, state changes... Shortly speaking, you would need to write a GUI library like Qt or wxWidgets, but with all controls drawing implemented in OpenGL.
2) You can use 3rd party libs.
Well, simply read the spec and use them. Examples:
GiGi
GLUI
Also, you may want to read this: OpenGL Forum
However, if you don't have to use OpenGL-based solution, I would suggest you use wxWidgets. I've been using it for years. It's my favourite cross-platform GUI library with solid support, quite big community and reliable, up-to-date online/offline documentation.

Qt - effects on no-opengl widgets

i wanna make some nice user interface, but still using just classic ui elements from Qt.
For instance i have 2 forms and i wanna make some transition between them. For instance rotate first ui screen and make it disappear. It's possible in some way to use shader? Is any way how to do complex ui animations with classic ui elements?
Qt has a whole animation framework. It works on both the QML widgets and for the classic UI elements that you're using. There's some examples of use here, that should be able to get you started.
The simplest way to do it would be to use the Qt Declarative a.k.a. Qt Quick 1. It's based on QGraphicsScene, with the latter offering a reasonable way of integrating legacy widgets. It'll be likely the simplest way to offer animations with widgets.
You may wish to see an overview of GUI technologies available in Qt 5, to see how Qt Quick 1 fits in.

Qt library for 2D/3D game development

As a hobby, I've been working on remaking an old video game, and I want to avoid reinventing the wheel where possible. The game is heavily GUI-based, but the GUI needs to be customized in terms of look-and-feel, and also needs to work with 3D OpenGL rendering for a few game screens.
To give you an idea, here's a screenshot from the initial prototype:
There's a lot of animation used, and 3D also, but the GUI widgets behave much the same as in a standard desktop application.
Thus far, I've been using my own GUI library (it's not robust or complete, and I've been running into some problems).
I've been considering migrating to Qt given it's reputation and impressive features, and some of the nice screenshots on the Qt website. But I've never used Qt before, so I don't really have an idea of what it's capable of, or what kind of time investment would be required to learn it. (Note I've used FLTK).
My question is: would it be possible / practical to use Qt in this situation?
UPDATE: After mocking up some game screens in Qt, I've decided not to use it. While it supports many of the features I need out-of-the-box (particularly through Style Sheets), I need to support custom bitmap-based pre-rendered fonts (I can't convert/replace them). And I can't subclass QFont, or reimplement it without it breaking in future Qt releases. That said, I was extremely impressed with Qt (both in its ease of use, and good documentation). I will be borrowing some of its features for my own engine. Thank you to all who provided input.
It's hard to know everything your game needs to do based on a screenshot; however, I will echo the sentiments of other posters here and provide a couple of avenues for you to look at.
One, is that you might want to consider QtQuick over the GraphicsView Framework, but this REALLY depends on what you need to do. I just want to throw it out there as an alternative so you don't miss it. This tutorial uses QtQuick to put together a really slick looking connect four style game. This may be more simplistic than what you want to go for, but then again, maybe it isn't, it depends on what you need to do.
Second, before writing custom paint events for all of your buttons, I would consider using Qt Style Sheets and style your widgets in a CSS like syntax. This will allow you to change the look and feel of your GUI in a very flexible way really quickly. Based on your screenshot, I think you can get what you want out of style sheets much faster than subclassing and rolling your own setup. But once again, it's hard to know based on one screenshot. Here's an example of a dark and orange GUI that was implemented using only Qt Style Sheets. The border-radius property of QPushButton's style sheet would give you the rounded buttons (ref).
The simple answer has been given above but to throw some more thoughts in: yes it's possible, you probably won't need to fight against Qt too much. For the most part the recommended advice for going to heavily customised widgets like that is subclass and implemented the paint event yourself.
You can then use a load of basic drawing primitives to get the basic shapes for the elements and expand from there. There's actually a couple of questions on here with really good resources about how to do it.

Common game controls/ User interface libraries or source code?

Sorry for the ackward title, but i don't know what to call it exactly. I'm looking for code or libraries that allow easy creation of commonly used user input devices, and code/libs that make gaming controls easy to set up (i'm using SFML and Box2D at the moment)
I don't want to re-invent things like buttons, arrows being placed wherever the mouse is located, and more game specific items such as "controls settings" or even being able to drag objects around with the mouse.
More specifically i want source code for interfaces that....
Makes Buttons and Textboxes easy to create
allows mouse input to press buttons or drag objects in games
has "Focuses" (like a textbox being able to gain focus and be typed in)
Is compatable with SFML/Box2D
and code for common game mechanics/controls that....
Allows easy setup of controls for a game
Makes events like clicking and holding on an object easy to setup, as so objects can be dragged around afterward
Are there any simple libraries or resources out there that i can use to avoid spending much of my time coding these now standard input devices/tecniques?
I think CEGUI is the type of thing you are looking for:
http://www.cegui.org.uk/wiki/index.php/Main_Page
It is a GUI framework to work with OpenGL. Some others can be found in this list.
Still, if I were you, I would just use a major toolkit, such as GTK, Qt, or wxWidgets combined with SFML instead of dealing with CEGUI.
SFML has guides for Qt and wxWidgets with the rest of them at http://www.sfml-dev.org/tutorials/1.6/.
I have created my own little guide for GTK here: http://lalaland.github.com/gtkGuide.html

Gui library for game

I'm making a game with OpenGL render api. Now I need in level editor. It should consist of lots of widgets parents/children etc, so it's hard to write need widgets by hands.
Any ideas about good gui-system which can be easilly connected with opengl? The most important part is gui editing. I really need some editing-tool for it.
Thanks
You should have a look to http://qt.nokia.com/ .
It is very easy to inject the OpenGL rendering into Qt widgets.
To easily edit your GUI, you can use Qt Creator ( http://qt.nokia.com/products/developer-tools ).
You have several options (and this has been answered before, but probably not exactly like this):
SDL: very good abstraction layer for audio, graphics and anything related. It will force you to write your widget stuff by hand.
Qt: has an OpenGL module that makes it easy to set up an OpenGL context. It will make widgets and everything very easy.
wxWidgets: same as Qt, but has slightly worse documentation and tools (if I might be so blunt)
I'd go with number two: it has a beautiful Designer tool to create Widgets with all the fancyness you'll need. OpenGL is also built right in.
If you're running Windows (can't confirm Mono will do it), another option would be to use C# and WinForms to make your life significantly easier.
Check out CEGUI:
http://www.cegui.org.uk/wiki/index.php/Main_Page
It defines its GUIs in XML and has editors for it.