Skip to content

Commit

Permalink
Update hover on select mode change
Browse files Browse the repository at this point in the history
  • Loading branch information
vanjac committed Sep 4, 2023
1 parent 89daec3 commit 4aaf2d7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class MainWindow : public chroma::WindowImpl {
ViewportWindow mainViewport;
std::unordered_set<std::unique_ptr<ViewportWindow>> extraViewports;

void updateHover();
void setSelMode(SelectMode mode);
void setTool(Tool tool);
void closeExtraViewports();
void resetModel();
Expand Down

0 comments on commit 4aaf2d7

Please sign in to comment.