ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
60.97k stars 10.29k forks source link

New feature: ASCII drawing with ImTui #7199

Open katemonster33 opened 10 months ago

katemonster33 commented 10 months ago

Version/Branch of Dear ImGui:

Version 1.89.6, Branch: master

Back-ends:

imgui_impl_sdl2.cpp +imgui_impl_sdlrenderer2.cpp, imtui-impl-ncurses.cpp + imtui-impl-text.cpp

Compiler, OS:

MSVC, mac os/clang, linux/clang, linux/gcc

Full config/build information:

No response

Details:

Hello! I am a dev working on Cataclysm: Dark Days Ahead (https://github.com/CleverRaven/Cataclysm-DDA). I am integrating ImGui into the game. We use SDL and ncurses(terminal) builds and on my current branch we have both running off the same ImGui sources, with the ImTui backend for ncurses builds. It's working well for us but we do not use all the features that ImGui offers. My current version of ImGui that the game uses is here https://github.com/katemonster33/imgui under 'v1.89' branch. It's a modified version of v1.89.6. In order to fix drawing issues in ImGui on ASCII builds, I added several '#ifdef IMTUI' lines in places where it was needed, I basically forked ggerganov's imgui repo, rebased onto v1.89.6 and added the #ifdef's.

If you're interested, I would love to workshop this branch into something that could be merged into this repository. Maybe replacing the #ifdef's with some sort of if statement related to the ImGui style? The original developer of ImTui, ggerganov made it sound in the past like there was interest in getting this feature into master, so I wanted to check here.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
MoreCodeToExplainMyIssue();
ImGui::End();
ocornut commented 4 months ago

Looks like to closed this before I had a chance to answer.

If you're interested, I would love to workshop this branch into something that could be merged into this repository. Maybe replacing the #ifdef's with some sort of if statement related to the ImGui style? The original developer of ImTui, ggerganov made it sound in the past like there was interest in getting this feature into master, so I wanted to check here.

My general intuition is that it's going to be too much side-tracking/maintenance work for me to have this into master, and as I strongly need to pick my battles for this project to stay sane, I need to avoid it. I think however it may make sense that someone maintain an official ImTui by merging latest dear imgui into this (and it looks like you already did some of that work). I personally maintain quite a few test branches of similar scope and rebasing isn't that difficult.

If there is a situation where some maintenance work on imtui could be greatly facilitated by a small change on my end, I would be open to it.

katemonster33 commented 4 months ago

@ocornut I opened this issue to try and start the conversation about how we could workshop what I've done into something maintainable for the repo. Since you responded I'll reopen the issue.

Right now the patch is a series of #ifdef statements. If ImTui is enabled, then certain extra space within elements are skipped. Like, for drawing a button, instead of drawing the border pixels and ItemSpacing pixels around the button, ImTui draws only the text and colors the background with the button background color.

So maybe as a starting point for allowing drawing with ImTui, we could allow all the extra spacing pixels within elements to be configured? Then we could just have the ImTui backend set all those to 0

ocornut commented 4 months ago

Wouldn't setting those values e.g. style.FrameBorderSize, style.ItemSpacing etc. to zero essentially do the same? I would need to see exact code you are referring to.