ocornut / imgui

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

Virtual scrolling and columns #543

Open tambry opened 8 years ago

tambry commented 8 years ago

Hi!

So I'm just beginning to use ImGui to write a debugger for my N-Gage emulator project (NGEmu for short). The first thing that I want to accomplish is displaying a big list, which would always point to the PC (program counter) and which would display if the line contains a breakpoint (red dot?), the memory address (up to 0x380000), the bytes at the memory address and the instruction name, if the memory location contains an instruction. It should also be able to group the bytes together depending on the instruction. Adding such a huge number of elements every frame is obviously not possible. Is there a way to get the number of elements being displayed by the list and then have it add the needed elements?

An example posted in #123 for ProDBG seems to more or less showcase the structure for a disassembly window that I want.

ocornut commented 8 years ago

Hi Raul,

What you typically want here is to "seek" directly in the visible portion of the display. If you item heights are fixed this is trivial. Look at the ImGuiListClipper helper in imgui_demo.cpp and in issues https://github.com/ocornut/imgui/search?q=ImGuiListClipper&type=Issues&utf8=%E2%9C%93

If your item heights are variable this would be a little more work for you, you may need to create some adhoc data structure to help you identity the item number based on a Y position.

-Omar

tambry commented 8 years ago

Thank you very much for the advice, works like a charm! I'm currently slightly confused by how to set the width of a column. PushItemWidth seems to have no effect on the column. Would you be able to... push me in the right direction?

ocornut commented 8 years ago

SetColumnOffset tho all the columns API is largely lacking (see the various threads about columns).

tambry commented 8 years ago

Thank you very much. Seems like for now I don't have any problems with ImGui and I can continue with reverse-engineering.

tambry commented 8 years ago

@ocornut Is there any easy way to make a whole column line selectable? Using ImGui::Selectable I can make a part of the line selectable, but I'd prefer to have the whole line clickable and selectable.

ocornut commented 8 years ago

Have you looked at the flags for Selectale() ? Please look at the existing code and demo more carefully :)

tambry commented 8 years ago

Managed to not notice the usage in the demo. Thank you very much once again and I'll try to take a more through look the next time.

tambry commented 8 years ago

@ocornut Hi. Sorry again for bothering you once again. This time I've got 3 issues.

  1. Is there any way to be able to have the scrolling "locked" locked in a way, that it only displays full lines, and the half-lines wouldn't appear? Half-line problem can be usually easily observed by clicking somewhere randomly on the scroll-bar.
  2. What would be the easiest/most reliable way to scroll to a certain line? I'm unable to use the approach, that's used in the demo, as I use the ImGuiListClipper for my huge list. ImGui::SetScrollFromPosY(line * ImGui::GetTextLineHeight()) ^ Doesn't seem to quite centre the line.
  3. For some reason, the top-most line always only takes 1 click to add a breakpoint, while all others take 2 clicks.

The part where I use ImGui is available here: https://github.com/NGEmu/NGEmu/blob/master/NGEmu/Debugger/Debugger.cpp#L128