diff --git a/src/DrawingProgram/DrawingProgram.cpp b/src/DrawingProgram/DrawingProgram.cpp index 982d66e..511fa73 100644 --- a/src/DrawingProgram/DrawingProgram.cpp +++ b/src/DrawingProgram/DrawingProgram.cpp @@ -493,7 +493,7 @@ void DrawingProgram::right_click_action_menu(Vector2f popupPos, const std::funct innerContent(); } }, LayoutElement::Callbacks{ - .mouseButton = [&](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { + .onClick = [&](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { if(button.down && button.button != InputManager::MouseButton::RIGHT && !l->mouseHovering) clear_right_click_popup(); } diff --git a/src/GUIStuff/Elements/LayoutElement.cpp b/src/GUIStuff/Elements/LayoutElement.cpp index c636367..54adbe1 100644 --- a/src/GUIStuff/Elements/LayoutElement.cpp +++ b/src/GUIStuff/Elements/LayoutElement.cpp @@ -13,6 +13,7 @@ void LayoutElement::layout(const Clay_ElementId& id, const std::function(touch.fingerTapCount), + .pos = touch.pos + }); + } +} + +void LayoutElement::input_finger_motion_callback(const InputManager::FingerMotionCallbackArgs& motion) { + if(c.fingerMotion) c.fingerMotion(this, motion); +} + void LayoutElement::input_key_callback(const InputManager::KeyCallbackArgs& key) { if(c.key) c.key(this, key); } diff --git a/src/GUIStuff/Elements/LayoutElement.hpp b/src/GUIStuff/Elements/LayoutElement.hpp index beba2e5..9f9e46c 100644 --- a/src/GUIStuff/Elements/LayoutElement.hpp +++ b/src/GUIStuff/Elements/LayoutElement.hpp @@ -10,12 +10,17 @@ class LayoutElement : public Element { std::function mouseButton; std::function mouseMotion; std::function mouseWheel; + std::function fingerTouch; + std::function fingerMotion; + std::function onClick; std::function key; }; void layout(const Clay_ElementId& id, const std::function& layout, const Callbacks& c = {}); virtual void input_mouse_button_callback(const InputManager::MouseButtonCallbackArgs& button) override; virtual void input_mouse_motion_callback(const InputManager::MouseMotionCallbackArgs& motion) override; virtual void input_mouse_wheel_callback(const InputManager::MouseWheelCallbackArgs& wheel) override; + virtual void input_finger_touch_callback(const InputManager::FingerTouchCallbackArgs& touch) override; + virtual void input_finger_motion_callback(const InputManager::FingerMotionCallbackArgs& motion) override; virtual void input_key_callback(const InputManager::KeyCallbackArgs& key) override; private: Callbacks c; diff --git a/src/Screens/FileSelectScreen.cpp b/src/Screens/FileSelectScreen.cpp index a3bf90f..e7b7ea4 100644 --- a/src/Screens/FileSelectScreen.cpp +++ b/src/Screens/FileSelectScreen.cpp @@ -491,7 +491,7 @@ void FileSelectScreen::title_bar() { } } }, LayoutElement::Callbacks{ - .mouseButton = [&](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& m) { + .onClick = [&](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& m) { if(!l->mouseHovering && m.down) { moreOptionsMenu = MoreOptionsMenu::CLOSED; main.g.gui.set_to_layout(); @@ -720,7 +720,7 @@ void FileSelectScreen::menu_black_box() { }) { } }, LayoutElement::Callbacks{ - .mouseButton = [&] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& m) { + .onClick = [&] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& m) { if(m.down && m.button == InputManager::MouseButton::LEFT && l->mouseHovering) { mainMenuOpenAnim->animation_trigger_reverse(); gui.set_to_layout(); diff --git a/src/Screens/PhoneDrawingProgramScreen.cpp b/src/Screens/PhoneDrawingProgramScreen.cpp index 1685755..5c474ee 100644 --- a/src/Screens/PhoneDrawingProgramScreen.cpp +++ b/src/Screens/PhoneDrawingProgramScreen.cpp @@ -2,7 +2,6 @@ #include "../MainProgram.hpp" #include "DrawingProgramScreen.hpp" #include "Helpers/ConvertVec.hpp" -#include "../GUIStuff/Elements/LayoutElement.hpp" #include "../GUIStuff/ElementHelpers/ButtonHelpers.hpp" #include "../GUIStuff/ElementHelpers/LayoutHelpers.hpp" #include "../GUIStuff/ElementHelpers/TextLabelHelpers.hpp" diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index eba4156..a92a214 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -606,7 +606,7 @@ void Toolbar::top_toolbar() { #endif } }, LayoutElement::Callbacks { - .mouseButton = [&, mainMenuButton](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { + .onClick = [&, mainMenuButton](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { if(!l->mouseHovering && button.down && !mainMenuButton->mouseHovering) { menuPopUpOpen = false; gui.set_to_layout(); @@ -846,7 +846,7 @@ void Toolbar::grid_menu(Element* gridMenuButton) { } } }, LayoutElement::Callbacks { - .mouseButton = [&, i] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { + .onClick = [&, i] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { if(l->mouseHovering && button.down && button.button == InputManager::MouseButton::LEFT) { gridMenu.selectedGrid = i; if(button.clicks == 2) { @@ -870,7 +870,7 @@ void Toolbar::grid_menu(Element* gridMenuButton) { }); } }, LayoutElement::Callbacks { - .mouseButton = [&, gridMenuButton] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { + .onClick = [&, gridMenuButton] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { if(!l->mouseHovering && !l->childMouseHovering && !gridMenuButton->mouseHovering && button.down) stop_displaying_grid_menu(); } @@ -928,7 +928,7 @@ void Toolbar::bookmark_menu(Element* bookmarkMenuButton) { main.world->bMan.setup_list_gui(); } }, LayoutElement::Callbacks { - .mouseButton = [&, bookmarkMenuButton] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { + .onClick = [&, bookmarkMenuButton] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { if(!l->mouseHovering && !l->childMouseHovering && !bookmarkMenuButton->mouseHovering && button.down) stop_displaying_bookmark_menu(); } @@ -958,7 +958,7 @@ void Toolbar::layer_menu(Element* layerMenuButton) { main.world->drawProg.layerMan.listGUI.setup_list_gui(); } }, LayoutElement::Callbacks { - .mouseButton = [&, layerMenuButton] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { + .onClick = [&, layerMenuButton] (LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { if(!l->mouseHovering && !l->childMouseHovering && !layerMenuButton->mouseHovering && button.down) stop_displaying_layer_menu(); } @@ -1216,7 +1216,7 @@ void Toolbar::color_picker_window(const char* id, Vector4f** color, GUIStuff::El }); } }, LayoutElement::Callbacks{ - .mouseButton = [&, b, color](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { + .onClick = [&, b, color](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { if(!l->mouseHovering && !l->childMouseHovering && !b->mouseHovering && button.down) { *color = nullptr; main.g.gui.set_to_layout(); @@ -2111,7 +2111,7 @@ void Toolbar::file_picker_gui() { text_label(gui, entry.filename().string()); } }, LayoutElement::Callbacks { - .mouseButton = [&, selectedEntry, entry](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { + .onClick = [&, selectedEntry, entry](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) { if(l->mouseHovering && button.button == InputManager::MouseButton::LEFT && button.down) { gui.set_post_callback_func([&, button, selectedEntry, entry] { if(selectedEntry && button.clicks >= 2) {