Handmade Hero » Forums » Code » Handmade GUI?
Raybolio
Robert Toth
12 posts
#5318 Handmade GUI?
1 year, 9 months ago Edited by Robert Toth on Dec. 6, 2015, 11:45 p.m.

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
mmozeiko
Mārtiņš Možeiko
1477 posts
1 project
#5319 Handmade GUI?
1 year, 9 months ago

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
Raybolio
Robert Toth
12 posts
#5321 Handmade GUI?
1 year, 9 months ago

Thank you!
I'll check it out.
omar
Omar
2 posts
#5354 Handmade GUI?
1 year, 9 months ago Edited by Omar on Dec. 11, 2015, 10:20 a.m.

(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.
gingerBill
Ginger Bill
212 posts
2 projects

I am ginger thus have no soul.

#5355 Handmade GUI?
1 year, 9 months ago

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
Omar
2 posts
#5366 Handmade GUI?
1 year, 9 months ago

Glad it is useful!
Raybolio
Robert Toth
12 posts
#5367 Handmade GUI?
1 year, 9 months ago

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
msmshazan
Shazan Shums
162 posts

Some day I will make quality software.
Programming FTW.

#12016 Handmade GUI?
4 months ago

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?

Just being curious on programming....
ratchetfreak
298 posts
#12017 Handmade GUI?
4 months ago

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.
msmshazan
Shazan Shums
162 posts

Some day I will make quality software.
Programming FTW.

#12018 Handmade GUI?
4 months ago

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 .

Just being curious on programming....
mmozeiko
Mārtiņš Možeiko
1477 posts
1 project
#12019 Handmade GUI?
4 months ago Edited by Mārtiņš Možeiko on May 23, 2017, 4:48 a.m.

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.