ggerganov / imtui

ImTui: Immediate Mode Text-based User Interface C++ Library
https://imtui.ggerganov.com
MIT License
3.04k stars 127 forks source link

Missing ImGui Tables demo #33

Closed dufferzafar closed 2 years ago

dufferzafar commented 2 years ago

Currently, Imtui seems to support Imgui v1.81 whose demo has a bunch of table related stuff, which Imtui seems to be missing.

ImGui Demo v1.81 (has lots of table related demo items):

image

ImTui (master) (ncurses_demo) (doesn't have majority of table related items):

image

dufferzafar commented 2 years ago

Silly me. I thought Imtui was just rendering the ImGui demo directly! 😅

I looked at the code and with so many of the ImGui:: lines, i thought Line 43 was ImGui::ShowDemoWindow rather than ImTui::ShowDemoWindow

https://github.com/ggerganov/imtui/blob/bd5a9f0db013174e1cf389386f0c944f592aba47/examples/ncurses0/main.cpp#L22-L45

Anyway, I still feel we should update our demo to match v1.81 demo as much as possible.

ggerganov commented 2 years ago

Initial pass for adding "Tables & Columns" demo is now available on master. Probably needs some more refinements for proper display in the terminal

ggerganov commented 2 years ago

Here is quick preview:

tables

dufferzafar commented 2 years ago

I had copy-pasted the code from imgui_demo.cpp to imtui_demo.cpp and got this working as well.

Glad that you pushed it to master though.

Probably needs some more refinements for proper display in the terminal

Yeah. The tables don't look that good. I was going to create a separate issue for that as well!

I'll list all issues that I found here:

  1. Borders & Backgrounds are not correctly applied. In the default example, rows should have alternating colors while the first two rows have same color, and then the next two rows have same.
  2. Toggling any of the borders like ImGuiTableFlags_Borders totally breaks the table view.
  3. Columns can be resized, but the separator is not really visible. #28 mentions missing separator as well. In cases where the separator is visible, I feel it is "too thick"

This screenshot is from visidata - an ncurses application that i'm trying to partially recreate in C++. This is my ideal goal wrt columns. I think they just have a single character as a separator.

image

ggerganov commented 2 years ago

Most of the issues should be fixed now on latest master (don't forget to update the submodule too):

imtui-tables

I don't think we can support horizontal separators though.