Handmade Hero»Forums»Code
Robert Toth
12 posts
Handmade GUI?
Edited by Robert Toth on
Hi!

First of all, if you are reading this Casey then thank you very much. You are like some genie that popped up and started answering all my questions from my youth. Unfortunately, I gave up on windows and game programing in my early teens because learning that stuff seemed impossibly hard. But it's never too late, especially with people like you broadcasting pure gold!

Now to the question: I was thinking of creating some simple photo organizing application to get my hand dirty with windows programming and C, also I need one :)

I've read about how many of you have been writing text editors and what not. So I'm wondering, is it foolish to create my own GUI? I mean, if I'm in control of the buffer that gets drawn I can draw anything anyway I want right? GUI included. But am I getting myself in too deep? Are there very complex issues I will have to deal with that is specific to GUI design?

Actually, I'll probably just do it because I want to. But is there anything I should be aware of you think? Just to get my expectations right.. or in the right ballpark at least.

Thanks!
-Robert
Mārtiņš Možeiko
2233 posts / 1 project
Handmade GUI?
Hi!
If you haven't read anything on imgui, start with this: http://mollyrocket.com/861

Casey used same concept when implementing debug UI in handmade hero. Look for videos around day 196 and up.

Or if you want use very nice library that implements this concept, look here: https://github.com/ocornut/imgui
Robert Toth
12 posts
Handmade GUI?
Thank you!
I'll check it out.
Omar
6 posts
None
Handmade GUI?
Edited by Omar on
(nb: I am the author of that library linked above)

It is never foolish to write your own code! You'll face issues but this is also how you learn and skill up. Basically you want to decide where you'll put most of your learning energy, if GUI interest you or GUI are an essential component of your application it is probably worth pursuing. If you want to focus more on another aspect of the application an off the shelf library can be helpful. That said, the concepts of building a GUI aren't very hard.

The imgui concept which Casey helped coin and formalize is a very simple and powerful thing. It has a really soft learning curve so you might want to give a go at writing something yourself to have a better feel of how they are done, even if you end up switching to a premade one later (and often you'll be a better user if you understand how the thing works). In the github link above under the "References" section you'll find other links with written articles describing imgui ideas in more details and they are definitively worth reading.

Now, on most other corners of the internet they would probably redirect you to "retained" type of GUI library which are much more common, and there's countless of them available you can look for inspiration. Casey and I are firm defender of immediate-mode interface style but if you want to pursue your own you'll probably want to understand both paradigms if only to understand their pros and cons and see what you feel yourself.
Ginger Bill
222 posts / 2 projects
I am ginger thus have no soul.
Handmade GUI?
I would like to thank you Omar for your imgui library. I have been using for internal tools and it is absolutely brilliant. Very easy to setup and customize.

I have built my own imgui before but not with all the features already so I would like to thank you.
Omar
6 posts
None
Handmade GUI?
Glad it is useful!
Robert Toth
12 posts
Handmade GUI?
Thank you Omar for your answer.

It may be that I'm a bit biased because most of what Casey says just seems so reasonable to me and coming from the very corporate-overcomplicated world of e-commerce development in C# .NET the thought of more direct and hands-on approaches appeals to me greatly.

I will indeed code it all myself. I'm in no hurry and the point is to learn as much as I can about all the parts of an application.

Thank you again for the inspiration :)

/Robert
Shazan Shums
158 posts
Some day I will make quality software. Programming FTW.
Handmade GUI?
It is odd to reply to an old thread but why not. I was wondering is there any references like books or papers regarding implementing GUI from scratch without any platform specific stuff?
498 posts
Handmade GUI?
msmshazan
It is odd to reply to an old thread but why not. I was wondering is there any references like books or papers regarding implementing GUI from scratch without any platform specific stuff?


That's kind of impossible. You need to talk to the platform when doing stuff from scratch.
Shazan Shums
158 posts
Some day I will make quality software. Programming FTW.
Handmade GUI?
No what I mean is that instead of using com in windows for example how to create radio boxes , list ,combo boxes from scratch by writing to pixels in a buffer. Where I can implemented functions for that .
Mārtiņš Možeiko
2233 posts / 1 project
Handmade GUI?
Edited by Mārtiņš Možeiko on
You need exactly 0 lines of COM to create radio buttons, list or combo boxes and other win32 GUI elements. I'm not sure why you think COM is needed for this, because everything happens with simple CreateWindowEx call. Here's an example for combo box: https://msdn.microsoft.com/en-us/...ary/windows/desktop/hh298364.aspx

Here are examples/documentation for all these elements:
* radio buttons: https://msdn.microsoft.com/en-us/...sktop/bb775947.aspx#radio_buttons
* list box: https://msdn.microsoft.com/en-us/...ary/windows/desktop/bb775146.aspx
* combo box: https://msdn.microsoft.com/en-us/...ary/windows/desktop/bb775792.aspx
Look in the menu on the left side for other UI elements.

As for information how to create gui by drawing pixels into framebuffer, you can continue watching HandmadeHero. Casey creates simple debug UI system around day 176 to 220. Later it is improved in 247-251.