DearPyGui icon indicating copy to clipboard operation
DearPyGui copied to clipboard

Updating backend ImGui/ImPlot/ImNodes to latest versions

Open SamuMazzi opened this issue 1 year ago • 61 comments


name: Updating backend ImGui/ImPlot/ImNodes about: Updated backends title: Updating backend ImGui/ImPlot/ImNodes assignees: ''


After a loooooot of work and time, we've finally finished the PR. A huge thank you to @v-ein for all the help and support.

Description

This PR aims to update the ImGui/ImPlot/ImNodes backends of DPG to way more recent versions.

Currently, DPG relies on really old version of these packages (~2/3 years old), now this is the situation before/after the PR:

  • ImGui: 1.83 (May 2021) -> 1.91.0 (July 2024)
  • ImPlot: 0.11 (May 2021) -> 0.17 (January 2024)
  • ImNodes: 0.5 (April 2022) -> updated to the latest available (March 2024)

Those versions are the latest available at the moment of merging the PR and they are supported by DPG but this doesn't mean that we implemented every single feature from those libraries (many are still missing like multi-selection, several flags in different components, new API for shortcuts, etc...).

Below will be listed a summary of the major changes and new features. We tried to be as much backward compatible as possible. And hopefully you may not need to change anything in your current code.

Issues solved

  • Fix #2173, #2013, #1593 (last 2 issues are closed but not solved, but they are all related)
  • Fix #2108
  • Fix #2016

Changes

  • Now there can be 3 x-axes other than the currently supported 3 y-axes
  • New StackToolWindow
  • New query API for plots. Now multiple queries can be created and managed. Check the demo and the new parameters in add_plot to have more info
  • Now label parameter in add_separator will put a label inside the separator
  • ctrl + tab navigation across windows independent from keyboard_navigation parameter
  • Add Presentation section to MetricsTool like in the original ImGui
  • enable parameter in add_group will apply mvStyleVar_DisabledAlpha to all its children

Here is a list of all the new and deprecated arguments and functions.

Note: all deprecated functions and arguments are still accepted by DearPyGui API. Some of them may still work, some are ignored, but none should crash your application.

New functions

  • add_axis_tag
  • add_bar_group_series
  • add_inf_line_series
  • add_digital_series
  • get_plot_query_rects
  • set_axis_limits_constraints
  • reset_axis_limits_constraints
  • set_axis_zoom_constraints
  • reset_axis_zoom_constraints

New arguments

Function Arguments
add_2d_histogram_series
col_major
add_button
repeat
add_child_window






always_auto_resize
always_use_window_padding
auto_resize_x
auto_resize_y
frame_style
resizable_x
resizable_y
add_colormap_scale


format
mirror
reverse_dir
add_combo
fit_width
add_custom_series
no_fit
add_drag_line



delayed
no_cursor
no_fit
no_inputs
add_drag_point





clamped
delayed
no_cursor
no_fit
no_inputs
offset
add_group
enabled
add_heat_series
col_major
add_histogram_series

cumulative
horizontal
add_input_text





always_overwrite
auto_select_all
ctrl_enter_for_new_line
escape_clears_all
no_horizontal_scroll
no_undo_redo
add_line_series




loop
no_clip
segments
shaded
skip_nan
add_pie_series
ignore_hidden
add_plot







max_query_rects
min_query_rects
no_frame
no_inputs
override_mod
query_color
zoom_mod
zoom_rate
add_plot_axis











auto_fit
foreground_grid
no_highlight
no_initial_fit
no_label
no_menus
no_side_switch
opposite
pan_stretch
range_fit
scale
tick_format
add_plot_legend




no_buttons
no_highlight_axis
no_highlight_item
no_menus
sort
add_scatter_series
no_clip
add_stair_series

pre_step
shaded
add_stem_series
horizontal
add_subplots
share_series
add_table_column

angled_header
no_header_label
add_text_point
offset
add_tree_node

span_full_width
span_text_width
add_window
unsaved_document
configure_app



anti_aliased_fill
anti_aliased_lines
anti_aliased_lines_use_tex
docking_shift_only

Deprecated functions

  • add_hline_series: use add_inf_line_series()
  • add_vline_series: use add_inf_line_series()
  • get_plot_query_area: use get_plot_query_rects()
  • is_plot_queried: use get_plot_query_rects()

Deprecated arguments

Function Argument Explanation
add_histogram_series cumlative Deprecated because of a typo: use cumulative
add_image_button frame_padding Not supported anymore by Dear ImGui; still works in DPG but will eventually be removed.
add_plot anti_aliased Not supported by ImPlot anymore. To enable/disable anti-aliasing, use dpg.configure_app() with the anti_aliasing parameters.
add_plot no_child Removed in ImPlot as child windows are no longer needed to capture scroll.
add_plot no_highlight Removed because not supported by ImPlot anymore. To control the highlighting of series use the same argument in add_plot_legend.
add_plot

query_button
query_mod
This refers to the old way of querying in ImPlot, now replaced with add_drag_rect().
add_plot_axis log_scale Use scale=dpg.mvPlotScale_Log10 instead.
add_plot_axis time Use scale=dpg.mvPlotScale_Time instead.
add_text_point

x_offset
y_offset
Use the offset argument instead.

Nerd info (for developers)

Why?

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.

At 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.

OpenGL

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 changes 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.

Major concerns

  • As I said earlier, now there are less keyboard buttons than before, I think that they'll add more in the future, but I don't know how to solve this problem.
  • In my workplace we have never used ImNodes so we haven't tested that a lot. There haven't been any huge updates during these years so there shouldn't be a lot (or any) problems. If someone's willing to help and take a look, they'd be welcome.

Notes

There are still tons of updates and new features that can be implemented (i.e. Shortcuts API, Multi select, and many others), then if you want to take a look on what happened check this for ImPlot and ImGui

In ~2022 ImGui moved all the docking stuff in a separate branch, so now we're relying on that branch. This is not a big difference because it's always rebased on the main branch on every update and should be merged in the master in the version 2.0

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).

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.

SamuMazzi avatar Feb 07 '24 09:02 SamuMazzi