Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions src/mvSlider3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ static bool SliderScalar3D(char const* pLabel, float* pValueX, float* pValueY, f
bool bModified = false;
bool hovered;
bool held;
bool pressed = ImGui::ButtonBehavior(oZDragRect, ImGui::GetID("##HandleZ"), &hovered, &held);
if (hovered && held)
ImGuiID iHandleID = ImGui::GetID("##HandleZ");
ImGui::KeepAliveID(iHandleID);
bool pressed = ImGui::ButtonBehavior(oZDragRect, iHandleID, &hovered, &held);
if (held)
{
if (DistToSegmentSqr(vMousePos, vDragStart, vDragEnd) < 100.0f) // 100 is arbitrary threshold
{
Expand All @@ -141,8 +143,10 @@ static bool SliderScalar3D(char const* pLabel, float* pValueX, float* pValueY, f
ImRect const oXYDrag((vRectEnd - vRectStart) * fScaleZ + vRectStart,
(vRectEnd - vRectStart) * fScaleZ + vRectStart + ImVec2(2.0f * fX3, 2.0f * fY3));
//if (ImGui::IsMouseHoveringRect(oXYDrag.Min - vSecurity, oXYDrag.Max + vSecurity) && ImGui::IsMouseDown(ImGuiMouseButton_Left))
pressed = ImGui::ButtonBehavior(oXYDrag, ImGui::GetID("##Zone"), &hovered, &held);
if (hovered && held)
iHandleID = ImGui::GetID("##Zone");
ImGui::KeepAliveID(iHandleID);
pressed = ImGui::ButtonBehavior(oXYDrag, iHandleID, &hovered, &held);
if (held)
{
ImVec2 const vLocalPos = ImGui::GetMousePos() - oXYDrag.Min;

Expand Down Expand Up @@ -220,8 +224,10 @@ static bool SliderScalar3D(char const* pLabel, float* pValueX, float* pValueY, f

//if (ImGui::IsMouseHoveringRect(vHandlePosX - ImVec2(fHandleRadius, fHandleRadius) - vSecurity, vHandlePosX + ImVec2(fHandleRadius, fHandleRadius) + vSecurity) &&
// ImGui::IsMouseDown(ImGuiMouseButton_Left))
pressed = ImGui::ButtonBehavior(handle_x_bb, ImGui::GetID("##HandleX"), &hovered, &held);
if (hovered && held)
iHandleID = ImGui::GetID("##HandleX");
ImGui::KeepAliveID(iHandleID);
pressed = ImGui::ButtonBehavior(handle_x_bb, iHandleID, &hovered, &held);
if (held)
{
float const fCursorPosX = ImGui::GetMousePos().x - vStart.x;

Expand All @@ -231,8 +237,10 @@ static bool SliderScalar3D(char const* pLabel, float* pValueX, float* pValueY, f
}
//else if (ImGui::IsMouseHoveringRect(vHandlePosY - ImVec2(fHandleRadius, fHandleRadius) - vSecurity, vHandlePosY + ImVec2(fHandleRadius, fHandleRadius) + vSecurity) &&
// ImGui::IsMouseDown(ImGuiMouseButton_Left))
pressed = ImGui::ButtonBehavior(handle_y_bb, ImGui::GetID("##HandleY"), &hovered, &held);
if (hovered && held)
iHandleID = ImGui::GetID("##HandleY");
ImGui::KeepAliveID(iHandleID);
pressed = ImGui::ButtonBehavior(handle_y_bb, iHandleID, &hovered, &held);
if (held)
{
float const fCursorPosY = ImGui::GetMousePos().y - vStart.y;

Expand Down
Loading