diff --git a/src/DrawingProgram/DrawingProgram.cpp b/src/DrawingProgram/DrawingProgram.cpp index 0677acc..b7ef4e4 100644 --- a/src/DrawingProgram/DrawingProgram.cpp +++ b/src/DrawingProgram/DrawingProgram.cpp @@ -98,8 +98,6 @@ void DrawingProgram::input_mouse_button_callback(const InputManager::MouseButton } } else { - if(!rightClickPopupHoverOnClick) - clear_right_click_popup(); if(!world.main.g.gui.cursor_obstructed()) { if(button.button == InputManager::MouseButton::LEFT && !controls.middleClickHeld) { controls.leftClickHeld = true; @@ -389,7 +387,6 @@ void DrawingProgram::right_click_popup_gui() { void DrawingProgram::set_right_click_popup_location(const Vector2f& newLoc) { if(!rightClickPopupLocation.has_value() || rightClickPopupLocation.value() != newLoc) { rightClickPopupLocation = newLoc; - rightClickPopupHoverOnClick = false; world.main.g.gui.set_to_layout(); } } @@ -398,7 +395,6 @@ void DrawingProgram::clear_right_click_popup() { if(rightClickPopupLocation.has_value()) { rightClickPopupLocation = std::nullopt; world.main.g.gui.set_to_layout(); - rightClickPopupHoverOnClick = false; } } diff --git a/src/DrawingProgram/DrawingProgram.hpp b/src/DrawingProgram/DrawingProgram.hpp index 8cfd7b3..a6fff4b 100644 --- a/src/DrawingProgram/DrawingProgram.hpp +++ b/src/DrawingProgram/DrawingProgram.hpp @@ -70,7 +70,9 @@ class DrawingProgram { void input_pen_touch_callback(const InputManager::PenTouchCallbackArgs& touch); void input_pen_motion_callback(const InputManager::PenMotionCallbackArgs& motion); void input_pen_axis_callback(const InputManager::PenAxisCallbackArgs& axis); - bool rightClickPopupHoverOnClick = false; + + void set_right_click_popup_location(const Vector2f& newLoc); + void clear_right_click_popup(); private: void process_transform_message(const std::vector>& transforms); @@ -129,8 +131,6 @@ class DrawingProgram { std::optional rightClickPopupLocation; - void set_right_click_popup_location(const Vector2f& newLoc); - void clear_right_click_popup(); uint32_t nextID = 0; diff --git a/src/GUIStuff/ElementHelpers/PopupHelpers.cpp b/src/GUIStuff/ElementHelpers/PopupHelpers.cpp index 4e1eb68..19ac737 100644 --- a/src/GUIStuff/ElementHelpers/PopupHelpers.cpp +++ b/src/GUIStuff/ElementHelpers/PopupHelpers.cpp @@ -1,12 +1,11 @@ #include "PopupHelpers.hpp" -#include "../Elements/LayoutElement.hpp" namespace GUIStuff { namespace ElementHelpers { void paint_circle_popup_menu(GUIManager& gui, const char* id, const Vector2f& centerPos, const PaintCircleMenu::Data& val) { constexpr float size = 300.0f; - gui.element(id, [&] (const Clay_ElementId& lId) { - CLAY(lId, {.layout = { + gui.new_id(id, [&] { + CLAY_AUTO_ID({.layout = { .sizing = {.width = CLAY_SIZING_FIXED(size), .height = CLAY_SIZING_FIXED(size)} }, .floating = { diff --git a/src/GUIStuff/Elements/PaintCircleMenu.cpp b/src/GUIStuff/Elements/PaintCircleMenu.cpp index 8a1446b..4ecff19 100644 --- a/src/GUIStuff/Elements/PaintCircleMenu.cpp +++ b/src/GUIStuff/Elements/PaintCircleMenu.cpp @@ -27,7 +27,7 @@ void PaintCircleMenu::layout(const Clay_ElementId& id, const Data& data) { } bool PaintCircleMenu::collides_with_point(const Vector2f& p) const { - return boundingBox.has_value() && SCollision::collide(SCollision::Circle(boundingBox.value().center(), CIRCLE_END), p); + return boundingBox.has_value() && SCollision::collide(SCollision::Circle(boundingBox.value().center(), CIRCLE_END), p) && !SCollision::collide(SCollision::Circle(boundingBox.value().center(), PALETTE_START), p); } void PaintCircleMenu::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) { @@ -100,10 +100,6 @@ void PaintCircleMenu::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_Rend draw_rotate_bar(canvas, io, skiaAA); draw_palette_bar(canvas, io, skiaAA); - SkPaint p; - p.setAntiAlias(skiaAA); - p.setColor4f(color_mul_alpha(io.theme->backColor1, 0.5f)); - canvas->drawCircle(0.0f, 0.0f, PALETTE_START, p); canvas->restore(); } diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index c37332b..35ca62f 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -425,7 +425,8 @@ void Toolbar::paint_popup(Vector2f popupPos) { gui.set_to_layout(); }, .mouseButton = [&](const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) { - main.world->drawProg.rightClickPopupHoverOnClick = mouseHovering; + if(!mouseHovering && button.down && button.button != InputManager::MouseButton::RIGHT) + main.world->drawProg.clear_right_click_popup(); } }); });