You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a suggestion, you should use InvisibleButton() (or lower-level ButtonBehavior() to process inputs).
Using IsMouseHoveringRect() is incorrect and won't handle window overlaps, inputs inhibition by popups, drag and drop and other features.
Reacted by Rafael Ristovski, BigMacTim, skhiat and Hippy
I cloned this widget in Python with pyimgui. Here are some words:
We need the slider to work on integers as well. That's actually what my implementation is doing.
Invisible buttons (one for clicking and dragging on the board, two for the X, Y handles) work very well. However, to detect dragging for a specific widget, I have to save a global state (id of widget being pressed (imgui.is_item_hovered() and imgui.is_mouse_down()) and not released since then (imgui.is_mouse_released())) somewhere. In C++ we should be able to manage the state with ImGui::GetStateStorage().
There should be an option to choose in which directory Y value grows. My version places (0, 0) on top-left corner and the Y value grows top->bottom.
The label of the widget shouldn't be mandatory. The "Values" display shouldn't be mandatory. With the values returned, users can easily choose from drag_int, input_int2, etc.
The x position of X handle and y position of Y handle should never change. When dragging int, I compute the maximum digits of min_value_y and max_value_y, use that to set Y handle.
Although my version is also a strict square, an option to let the slider match the ration of delta X and delta Y may be interesting.
We need the slider to work on integers as well. That's actually what my implementation is doing.
Fixed [For any type we have a Scalar Version]
Invisible buttons (one for clicking and dragging on the board, two for the X, Y handles) work very well. However, to detect dragging for a specific widget, I have to save a global state (id of widget being pressed (imgui.is_item_hovered() and imgui.is_mouse_down()) and not released since then (imgui.is_mouse_released())) somewhere. In C++ we should be able to manage the state with ImGui::GetStateStorage().
Now it's implemented with ImGui::ButtonBehavior(frame_bb, ImGui::GetID("##Zone"), &hovered, &held);
Can be extended to store state (IsPressed) etc, not done yet.
There should be an option to choose in which directory Y value grows. My version places (0, 0) on top-left corner and the Y value grows top->bottom.
For me it's as design, it is just a decision to fit with regular plot XY {X left to right, Y bottom to up}.
The label of the widget shouldn't be mandatory. The "Values" display shouldn't be mandatory. With the values returned, users can easily choose from drag_int, input_int2, etc.
Not sure I understand, but I plan to extend with Style to handle some of those use cases.
The x position of X handle and y position of Y handle should never change. When dragging int, I compute the maximum digits of min_value_y and max_value_y, use that to set Y handle.
Good point, I'll do similar thing.
Although my version is also a strict square, an option to let the slider match the ration of delta X and delta Y may be interesting.
Activity
ocornut commentedon Sep 27, 2020
Nice work!
As a suggestion, you should use
InvisibleButton()(or lower-levelButtonBehavior()to process inputs).Using
IsMouseHoveringRect()is incorrect and won't handle window overlaps, inputs inhibition by popups, drag and drop and other features.zhihaoy commentedon Oct 28, 2020
I cloned this widget in Python with pyimgui. Here are some words:
imgui.is_item_hovered() and imgui.is_mouse_down()) and not released since then (imgui.is_mouse_released())) somewhere. In C++ we should be able to manage the state withImGui::GetStateStorage().(0, 0)on top-left corner and the Y value grows top->bottom.drag_int,input_int2, etc.soufianekhiat commentedon Mar 16, 2021
@zhihaoy:
Thanks for the feedback.
I released a new version with various other Widgets, check out here for an updated version here:
https://github.com/soufianekhiat/DearWidgets