What is the recommended way to create/extend imgui with my own widgets?


#1

I have created a custom PlotEx() (with plotlines and plothistogram helpers) that plots horizontally and vertically, forward and backwards, i.e. mirroring the plot directions in 2 dimensions. I did this by passing two extra arguments with some predefined constant values and some bit maps. I have put a lot of effort in minimizing the changes to PlotEx()… but by reading the community entries here and in github, it is apparent that these sort of changes will never rollup to the main imgui, so why bother in trying to minimize deltas. Therefore, I guess I have created my own fancy widget, but I would still like to: 1-make it available 2- contain the code 3- minimize the locations of change when upgrades come out.

What is the ImGui best practice to achieve this? I have read some entries about #including a file… but they are a few years old.


#2

The easiest is to just provide the new code in your own file and make zero change to dear imgui.

PlotEx() is currently too limited. While waiting for a better plot/graph api it is reasoanble to just copy it and make your own.

it is apparent that these sort of changes will never rollup to the main imgui,

Just to clarify, improvement to Plot functions are very desirable but adding new parameters to the existing public function is just going to lead us into a bigger problem. I think the direction to head up is to completely redesign the plot API.


#3

OK. I understand. So let’s say I have a customized PlotExXX() and a customized PlotLinesXX()… where should I store them (.h, .cpp), and what headers to include?

I would like your advice to make this as painless as possible.


#4

Store them in your own files… e.g. my_imgui_extensions.cpp/.h.
You need to include imgui.h and imgui_internal.h to access the internal structures from your .cpp file (but don’t need to expose them to the rest of the code)