diff --git a/CMakeLists.txt b/CMakeLists.txt
index 623f472..714926f 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -203,9 +203,7 @@ else()
endif()
if(NOT EMSCRIPTEN)
- if(ANDROID)
- find_package(game-text-input REQUIRED CONFIG)
- else()
+ if(NOT ANDROID)
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3-shared)
endif()
find_package(LibDataChannel REQUIRED)
@@ -384,7 +382,7 @@ if(NO_CONAN_BUILD)
else()
target_link_libraries(main skia-infinipaint::skia-infinipaint)
if(ANDROID)
- target_link_libraries(main SDL3::SDL3 game-text-input::game-text-input)
+ target_link_libraries(main SDL3::SDL3)
else()
target_link_libraries(main sdl-infinipaint::sdl-infinipaint)
endif()
diff --git a/android-project/app/src/main/res/values/styles.xml b/android-project/app/src/main/res/values/styles.xml
index 7456b1b..5f0d0ec 100644
--- a/android-project/app/src/main/res/values/styles.xml
+++ b/android-project/app/src/main/res/values/styles.xml
@@ -3,5 +3,8 @@
diff --git a/src/DrawingProgram/DrawingProgram.cpp b/src/DrawingProgram/DrawingProgram.cpp
index 997b06b..982d66e 100644
--- a/src/DrawingProgram/DrawingProgram.cpp
+++ b/src/DrawingProgram/DrawingProgram.cpp
@@ -438,36 +438,59 @@ void DrawingProgram::selection_action_menu(Vector2f popupPos) {
GUIStuff::GUIManager& gui = world.main.g.gui;
+ right_click_action_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();
+ world.main.input.call_paste(CustomEvents::PasteEvent::DataType::IMAGE, {
+ .pastePosition = 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_action_menu(Vector2f popupPos, const std::function& innerContent) {
+ using namespace GUIStuff;
+ using namespace ElementHelpers;
+
+ GUIStuff::GUIManager& gui = world.main.g.gui;
+
gui.set_z_index(-1, [&] {
gui.element("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();
- world.main.input.call_paste(CustomEvents::PasteEvent::DataType::IMAGE, {
- .pastePosition = 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();
- });
+ CLAY_AUTO_ID({
+ .layout = {
+ .sizing = {.width = CLAY_SIZING_FIT(100), .height = CLAY_SIZING_FIT(0)},
+ .padding = CLAY_PADDING_ALL(gui.io.theme->padding1),
+ .childGap = 1,
+ .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
+ .layoutDirection = CLAY_TOP_TO_BOTTOM
+ },
+ .backgroundColor = convert_vec4(gui.io.theme->backColor1),
+ .cornerRadius = CLAY_CORNER_RADIUS(gui.io.theme->windowCorners1)
+ }) {
+ innerContent();
}
}, LayoutElement::Callbacks{
.mouseButton = [&](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) {
diff --git a/src/DrawingProgram/DrawingProgram.hpp b/src/DrawingProgram/DrawingProgram.hpp
index c74c216..7d7cc76 100644
--- a/src/DrawingProgram/DrawingProgram.hpp
+++ b/src/DrawingProgram/DrawingProgram.hpp
@@ -84,6 +84,7 @@ class DrawingProgram {
void update_downloading_dropped_files();
void selection_action_menu(Vector2f popupPos);
+ void right_click_action_menu(Vector2f popupPos, const std::function& innerContent);
void popup_menu_action_button(const char* id, const char* text, const std::function& onClick);
void rebuild_cache();
diff --git a/src/DrawingProgram/Tools/EditTools/TextBoxEditTool.cpp b/src/DrawingProgram/Tools/EditTools/TextBoxEditTool.cpp
index 2465287..0a168d8 100644
--- a/src/DrawingProgram/Tools/EditTools/TextBoxEditTool.cpp
+++ b/src/DrawingProgram/Tools/EditTools/TextBoxEditTool.cpp
@@ -282,34 +282,27 @@ void TextBoxEditTool::right_click_popup_gui(Toolbar& t, Vector2f popupPos) {
auto& gui = drawP.world.main.g.gui;
auto& a = static_cast(comp->obj->get_comp());
- gui.set_z_index(-1, [&] {
- gui.element("Text popup menu", popupPos, [&] {
- text_label_light(gui, "Text menu");
- InputManager& input = drawP.world.main.input;
- drawP.popup_menu_action_button("Paste", "Paste", [&] {
- drawP.world.main.input.call_paste(CustomEvents::PasteEvent::DataType::TEXT, { .allowRichText = true });
- });
- drawP.popup_menu_action_button("Paste without formatting", "Paste without formatting", [&] {
- drawP.world.main.input.call_paste(CustomEvents::PasteEvent::DataType::TEXT, { .allowRichText = false });
- });
- if(a.cursor->selectionBeginPos != a.cursor->selectionEndPos) {
- drawP.popup_menu_action_button("Copy", "Copy", [&] {
- input.set_clipboard_plain_and_richtext_pair(a.textBox->process_copy(*a.cursor));
- });
- drawP.popup_menu_action_button("Cut", "Cut", [&] {
- userInput->do_textbox_operation_with_undo([&]() {
- input.set_clipboard_plain_and_richtext_pair(a.textBox->process_cut(*a.cursor));
- });
- commit_update_and_layout_func();
- set_styles_at_selection(a);
- });
- }
- }, LayoutElement::Callbacks{
- .mouseButton = [&](LayoutElement*, const InputManager::MouseButtonCallbackArgs& button) {
- if(button.down && button.button != InputManager::MouseButton::RIGHT)
- drawP.clear_right_click_popup();
- }
+ drawP.right_click_action_menu(popupPos, [&] {
+ text_label_light(gui, "Text menu");
+ InputManager& input = drawP.world.main.input;
+ drawP.popup_menu_action_button("Paste", "Paste", [&] {
+ drawP.world.main.input.call_paste(CustomEvents::PasteEvent::DataType::TEXT, { .allowRichText = true });
});
+ drawP.popup_menu_action_button("Paste without formatting", "Paste without formatting", [&] {
+ drawP.world.main.input.call_paste(CustomEvents::PasteEvent::DataType::TEXT, { .allowRichText = false });
+ });
+ if(a.cursor->selectionBeginPos != a.cursor->selectionEndPos) {
+ drawP.popup_menu_action_button("Copy", "Copy", [&] {
+ input.set_clipboard_plain_and_richtext_pair(a.textBox->process_copy(*a.cursor));
+ });
+ drawP.popup_menu_action_button("Cut", "Cut", [&] {
+ userInput->do_textbox_operation_with_undo([&]() {
+ input.set_clipboard_plain_and_richtext_pair(a.textBox->process_cut(*a.cursor));
+ });
+ commit_update_and_layout_func();
+ set_styles_at_selection(a);
+ });
+ }
});
}
diff --git a/src/GUIHolder.cpp b/src/GUIHolder.cpp
index 1c3b8fc..e70227c 100644
--- a/src/GUIHolder.cpp
+++ b/src/GUIHolder.cpp
@@ -100,7 +100,7 @@ void GUIHolder::update() {
void GUIHolder::window_update() {
calculate_final_gui_scale();
- gui.update_window(main.window.safeArea.min, main.window.safeArea.dim(), final_gui_scale());
+ gui.update_window(main.window.size.cast(), main.window.safeArea, final_gui_scale());
}
float GUIHolder::final_gui_scale() {
diff --git a/src/GUIStuff/Elements/CheckBox.cpp b/src/GUIStuff/Elements/CheckBox.cpp
index 2bf2456..cd396d0 100644
--- a/src/GUIStuff/Elements/CheckBox.cpp
+++ b/src/GUIStuff/Elements/CheckBox.cpp
@@ -2,6 +2,7 @@
#include
#include
#include "../GUIManager.hpp"
+#include "../../TimePoint.hpp"
namespace GUIStuff {
diff --git a/src/GUIStuff/Elements/GUIStuffHelpers.hpp b/src/GUIStuff/Elements/GUIStuffHelpers.hpp
index 21204ca..57ae07b 100644
--- a/src/GUIStuff/Elements/GUIStuffHelpers.hpp
+++ b/src/GUIStuff/Elements/GUIStuffHelpers.hpp
@@ -1,7 +1,6 @@
#pragma once
#include "Helpers/ConvertVec.hpp"
#include
-#include "../../TimePoint.hpp"
#include
#include
#include
@@ -12,7 +11,6 @@
#include
#include
#include
-#include "../../RichText/TextBox.hpp"
#include "../../InputManager.hpp"
#include "../GUIManagerID.hpp"
@@ -108,8 +106,8 @@ struct UpdateInputData {
float deltaTime = 0.0f;
float guiScaleMultiplier = 1.0f;
- Vector2f windowPos = {0.0f, 0.0f};
Vector2f windowSize = {0.0f, 0.0f};
+ SCollision::AABB safeWindowRect;
std::shared_ptr fonts;
sk_sp textTypeface;
diff --git a/src/GUIStuff/Elements/PositionAdjustingPopupMenu.cpp b/src/GUIStuff/Elements/PositionAdjustingPopupMenu.cpp
index 56cf994..41a2cbf 100644
--- a/src/GUIStuff/Elements/PositionAdjustingPopupMenu.cpp
+++ b/src/GUIStuff/Elements/PositionAdjustingPopupMenu.cpp
@@ -11,7 +11,7 @@ void PositionAdjustingPopupMenu::layout(const Clay_ElementId& id, Vector2f popup
auto& bb = layoutElement->get_bb().value();
if((popupPos.y() + bb.height()) > gui.io.windowSize.y())
popupPos.y() -= bb.height();
- if((popupPos.x() + bb.width()) > gui.io.windowSize.x())
+ if((popupPos.x() + bb.width()) > gui.io.windowSize.y())
popupPos.x() -= bb.width();
}
diff --git a/src/GUIStuff/Elements/RadioButton.cpp b/src/GUIStuff/Elements/RadioButton.cpp
index 70327ed..3c55a92 100644
--- a/src/GUIStuff/Elements/RadioButton.cpp
+++ b/src/GUIStuff/Elements/RadioButton.cpp
@@ -1,5 +1,6 @@
#include "RadioButton.hpp"
#include "../GUIManager.hpp"
+#include "../../TimePoint.hpp"
namespace GUIStuff {
diff --git a/src/GUIStuff/Elements/TextBox.impl.hpp b/src/GUIStuff/Elements/TextBox.impl.hpp
index 2d1937e..3c70347 100644
--- a/src/GUIStuff/Elements/TextBox.impl.hpp
+++ b/src/GUIStuff/Elements/TextBox.impl.hpp
@@ -73,7 +73,7 @@ template void TextBox::clay_draw(SkCanvas* canvas, UpdateInputDa
template void TextBox::select() {
if(!is_selected()) {
- SCollision::AABB rect = {(boundingBox.value().min + gui.io.windowPos) * gui.io.guiScaleMultiplier, (boundingBox.value().max + gui.io.windowPos) * gui.io.guiScaleMultiplier};
+ SCollision::AABB rect = {boundingBox.value().min * gui.io.guiScaleMultiplier, boundingBox.value().max * gui.io.guiScaleMultiplier};
unsigned id = gui.io.input->set_text_box_front(rect, userInfo.textInputProps);
edit = TextEditData(id, textbox, cur);
}
diff --git a/src/GUIStuff/GUIManager.cpp b/src/GUIStuff/GUIManager.cpp
index 6bb01d0..9e63e32 100644
--- a/src/GUIStuff/GUIManager.cpp
+++ b/src/GUIStuff/GUIManager.cpp
@@ -74,11 +74,8 @@ void GUIManager::clip_rect_transform(SkCanvas* canvas, std::vector c = clipRect.value();
c.min *= io.guiScaleMultiplier;
c.max *= io.guiScaleMultiplier;
- c.min += io.windowPos;
- c.max += io.windowPos;
canvas->clipIRect(c.get_sk_irect());
}
- canvas->translate(io.windowPos.x(), io.windowPos.y());
canvas->scale(io.guiScaleMultiplier, io.guiScaleMultiplier);
}
@@ -286,7 +283,6 @@ void GUIManager::draw(SkCanvas* c, bool skiaAA) {
void GUIManager::draw_force(SkCanvas* canvas, bool skiaAA) {
canvas->save();
- canvas->translate(io.windowPos.x(), io.windowPos.y());
canvas->scale(io.guiScaleMultiplier, io.guiScaleMultiplier);
for(size_t i = 0; i < static_cast(renderCommands.length); i++) {
@@ -521,13 +517,15 @@ GUIFloatAnimation* GUIManager::float_animation(const char* animationID, const GU
return toRet;
}
-void GUIManager::update_window(const Vector2f& windowPos, const Vector2f& windowSize, float guiScaleMultiplier) {
- if(io.windowPos != windowPos || io.windowSize != windowSize || io.guiScaleMultiplier != guiScaleMultiplier) {
+void GUIManager::update_window(const Vector2f& windowSize, const SCollision::AABB& safeWindowRect, float guiScaleMultiplier) {
+ if(io.windowSize != windowSize || io.safeWindowRect != safeWindowRect || io.guiScaleMultiplier != guiScaleMultiplier) {
io.redrawSurface = true;
set_to_layout();
}
- io.windowPos = windowPos;
io.windowSize = windowSize / guiScaleMultiplier;
+ io.safeWindowRect = safeWindowRect;
+ io.safeWindowRect.min /= guiScaleMultiplier;
+ io.safeWindowRect.max /= guiScaleMultiplier;
io.guiScaleMultiplier = guiScaleMultiplier;
}
@@ -692,19 +690,16 @@ void GUIManager::input_key_callback(const InputManager::KeyCallbackArgs& key) {
}
void GUIManager::input_mouse_button_callback(InputManager::MouseButtonCallbackArgs button) {
- button.pos -= io.windowPos;
button.pos /= io.guiScaleMultiplier;
mouse_callback(button.pos, [&button] (ElementContainer* e) { e->elem->input_mouse_button_callback(button); });
}
void GUIManager::input_mouse_motion_callback(InputManager::MouseMotionCallbackArgs motion) {
- motion.pos -= io.windowPos;
motion.pos /= io.guiScaleMultiplier;
mouse_callback(motion.pos, [&motion] (ElementContainer* e) { e->elem->input_mouse_motion_callback(motion); });
}
void GUIManager::input_mouse_wheel_callback(InputManager::MouseWheelCallbackArgs wheel) {
- wheel.mousePos -= io.windowPos;
wheel.mousePos /= io.guiScaleMultiplier;
mouse_callback(wheel.mousePos, [&wheel] (ElementContainer* e) { e->elem->input_mouse_wheel_callback(wheel); });
}
diff --git a/src/GUIStuff/GUIManager.hpp b/src/GUIStuff/GUIManager.hpp
index 04c862e..f3d1e5c 100644
--- a/src/GUIStuff/GUIManager.hpp
+++ b/src/GUIStuff/GUIManager.hpp
@@ -26,7 +26,7 @@ class GUIManager {
GUIFloatAnimation* float_animation(const char* animationID, const GUIFloatAnimationData& animation);
void update();
- void update_window(const Vector2f& windowPos, const Vector2f& windowSize, float guiScaleMultiplier);
+ void update_window(const Vector2f& windowRect, const SCollision::AABB& safeWindowRect, float guiScaleMultiplier);
UpdateInputData io;
diff --git a/src/Screens/FileSelectScreen.cpp b/src/Screens/FileSelectScreen.cpp
index 338b327..094cc04 100644
--- a/src/Screens/FileSelectScreen.cpp
+++ b/src/Screens/FileSelectScreen.cpp
@@ -128,7 +128,7 @@ void FileSelectScreen::main_display() {
main_menu();
CLAY_AUTO_ID({
.layout = {
- .sizing = {.width = CLAY_SIZING_FIXED(gui.io.windowSize.x()), .height = CLAY_SIZING_GROW(0)},
+ .sizing = {.width = CLAY_SIZING_FIXED(gui.io.safeWindowRect.width()), .height = CLAY_SIZING_GROW(0)},
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP },
.layoutDirection = CLAY_TOP_TO_BOTTOM,
},
diff --git a/src/Screens/PhoneDrawingProgramScreen.cpp b/src/Screens/PhoneDrawingProgramScreen.cpp
index ab4469f..a37d244 100644
--- a/src/Screens/PhoneDrawingProgramScreen.cpp
+++ b/src/Screens/PhoneDrawingProgramScreen.cpp
@@ -22,35 +22,39 @@ void PhoneDrawingProgramScreen::gui_layout_run() {
}
void PhoneDrawingProgramScreen::main_display() {
- auto& gui = main.g.gui;
- auto& io = gui.io;
CLAY_AUTO_ID({
.layout = {
.sizing = { .width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0) },
.layoutDirection = CLAY_TOP_TO_BOTTOM
},
}) {
- gui.element("top toolbar", [&](LayoutElement* l, const Clay_ElementId& lId) {
- CLAY(lId, {
- .layout = {
- .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) },
- .childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER},
- .layoutDirection = CLAY_LEFT_TO_RIGHT
- },
- .backgroundColor = convert_vec4(io.theme->backColor0),
- .border = {
- .color = convert_vec4(io.theme->frontColor1),
- .width = {.bottom = 1}
- }
- }) {
- svg_icon_button(gui, "back exit button", "data/icons/RemixIcon/arrow-left-s-line.svg", {
- .drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
- .onClick = [&] {
- main.set_tab_to_close(main.world.get());
- main.screen = std::make_unique(main);
- }
- });
- }
- });
+ top_toolbar();
}
}
+
+void PhoneDrawingProgramScreen::top_toolbar() {
+ auto& gui = main.g.gui;
+ auto& io = gui.io;
+ gui.element("top toolbar", [&](LayoutElement* l, const Clay_ElementId& lId) {
+ CLAY(lId, {
+ .layout = {
+ .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) },
+ .childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER},
+ .layoutDirection = CLAY_LEFT_TO_RIGHT
+ },
+ .backgroundColor = convert_vec4(io.theme->backColor0),
+ .border = {
+ .color = convert_vec4(io.theme->frontColor1),
+ .width = {.bottom = 1}
+ }
+ }) {
+ svg_icon_button(gui, "back exit button", "data/icons/RemixIcon/arrow-left-s-line.svg", {
+ .drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
+ .onClick = [&] {
+ main.set_tab_to_close(main.world.get());
+ main.screen = std::make_unique(main);
+ }
+ });
+ }
+ });
+}
diff --git a/src/Screens/PhoneDrawingProgramScreen.hpp b/src/Screens/PhoneDrawingProgramScreen.hpp
index cd89f26..9ada752 100644
--- a/src/Screens/PhoneDrawingProgramScreen.hpp
+++ b/src/Screens/PhoneDrawingProgramScreen.hpp
@@ -8,5 +8,6 @@ class PhoneDrawingProgramScreen : public DrawingProgramScreen {
virtual void update() override;
virtual void gui_layout_run() override;
private:
+ void top_toolbar();
void main_display();
};
diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp
index 25bfcbd..eba4156 100644
--- a/src/Toolbar.cpp
+++ b/src/Toolbar.cpp
@@ -216,7 +216,7 @@ void Toolbar::layout_run() {
if(drawGui) {
CLAY_AUTO_ID({
.layout = {
- .sizing = {.width = CLAY_SIZING_FIT(gui.io.windowSize.x()), .height = CLAY_SIZING_FIT(gui.io.windowSize.y())},
+ .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
.padding = CLAY_PADDING_ALL(io.theme->padding1),
.childGap = io.theme->childGap1,
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
diff --git a/src/Toolbar.hpp b/src/Toolbar.hpp
index 2f2b16e..8d2ee20 100644
--- a/src/Toolbar.hpp
+++ b/src/Toolbar.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "GUIStuff/Elements/ScrollArea.hpp"
#include "DrawData.hpp"
+#include "TimePoint.hpp"
#include "Helpers/FileDownloader.hpp"
#include
#include