Right click popups working
This commit is contained in:
parent
d89aabff81
commit
2eb2672329
29 changed files with 198 additions and 177 deletions
|
|
@ -91,30 +91,33 @@ void DrawingProgram::input_mouse_button_callback(const InputManager::MouseButton
|
|||
if(button.down) {
|
||||
if(button.button == InputManager::MouseButton::RIGHT) {
|
||||
if(!controls.middleClickHeld && !controls.leftClickHeld) {
|
||||
if(world.main.toolbar.rightClickPopupLocation)
|
||||
world.main.toolbar.rightClickPopupLocation = std::nullopt;
|
||||
if(rightClickPopupLocation.has_value())
|
||||
clear_right_click_popup();
|
||||
else
|
||||
world.main.toolbar.rightClickPopupLocation = world.main.input.mouse.pos / world.main.g.final_gui_scale();
|
||||
set_right_click_popup_location(world.main.input.mouse.pos / world.main.g.final_gui_scale());
|
||||
}
|
||||
}
|
||||
else {
|
||||
world.main.toolbar.rightClickPopupLocation = std::nullopt;
|
||||
if(button.button == InputManager::MouseButton::LEFT && !controls.middleClickHeld) {
|
||||
controls.leftClickHeld = true;
|
||||
buttonCallbacks(button);
|
||||
}
|
||||
else if(button.button == InputManager::MouseButton::MIDDLE) {
|
||||
if(controls.leftClickHeld) {
|
||||
controls.leftClickHeld = false;
|
||||
InputManager::MouseButtonCallbackArgs leftReleaseCallback;
|
||||
leftReleaseCallback.clicks = 0;
|
||||
leftReleaseCallback.down = false;
|
||||
leftReleaseCallback.pos = button.pos;
|
||||
leftReleaseCallback.button = InputManager::MouseButton::LEFT;
|
||||
buttonCallbacks(leftReleaseCallback);
|
||||
if(!rightClickPopupHoverOnClick)
|
||||
clear_right_click_popup();
|
||||
if(!world.main.g.gui.cursor_obstructed()) {
|
||||
if(button.button == InputManager::MouseButton::LEFT && !controls.middleClickHeld) {
|
||||
controls.leftClickHeld = true;
|
||||
buttonCallbacks(button);
|
||||
}
|
||||
else if(button.button == InputManager::MouseButton::MIDDLE) {
|
||||
if(controls.leftClickHeld) {
|
||||
controls.leftClickHeld = false;
|
||||
InputManager::MouseButtonCallbackArgs leftReleaseCallback;
|
||||
leftReleaseCallback.clicks = 0;
|
||||
leftReleaseCallback.down = false;
|
||||
leftReleaseCallback.pos = button.pos;
|
||||
leftReleaseCallback.button = InputManager::MouseButton::LEFT;
|
||||
buttonCallbacks(leftReleaseCallback);
|
||||
}
|
||||
controls.middleClickHeld = true;
|
||||
buttonCallbacks(button);
|
||||
}
|
||||
controls.middleClickHeld = true;
|
||||
buttonCallbacks(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -378,12 +381,34 @@ void DrawingProgram::toolbar_gui() {
|
|||
});
|
||||
}
|
||||
|
||||
void DrawingProgram::right_click_popup_gui() {
|
||||
if(rightClickPopupLocation.has_value())
|
||||
drawTool->right_click_popup_gui(rightClickPopupLocation.value());
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
void DrawingProgram::clear_right_click_popup() {
|
||||
if(rightClickPopupLocation.has_value()) {
|
||||
rightClickPopupLocation = std::nullopt;
|
||||
world.main.g.gui.set_to_layout();
|
||||
rightClickPopupHoverOnClick = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawingProgram::popup_menu_action_button(const char* id, const char* text, const std::function<void()>& onClick) {
|
||||
GUIStuff::GUIManager& gui = world.main.g.gui;
|
||||
|
||||
GUIStuff::ElementHelpers::text_button(gui, id, text, {
|
||||
.drawType = GUIStuff::SelectableButton::DrawType::TRANSPARENT_ALL,
|
||||
.wide = true,
|
||||
.centered = false,
|
||||
.onClick = onClick
|
||||
});
|
||||
}
|
||||
|
|
@ -393,45 +418,43 @@ void DrawingProgram::selection_action_menu(Vector2f popupPos) {
|
|||
using namespace GUIStuff;
|
||||
using namespace ElementHelpers;
|
||||
|
||||
Toolbar& t = world.main.toolbar;
|
||||
GUIStuff::GUIManager& gui = world.main.g.gui;
|
||||
auto& io = gui.io;
|
||||
|
||||
gui.element<PositionAdjustingPopupMenu>("Selection popup menu", popupPos, [&, popupPos] {
|
||||
text_label_light(gui, "Selection menu");
|
||||
popup_menu_action_button("Paste", "Paste", [&] {
|
||||
selection.deselect_all();
|
||||
selection.paste_clipboard(popupPos * world.main.g.final_gui_scale());
|
||||
gui.set_z_index(-1, [&] {
|
||||
gui.element<PositionAdjustingPopupMenu>("Selection popup menu", popupPos, [&] {
|
||||
text_label_light(gui, "Selection menu");
|
||||
popup_menu_action_button("Paste", "Paste", [&, popupPos] {
|
||||
selection.deselect_all();
|
||||
selection.paste_clipboard(popupPos * world.main.g.final_gui_scale());
|
||||
});
|
||||
popup_menu_action_button("Paste Image", "Paste Image", [&, popupPos] {
|
||||
selection.deselect_all();
|
||||
selection.paste_image(popupPos * world.main.g.final_gui_scale());
|
||||
});
|
||||
if(selection.is_something_selected()) {
|
||||
popup_menu_action_button("Copy", "Copy", [&] {
|
||||
selection.selection_to_clipboard();
|
||||
});
|
||||
popup_menu_action_button("Cut", "Cut", [&] {
|
||||
selection.selection_to_clipboard();
|
||||
selection.delete_all();
|
||||
});
|
||||
popup_menu_action_button("Delete", "Delete", [&] {
|
||||
selection.delete_all();
|
||||
});
|
||||
popup_menu_action_button("Bring to front of layer", "Bring to front of layer", [&] {
|
||||
selection.push_selection_to_front();
|
||||
});
|
||||
popup_menu_action_button("Send to back of layer", "Send to back of layer", [&] {
|
||||
selection.push_selection_to_back();
|
||||
});
|
||||
}
|
||||
});
|
||||
popup_menu_action_button("Paste Image", "Paste Image", [&] {
|
||||
selection.deselect_all();
|
||||
selection.paste_image(popupPos * world.main.g.final_gui_scale());
|
||||
});
|
||||
if(selection.is_something_selected()) {
|
||||
popup_menu_action_button("Copy", "Copy", [&] {
|
||||
selection.selection_to_clipboard();
|
||||
});
|
||||
popup_menu_action_button("Cut", "Cut", [&] {
|
||||
selection.selection_to_clipboard();
|
||||
selection.delete_all();
|
||||
});
|
||||
popup_menu_action_button("Delete", "Delete", [&] {
|
||||
selection.delete_all();
|
||||
});
|
||||
popup_menu_action_button("Bring to front of layer", "Bring to front of layer", [&] {
|
||||
selection.push_selection_to_front();
|
||||
});
|
||||
popup_menu_action_button("Send to back of layer", "Send to back of layer", [&] {
|
||||
selection.push_selection_to_back();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void DrawingProgram::right_click_popup_gui(Vector2f popupPos) {
|
||||
Toolbar& t = world.main.toolbar;
|
||||
GUIStuff::GUIManager& gui = world.main.g.gui;
|
||||
auto& io = gui.io;
|
||||
|
||||
gui.new_id("Drawing Program right click GUI", [&] {
|
||||
drawTool->right_click_popup_gui(popupPos);
|
||||
|
|
@ -441,7 +464,6 @@ void DrawingProgram::right_click_popup_gui(Vector2f popupPos) {
|
|||
void DrawingProgram::tool_options_gui() {
|
||||
using namespace GUIStuff;
|
||||
|
||||
Toolbar& t = world.main.toolbar;
|
||||
GUIStuff::GUIManager& gui = world.main.g.gui;
|
||||
auto& io = gui.io;
|
||||
|
||||
|
|
@ -524,7 +546,7 @@ bool DrawingProgram::is_selection_allowing_tool(DrawingProgramToolType typeToChe
|
|||
void DrawingProgram::switch_to_tool_ptr(std::unique_ptr<DrawingProgramToolBase> newTool) {
|
||||
drawTool->switch_tool(newTool->get_type());
|
||||
drawTool = std::move(newTool);
|
||||
world.main.toolbar.rightClickPopupLocation = std::nullopt;
|
||||
clear_right_click_popup();
|
||||
world.main.g.gui.set_to_layout();
|
||||
}
|
||||
|
||||
|
|
@ -532,7 +554,7 @@ void DrawingProgram::switch_to_tool(DrawingProgramToolType newToolType, bool for
|
|||
if(newToolType != drawTool->get_type() || force) {
|
||||
drawTool->switch_tool(newToolType);
|
||||
drawTool = DrawingProgramToolBase::allocate_tool_type(*this, newToolType);
|
||||
world.main.toolbar.rightClickPopupLocation = std::nullopt;
|
||||
clear_right_click_popup();
|
||||
world.main.g.gui.set_to_layout();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ class DrawingProgram {
|
|||
DrawingProgram(World& initWorld);
|
||||
void server_init_no_file();
|
||||
void toolbar_gui();
|
||||
void right_click_popup_gui();
|
||||
void tool_options_gui();
|
||||
void right_click_popup_gui(Vector2f popupPos);
|
||||
void update();
|
||||
|
|
@ -69,6 +70,7 @@ 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;
|
||||
private:
|
||||
void process_transform_message(const std::vector<std::pair<NetworkingObjects::NetObjID, CoordSpaceHelper>>& transforms);
|
||||
|
||||
|
|
@ -125,6 +127,11 @@ class DrawingProgram {
|
|||
|
||||
std::unique_ptr<DrawingProgramToolBase> drawTool;
|
||||
|
||||
std::optional<Vector2f> rightClickPopupLocation;
|
||||
|
||||
void set_right_click_popup_location(const Vector2f& newLoc);
|
||||
void clear_right_click_popup();
|
||||
|
||||
uint32_t nextID = 0;
|
||||
|
||||
friend class EyeDropperTool;
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@ void CheckBox::layout(const Clay_ElementId& id, const std::function<bool()>& isT
|
|||
}) {}
|
||||
}
|
||||
|
||||
bool CheckBox::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
void CheckBox::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
isHovering = mouseHovering;
|
||||
if(isHovering && button.button == InputManager::MouseButton::LEFT && button.down)
|
||||
gui.set_post_callback_func([&](){if(onClick) onClick();});
|
||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
bool CheckBox::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
void CheckBox::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
isHovering = mouseHovering;
|
||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ class CheckBox : public Element {
|
|||
CheckBox(GUIManager& gui);
|
||||
|
||||
virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override;
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
|
||||
void layout(const Clay_ElementId& id, const std::function<bool()>& isTicked, const std::function<void()>& onClick);
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ template <typename T> class ColorPicker : public Element {
|
|||
ColorPicker(GUIManager& gui);
|
||||
void layout(const Clay_ElementId& id, T* data, bool selectAlpha, const std::function<void()>& onChange);
|
||||
virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA);
|
||||
bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
private:
|
||||
void update_color_picker_pos(const Vector2f& p);
|
||||
float get_sv_selection_area_size();
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ template <typename T> void ColorPicker<T>::clay_draw(SkCanvas* canvas, UpdateInp
|
|||
canvas->restore();
|
||||
}
|
||||
|
||||
template <typename T> bool ColorPicker<T>::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
template <typename T> void ColorPicker<T>::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
held = HeldBar::NONE;
|
||||
if(mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down && boundingBox.has_value()) {
|
||||
auto& bb = boundingBox.value();
|
||||
|
|
@ -103,12 +103,12 @@ template <typename T> bool ColorPicker<T>::input_mouse_button_callback(const Inp
|
|||
}
|
||||
}
|
||||
update_color_picker_pos(button.pos);
|
||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||
Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
template <typename T> bool ColorPicker<T>::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
template <typename T> void ColorPicker<T>::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
update_color_picker_pos(motion.pos);
|
||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
||||
template <typename T> void ColorPicker<T>::update_color_picker_pos(const Vector2f& p) {
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ namespace GUIStuff {
|
|||
|
||||
void Element::tick_update() {}
|
||||
|
||||
bool Element::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) { return mouseHovering; }
|
||||
bool Element::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) { return mouseHovering; }
|
||||
bool Element::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) { return mouseHovering; }
|
||||
void Element::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) { }
|
||||
void Element::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) { }
|
||||
void Element::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) { }
|
||||
void Element::input_key_callback(const InputManager::KeyCallbackArgs& key) {}
|
||||
|
||||
void Element::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) {}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace GUIStuff {
|
|||
virtual void tick_update();
|
||||
|
||||
// Return true when mouse obstructs what's behind it
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering);
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering);
|
||||
virtual bool input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering);
|
||||
virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering);
|
||||
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering);
|
||||
virtual void input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering);
|
||||
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
||||
protected:
|
||||
static SCollision::AABB<float> get_bb_from_command(Clay_RenderCommand* command);
|
||||
|
|
|
|||
|
|
@ -10,21 +10,18 @@ void LayoutElement::layout(const Clay_ElementId& id, const std::function<void(co
|
|||
layout(id);
|
||||
}
|
||||
|
||||
bool LayoutElement::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
if(c.mouseButton)
|
||||
return c.mouseButton(button, mouseHovering);
|
||||
void LayoutElement::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
if(c.mouseButton) c.mouseButton(button, mouseHovering);
|
||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
bool LayoutElement::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
if(c.mouseMotion)
|
||||
return c.mouseMotion(motion, mouseHovering);
|
||||
void LayoutElement::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
if(c.mouseMotion) c.mouseMotion(motion, mouseHovering);
|
||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
||||
bool LayoutElement::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) {
|
||||
if(c.mouseWheel)
|
||||
return c.mouseWheel(wheel, mouseHovering);
|
||||
void LayoutElement::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) {
|
||||
if(c.mouseWheel) c.mouseWheel(wheel, mouseHovering);
|
||||
return Element::input_mouse_wheel_callback(wheel, mouseHovering);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ class LayoutElement : public Element {
|
|||
public:
|
||||
LayoutElement(GUIManager& gui);
|
||||
struct Callbacks {
|
||||
std::function<bool(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering)> mouseButton;
|
||||
std::function<bool(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering)> mouseMotion;
|
||||
std::function<bool(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering)> mouseWheel;
|
||||
std::function<void(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering)> mouseButton;
|
||||
std::function<void(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering)> mouseMotion;
|
||||
std::function<void(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering)> mouseWheel;
|
||||
std::function<void(const InputManager::KeyCallbackArgs& key)> key;
|
||||
};
|
||||
void layout(const Clay_ElementId& id, const std::function<void(const Clay_ElementId&)>& layout, const Callbacks& c = {});
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual bool input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) override;
|
||||
virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual void input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) override;
|
||||
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key) override;
|
||||
private:
|
||||
Callbacks c;
|
||||
|
|
|
|||
|
|
@ -73,19 +73,19 @@ template <typename T> class NumberSlider : public Element {
|
|||
|
||||
canvas->restore();
|
||||
}
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override {
|
||||
virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override {
|
||||
isHovering = mouseHovering;
|
||||
isHeld = isHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
||||
if(isHeld && boundingBox.has_value())
|
||||
update_slider_pos(button.pos);
|
||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||
Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override {
|
||||
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override {
|
||||
isHovering = mouseHovering;
|
||||
if(isHeld && boundingBox.has_value())
|
||||
update_slider_pos(motion.pos);
|
||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -30,26 +30,33 @@ bool PaintCircleMenu::collides_with_point(const Vector2f& p) const {
|
|||
return boundingBox.has_value() && SCollision::collide(SCollision::Circle<float>(boundingBox.value().center(), CIRCLE_END), p);
|
||||
}
|
||||
|
||||
bool PaintCircleMenu::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
void PaintCircleMenu::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
if(d.mouseButton) d.mouseButton(button, mouseHovering);
|
||||
isHovering = mouseHovering;
|
||||
isHeld = isHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
||||
update_paint_circle_menu_mouse_hover(button.pos);
|
||||
isRotateBarHeld = isRotateBarHovered && isHeld;
|
||||
update_paint_circle_menu_mouse(button.pos, button.button == InputManager::MouseButton::LEFT && button.down);
|
||||
return mouseHovering && collides_with_point(button.pos);
|
||||
Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
bool PaintCircleMenu::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
void PaintCircleMenu::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
isHovering = mouseHovering;
|
||||
update_paint_circle_menu_mouse_hover(motion.pos);
|
||||
update_paint_circle_menu_mouse(motion.pos, false);
|
||||
return mouseHovering && collides_with_point(motion.pos);
|
||||
Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
||||
void PaintCircleMenu::update_paint_circle_menu_mouse_hover(const Vector2f& p) {
|
||||
float distFromCenter = vec_distance(p, boundingBox.value().center());
|
||||
isRotateBarHovered = isHovering && distFromCenter > ROTATE_START && distFromCenter < CIRCLE_END;
|
||||
isColorBarHovered = isHovering && distFromCenter > PALETTE_START && distFromCenter < ROTATE_START;
|
||||
}
|
||||
|
||||
void PaintCircleMenu::update_paint_circle_menu_mouse(const Vector2f& p, bool leftClicked) {
|
||||
if(boundingBox.has_value()) {
|
||||
Vector2f vecFromCenter = (p - boundingBox.value().center()).normalized();
|
||||
float distFromCenter = vec_distance(p, boundingBox.value().center());
|
||||
isRotateBarHovered = isHovering && distFromCenter > ROTATE_START && distFromCenter < CIRCLE_END;
|
||||
isRotateBarHeld = isRotateBarHovered && isHeld;
|
||||
isColorBarHovered = isHovering && distFromCenter > PALETTE_START && distFromCenter < ROTATE_START;
|
||||
|
||||
Vector2f vecFromCenter = (p - boundingBox.value().center()).normalized();
|
||||
if(isColorBarHovered) {
|
||||
double selectionAngle = std::atan2(-vecFromCenter.y(), -vecFromCenter.x()) + std::numbers::pi;
|
||||
colorSelectionIndex = (selectionAngle / (std::numbers::pi * 2.0)) * d.palette.size();
|
||||
|
|
@ -69,8 +76,8 @@ void PaintCircleMenu::update_paint_circle_menu_mouse(const Vector2f& p, bool lef
|
|||
break;
|
||||
}
|
||||
}
|
||||
d.onRotate();
|
||||
}
|
||||
d.onRotate();
|
||||
});
|
||||
}
|
||||
else if(isColorBarHovered && leftClicked) {
|
||||
|
|
|
|||
|
|
@ -12,12 +12,13 @@ class PaintCircleMenu : public Element {
|
|||
std::vector<Vector3f> palette;
|
||||
std::function<void()> onRotate;
|
||||
std::function<void()> onPaletteClick;
|
||||
std::function<void(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering)> mouseButton;
|
||||
};
|
||||
void layout(const Clay_ElementId& id, const Data& data);
|
||||
virtual bool collides_with_point(const Vector2f& p) const override;
|
||||
virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override;
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
private:
|
||||
void draw_rotate_bar(SkCanvas* canvas, UpdateInputData& io, bool skiaAA);
|
||||
void draw_palette_bar(SkCanvas* canvas, UpdateInputData& io, bool skiaAA);
|
||||
|
|
@ -29,6 +30,7 @@ class PaintCircleMenu : public Element {
|
|||
bool isColorBarHovered = false;
|
||||
bool isHeld = false;
|
||||
|
||||
void update_paint_circle_menu_mouse_hover(const Vector2f& p);
|
||||
void update_paint_circle_menu_mouse(const Vector2f& p, bool leftClicked);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ namespace GUIStuff {
|
|||
|
||||
PositionAdjustingPopupMenu::PositionAdjustingPopupMenu(GUIManager& gui): Element(gui) {}
|
||||
|
||||
void PositionAdjustingPopupMenu::layout(const Clay_ElementId& id, Vector2f popupPos, const std::function<void()>& innerContent) {
|
||||
void PositionAdjustingPopupMenu::layout(const Clay_ElementId& id, Vector2f popupPos, const std::function<void()>& innerContent, const LayoutElement::Callbacks& callbacks) {
|
||||
if(layoutElement && layoutElement->get_bb().has_value()) {
|
||||
auto& bb = layoutElement->get_bb().value();
|
||||
if((popupPos.y() + bb.height()) > gui.io.windowSize.y())
|
||||
|
|
@ -34,7 +34,7 @@ void PositionAdjustingPopupMenu::layout(const Clay_ElementId& id, Vector2f popup
|
|||
}) {
|
||||
innerContent();
|
||||
}
|
||||
});
|
||||
}, callbacks);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ namespace GUIStuff {
|
|||
class PositionAdjustingPopupMenu : public Element {
|
||||
public:
|
||||
PositionAdjustingPopupMenu(GUIManager& gui);
|
||||
void layout(const Clay_ElementId& id, Vector2f popupPos, const std::function<void()>& innerContent);
|
||||
void layout(const Clay_ElementId& id, Vector2f popupPos, const std::function<void()>& innerContent, const LayoutElement::Callbacks& callbacks = {});
|
||||
private:
|
||||
LayoutElement* layoutElement = nullptr;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,16 +18,16 @@ void RadioButton::layout(const Clay_ElementId& id, const std::function<bool()>&
|
|||
}) {}
|
||||
}
|
||||
|
||||
bool RadioButton::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
void RadioButton::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
isHovering = mouseHovering;
|
||||
if(isHovering && button.button == InputManager::MouseButton::LEFT && button.down)
|
||||
gui.set_post_callback_func([&] { if(onClick) onClick(); });
|
||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||
Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
bool RadioButton::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
void RadioButton::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
isHovering = mouseHovering;
|
||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
||||
void RadioButton::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) {
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ class RadioButton : public Element {
|
|||
public:
|
||||
RadioButton(GUIManager& gui);
|
||||
virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override;
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
|
||||
void layout(const Clay_ElementId& id, const std::function<bool()>& isTicked, const std::function<void()>& onClick);
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -34,26 +34,30 @@ float RotateWheel::wheel_end() {
|
|||
return boundingBox.value().width() * 0.5f;
|
||||
}
|
||||
|
||||
bool RotateWheel::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
void RotateWheel::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
isHovering = mouseHovering;
|
||||
isHeld = isHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
||||
update_rotate_wheel_mouse_hover(button.pos);
|
||||
isRotateBarHeld = isRotateBarHovered && isHeld;
|
||||
update_paint_circle_menu_mouse(button.pos);
|
||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||
update_rotate_wheel_mouse(button.pos);
|
||||
Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
bool RotateWheel::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
void RotateWheel::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
isHovering = mouseHovering;
|
||||
update_paint_circle_menu_mouse(motion.pos);
|
||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
update_rotate_wheel_mouse_hover(motion.pos);
|
||||
update_rotate_wheel_mouse(motion.pos);
|
||||
Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
||||
void RotateWheel::update_paint_circle_menu_mouse(const Vector2f& p) {
|
||||
void RotateWheel::update_rotate_wheel_mouse_hover(const Vector2f& p) {
|
||||
float distFromCenter = vec_distance(p, boundingBox.value().center());
|
||||
isRotateBarHovered = isHovering && distFromCenter > wheel_start() && distFromCenter < wheel_end();
|
||||
}
|
||||
|
||||
void RotateWheel::update_rotate_wheel_mouse(const Vector2f& p) {
|
||||
if(boundingBox.has_value()) {
|
||||
Vector2f vecFromCenter = (p - boundingBox.value().center()).normalized();
|
||||
float distFromCenter = vec_distance(p, boundingBox.value().center());
|
||||
isRotateBarHovered = isHovering && distFromCenter > wheel_start() && distFromCenter < wheel_end();
|
||||
|
||||
if(isRotateBarHeld) {
|
||||
gui.set_post_callback_func([&, vecFromCenter] {
|
||||
auto& rotationAngle = *rotateAngle;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ class RotateWheel : public Element {
|
|||
RotateWheel(GUIManager& gui);
|
||||
void layout(const Clay_ElementId& id, double* rotateAngle, const std::function<void()>& onChange);
|
||||
virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override;
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
|
||||
private:
|
||||
float wheel_start();
|
||||
|
|
@ -23,7 +23,8 @@ class RotateWheel : public Element {
|
|||
bool isRotateBarHovered = false;
|
||||
std::function<void()> onChange;
|
||||
|
||||
void update_paint_circle_menu_mouse(const Vector2f& p);
|
||||
void update_rotate_wheel_mouse_hover(const Vector2f& p);
|
||||
void update_rotate_wheel_mouse(const Vector2f& p);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,20 +142,12 @@ void ScrollArea::reset_scroll() {
|
|||
scrollOffset = {0.0f, 0.0f};
|
||||
}
|
||||
|
||||
bool ScrollArea::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
bool ScrollArea::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
||||
void ScrollArea::clamp_scroll() {
|
||||
scrollOffset.x() = std::clamp(scrollOffset.x(), -std::max(0.0f, contentDimensions.x() - containerDimensions.x()), 0.0f);
|
||||
scrollOffset.y() = std::clamp(scrollOffset.y(), -std::max(0.0f, contentDimensions.y() - containerDimensions.y()), 0.0f);
|
||||
}
|
||||
|
||||
bool ScrollArea::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) {
|
||||
void ScrollArea::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) {
|
||||
if(mouseHovering) {
|
||||
Vector2f oldScrollOffset = scrollOffset;
|
||||
|
||||
|
|
@ -168,7 +160,7 @@ bool ScrollArea::input_mouse_wheel_callback(const InputManager::MouseWheelCallba
|
|||
if(oldScrollOffset != scrollOffset)
|
||||
gui.set_to_layout();
|
||||
}
|
||||
return Element::input_mouse_wheel_callback(wheel, mouseHovering);
|
||||
Element::input_mouse_wheel_callback(wheel, mouseHovering);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,7 @@ class ScrollArea : public Element {
|
|||
void layout(const Clay_ElementId& id, const Options& options);
|
||||
void reset_scroll();
|
||||
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual bool input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) override;
|
||||
virtual void input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) override;
|
||||
private:
|
||||
Options opts;
|
||||
bool isScrollbarHeldY = false;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ void SelectableButton::layout(const Clay_ElementId& id, const Data& d) {
|
|||
}
|
||||
}
|
||||
|
||||
bool SelectableButton::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
void SelectableButton::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
bool oldIsHovering = isHovering;
|
||||
bool oldIsHeld = isHeld;
|
||||
isHovering = mouseHovering;
|
||||
|
|
@ -74,15 +74,15 @@ bool SelectableButton::input_mouse_button_callback(const InputManager::MouseButt
|
|||
}
|
||||
else if(isHovering != oldIsHovering || isHeld != oldIsHeld)
|
||||
gui.set_to_layout();
|
||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||
Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
bool SelectableButton::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
void SelectableButton::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
bool oldIsHovering = isHovering;
|
||||
isHovering = mouseHovering;
|
||||
if(isHovering != oldIsHovering)
|
||||
gui.set_to_layout();
|
||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ class SelectableButton : public Element {
|
|||
|
||||
SelectableButton(GUIManager& gui);
|
||||
void layout(const Clay_ElementId& id, const Data& d);
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
|
||||
private:
|
||||
bool isHovering = false;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ template <typename T> class TextBox : public Element {
|
|||
|
||||
void layout(const Clay_ElementId& id, const TextBoxData<T>& userInfo);
|
||||
virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) override;
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key) override;
|
||||
~TextBox();
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ template <typename T> void TextBox<T>::clay_draw(SkCanvas* canvas, UpdateInputDa
|
|||
canvas->restore();
|
||||
}
|
||||
|
||||
template <typename T> bool TextBox<T>::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
template <typename T> void TextBox<T>::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
auto& io = gui.io;
|
||||
|
||||
if(button.button == InputManager::MouseButton::LEFT && boundingBox.has_value()) {
|
||||
|
|
@ -84,13 +84,13 @@ template <typename T> bool TextBox<T>::input_mouse_button_callback(const InputMa
|
|||
textbox->process_mouse_left_button(*cur, button.pos - boundingBox.value().min, 0, false, gui.io.input->key(InputManager::KEY_TEXT_SHIFT).held);
|
||||
}
|
||||
}
|
||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||
Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
template <typename T> bool TextBox<T>::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
template <typename T> void TextBox<T>::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
if(boundingBox.has_value())
|
||||
textbox->process_mouse_left_button(*cur, motion.pos - boundingBox.value().min, 0, gui.io.input->mouse.leftDown, gui.io.input->key(InputManager::KEY_TEXT_SHIFT).held);
|
||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
||||
template <typename T> void TextBox<T>::input_key_callback(const InputManager::KeyCallbackArgs& key) {
|
||||
|
|
|
|||
|
|
@ -281,15 +281,4 @@ void TreeListing::select_and_unselect_parents(const std::vector<NetworkingObject
|
|||
//selectionData.objsSelected.emplace(newSelectedObj);
|
||||
}
|
||||
|
||||
bool TreeListing::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||
}
|
||||
|
||||
bool TreeListing::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||
}
|
||||
|
||||
void TreeListing::input_key_callback(const InputManager::KeyCallbackArgs& key) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,6 @@ class TreeListing : public Element {
|
|||
|
||||
TreeListing(GUIManager& gui);
|
||||
void layout(const Clay_ElementId& id, NetworkingObjects::NetObjID rootObjID, const DisplayData& displayData, SelectionData& selectionData);
|
||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key) override;
|
||||
private:
|
||||
bool dragHoldSelected = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -406,20 +406,28 @@ void Toolbar::save_as_func() {
|
|||
}
|
||||
|
||||
void Toolbar::paint_popup(Vector2f popupPos) {
|
||||
using namespace GUIStuff;
|
||||
auto& gui = main.g.gui;
|
||||
auto& io = main.g.gui.io;
|
||||
|
||||
double newRotationAngle = 0.0;
|
||||
paint_circle_popup_menu(gui, "paint circle popup", popupPos, {
|
||||
.rotationAngle = &main.world->drawData.cam.c.rotation,
|
||||
.selectedColor = main.world->drawProg.get_foreground_color_ptr(),
|
||||
.palette = paletteData.palettes[paletteData.selectedPalette].colors,
|
||||
.onRotate = [&] {
|
||||
main.world->drawData.cam.c.rotate_about(main.world->drawData.cam.c.from_space(main.window.size.cast<float>() * 0.5f), newRotationAngle - main.world->drawData.cam.c.rotation);
|
||||
},
|
||||
.onPaletteClick = [&] {
|
||||
gui.set_to_layout();
|
||||
}
|
||||
std::shared_ptr<double> newRotationAngle = std::make_shared<double>(main.world->drawData.cam.c.rotation);
|
||||
|
||||
gui.set_z_index(-1, [&] {
|
||||
paint_circle_popup_menu(gui, "paint circle popup", popupPos, {
|
||||
.rotationAngle = newRotationAngle.get(),
|
||||
.selectedColor = main.world->drawProg.get_foreground_color_ptr(),
|
||||
.palette = paletteData.palettes[paletteData.selectedPalette].colors,
|
||||
.onRotate = [&, newRotationAngle] {
|
||||
main.world->drawData.cam.c.rotate_about(main.world->drawData.cam.c.from_space(main.window.size.cast<float>() * 0.5f), *newRotationAngle - main.world->drawData.cam.c.rotation);
|
||||
*newRotationAngle = main.world->drawData.cam.c.rotation;
|
||||
gui.set_to_layout();
|
||||
},
|
||||
.onPaletteClick = [&] {
|
||||
gui.set_to_layout();
|
||||
},
|
||||
.mouseButton = [&](const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||
main.world->drawProg.rightClickPopupHoverOnClick = mouseHovering;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -636,7 +644,6 @@ void Toolbar::top_toolbar() {
|
|||
menuPopupOpenFlipped = true;
|
||||
gui.set_to_layout();
|
||||
}
|
||||
return mouseHovering;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -1225,6 +1232,7 @@ void Toolbar::drawing_program_gui() {
|
|||
// }
|
||||
//}
|
||||
main.world->drawProg.tool_options_gui();
|
||||
main.world->drawProg.right_click_popup_gui();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2150,7 +2158,6 @@ void Toolbar::file_picker_gui() {
|
|||
});
|
||||
gui.set_to_layout();
|
||||
}
|
||||
return mouseHovering;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,8 +61,6 @@ class Toolbar {
|
|||
bool isUpdatingColorLeft = false;
|
||||
bool isUpdatingColorRight = false;
|
||||
|
||||
std::optional<Vector2f> rightClickPopupLocation;
|
||||
|
||||
bool app_close_requested();
|
||||
private:
|
||||
static void sdl_open_file_dialog_callback(void* userData, const char * const * fileList, int filter);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue