FIX:mousewheel bug in preview slider
Change-Id: I9366a9c36250519259c132380e0a69697b6ee18c
This commit is contained in:
parent
ecc76d0f33
commit
07dd4c3672
|
@ -118,6 +118,7 @@ int ImGuiWrapper::TOOLBAR_WINDOW_FLAGS = ImGuiWindowFlags_AlwaysAutoResize
|
||||||
| ImGuiWindowFlags_NoCollapse
|
| ImGuiWindowFlags_NoCollapse
|
||||||
| ImGuiWindowFlags_NoTitleBar;
|
| ImGuiWindowFlags_NoTitleBar;
|
||||||
|
|
||||||
|
static float accer = 1.f;
|
||||||
|
|
||||||
bool get_data_from_svg(const std::string &filename, unsigned int max_size_px, ThumbnailData &thumbnail_data)
|
bool get_data_from_svg(const std::string &filename, unsigned int max_size_px, ThumbnailData &thumbnail_data)
|
||||||
{
|
{
|
||||||
|
@ -195,21 +196,7 @@ bool slider_behavior(ImGuiID id, const ImRect& region, const ImS32 v_min, const
|
||||||
if (axis == ImGuiAxis_Y)
|
if (axis == ImGuiAxis_Y)
|
||||||
mouse_wheel_responsive_region = ImRect(region.Min - ImVec2(0, handle_sz.y), region.Max + ImVec2(0, handle_sz.y));
|
mouse_wheel_responsive_region = ImRect(region.Min - ImVec2(0, handle_sz.y), region.Max + ImVec2(0, handle_sz.y));
|
||||||
if (ImGui::ItemHoverable(mouse_wheel_responsive_region, id)) {
|
if (ImGui::ItemHoverable(mouse_wheel_responsive_region, id)) {
|
||||||
#ifdef __APPLE__
|
v_new = ImClamp(*out_value + (ImS32)(context.IO.MouseWheel * accer), v_min, v_max);
|
||||||
if (io.KeyShift)
|
|
||||||
v_new = ImClamp(*out_value - 5 * (ImS32) (context.IO.MouseWheel), v_min, v_max);
|
|
||||||
else if (io.KeyCtrl)
|
|
||||||
v_new = ImClamp(*out_value + 5 * (ImS32) (context.IO.MouseWheel), v_min, v_max);
|
|
||||||
else {
|
|
||||||
v_new = ImClamp(*out_value + (ImS32) (context.IO.MouseWheel), v_min, v_max);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (io.KeyCtrl || io.KeyShift)
|
|
||||||
v_new = ImClamp(*out_value + 5 * (ImS32) (context.IO.MouseWheel), v_min, v_max);
|
|
||||||
else {
|
|
||||||
v_new = ImClamp(*out_value + (ImS32) (context.IO.MouseWheel), v_min, v_max);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
// drag behavior
|
// drag behavior
|
||||||
if (context.ActiveId == id)
|
if (context.ActiveId == id)
|
||||||
|
@ -416,9 +403,9 @@ bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt)
|
||||||
io.MouseDown[1] = evt.RightIsDown();
|
io.MouseDown[1] = evt.RightIsDown();
|
||||||
io.MouseDown[2] = evt.MiddleIsDown();
|
io.MouseDown[2] = evt.MiddleIsDown();
|
||||||
float wheel_delta = static_cast<float>(evt.GetWheelDelta());
|
float wheel_delta = static_cast<float>(evt.GetWheelDelta());
|
||||||
if (wheel_delta != 0.0f)
|
if (wheel_delta != 0.0f) {
|
||||||
io.MouseWheel = static_cast<float>(evt.GetWheelRotation()) / wheel_delta;
|
io.MouseWheel = evt.GetWheelRotation() > 0 ? 1.f : -1.f;
|
||||||
|
}
|
||||||
unsigned buttons = (evt.LeftIsDown() ? 1 : 0) | (evt.RightIsDown() ? 2 : 0) | (evt.MiddleIsDown() ? 4 : 0);
|
unsigned buttons = (evt.LeftIsDown() ? 1 : 0) | (evt.RightIsDown() ? 2 : 0) | (evt.MiddleIsDown() ? 4 : 0);
|
||||||
m_mouse_buttons = buttons;
|
m_mouse_buttons = buttons;
|
||||||
|
|
||||||
|
@ -435,6 +422,19 @@ bool ImGuiWrapper::update_key_data(wxKeyEvent &evt)
|
||||||
|
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
|
||||||
|
if (evt.CmdDown()) {
|
||||||
|
accer = 5.f;
|
||||||
|
}
|
||||||
|
else if (evt.ShiftDown()) {
|
||||||
|
#ifdef __APPLE__
|
||||||
|
accer = -5.f;
|
||||||
|
#else
|
||||||
|
accer = 5.f;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
accer = 1.f;
|
||||||
|
|
||||||
if (evt.GetEventType() == wxEVT_CHAR) {
|
if (evt.GetEventType() == wxEVT_CHAR) {
|
||||||
// Char event
|
// Char event
|
||||||
const auto key = evt.GetUnicodeKey();
|
const auto key = evt.GetUnicodeKey();
|
||||||
|
|
Loading…
Reference in New Issue