Right click popups working
This commit is contained in:
parent
d89aabff81
commit
2eb2672329
29 changed files with 198 additions and 177 deletions
|
|
@ -91,14 +91,16 @@ void DrawingProgram::input_mouse_button_callback(const InputManager::MouseButton
|
||||||
if(button.down) {
|
if(button.down) {
|
||||||
if(button.button == InputManager::MouseButton::RIGHT) {
|
if(button.button == InputManager::MouseButton::RIGHT) {
|
||||||
if(!controls.middleClickHeld && !controls.leftClickHeld) {
|
if(!controls.middleClickHeld && !controls.leftClickHeld) {
|
||||||
if(world.main.toolbar.rightClickPopupLocation)
|
if(rightClickPopupLocation.has_value())
|
||||||
world.main.toolbar.rightClickPopupLocation = std::nullopt;
|
clear_right_click_popup();
|
||||||
else
|
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 {
|
else {
|
||||||
world.main.toolbar.rightClickPopupLocation = std::nullopt;
|
if(!rightClickPopupHoverOnClick)
|
||||||
|
clear_right_click_popup();
|
||||||
|
if(!world.main.g.gui.cursor_obstructed()) {
|
||||||
if(button.button == InputManager::MouseButton::LEFT && !controls.middleClickHeld) {
|
if(button.button == InputManager::MouseButton::LEFT && !controls.middleClickHeld) {
|
||||||
controls.leftClickHeld = true;
|
controls.leftClickHeld = true;
|
||||||
buttonCallbacks(button);
|
buttonCallbacks(button);
|
||||||
|
|
@ -118,6 +120,7 @@ void DrawingProgram::input_mouse_button_callback(const InputManager::MouseButton
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if(!button.down) {
|
else if(!button.down) {
|
||||||
if(controls.leftClickHeld && button.button == InputManager::MouseButton::LEFT) {
|
if(controls.leftClickHeld && button.button == InputManager::MouseButton::LEFT) {
|
||||||
controls.leftClickHeld = false;
|
controls.leftClickHeld = false;
|
||||||
|
|
@ -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) {
|
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::GUIManager& gui = world.main.g.gui;
|
||||||
|
|
||||||
GUIStuff::ElementHelpers::text_button(gui, id, text, {
|
GUIStuff::ElementHelpers::text_button(gui, id, text, {
|
||||||
.drawType = GUIStuff::SelectableButton::DrawType::TRANSPARENT_ALL,
|
.drawType = GUIStuff::SelectableButton::DrawType::TRANSPARENT_ALL,
|
||||||
.wide = true,
|
.wide = true,
|
||||||
|
.centered = false,
|
||||||
.onClick = onClick
|
.onClick = onClick
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -393,17 +418,16 @@ void DrawingProgram::selection_action_menu(Vector2f popupPos) {
|
||||||
using namespace GUIStuff;
|
using namespace GUIStuff;
|
||||||
using namespace ElementHelpers;
|
using namespace ElementHelpers;
|
||||||
|
|
||||||
Toolbar& t = world.main.toolbar;
|
|
||||||
GUIStuff::GUIManager& gui = world.main.g.gui;
|
GUIStuff::GUIManager& gui = world.main.g.gui;
|
||||||
auto& io = gui.io;
|
|
||||||
|
|
||||||
gui.element<PositionAdjustingPopupMenu>("Selection popup menu", popupPos, [&, popupPos] {
|
gui.set_z_index(-1, [&] {
|
||||||
|
gui.element<PositionAdjustingPopupMenu>("Selection popup menu", popupPos, [&] {
|
||||||
text_label_light(gui, "Selection menu");
|
text_label_light(gui, "Selection menu");
|
||||||
popup_menu_action_button("Paste", "Paste", [&] {
|
popup_menu_action_button("Paste", "Paste", [&, popupPos] {
|
||||||
selection.deselect_all();
|
selection.deselect_all();
|
||||||
selection.paste_clipboard(popupPos * world.main.g.final_gui_scale());
|
selection.paste_clipboard(popupPos * world.main.g.final_gui_scale());
|
||||||
});
|
});
|
||||||
popup_menu_action_button("Paste Image", "Paste Image", [&] {
|
popup_menu_action_button("Paste Image", "Paste Image", [&, popupPos] {
|
||||||
selection.deselect_all();
|
selection.deselect_all();
|
||||||
selection.paste_image(popupPos * world.main.g.final_gui_scale());
|
selection.paste_image(popupPos * world.main.g.final_gui_scale());
|
||||||
});
|
});
|
||||||
|
|
@ -426,12 +450,11 @@ void DrawingProgram::selection_action_menu(Vector2f popupPos) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawingProgram::right_click_popup_gui(Vector2f popupPos) {
|
void DrawingProgram::right_click_popup_gui(Vector2f popupPos) {
|
||||||
Toolbar& t = world.main.toolbar;
|
|
||||||
GUIStuff::GUIManager& gui = world.main.g.gui;
|
GUIStuff::GUIManager& gui = world.main.g.gui;
|
||||||
auto& io = gui.io;
|
|
||||||
|
|
||||||
gui.new_id("Drawing Program right click GUI", [&] {
|
gui.new_id("Drawing Program right click GUI", [&] {
|
||||||
drawTool->right_click_popup_gui(popupPos);
|
drawTool->right_click_popup_gui(popupPos);
|
||||||
|
|
@ -441,7 +464,6 @@ void DrawingProgram::right_click_popup_gui(Vector2f popupPos) {
|
||||||
void DrawingProgram::tool_options_gui() {
|
void DrawingProgram::tool_options_gui() {
|
||||||
using namespace GUIStuff;
|
using namespace GUIStuff;
|
||||||
|
|
||||||
Toolbar& t = world.main.toolbar;
|
|
||||||
GUIStuff::GUIManager& gui = world.main.g.gui;
|
GUIStuff::GUIManager& gui = world.main.g.gui;
|
||||||
auto& io = gui.io;
|
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) {
|
void DrawingProgram::switch_to_tool_ptr(std::unique_ptr<DrawingProgramToolBase> newTool) {
|
||||||
drawTool->switch_tool(newTool->get_type());
|
drawTool->switch_tool(newTool->get_type());
|
||||||
drawTool = std::move(newTool);
|
drawTool = std::move(newTool);
|
||||||
world.main.toolbar.rightClickPopupLocation = std::nullopt;
|
clear_right_click_popup();
|
||||||
world.main.g.gui.set_to_layout();
|
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) {
|
if(newToolType != drawTool->get_type() || force) {
|
||||||
drawTool->switch_tool(newToolType);
|
drawTool->switch_tool(newToolType);
|
||||||
drawTool = DrawingProgramToolBase::allocate_tool_type(*this, 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();
|
world.main.g.gui.set_to_layout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class DrawingProgram {
|
||||||
DrawingProgram(World& initWorld);
|
DrawingProgram(World& initWorld);
|
||||||
void server_init_no_file();
|
void server_init_no_file();
|
||||||
void toolbar_gui();
|
void toolbar_gui();
|
||||||
|
void right_click_popup_gui();
|
||||||
void tool_options_gui();
|
void tool_options_gui();
|
||||||
void right_click_popup_gui(Vector2f popupPos);
|
void right_click_popup_gui(Vector2f popupPos);
|
||||||
void update();
|
void update();
|
||||||
|
|
@ -69,6 +70,7 @@ class DrawingProgram {
|
||||||
void input_pen_touch_callback(const InputManager::PenTouchCallbackArgs& touch);
|
void input_pen_touch_callback(const InputManager::PenTouchCallbackArgs& touch);
|
||||||
void input_pen_motion_callback(const InputManager::PenMotionCallbackArgs& motion);
|
void input_pen_motion_callback(const InputManager::PenMotionCallbackArgs& motion);
|
||||||
void input_pen_axis_callback(const InputManager::PenAxisCallbackArgs& axis);
|
void input_pen_axis_callback(const InputManager::PenAxisCallbackArgs& axis);
|
||||||
|
bool rightClickPopupHoverOnClick = false;
|
||||||
private:
|
private:
|
||||||
void process_transform_message(const std::vector<std::pair<NetworkingObjects::NetObjID, CoordSpaceHelper>>& transforms);
|
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::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;
|
uint32_t nextID = 0;
|
||||||
|
|
||||||
friend class EyeDropperTool;
|
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;
|
isHovering = mouseHovering;
|
||||||
if(isHovering && button.button == InputManager::MouseButton::LEFT && button.down)
|
if(isHovering && button.button == InputManager::MouseButton::LEFT && button.down)
|
||||||
gui.set_post_callback_func([&](){if(onClick) onClick();});
|
gui.set_post_callback_func([&](){if(onClick) onClick();});
|
||||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
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;
|
isHovering = mouseHovering;
|
||||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ class CheckBox : public Element {
|
||||||
CheckBox(GUIManager& gui);
|
CheckBox(GUIManager& gui);
|
||||||
|
|
||||||
virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) 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 void 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_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);
|
void layout(const Clay_ElementId& id, const std::function<bool()>& isTicked, const std::function<void()>& onClick);
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,8 @@ template <typename T> class ColorPicker : public Element {
|
||||||
ColorPicker(GUIManager& gui);
|
ColorPicker(GUIManager& gui);
|
||||||
void layout(const Clay_ElementId& id, T* data, bool selectAlpha, const std::function<void()>& onChange);
|
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);
|
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;
|
void 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_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||||
private:
|
private:
|
||||||
void update_color_picker_pos(const Vector2f& p);
|
void update_color_picker_pos(const Vector2f& p);
|
||||||
float get_sv_selection_area_size();
|
float get_sv_selection_area_size();
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ template <typename T> void ColorPicker<T>::clay_draw(SkCanvas* canvas, UpdateInp
|
||||||
canvas->restore();
|
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;
|
held = HeldBar::NONE;
|
||||||
if(mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down && boundingBox.has_value()) {
|
if(mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down && boundingBox.has_value()) {
|
||||||
auto& bb = boundingBox.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);
|
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);
|
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) {
|
template <typename T> void ColorPicker<T>::update_color_picker_pos(const Vector2f& p) {
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ namespace GUIStuff {
|
||||||
|
|
||||||
void Element::tick_update() {}
|
void Element::tick_update() {}
|
||||||
|
|
||||||
bool Element::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) { return mouseHovering; }
|
void Element::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) { }
|
||||||
bool Element::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) { return mouseHovering; }
|
void Element::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) { }
|
||||||
bool Element::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) { return mouseHovering; }
|
void Element::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) { }
|
||||||
void Element::input_key_callback(const InputManager::KeyCallbackArgs& key) {}
|
void Element::input_key_callback(const InputManager::KeyCallbackArgs& key) {}
|
||||||
|
|
||||||
void Element::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) {}
|
void Element::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) {}
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ namespace GUIStuff {
|
||||||
virtual void tick_update();
|
virtual void tick_update();
|
||||||
|
|
||||||
// Return true when mouse obstructs what's behind it
|
// Return true when mouse obstructs what's behind it
|
||||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering);
|
virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering);
|
||||||
virtual bool input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering);
|
virtual void 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_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering);
|
||||||
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key);
|
||||||
protected:
|
protected:
|
||||||
static SCollision::AABB<float> get_bb_from_command(Clay_RenderCommand* command);
|
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);
|
layout(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayoutElement::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
void LayoutElement::input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||||
if(c.mouseButton)
|
if(c.mouseButton) c.mouseButton(button, mouseHovering);
|
||||||
return c.mouseButton(button, mouseHovering);
|
|
||||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
return Element::input_mouse_button_callback(button, mouseHovering);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayoutElement::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
void LayoutElement::input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) {
|
||||||
if(c.mouseMotion)
|
if(c.mouseMotion) c.mouseMotion(motion, mouseHovering);
|
||||||
return c.mouseMotion(motion, mouseHovering);
|
|
||||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LayoutElement::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) {
|
void LayoutElement::input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering) {
|
||||||
if(c.mouseWheel)
|
if(c.mouseWheel) c.mouseWheel(wheel, mouseHovering);
|
||||||
return c.mouseWheel(wheel, mouseHovering);
|
|
||||||
return Element::input_mouse_wheel_callback(wheel, mouseHovering);
|
return Element::input_mouse_wheel_callback(wheel, mouseHovering);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,15 @@ class LayoutElement : public Element {
|
||||||
public:
|
public:
|
||||||
LayoutElement(GUIManager& gui);
|
LayoutElement(GUIManager& gui);
|
||||||
struct Callbacks {
|
struct Callbacks {
|
||||||
std::function<bool(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering)> mouseButton;
|
std::function<void(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering)> mouseButton;
|
||||||
std::function<bool(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering)> mouseMotion;
|
std::function<void(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering)> mouseMotion;
|
||||||
std::function<bool(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering)> mouseWheel;
|
std::function<void(const InputManager::MouseWheelCallbackArgs& wheel, bool mouseHovering)> mouseWheel;
|
||||||
std::function<void(const InputManager::KeyCallbackArgs& key)> key;
|
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 = {});
|
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 void 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_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;
|
||||||
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key) override;
|
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key) override;
|
||||||
private:
|
private:
|
||||||
Callbacks c;
|
Callbacks c;
|
||||||
|
|
|
||||||
|
|
@ -73,19 +73,19 @@ template <typename T> class NumberSlider : public Element {
|
||||||
|
|
||||||
canvas->restore();
|
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;
|
isHovering = mouseHovering;
|
||||||
isHeld = isHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
isHeld = isHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
||||||
if(isHeld && boundingBox.has_value())
|
if(isHeld && boundingBox.has_value())
|
||||||
update_slider_pos(button.pos);
|
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;
|
isHovering = mouseHovering;
|
||||||
if(isHeld && boundingBox.has_value())
|
if(isHeld && boundingBox.has_value())
|
||||||
update_slider_pos(motion.pos);
|
update_slider_pos(motion.pos);
|
||||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
Element::input_mouse_motion_callback(motion, mouseHovering);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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);
|
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;
|
isHovering = mouseHovering;
|
||||||
isHeld = isHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
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);
|
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);
|
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) {
|
void PaintCircleMenu::update_paint_circle_menu_mouse(const Vector2f& p, bool leftClicked) {
|
||||||
if(boundingBox.has_value()) {
|
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) {
|
if(isColorBarHovered) {
|
||||||
double selectionAngle = std::atan2(-vecFromCenter.y(), -vecFromCenter.x()) + std::numbers::pi;
|
double selectionAngle = std::atan2(-vecFromCenter.y(), -vecFromCenter.x()) + std::numbers::pi;
|
||||||
colorSelectionIndex = (selectionAngle / (std::numbers::pi * 2.0)) * d.palette.size();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d.onRotate();
|
|
||||||
}
|
}
|
||||||
|
d.onRotate();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else if(isColorBarHovered && leftClicked) {
|
else if(isColorBarHovered && leftClicked) {
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,13 @@ class PaintCircleMenu : public Element {
|
||||||
std::vector<Vector3f> palette;
|
std::vector<Vector3f> palette;
|
||||||
std::function<void()> onRotate;
|
std::function<void()> onRotate;
|
||||||
std::function<void()> onPaletteClick;
|
std::function<void()> onPaletteClick;
|
||||||
|
std::function<void(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering)> mouseButton;
|
||||||
};
|
};
|
||||||
void layout(const Clay_ElementId& id, const Data& data);
|
void layout(const Clay_ElementId& id, const Data& data);
|
||||||
virtual bool collides_with_point(const Vector2f& p) const override;
|
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 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 void 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_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||||
private:
|
private:
|
||||||
void draw_rotate_bar(SkCanvas* canvas, UpdateInputData& io, bool skiaAA);
|
void draw_rotate_bar(SkCanvas* canvas, UpdateInputData& io, bool skiaAA);
|
||||||
void draw_palette_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 isColorBarHovered = false;
|
||||||
bool isHeld = 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);
|
void update_paint_circle_menu_mouse(const Vector2f& p, bool leftClicked);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ namespace GUIStuff {
|
||||||
|
|
||||||
PositionAdjustingPopupMenu::PositionAdjustingPopupMenu(GUIManager& gui): Element(gui) {}
|
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()) {
|
if(layoutElement && layoutElement->get_bb().has_value()) {
|
||||||
auto& bb = layoutElement->get_bb().value();
|
auto& bb = layoutElement->get_bb().value();
|
||||||
if((popupPos.y() + bb.height()) > gui.io.windowSize.y())
|
if((popupPos.y() + bb.height()) > gui.io.windowSize.y())
|
||||||
|
|
@ -34,7 +34,7 @@ void PositionAdjustingPopupMenu::layout(const Clay_ElementId& id, Vector2f popup
|
||||||
}) {
|
}) {
|
||||||
innerContent();
|
innerContent();
|
||||||
}
|
}
|
||||||
});
|
}, callbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace GUIStuff {
|
||||||
class PositionAdjustingPopupMenu : public Element {
|
class PositionAdjustingPopupMenu : public Element {
|
||||||
public:
|
public:
|
||||||
PositionAdjustingPopupMenu(GUIManager& gui);
|
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:
|
private:
|
||||||
LayoutElement* layoutElement = nullptr;
|
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;
|
isHovering = mouseHovering;
|
||||||
if(isHovering && button.button == InputManager::MouseButton::LEFT && button.down)
|
if(isHovering && button.button == InputManager::MouseButton::LEFT && button.down)
|
||||||
gui.set_post_callback_func([&] { if(onClick) onClick(); });
|
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;
|
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) {
|
void RadioButton::clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ class RadioButton : public Element {
|
||||||
public:
|
public:
|
||||||
RadioButton(GUIManager& gui);
|
RadioButton(GUIManager& gui);
|
||||||
virtual void clay_draw(SkCanvas* canvas, UpdateInputData& io, Clay_RenderCommand* command, bool skiaAA) 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 void 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_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);
|
void layout(const Clay_ElementId& id, const std::function<bool()>& isTicked, const std::function<void()>& onClick);
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -34,26 +34,30 @@ float RotateWheel::wheel_end() {
|
||||||
return boundingBox.value().width() * 0.5f;
|
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;
|
isHovering = mouseHovering;
|
||||||
isHeld = isHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
isHeld = isHovering && button.button == InputManager::MouseButton::LEFT && button.down;
|
||||||
|
update_rotate_wheel_mouse_hover(button.pos);
|
||||||
isRotateBarHeld = isRotateBarHovered && isHeld;
|
isRotateBarHeld = isRotateBarHovered && isHeld;
|
||||||
update_paint_circle_menu_mouse(button.pos);
|
update_rotate_wheel_mouse(button.pos);
|
||||||
return Element::input_mouse_button_callback(button, mouseHovering);
|
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;
|
isHovering = mouseHovering;
|
||||||
update_paint_circle_menu_mouse(motion.pos);
|
update_rotate_wheel_mouse_hover(motion.pos);
|
||||||
return Element::input_mouse_motion_callback(motion, mouseHovering);
|
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) {
|
||||||
if(boundingBox.has_value()) {
|
|
||||||
Vector2f vecFromCenter = (p - boundingBox.value().center()).normalized();
|
|
||||||
float distFromCenter = vec_distance(p, boundingBox.value().center());
|
float distFromCenter = vec_distance(p, boundingBox.value().center());
|
||||||
isRotateBarHovered = isHovering && distFromCenter > wheel_start() && distFromCenter < wheel_end();
|
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();
|
||||||
if(isRotateBarHeld) {
|
if(isRotateBarHeld) {
|
||||||
gui.set_post_callback_func([&, vecFromCenter] {
|
gui.set_post_callback_func([&, vecFromCenter] {
|
||||||
auto& rotationAngle = *rotateAngle;
|
auto& rotationAngle = *rotateAngle;
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ class RotateWheel : public Element {
|
||||||
RotateWheel(GUIManager& gui);
|
RotateWheel(GUIManager& gui);
|
||||||
void layout(const Clay_ElementId& id, double* rotateAngle, const std::function<void()>& onChange);
|
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 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 void 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_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float wheel_start();
|
float wheel_start();
|
||||||
|
|
@ -23,7 +23,8 @@ class RotateWheel : public Element {
|
||||||
bool isRotateBarHovered = false;
|
bool isRotateBarHovered = false;
|
||||||
std::function<void()> onChange;
|
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};
|
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() {
|
void ScrollArea::clamp_scroll() {
|
||||||
scrollOffset.x() = std::clamp(scrollOffset.x(), -std::max(0.0f, contentDimensions.x() - containerDimensions.x()), 0.0f);
|
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);
|
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) {
|
if(mouseHovering) {
|
||||||
Vector2f oldScrollOffset = scrollOffset;
|
Vector2f oldScrollOffset = scrollOffset;
|
||||||
|
|
||||||
|
|
@ -168,7 +160,7 @@ bool ScrollArea::input_mouse_wheel_callback(const InputManager::MouseWheelCallba
|
||||||
if(oldScrollOffset != scrollOffset)
|
if(oldScrollOffset != scrollOffset)
|
||||||
gui.set_to_layout();
|
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 layout(const Clay_ElementId& id, const Options& options);
|
||||||
void reset_scroll();
|
void reset_scroll();
|
||||||
|
|
||||||
virtual bool input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) override;
|
virtual void input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel, 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;
|
|
||||||
private:
|
private:
|
||||||
Options opts;
|
Options opts;
|
||||||
bool isScrollbarHeldY = false;
|
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 oldIsHovering = isHovering;
|
||||||
bool oldIsHeld = isHeld;
|
bool oldIsHeld = isHeld;
|
||||||
isHovering = mouseHovering;
|
isHovering = mouseHovering;
|
||||||
|
|
@ -74,15 +74,15 @@ bool SelectableButton::input_mouse_button_callback(const InputManager::MouseButt
|
||||||
}
|
}
|
||||||
else if(isHovering != oldIsHovering || isHeld != oldIsHeld)
|
else if(isHovering != oldIsHovering || isHeld != oldIsHeld)
|
||||||
gui.set_to_layout();
|
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;
|
bool oldIsHovering = isHovering;
|
||||||
isHovering = mouseHovering;
|
isHovering = mouseHovering;
|
||||||
if(isHovering != oldIsHovering)
|
if(isHovering != oldIsHovering)
|
||||||
gui.set_to_layout();
|
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);
|
SelectableButton(GUIManager& gui);
|
||||||
void layout(const Clay_ElementId& id, const Data& d);
|
void layout(const Clay_ElementId& id, const Data& d);
|
||||||
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;
|
||||||
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;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isHovering = false;
|
bool isHovering = false;
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ template <typename T> class TextBox : public Element {
|
||||||
|
|
||||||
void layout(const Clay_ElementId& id, const TextBoxData<T>& userInfo);
|
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 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 void 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_motion_callback(const InputManager::MouseMotionCallbackArgs& motion, bool mouseHovering) override;
|
||||||
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key) override;
|
virtual void input_key_callback(const InputManager::KeyCallbackArgs& key) override;
|
||||||
~TextBox();
|
~TextBox();
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ template <typename T> void TextBox<T>::clay_draw(SkCanvas* canvas, UpdateInputDa
|
||||||
canvas->restore();
|
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;
|
auto& io = gui.io;
|
||||||
|
|
||||||
if(button.button == InputManager::MouseButton::LEFT && boundingBox.has_value()) {
|
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);
|
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())
|
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);
|
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) {
|
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);
|
//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);
|
TreeListing(GUIManager& gui);
|
||||||
void layout(const Clay_ElementId& id, NetworkingObjects::NetObjID rootObjID, const DisplayData& displayData, SelectionData& selectionData);
|
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:
|
private:
|
||||||
bool dragHoldSelected = false;
|
bool dragHoldSelected = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -406,21 +406,29 @@ void Toolbar::save_as_func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Toolbar::paint_popup(Vector2f popupPos) {
|
void Toolbar::paint_popup(Vector2f popupPos) {
|
||||||
|
using namespace GUIStuff;
|
||||||
auto& gui = main.g.gui;
|
auto& gui = main.g.gui;
|
||||||
auto& io = main.g.gui.io;
|
|
||||||
|
|
||||||
double newRotationAngle = 0.0;
|
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, {
|
paint_circle_popup_menu(gui, "paint circle popup", popupPos, {
|
||||||
.rotationAngle = &main.world->drawData.cam.c.rotation,
|
.rotationAngle = newRotationAngle.get(),
|
||||||
.selectedColor = main.world->drawProg.get_foreground_color_ptr(),
|
.selectedColor = main.world->drawProg.get_foreground_color_ptr(),
|
||||||
.palette = paletteData.palettes[paletteData.selectedPalette].colors,
|
.palette = paletteData.palettes[paletteData.selectedPalette].colors,
|
||||||
.onRotate = [&] {
|
.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);
|
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 = [&] {
|
.onPaletteClick = [&] {
|
||||||
gui.set_to_layout();
|
gui.set_to_layout();
|
||||||
|
},
|
||||||
|
.mouseButton = [&](const InputManager::MouseButtonCallbackArgs& button, bool mouseHovering) {
|
||||||
|
main.world->drawProg.rightClickPopupHoverOnClick = mouseHovering;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Toolbar::top_toolbar() {
|
void Toolbar::top_toolbar() {
|
||||||
|
|
@ -636,7 +644,6 @@ void Toolbar::top_toolbar() {
|
||||||
menuPopupOpenFlipped = true;
|
menuPopupOpenFlipped = true;
|
||||||
gui.set_to_layout();
|
gui.set_to_layout();
|
||||||
}
|
}
|
||||||
return mouseHovering;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1225,6 +1232,7 @@ void Toolbar::drawing_program_gui() {
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
main.world->drawProg.tool_options_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();
|
gui.set_to_layout();
|
||||||
}
|
}
|
||||||
return mouseHovering;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,6 @@ class Toolbar {
|
||||||
bool isUpdatingColorLeft = false;
|
bool isUpdatingColorLeft = false;
|
||||||
bool isUpdatingColorRight = false;
|
bool isUpdatingColorRight = false;
|
||||||
|
|
||||||
std::optional<Vector2f> rightClickPopupLocation;
|
|
||||||
|
|
||||||
bool app_close_requested();
|
bool app_close_requested();
|
||||||
private:
|
private:
|
||||||
static void sdl_open_file_dialog_callback(void* userData, const char * const * fileList, int filter);
|
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