From 4aaf2d76b3e0b41d81aae9c95e867ba0a20ce49b Mon Sep 17 00:00:00 2001 From: j v Date: Mon, 4 Sep 2023 12:17:27 -0700 Subject: [PATCH] Update hover on select mode change --- src/main.cpp | 28 +++++++++++++++++----------- src/main.h | 2 ++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e6f064d..ad68916 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,12 +52,6 @@ size_t numDrawPoints() { } } -static void setSelMode(SelectMode mode) { - g_state.selMode = mode; - if (!(TOOL_FLAGS[g_tool] & (1 << mode))) - g_tool = TOOL_SELECT; -} - static void resetToolState() { g_drawVerts.clear(); } @@ -326,6 +320,22 @@ void MainWindow::showStdException(std::exception e) { MessageBoxA(wnd, e.what(), "Unexpected Error", MB_ICONERROR); } +void MainWindow::updateHover() { + POINT pt = cursorPos(); + if (hoveredViewport && WindowFromPoint(pt) == hoveredViewport->wnd) { + hoveredViewport->updateHover(screenToClient(hoveredViewport->wnd, pt)); + setCursorHitTest(hoveredViewport->wnd, pt); + } +} + +void MainWindow::setSelMode(SelectMode mode) { + g_state.selMode = mode; + if (!(TOOL_FLAGS[g_tool] & (1 << mode))) + setTool(TOOL_SELECT); + else + updateHover(); +} + void MainWindow::setTool(Tool tool) { g_tool = tool; resetToolState(); @@ -334,11 +344,7 @@ void MainWindow::setTool(Tool tool) { if ((TOOL_FLAGS[tool] & TOOLF_DRAW) && (TOOL_FLAGS[tool] & TOOLF_HOVFACE)) if (auto face = g_hoverFace.find(g_state.surf)) g_state.workPlane = facePlane(g_state.surf, *face); - POINT pt = cursorPos(); - if (hoveredViewport && WindowFromPoint(pt) == hoveredViewport->wnd) { - hoveredViewport->updateHover(screenToClient(hoveredViewport->wnd, pt)); - setCursorHitTest(hoveredViewport->wnd, pt); - } + updateHover(); } bool MainWindow::removeViewport(ViewportWindow *viewport) { diff --git a/src/main.h b/src/main.h index 2423471..1c43bec 100644 --- a/src/main.h +++ b/src/main.h @@ -73,6 +73,8 @@ class MainWindow : public chroma::WindowImpl { ViewportWindow mainViewport; std::unordered_set> extraViewports; + void updateHover(); + void setSelMode(SelectMode mode); void setTool(Tool tool); void closeExtraViewports(); void resetModel();