vurtun / nuklear

A single-header ANSI C gui library
13.66k stars 1.11k forks source link

[feature request]Text inline color coding. #575

Open uq1 opened 6 years ago

uq1 commented 6 years ago

Any chance inline color coding (and maybe bold?) options could be added?

Coule be either like HTML or even something as simple as some basic color options using something like quake 3 color codes "^1" for color 1, etc?

This would be really useful for all text fields, and keep ui code much cleaner.

dumblob commented 6 years ago

Let me oppose this proposal. I know it's a needed feature, but because of its implementation complexity I wouldn't make it a part of Nuklear, but rather a separate single-header library independent from a font rendering backend (to allow using Freetype as well as stb_truetype.h etc.).

I can imagine this separate single-header library would be a highly configurable (in compile time) text editor supporting at least the following (from the most important to the least):

uq1 commented 6 years ago

That is way more then I need, but would be awesome. I guess if it's going to be done, it may as well be done in a complete way :+1:

I (rather hackily) changed the code myself to do simple Q3 style color markers, which is enough for me for now.

I also had to create my own tooltip code to give multi-line tooltips for the game i'm working on as you can see in the attached screenshot. I have noticed when i select an inventory item from the inventory window I made, the window background goes clear though. Not sure why.

image2

dumblob commented 6 years ago

@uq1 looks good. Do you have the source for it somewhere? I could not find in your GitHub repositories. I'd like to see the amount and complexity of those patches just to guess the effort for the "full-featured" text editor generic "widget" I described above.

uq1 commented 6 years ago

The repo is here: https://github.com/Stoiss/Rend2

My hacky modifications to nuklear.h here: https://github.com/Stoiss/Rend2/blob/rend2/codemp/rd-warzone/nuklear.h

And my GUI code calling it is here: https://github.com/Stoiss/Rend2/blob/rend2/codemp/rd-warzone/warzone_gui.cpp

The assets used (and current test version) are here: https://github.com/Stoiss/WZassets (will require Star Wars: Jedi Academy game assets as well to use it)

The tooltip text in there is static, but I have written game code to use it. Just not linked up yet. This might be useful to you, however, as the warzone-gui.cpp code is based on the demo code, so you should be able to copy/paste back the other way if you want to test or play around.