New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updating backend ImGui/ImPlot/ImNodes to latest versions #2275
base: master
Are you sure you want to change the base?
Conversation
- added submodule implot - discontinued docking support - updated documentation - bump imgui and implot versions to ImGui 1.83 and ImPlot 0.13 - renamed variables to match the new backend - added new flags to several plots - Added legacy support for new IO backend - Changed (but not functioning yet) query in plots - Added gl3w to "thirdparty" to avoid dependency in imgui "examples" folder - Modified build process - Added style variable `mvStyleVar_DisabledAlpha` - Added flags to Drag* widgets
For those who're wondering, it wasn't possible to do an incremental update to the latest version mostly because of several problems with the OpenGL libraries. In the end, bump directly to the latest version seemed the most stable and overall best solution. - `str_ends_with` added to check images extensions - assertion enabled - Implemented some of the ImGuiChildFlags - Removed old parameters for plots - Mocked (/commented) several functions so that they can be improved later (ImageButton, ColormapScale, PlotXLines, etc...) - Cast every key input to ImGuiKey - IMPORTANT: Changed GetItem logic because it was deeply broken (for some unknown problem, so maybe the problem is still there) - Removed useless dependencies - Assigned default values in struct for mvPlotConfig "_mod" - Replaced `IM_OFFSETOF` with `offsetof` - Updated ImGui to version 1.90.1 - Updated ImPlot to version 0.16 - Updated ImNodes to latest release - Added TODO.md
- added Infinite Line Series - udpated todo
- Start migration to new IO (deleting GetKeyConstants) - Update all .py files - Updated some of the flags of plots (still not all of them) - Added if statement to BeginTooltip, to mantain consistency with other widgets - Add "SeparatorText()" - Add script to build and generate python files automatically - Started Stack Tool window - IsMouseDoubleClicked() -> GetMouseClickedCount() as suggested in ImGui - Fixed metric windows - Several refactors - New table params
- Removed keys data structure - Fix regression custom series - Fix drawing plots
Also: - added parameters for stairs plot
Also: - removed deprecated keys - fix typo in param of subplots function
- Fix no_outliers typo - Clean .md files - Added flags for InputText
- Added GroupBarSeries - Reimplemented quering in plots - Cleaned internal mvPlotConfig - Fixed demo
- Removed 'area_series` in favor of `line_series` + `shaded` flag - Added remaining flags to plots - Refactor of `XSeriesConfig` structs - Added some mvKeys - Updated documentation mainly for DragTools and ChildWindow
- Added ImageSeriesFlags - Update implot version
- Fixed ColormapScale and added flags - Added DigitalSeries - Updated demo, also removing dependency to numpy
A couple of words on declaring arguments deprecated. Right now, DPG has two options to deprecate an argument:
I'd suggest that we add one more option, where a warning will be issued but otherwise the argument will be passed into the C++ part the way it did before, with its original name. This can be used for arguments that we want to retain for backward compatibility (maybe delete later), but also want to point the user to a newer, better way to do the same thing. We can name it simply |
src/mvAppItem.cpp
Outdated
setup.about = "Adds an error series to a plot."; | ||
args.push_back({ mvPyDataType::DoubleList, "values" }); | ||
args.push_back({ mvPyDataType::StringList, "label_ids" }); | ||
args.push_back({ mvPyDataType::Integer, "item_count" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item_count
and group_count
: We already have the total length of the values
list, and can therefore deduce one of these arguments from another. I suggest to replace them with a single value specifying the number of bars in a group, and name it group_size
(see also comments on the current group_size
argument below). Then then number of items can be calculated from the list size.
What's more, I think we need to add more safety around list sizes. Right now, if labels
is shorter than the number of groups, DPG will segfault. Since both values
and labels
are positional args (i.e. both will for sure be passed in), we can check that their sizes are correct (e.g. values
is a multiple of group_size
, and labels
is no longer than len(values)/group_size
), and raise an exception if they aren't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do you suggest to put these checks? I was thinking in the draw
function: maybe it's not the ideal place to put them, but otherwise I should put them in set_positional_configuration
, set_configuration
and fill_configuration_dict
and I should replicate code and I don't love it tbh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The drawback of checking them in draw_group_bar_series
is that we can't raise an exception there. I'd prefer to signal the error right away. This means we need to check these sizes in set_positional_configuration
and set_configuration
, but not in fill_configuration_dict
. To prevent code duplication, let's add a helper function like ValidateBarGroupConfig(mvGroupBarSeriesConfig& outConfig)
and call it from both set_positional_configuration
and set_configuration
. You can even declare it static so that it's not visible outside of mvPlotting.cpp.
To raise an exception, use mvThrowPythonError
. If I remember correctly, there's no need to return anything to Python in this case. Don't look at how DPG does it - in many cases throughout DPG code, it returns None
after mvThrowPythonError
- this is actually wrong and it crashes in debug mode (documented in #2097).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I was implementing this and then I recognized that if I use the function as you told me (with mvGroupBarSeriesConfig& outConfig
as parameter) I can check the state only when it's already been set, then if there's some error I should restore back to how it was.
Or mvThrowPythonError
takes care of it by itself? (But I don't think so)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mvThrowPythonError
will just store exception info inside of Python so that when it gets back from C++, it raises the exception.
Yes, looks like we need to either back up the old state, or to have a function like SetBarGroupData(mvGroupBarSeriesConfig& outConfig, some-other-parms)
that would store values
, labels
, and group_size
in the config in a single atomic operation (first checking that new values are valid). "Some-other-parms" here could be three PyObject*
obtained from keyword args or from positional args, and SetBarGroupData
would parse them into local variables, replacing NULLs with values from the config. It can then validate the values and store in the config.
Now it's based on the detection of the OS and no more on the function `strnicmp` itself
args.push_back({ mvPyDataType::Double, "y" }); | ||
args.push_back({ mvPyDataType::Integer, "x_offset", mvArgType::KEYWORD_ARG }); | ||
args.push_back({ mvPyDataType::Integer, "y_offset", mvArgType::KEYWORD_ARG }); | ||
args.push_back({ mvPyDataType::DoubleList, "x" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x
, y
: Changing these to list-type and at the same time asking the user to only pass one element (rather than enforcing it via type system) looks really weird. What's the reason behind this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was because of consistency with all the other series... I'm pretty sure I tried to accept single elements but I couldn't. Anyway I'll try again and I'll tell you if and where I get stuck
src/mvBasicWidgets.cpp
Outdated
@@ -6398,17 +6431,17 @@ DearPyGui::draw_tooltip(ImDrawList* drawlist, mvAppItem& item) | |||
} | |||
apply_local_theming(&item); | |||
|
|||
ImGui::BeginTooltip(); | |||
if(ImGui::BeginTooltip()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this condition might makes tooltip rendering more efficient in some cases (not in the current version of ImGui though 😁), it will also lead to item state "getting stuck" like it was on menu widgets in #2245. We need to update the state even when BeginTooltip
returns false
. Obviously state.visible
will be false in this case; rectSize
should probably be (0, 0); not sure about content region - probably (0, 0) too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I applied this, tell me if it's correct in the next commit. Otherwise, if this can lead to others issues, I can simply remove that if statement
…ments - add `DEPRECATED_KEYWORD_ARG` to use in cases where you accept a deprecated argument but you suggest the user to move to the new one. - changed `invert` to `reverse_dir` argument in `color_map_scale` - changed some helper text - restored `cumlative` as deprecated argument - add old functions as deprecated: `add_hline_series` and `add_vline_series`
- `mvGroupBarSeries` to `mvBarGroupSeries` and change its parameters - `mvTag` to `mvAxisTag`, together with `add_axis_tag` instead of `add_plot_tag`. Also now it is a type 1 item. - change some parameters' names - reintroduce removed parameters as DEPRECATED and changed other parameters' names in `add_plot`, `add_axis_plot` and `add_label_series` - change `no_outliers` to `outliers` in Histograms - reintroduce deprecated `is_plot_queried` and `get_plot_query_area`
…eters - add style variables: `TabBorderSize`, `TabAngledHeadersAngle`, `TableAngleHeaderTextAlign` - fix `angled_header` parameter for TableColumn - effectively reactivate `frame_padding` in `ImageButton` - fix typo in `ImGuiStyleVar_TabBarBorderSize` - add some `span_` parameters to `tree_node` and added them to Demo (others still need to be tested) - update ProgressBar documentation to tell the user the possibility to enable indeterminate progress bar - update ImGui backend to 1.90.6
A note on key modifiers in the plot (this seems to be the only place where we can pass modifiers): While it might look natural to pass It would be even better to modify the code so that |
- fix typos and remove useless comments - restore old documentation - revert BOM changes - revert adding of `set_anti_aliasing` function in favour of adding new parameters to `configure_app` - change documentation of some parameters - remove useless variables like `unsaved_document` - fix "Mouse clicks count" so that now shows the number of counts and not the button creating them - implement `_query_dirty` to make the query rects behave correctly inside plots and fix callback for them - change `DEPRECATED_KEYWORD_ARG` parameter - hide redundant window in `StackWindow` - fix bug related to tooltip with angle headers - restore missing Docking style colors
This breaks the old behavior of having multiple Y axes of type v-ein/DearPyGui-fixes@c62d78d...bugfix/auto-y-axes In addition, the fix removes Here's a script to test it all: import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title=f"Test - {dpg.get_dearpygui_version()}", width=500, height=750)
with dpg.window(label="Old way"):
with dpg.plot():
dpg.add_plot_axis(dpg.mvXAxis)
dpg.add_plot_axis(dpg.mvYAxis, label="Y1")
dpg.add_plot_axis(dpg.mvYAxis)
dpg.add_plot_axis(dpg.mvYAxis, label="Y3")
if hasattr(dpg, "mvYAxis2"):
with dpg.window(label="New way", pos=(0, 350)):
with dpg.plot():
dpg.add_plot_axis(dpg.mvXAxis)
dpg.add_plot_axis(dpg.mvYAxis, label="Y1")
dpg.add_plot_axis(dpg.mvYAxis2)
dpg.add_plot_axis(dpg.mvYAxis3, label="Y3")
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context() (The label on Y2 is omitted deliberately in order to test label assignment). |
@@ -4188,31 +4322,14 @@ DearPyGui::GetEntityParser(mvAppItemType type) | |||
args.push_back({ mvPyDataType::DoubleList, "y2", mvArgType::KEYWORD_ARG, "[]" }); | |||
args.push_back({ mvPyDataType::DoubleList, "y3", mvArgType::KEYWORD_ARG, "[]" }); | |||
args.push_back({ mvPyDataType::Bool, "tooltip", mvArgType::KEYWORD_ARG, "True", "Show tooltip when plot is hovered." }); | |||
args.push_back({ mvPyDataType::Bool, "no_fit", mvArgType::KEYWORD_ARG, "False", "the item won't be considered for plot fits" }); | |||
args.push_back({ mvPyDataType::Bool, "no_legend", mvArgType::KEYWORD_ARG, "False", "the item won't have a legend entry displayed" }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no_legend
: Why do we need this argument on custom_series
? Won't leaving the label empty be sufficient? AFAIK using empty labels to hide the legend entry works on all types of series in both old and updated DPG.
The ImPlot code treats both ImPlotItemFlags_NoLegend
and an empty label identically:
if (!ImHasFlag(flags, ImPlotItemFlags_NoLegend) && ImGui::FindRenderedTextEnd(label_id, nullptr) != label_id)
So you're telling to just put in the explanation of the parameters that you can disable that feature by just putting -1? (Ignoring the alternative of modifying implot itself) Otherwise tell me if I got it wrong |
Yeah, kind of that. We can even define a new constant, like setup.about = "Adds a plot which is used to hold series, and can be drawn to with draw commands. For all _mod parameters use mvKey_ModX enums, or mvKey_ModDisabled to disable the modifier."; |
…r fixes - Remove hideable arguments in `add_table` in demo - Improve documentation and change some parameters' names - Remove `disabled` parameter in `add_table_column` - Update state of tooltip when not shown - Change type of `decimalPoint` - Restore old `Mx` instead of `ImPlot::GetCurrentContext()->Style.LineWeight` - Remove useless performance improvement in `GetItem`
… widgets Also, improve internal handling of flags and names of axes together with slight changes to parameters default values
name: Updating backend ImGui/ImPlot/ImNodes
about: Updated backends
title: Updating backend ImGui/ImPlot/ImNodes
assignees: ''
Description
This PR aims to update the
Im*
backends of DPG to way more recent versions.Currently DPG relies on ImGui 1.83 (last commit around May 2021), ImPlot 0.11 (always around that date) and ImNodes (which is the less updated). With this PR we'll have ImGui 1.90.6 and ImPlot 0.17 (for the major updates see below).
Background: ImGui is currently sponsored by big tech companies like Adobe, Blizzard, Activision, etc. so we can expect a lot of improvements with the update (there are already ton of them) and we can expect a lot of people working on the really ugly/hard things like graphical backend libraries.
Why?
In my workplace we are about to ship a product based on DPG. Because of my job, I had to edit the backend and then I found out that what I edited was already modified in the new ImGui and then I also found out that the ImGui version we were relying on in DPG was really old.
We want to stick with this library but I honestly told them that I don't see the point of relying on an almost dead (okay, no, maintenance mode) library, so we decided to either upgrade it or drop it and replace it with something else.
I know that this is quite a huge change, and that several problems can arise but I also think that it can be definitely worth it. Also with this huge community all of these changes can be "easily" tested.
Changes
If you want to take a look to the original releases you can find them here for ImGui and here for ImPlot
You'll probably find better explanations (and images/videos) of what I'm gonna tell you below.
(Keep in mind that many other improvements have been made, but these are the most important ones in my opinion)
OpenGL
(This has been on of the hardest problem to solve actually)
Currently, for the build, DPG relies on gl3w in the examples folder of ImGui. This doesn't sound like a really stable thing and indeed a couple of releases later, that's been removed, so I added gl3w directly in the
thirdparty
folder.Also ImGui decided to make some heavy changings in order to be more cross-platform. One of these, which is also my biggest concern about all of this work, is about the buttons of the keyboard. These are now less than before, and they have been all mapped to predefined values in ImGui. So if someone used them heavily now they could have some problem.
Issues solved (afaik)
New Features
Drag*
widgets there are new parametersdelayed
,no_cursor
,no_fit
,no_inputs
_mod
button to enable certain actions only when that button is pressed (i.e. select, zoom, override, etc...) and you can also decide the zoom rateStackToolWindow
Infinite line series
(just a wrapper for Vertical and Horizontal line series), Digital Series, Group Bar Seriesset_axis_limits_constraints()
andset_axis_zoom_constraints()
dpg.add_plot_tag()
: now there can be tags attached to the axesdpg.add_window()
dpg.add_legend()
ColorMapScale
filter_set
(beta)dpg.add_group()
(equivalent of new featureImGui::BeginDisabled()
)Breaking changes
mvStyleVar
optionsdpg.add_plot_axis(mvXAxis2)
)dpg.add_child_window()
Changes expected in the future from ImGui
Major concerns
Notes
Everything was tested with Valgrind in order to be sure that there wasn't any kind of accidental memory leak (or at least not more than those who were already there).
Don't look at the README.md and TODO.md, it's nothing but development garbage, it'll be removed when merged. In case you'll read the TODO you'll see that there are still many (not too many) things to do. These are all new features and I'd say, almost all little ones, or difficult to implement, so they can actually be implemented later in the future.
My main goal here was to have a real feedback from the most expert users on this work.
I hope I was clear enough!
I'd like to improve this library because I think it's really great, so any kind of suggestion will be well accepted.