Skip to content

Commit

Permalink
fix: fix label series parameters
Browse files Browse the repository at this point in the history
It seems that the label series wasn't working correctly because of a silly error.
Also the parameters have been made more consistent with the other widgets of the same kind (look at the offset parameter)

Also, TODO updated
  • Loading branch information
SamuMazzi committed Feb 22, 2024
1 parent 8e5353d commit c6b7197
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 37 deletions.
18 changes: 7 additions & 11 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- [x] Antialiasing activated?
- [ ] Disable keyboard navigation
- [ ] Implement TagX/Y also on secondary axes
- [x] mo_mouse_pos -> no_mouse_text
- [ ] Bugfix:
- [x] Crash on tests teardown
- [x] Crash when opening table in demo: `void ImGui::TableSetColumnEnabled(int, bool): Assertion 'table->Flags & ImGuiTableFlags_Hideable' failed.`
Expand All @@ -22,7 +23,8 @@
- [x] While scrolling on plots before start tracing: `bool ImPlot::BeginPlot(const char*, const ImVec2&, ImPlotFlags): Assertion '(gp.CurrentPlot == nullptr) && "Mismatched BeginPlot()/EndPlot()!"' failed.`
- [x] When adding mvTool_Metrics it gives `T& ImVector<T>::operator[](int) [with T = ImVec2]: Assertion 'i >= 0 && i < Size' failed.`
- [x] mvTool_Metrics doesn't show the "Presentation" plot anymore.
- [ ] Crash when pressing button up/down in the `mvTool_ItemRegistry`, probably a problem with function MoveItemUp/Down in `mvItemRegistry.cpp`
- [x] Crash when pressing button up/down in the `mvTool_ItemRegistry`, probably a problem with function MoveItemUp/Down in `mvItemRegistry.cpp`
- [x] Fix label series
- Not sure:
- [ ] Expose `GetMouseClickedCount()` to Python?

Expand All @@ -45,11 +47,10 @@
- [x] Added GetMouseClickedCount() function, returning the number of successive clicks (so IsMouseDoubleClicked(ImGuiMouseButton_Left) is same as GetMouseClickedCount(ImGuiMouseButton_Left) == 2, but it allows testing for triple clicks and more).
- [ ] [V 1.87](https://github.com/ocornut/imgui/releases/tag/v1.87)
Probably all the IO "issues" are deeply linked between them
- [ ] Reworked IO mouse input API: Added io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() functions, obsoleting writing directly to io.MousePos, io.MouseDown[], io.MouseWheel, etc.
- [ ] Reworked IO keyboard input API: Added io.AddKeyEvent() function, obsoleting writing directly to io.KeyMap[], io.KeysDown[] arrays.
- [x] Reworked IO mouse input API: Added io.AddMousePosEvent(), io.AddMouseButtonEvent(), io.AddMouseWheelEvent() functions, obsoleting writing directly to io.MousePos, io.MouseDown[], io.MouseWheel, etc.
- [x] Reworked IO keyboard input API: Added io.AddKeyEvent() function, obsoleting writing directly to io.KeyMap[], io.KeysDown[] arrays.
- [ ] Reworked IO nav/gamepad input API and unifying inputs sources: Added full range of ImGuiKey_GamepadXXXX enums (e.g. ImGuiKey_GamepadDpadUp, ImGuiKey_GamepadR2) to use with io.AddKeyEvent(), io.AddKeyAnalogEvent().
- [ ] Added io.AddKeyAnalogEvent() function, obsoleting writing directly to io.NavInputs[] arrays.
- [ ] IO: Added event based input queue API, which now trickles events to support low framerates. Previously the most common issue case (button presses in low framerates) was handled by backend. This is now handled by core automatically for all kind of inputs.
- [ ] [V 1.88](https://github.com/ocornut/imgui/releases/tag/v1.88)
- [ ] Internals: calling ButtonBehavior() without calling ItemAdd() now requires a KeepAliveID() call. This is because the KeepAliveID() call was moved from GetID() to ItemAdd() (probably nothing to do)
- [ ] IO: Added io.SetAppAcceptingEvents() to set a master flag for accepting key/mouse/characters events (default to true). Useful if you have native dialog boxes that are interrupting your application loop/refresh, and you want to disable events being queued while your app is frozen.
Expand All @@ -69,14 +70,13 @@ Probably all the IO "issues" are deeply linked between them
- [ ] Moved the optional "courtesy maths operators" implementation from imgui_internal.h in imgui.h. (important, must be checked)
- [ ] [V 1.89.5](https://github.com/ocornut/imgui/releases/tag/v1.89.5)
- [ ] IO: Added io.AddMouseSourceEvent() and ImGuiMouseSource enum.
- [ ] [V 1.89.6](https://github.com/ocornut/imgui/releases/tag/v1.89.6)
- [ ] Check little breaking changes in link
- [x] [V 1.89.6](https://github.com/ocornut/imgui/releases/tag/v1.89.6)
- [ ] [V 1.89.7](https://github.com/ocornut/imgui/releases/tag/v1.89.7)
- [ ] Moved io.HoverDelayShort/io.HoverDelayNormal to style.HoverDelayShort/style.HoverDelayNormal (maybe need to change TooltipConfig activation_delay and other attributes)
- [ ] Overlapping items
- [ ] Obsoleted SetItemAllowOverlap(): it didn't and couldn't work reliably since 1.89 (2022-11-15), and relied on ambiguously defined design. Use SetNextItemAllowOverlap() before item instead.
- [ ] Added SetNextItemAllowOverlap() (called before an item) as a replacement for using SetItemAllowOverlap() (called after an item). This is roughly equivalent to using the legacy SetItemAllowOverlap() call (public API) + ImGuiButtonFlags_AllowOverlap (internal).
- [ ] Tooltips: Added SetItemTooltip() and BeginItemTooltip() helper functions. They are shortcuts for the common idiom of using IsItemHovered().
- [x] Tooltips: Added SetItemTooltip() and BeginItemTooltip() helper functions. They are shortcuts for the common idiom of using IsItemHovered().
- [ ] IsItemHovered: Added ImGuiHoveredFlags_Stationary to require mouse being stationary when hovering a new item. Added style.HoverStationaryDelay (~0.15 sec). Once the mouse has been stationary once the state is preserved for same item.
- [ ] IsItemHovered: Added ImGuiHoveredFlags_ForTooltip as a shortcut for pulling flags from defaults.HoverFlagsForTooltipMouse or style.HoverFlagsForTooltipNav depending on active inputs.
- [ ] IsWindowHovered: Added support for ImGuiHoveredFlags_Stationary
Expand Down Expand Up @@ -120,10 +120,6 @@ Take a look at implot.cpp to have a better changelog.
- [x] [V 0.16](https://github.com/epezent/implot/releases/tag/v0.16)


### Completed Column ✓
- [x] mo_mouse_pos -> no_mouse_text


### Non working functions in demo
- [x] in histogram series min and max range should not be 0 and 1, but the min/max of the values
- [x] check density flag of histogram series
Expand Down
2 changes: 1 addition & 1 deletion dearpygui/_dearpygui.pyi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions dearpygui/_dearpygui_RTD.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions dearpygui/dearpygui.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions src/mvAppItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4203,13 +4203,12 @@ DearPyGui::GetEntityParser(mvAppItemType type)
MV_PARSER_ARG_SHOW)
);

args.push_back({ mvPyDataType::Double, "x" });
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" });
args.push_back({ mvPyDataType::DoubleList, "y" });
args.push_back({ mvPyDataType::FloatList, "offset", mvArgType::KEYWORD_ARG, "(0.0, 0.0)", "Offset of the shown label" });
args.push_back({ mvPyDataType::Bool, "vertical", mvArgType::KEYWORD_ARG, "False" });

setup.about = "Adds a label series to a plot.";
setup.about = "Adds a label series to a plot. x and y can only have one elements each.";
setup.category = { "Plotting", "Containers", "Widgets" };
break;
}
Expand Down
11 changes: 4 additions & 7 deletions src/mvPlotting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1730,8 +1730,7 @@ DearPyGui::draw_label_series(ImDrawList* drawlist, mvAppItem& item, const mvLabe
xptr = &(*config.value.get())[0];
yptr = &(*config.value.get())[1];

ImPlot::PlotText(item.info.internalLabel.c_str(), (*xptr)[0], (*yptr)[0],
ImVec2((float)config.xoffset, (float)config.yoffset), config.flags);
ImPlot::PlotText(item.config.specifiedLabel.c_str(), (*xptr)[0], (*yptr)[0], config.offset, config.flags);

// Begin a popup for a legend entry.
if (ImPlot::BeginLegendPopup(item.info.internalLabel.c_str(), 1))
Expand Down Expand Up @@ -2278,7 +2277,7 @@ DearPyGui::set_positional_configuration(PyObject* inDict, mvPieSeriesConfig& out
void
DearPyGui::set_positional_configuration(PyObject* inDict, mvLabelSeriesConfig& outConfig)
{
if (!VerifyRequiredArguments(GetParsers()[GetEntityCommand(mvAppItemType::mvPieSeries)], inDict))
if (!VerifyRequiredArguments(GetParsers()[GetEntityCommand(mvAppItemType::mvLabelSeries)], inDict))
return;

(*outConfig.value)[0] = ToDoubleVect(PyTuple_GetItem(inDict, 0));
Expand Down Expand Up @@ -2841,8 +2840,7 @@ DearPyGui::set_configuration(PyObject* inDict, mvLabelSeriesConfig& outConfig)
if (inDict == nullptr)
return;

if (PyObject* item = PyDict_GetItemString(inDict, "x_offset")) outConfig.xoffset = ToInt(item);
if (PyObject* item = PyDict_GetItemString(inDict, "y_offset")) outConfig.yoffset = ToInt(item);
if (PyObject* item = PyDict_GetItemString(inDict, "offset")) outConfig.offset = ToVec2(item);

if (PyObject* item = PyDict_GetItemString(inDict, "x")) { (*outConfig.value)[0] = ToDoubleVect(item); }
if (PyObject* item = PyDict_GetItemString(inDict, "y")) { (*outConfig.value)[1] = ToDoubleVect(item); }
Expand Down Expand Up @@ -3456,8 +3454,7 @@ DearPyGui::fill_configuration_dict(const mvLabelSeriesConfig& inConfig, PyObject
if (outDict == nullptr)
return;

PyDict_SetItemString(outDict, "x_offset", mvPyObject(ToPyInt(inConfig.xoffset)));
PyDict_SetItemString(outDict, "y_offset", mvPyObject(ToPyInt(inConfig.yoffset)));
PyDict_SetItemString(outDict, "offset", mvPyObject(ToPyPair(inConfig.offset.x, inConfig.offset.y)));

// helper to check and set bit
auto checkbitset = [outDict](const char* keyword, int flag, const int& flags)
Expand Down
8 changes: 5 additions & 3 deletions src/mvPlotting.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ struct mvPieSeriesConfig : _mvBasicSeriesConfig

struct mvLabelSeriesConfig : _mvBasicSeriesConfig
{
int xoffset = 0;
int yoffset = 0;
// In this case it wouldn't be really necessary to use a vector of vectors,
// but it's consistent with the rest of the series
ImVec2 offset = ImVec2(0.0f, 0.0f);
ImPlotTextFlags flags = ImPlotTextFlags_None;
};

Expand Down Expand Up @@ -717,7 +718,8 @@ class mvLabelSeries : public mvAppItem
void setDataSource(mvUUID dataSource) override { DearPyGui::set_data_source(*this, dataSource, configData.value); }
void* getValue() override { return &configData.value; }
PyObject* getPyValue() override { return ToPyList(*configData.value); }
void setPyValue(PyObject* value) override { *configData.value = ToVectVectDouble(value); }
void setPyValue(PyObject* value) override { *configData.value = ToVectVectDouble(value); }
// TODO: This should be changed, it doesn't make sense to force the user to set the value with [[x], [y]] when you could do [x, y]. It creates useless confusion
};

class mvImageSeries : public mvAppItem
Expand Down

0 comments on commit c6b7197

Please sign in to comment.