diff --git a/assets/data/icons/RemixIcon/bring-to-front.svg b/assets/data/icons/RemixIcon/bring-to-front.svg new file mode 100644 index 0000000..3145f18 --- /dev/null +++ b/assets/data/icons/RemixIcon/bring-to-front.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/data/icons/RemixIcon/clipboard-line.svg b/assets/data/icons/RemixIcon/clipboard-line.svg new file mode 100644 index 0000000..6362c17 --- /dev/null +++ b/assets/data/icons/RemixIcon/clipboard-line.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/data/icons/RemixIcon/scissors-line.svg b/assets/data/icons/RemixIcon/scissors-line.svg new file mode 100644 index 0000000..561234a --- /dev/null +++ b/assets/data/icons/RemixIcon/scissors-line.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/data/icons/RemixIcon/send-to-back.svg b/assets/data/icons/RemixIcon/send-to-back.svg new file mode 100644 index 0000000..1e5c06f --- /dev/null +++ b/assets/data/icons/RemixIcon/send-to-back.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/AndroidJNICalls.cpp b/src/AndroidJNICalls.cpp index f08bffe..9788576 100644 --- a/src/AndroidJNICalls.cpp +++ b/src/AndroidJNICalls.cpp @@ -23,6 +23,7 @@ #include "MainProgram.hpp" #include #include +#include #include #include #include "NetThreadManager.hpp" @@ -96,6 +97,7 @@ namespace AndroidJNICalls { } void startNetworkService() { + Logger::get().log("INFO", "[AndroidJNICalls::startNetworkService] Start service"); JNIEnv* env = static_cast(SDL_GetAndroidJNIEnv()); jobject activity = (jobject)SDL_GetAndroidActivity(); jclass clazz = env->GetObjectClass(activity); @@ -106,6 +108,7 @@ namespace AndroidJNICalls { } void stopNetworkService() { + Logger::get().log("INFO", "[AndroidJNICalls::stopNetworkService] Stop service"); JNIEnv* env = static_cast(SDL_GetAndroidJNIEnv()); jobject activity = (jobject)SDL_GetAndroidActivity(); jclass clazz = env->GetObjectClass(activity); @@ -342,4 +345,4 @@ Java_com_erroratline0_infinipaint_InfiniPaintNetworkService_networkServiceDestro NetThreadManager::get().destroy_thread(); } -#endif \ No newline at end of file +#endif diff --git a/src/ClientData.cpp b/src/ClientData.cpp index 13988f4..729b32b 100644 --- a/src/ClientData.cpp +++ b/src/ClientData.cpp @@ -23,6 +23,12 @@ #include "MainProgram.hpp" #include "ScaleUpCanvas.hpp" +#include +#include +#include +#include +#include + using namespace NetworkingObjects; enum class ClientDataCommand : uint8_t { @@ -210,28 +216,42 @@ void ClientData::draw_cursor(SkCanvas* canvas, const DrawData& drawData) const { canvas->translate(cursorPos.x(), cursorPos.y()); - SkPaint p(SkColor4f{cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.2f}); - p.setAntiAlias(drawData.skiaAA); - canvas->drawCircle(0.0f, 0.0f, 4.5f, p); - p.setStroke(true); - p.setStrokeWidth(1.0f); - p.setColor4f({cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.7f}); - canvas->drawCircle(0.0f, 0.0f, 5.0f, p); + { + SkPaint p(SkColor4f{cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.3f}); + p.setAntiAlias(drawData.skiaAA); + canvas->drawCircle(0.0f, 0.0f, 4.5f, p); + p.setStroke(true); + p.setStrokeWidth(1.0f); + p.setColor4f({cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.6f}); + canvas->drawCircle(0.0f, 0.0f, 5.0f, p); + } - SkFont f = drawData.main->g.gui.io.get_font(18.0f); - SkFontMetrics metrics; - f.getMetrics(&metrics); + Vector2f bounds; + std::unique_ptr paragraph; + { + skia::textlayout::ParagraphStyle pStyle; + pStyle.setTextAlign(skia::textlayout::TextAlign::kLeft); + skia::textlayout::TextStyle tStyle; + tStyle.setFontSize(18.0f); + tStyle.setFontFamilies(drawData.main->g.gui.io.fonts->get_default_font_families()); + tStyle.setForegroundPaint(SkPaint{SkColor4f{cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.6f}}); + pStyle.setTextStyle(tStyle); - float nextText = f.measureText(displayName.c_str(), displayName.length(), SkTextEncoding::kUTF8, nullptr); - Vector2f bounds{nextText, - metrics.fAscent + metrics.fDescent}; + skia::textlayout::ParagraphBuilderImpl a(pStyle, drawData.main->g.gui.io.fonts->collection, SkUnicodes::ICU::Make()); + a.addText(displayName.c_str(), displayName.length()); + paragraph = a.Build(); + paragraph->layout(std::numeric_limits::max()); + + bounds = {paragraph->getMaxIntrinsicWidth(), paragraph->getHeight()}; + } - SkPaint p2(SkColor4f{cursorColor.x(), cursorColor.y(), cursorColor.z(), 0.5f}); - p2.setAntiAlias(drawData.skiaAA); - canvas->drawSimpleText(displayName.c_str(), displayName.length(), SkTextEncoding::kUTF8, 6.0f, -metrics.fDescent, f, p2); + Vector2f textPos = {6.0f, -bounds.y()}; - SkPaint p3(color_mul_alpha(drawData.main->g.gui.io.theme->backColor1, 0.5f)); + SkPaint p3(color_mul_alpha(drawData.main->g.gui.io.theme->backColor1, 0.6f)); p3.setAntiAlias(drawData.skiaAA); - canvas->drawRoundRect(SkRect::MakeXYWH(6.0f, -bounds.y(), bounds.x(), bounds.y()), 3.0f, 3.0f, p3); + canvas->drawRoundRect(SkRect::MakeXYWH(textPos.x(), textPos.y(), bounds.x(), bounds.y()), 3.0f, 3.0f, p3); + + paragraph->paint(canvas, textPos.x(), textPos.y()); canvas->restore(); } diff --git a/src/DrawingProgram/DrawingProgram.cpp b/src/DrawingProgram/DrawingProgram.cpp index b2e9ea5..a23cd82 100644 --- a/src/DrawingProgram/DrawingProgram.cpp +++ b/src/DrawingProgram/DrawingProgram.cpp @@ -443,6 +443,12 @@ void DrawingProgram::clear_right_click_popup() { } } +void DrawingProgram::paste_object_clipboard(const Vector2f& pos) { + selection.deselect_all(); + selection.paste_clipboard(pos); + world.main.g.gui.set_to_layout(); +} + void DrawingProgram::popup_menu_action_button(const char* id, const char* text, const std::function& onClick) { GUIStuff::GUIManager& gui = world.main.g.gui; @@ -793,11 +799,16 @@ Vector4f* DrawingProgram::color_picker_color(Vector4f* oldColor) { } bool DrawingProgram::phone_gui_tool_specific_bottom_toolbar_exists() { + if(selection.is_something_selected()) + return true; return drawTool->phone_gui_tool_specific_bottom_toolbar_exists(); } void DrawingProgram::phone_gui_tool_specific_bottom_toolbar(PhoneDrawingProgramScreen& t) { - drawTool->phone_gui_tool_specific_bottom_toolbar(t); + if(selection.is_something_selected()) + selection.phone_selection_bottom_toolbar(t); + else + drawTool->phone_gui_tool_specific_bottom_toolbar(t); } void DrawingProgram::draw(SkCanvas* canvas, const DrawData& drawData) { diff --git a/src/DrawingProgram/DrawingProgram.hpp b/src/DrawingProgram/DrawingProgram.hpp index df1028b..18645c7 100644 --- a/src/DrawingProgram/DrawingProgram.hpp +++ b/src/DrawingProgram/DrawingProgram.hpp @@ -102,6 +102,8 @@ class DrawingProgram { void set_right_click_popup_location(const Vector2f& newLoc); void clear_right_click_popup(); + void paste_object_clipboard(const Vector2f& pos); + std::unique_ptr drawTool; private: void process_transform_message(const std::vector>& transforms); @@ -154,7 +156,6 @@ class DrawingProgram { }; std::vector droppedDownloadingFiles; - std::optional rightClickPopupLocation; uint32_t nextID = 0; diff --git a/src/DrawingProgram/DrawingProgramSelection.cpp b/src/DrawingProgram/DrawingProgramSelection.cpp index 9473e22..bd45277 100644 --- a/src/DrawingProgram/DrawingProgramSelection.cpp +++ b/src/DrawingProgram/DrawingProgramSelection.cpp @@ -43,6 +43,7 @@ #include "../GUIStuff/ElementHelpers/TextLabelHelpers.hpp" #include "../GUIStuff/ElementHelpers/RadioButtonHelpers.hpp" #include "../GUIStuff/ElementHelpers/LayoutHelpers.hpp" +#include "../GUIStuff/ElementHelpers/ButtonHelpers.hpp" DrawingProgramSelection::DrawingProgramSelection(DrawingProgram& initDrawP): drawP(initDrawP) @@ -93,6 +94,85 @@ void DrawingProgramSelection::phone_selection_gui(PhoneDrawingProgramScreen& t) }); } +void DrawingProgramSelection::phone_selection_bottom_toolbar(PhoneDrawingProgramScreen& t) { + using namespace GUIStuff; + using namespace ElementHelpers; + + auto& gui = drawP.world.main.g.gui; + + CLAY_AUTO_ID({ + .layout = { + .sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0) }, + .childGap = gui.io.theme->childGap1, + .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_CENTER}, + .layoutDirection = CLAY_LEFT_TO_RIGHT + } + }) { + gui.element("selection bottom toolbar", [&](LayoutElement*, const Clay_ElementId& lId) { + CLAY(lId, { + .layout = { + .sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)} + }, + .backgroundColor = convert_vec4(gui.io.theme->backColor1), + .cornerRadius = CLAY_CORNER_RADIUS(gui.io.theme->windowCorners1) + }) { + gui.clipping_element("selection tools scroll", ScrollArea::Options{ + .scrollHorizontal = true, + .clipHorizontal = true, + .scrollbarX = ScrollArea::ScrollbarType::NONE, + .layoutDirection = CLAY_LEFT_TO_RIGHT, + .xAlign = CLAY_ALIGN_X_LEFT, + .yAlign = CLAY_ALIGN_Y_CENTER, + .innerContent = [&](auto&) { + phone_bottom_toolbar_gui(t); + } + }); + } + }); + } +} + +void DrawingProgramSelection::phone_bottom_toolbar_gui(PhoneDrawingProgramScreen& t) { + using namespace GUIStuff; + using namespace ElementHelpers; + + auto& gui = drawP.world.main.g.gui; + + gui.new_id("phone selection bottom toolbar", [&] { + svg_icon_button(gui, "Copy button", "data/icons/RemixIcon/file-copy-line.svg", { + .drawType = SelectableButton::DrawType::TRANSPARENT_ALL, + .onClick = [&] { + selection_to_clipboard(); + } + }); + svg_icon_button(gui, "Cut button", "data/icons/RemixIcon/scissors-line.svg", { + .drawType = SelectableButton::DrawType::TRANSPARENT_ALL, + .onClick = [&] { + selection_to_clipboard(); + delete_all(); + } + }); + svg_icon_button(gui, "Delete button", "data/icons/trash.svg", { + .drawType = SelectableButton::DrawType::TRANSPARENT_ALL, + .onClick = [&] { + delete_all(); + } + }); + svg_icon_button(gui, "Bring to front of layer", "data/icons/RemixIcon/bring-to-front.svg", { + .drawType = SelectableButton::DrawType::TRANSPARENT_ALL, + .onClick = [&] { + push_selection_to_front(); + } + }); + svg_icon_button(gui, "Send to back of layer", "data/icons/RemixIcon/send-to-back.svg", { + .drawType = SelectableButton::DrawType::TRANSPARENT_ALL, + .onClick = [&] { + push_selection_to_back(); + } + }); + }); +} + void DrawingProgramSelection::update_selection_stroke_color() { if(strokeColorChangeData.oldColor != strokeColorChangeData.newColor) { for(auto& c : selectedSet) { diff --git a/src/DrawingProgram/DrawingProgramSelection.hpp b/src/DrawingProgram/DrawingProgramSelection.hpp index 04b93ee..9e18dc5 100644 --- a/src/DrawingProgram/DrawingProgramSelection.hpp +++ b/src/DrawingProgram/DrawingProgramSelection.hpp @@ -30,6 +30,7 @@ class DrawingProgramSelection { DrawingProgramSelection(DrawingProgram& initDrawP); void selection_gui(Toolbar& t); void phone_selection_gui(PhoneDrawingProgramScreen& t); + void phone_selection_bottom_toolbar(PhoneDrawingProgramScreen& t); void add_from_cam_coord_collider_to_selection(const SCollision::ColliderCollection& cC, DrawingProgramLayerManager::LayerSelector layerSelector, bool frontObjectOnly); void remove_from_cam_coord_collider_to_selection(const SCollision::ColliderCollection& cC, DrawingProgramLayerManager::LayerSelector layerSelector, bool frontObjectOnly); void erase_component(CanvasComponentContainer::ObjInfo* objToCheck); @@ -54,6 +55,7 @@ class DrawingProgramSelection { void input_mouse_button_on_canvas_callback_modify_selection(const InputManager::MouseButtonCallbackArgs& button); void input_mouse_motion_callback_modify_selection(const InputManager::MouseMotionCallbackArgs& motion); private: + void phone_bottom_toolbar_gui(PhoneDrawingProgramScreen& t); void translate_key(unsigned keyPressed, bool pressed); bool mouse_collided_with_selection_aabb(); bool mouse_collided_with_scale_point(); diff --git a/src/DrawingProgram/Tools/EditTool.cpp b/src/DrawingProgram/Tools/EditTool.cpp index 76fa9d1..d6c9ba3 100644 --- a/src/DrawingProgram/Tools/EditTool.cpp +++ b/src/DrawingProgram/Tools/EditTool.cpp @@ -182,6 +182,7 @@ void EditTool::input_mouse_button_on_canvas_callback(const InputManager::MouseBu if(pointDragging) pointDragging = nullptr; } + drawP.world.main.g.gui.set_to_layout(); } } diff --git a/src/DrawingProgram/Tools/EditTools/TextBoxEditTool.cpp b/src/DrawingProgram/Tools/EditTools/TextBoxEditTool.cpp index f12ea94..8774c75 100644 --- a/src/DrawingProgram/Tools/EditTools/TextBoxEditTool.cpp +++ b/src/DrawingProgram/Tools/EditTools/TextBoxEditTool.cpp @@ -310,7 +310,7 @@ void TextBoxEditTool::phone_gui_tool_specific_bottom_toolbar(PhoneDrawingProgram .layoutDirection = CLAY_LEFT_TO_RIGHT } }) { - gui.element("bottom toolbar", [&](LayoutElement*, const Clay_ElementId& lId) { + gui.element("text bottom toolbar", [&](LayoutElement*, const Clay_ElementId& lId) { CLAY(lId, { .layout = { .sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)} @@ -318,7 +318,7 @@ void TextBoxEditTool::phone_gui_tool_specific_bottom_toolbar(PhoneDrawingProgram .backgroundColor = convert_vec4(io.theme->backColor1), .cornerRadius = CLAY_CORNER_RADIUS(io.theme->windowCorners1) }) { - gui.clipping_element("tools scroll", ScrollArea::Options{ + gui.clipping_element("text tools scroll", ScrollArea::Options{ .scrollHorizontal = true, .clipHorizontal = true, .scrollbarX = ScrollArea::ScrollbarType::NONE, diff --git a/src/GlobalConfig.cpp b/src/GlobalConfig.cpp index ebfcddc..52d3eb1 100644 --- a/src/GlobalConfig.cpp +++ b/src/GlobalConfig.cpp @@ -75,7 +75,7 @@ nlohmann::json GlobalConfig::get_config_json(const InputManager& input) const { toRet["tablet"] = tablet; json debugJson; - debugJson["showPerformance"] = showPerformance; + debugJson["mobileUI"] = mobileUI; debugJson["jumpTransitionEasing"] = jumpTransitionEasing; debugJson["imageLoadMaxThreads"] = ImageResourceDisplay::IMAGE_LOAD_THREAD_COUNT_MAX; debugJson["cacheNodeResolution"] = DrawingProgramCache::CACHE_NODE_RESOLUTION; @@ -142,7 +142,7 @@ void GlobalConfig::set_config_json(InputManager& input, const nlohmann::json& j, try{j.at("tablet").at("brushMinimumSize").get_to(tabletOptions.brushMinimumSize);} catch(...) {} try{j.at("tablet").at("zoomWhilePenDownAndButtonHeld").get_to(tabletOptions.zoomWhilePenDownAndButtonHeld);} catch(...) {} - try{j.at("debug").at("showPerformance").get_to(showPerformance);} catch(...) {} + try{j.at("debug").at("mobileUI").get_to(mobileUI);} catch(...) {} try{j.at("debug").at("jumpTransitionEasing").get_to(jumpTransitionEasing);} catch(...) {} try{j.at("debug").at("imageLoadMaxThreads").get_to(ImageResourceDisplay::IMAGE_LOAD_THREAD_COUNT_MAX);} catch(...) {} try{j.at("debug").at("cacheNodeResolution").get_to(DrawingProgramCache::CACHE_NODE_RESOLUTION);} catch(...) {} diff --git a/src/GlobalConfig.hpp b/src/GlobalConfig.hpp index d677012..1b58826 100644 --- a/src/GlobalConfig.hpp +++ b/src/GlobalConfig.hpp @@ -59,6 +59,12 @@ class GlobalConfig { bool viewWebVersionWelcome = false; #endif +#ifdef __ANDROID__ + bool mobileUI = true; +#else + bool mobileUI = false; +#endif + struct TabletOptions { bool pressureAffectsBrushWidth = true; float smoothingSamplingTime = 0.04f; diff --git a/src/InputManager.cpp b/src/InputManager.cpp index f5124f7..18bf042 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -29,6 +29,7 @@ #include #include +#include "Helpers/MathExtras.hpp" #include "MainProgram.hpp" #include "AndroidJNICalls.hpp" @@ -820,6 +821,17 @@ void InputManager::backend_touch_finger_up_update(const SDL_TouchFingerEvent& e) } void InputManager::backend_touch_finger_motion_update(const SDL_TouchFingerEvent& e) { + constexpr float MINIMUM_MOTION_TO_CONSIDER_SQRD = 20.0f * 20.0f; + + isTouchDevice = true; + + if(touch.fingers.size() == 1 && touch.touchEventType == Touch::NO_TOUCH_EVENT) { + Vector2f newPos = backend_touch_cursor_pos_calculation({e.x, e.y}) * main.window.scale; + Vector2f oldPos = backend_touch_cursor_pos_calculation({touch.fingers[0].x, touch.fingers[0].y}) * main.window.scale; + if(vec_distance_sqrd(newPos, oldPos) < MINIMUM_MOTION_TO_CONSIDER_SQRD) + return; + } + switch(touch.touchEventType) { case Touch::NO_TOUCH_EVENT: { touch_finger_do_mouse_down(); @@ -855,8 +867,6 @@ void InputManager::backend_touch_finger_motion_update(const SDL_TouchFingerEvent .move = backend_touch_cursor_delta_calculation({e.dx, e.dy}), .fingerDownCount = touch.fingers.size() }); - - isTouchDevice = true; } void InputManager::update_safe_area() { @@ -1133,10 +1143,10 @@ void InputManager::Mouse::set_pos(const Vector2f& newPos) { } void InputManager::update() { - if(touch.touchEventType == Touch::NO_TOUCH_EVENT && (SDL_GetTicksNS() - touch.fingers[0].timestamp) > (200 * 1000000)) { // 200ms to determine whether touch is with a single finger - touch_finger_do_mouse_down(); - touch.touchEventType = Touch::ONE_FINGER_EVENT; - } + //if(touch.touchEventType == Touch::NO_TOUCH_EVENT && (SDL_GetTicksNS() - touch.fingers[0].timestamp) > (200 * 1000000)) { // 200ms to determine whether touch is with a single finger + // touch_finger_do_mouse_down(); + // touch.touchEventType = Touch::ONE_FINGER_EVENT; + //} } void InputManager::frame_reset(const Vector2i& windowSize) { diff --git a/src/NetThreadManager.cpp b/src/NetThreadManager.cpp index 22d6cfd..842e588 100644 --- a/src/NetThreadManager.cpp +++ b/src/NetThreadManager.cpp @@ -1,5 +1,6 @@ #include "NetThreadManager.hpp" #include +#include #include "AndroidJNICalls.hpp" #include "MainProgram.hpp" @@ -30,6 +31,7 @@ void NetThreadManager::synchronous_update() { void NetThreadManager::init_thread() { if(t) throw std::runtime_error("[NetThreadManager::init_thread] Thread can't exist when init_thread is called"); + Logger::get().log("INFO", "[NetThreadManager::init_thread] Starting network thread"); destroyThread = false; t = std::make_unique([&]{ thread_update(); }); } @@ -58,6 +60,7 @@ void NetThreadManager::thread_update() { void NetThreadManager::destroy_thread() { if(!t) throw std::runtime_error("[NetThreadManager::init_thread] Thread can't be null when destroy_thread is called"); + Logger::get().log("INFO", "[NetThreadManager::destroy_thread] Stopping network thread"); destroyThread = true; t->join(); t = nullptr; diff --git a/src/Screens/FileSelectScreen.cpp b/src/Screens/FileSelectScreen.cpp index 58e9848..9d3ea48 100644 --- a/src/Screens/FileSelectScreen.cpp +++ b/src/Screens/FileSelectScreen.cpp @@ -44,7 +44,6 @@ using namespace GUIStuff; using namespace ElementHelpers; FileSelectScreen::FileSelectScreen(MainProgram& m): Screen(m) { - main.g.gui.io.isTouchDevice = true; savePath = main.conf.configPath / "saves"; trashPath = main.conf.configPath / "trash"; infoPath = main.conf.configPath / "fileSelectInfo.json"; @@ -938,6 +937,9 @@ void FileSelectScreen::settings_view() { }); input_scalar_field(gui, "jump transition time", "Jump transition time", &main.conf.jumpTransitionTime, 0.01f, 1000.0f, {.decimalPrecision = 2}); checkbox_boolean_field(gui, "make all tools share same size", "Make all tools share size", &main.toolConfig.globalConf.useGlobalRelativeWidth); +#ifndef __ANDROID__ + checkbox_boolean_field(gui, "use mobile UI", "Use mobile UI (requires restart)", &main.conf.mobileUI); +#endif } } } diff --git a/src/Screens/PhoneDrawingProgramScreen.cpp b/src/Screens/PhoneDrawingProgramScreen.cpp index 353367e..26cbae5 100644 --- a/src/Screens/PhoneDrawingProgramScreen.cpp +++ b/src/Screens/PhoneDrawingProgramScreen.cpp @@ -532,6 +532,14 @@ void PhoneDrawingProgramScreen::top_toolbar_hidden_button_popup(GUIStuff::Elemen } }); + l.emplace_back(TopToolbarRemainingAreaButton{ + .name = "Paste", + .svgPath = "data/icons/RemixIcon/clipboard-line.svg", + .onClick = [&] { + main.world->drawProg.paste_object_clipboard(main.window.safeArea.center()); + } + }); + if(!main.world->netClient && !main.world->netServer) { l.emplace_back(TopToolbarRemainingAreaButton{ .name = "Host", diff --git a/src/Toolbar.cpp b/src/Toolbar.cpp index 7225c3d..8d3902d 100644 --- a/src/Toolbar.cpp +++ b/src/Toolbar.cpp @@ -234,9 +234,6 @@ void Toolbar::layout_run() { player_list(); else if(!main.world->drawProg.layerMan.is_a_layer_being_edited()) center_message("Select layer to edit message", "Select a layer to edit"); - - if(showPerformance) - performance_metrics(); } if(!main.world->clientStillConnecting) chat_box(); @@ -1251,62 +1248,6 @@ void Toolbar::color_palette(const char* id, Vector4f* color, const std::function }); } -void Toolbar::performance_metrics() { - auto& gui = main.g.gui; - auto& io = gui.io; - - CLAY_AUTO_ID({ - .layout = { - .sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0) }, - .padding = CLAY_PADDING_ALL(io.theme->padding1), - .childGap = io.theme->childGap1, - .childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_BOTTOM}, - .layoutDirection = CLAY_LEFT_TO_RIGHT - }, - .floating = {.offset = {-10, -10}, .attachPoints = {.element = CLAY_ATTACH_POINT_RIGHT_BOTTOM, .parent = CLAY_ATTACH_POINT_RIGHT_BOTTOM}, .pointerCaptureMode = CLAY_POINTER_CAPTURE_MODE_PASSTHROUGH, .attachTo = CLAY_ATTACH_TO_PARENT} - }) { - CLAY_AUTO_ID({ - .layout = { - .sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0) }, - .padding = CLAY_PADDING_ALL(io.theme->padding1), - .childGap = io.theme->childGap1, - .childAlignment = { .x = CLAY_ALIGN_X_RIGHT, .y = CLAY_ALIGN_Y_TOP}, - .layoutDirection = CLAY_TOP_TO_BOTTOM - }, - .backgroundColor = convert_vec4(color_mul_alpha(io.theme->backColor1, 0.7f)), - }) { - text_label(gui, "Undo queue"); - std::vector undoList = main.world->undo.get_front_undo_queue_names(10); - for(const std::string& u : undoList) - text_label(gui, u); - } - CLAY_AUTO_ID({ - .layout = { - .sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0) }, - .padding = CLAY_PADDING_ALL(io.theme->padding1), - .childGap = io.theme->childGap1, - .childAlignment = { .x = CLAY_ALIGN_X_RIGHT, .y = CLAY_ALIGN_Y_TOP}, - .layoutDirection = CLAY_TOP_TO_BOTTOM - }, - .backgroundColor = convert_vec4(color_mul_alpha(io.theme->backColor1, 0.7f)), - }) { - std::stringstream a; - a << "FPS: " << std::fixed << std::setprecision(0) << (1.0 / main.deltaTime); - text_label(gui, a.str()); - text_label(gui, "Item Count: " + std::to_string(main.world->drawProg.layerMan.total_component_count())); - std::stringstream b; - b << "Coord: " << main.world->drawData.cam.c.pos.x().display_int_str(5) << ", " << main.world->drawData.cam.c.pos.y().display_int_str(5); - text_label(gui, b.str()); - std::stringstream c; - c << "Zoom: " << main.world->drawData.cam.c.inverseScale.display_int_str(5); - text_label(gui, c.str()); - std::stringstream d; - d << "Rotation: " << main.world->drawData.cam.c.rotation; - text_label(gui, d.str()); - } - } -} - void Toolbar::player_list() { auto& gui = main.g.gui; @@ -1767,7 +1708,7 @@ void Toolbar::general_settings_inner_gui() { } case GSETTINGS_DEBUG: { general_scroll_area("debug settings menu", [&] { - checkbox_boolean_field(gui, "show performance metrics", "Show metrics", &showPerformance); + checkbox_boolean_field(gui, "use mobile UI", "Use mobile UI (requires restart)", &main.conf.mobileUI); input_scalars_field(gui, "jump transition easing", "Jump easing", &main.conf.jumpTransitionEasing, 4, -10.0f, 10.0f, { .decimalPrecision = 2 }); input_scalar_field(gui, "image load max threads", "Maximum image loading threads", &ImageResourceDisplay::IMAGE_LOAD_THREAD_COUNT_MAX, 1, 10000); text_label_light(gui, "Cache related settings"); diff --git a/src/Toolbar.hpp b/src/Toolbar.hpp index 20a88ac..bd855fb 100644 --- a/src/Toolbar.hpp +++ b/src/Toolbar.hpp @@ -102,7 +102,6 @@ class Toolbar { void file_picker_gui_refresh_entries(); void file_picker_gui_done(); void file_picker_gui(); - void performance_metrics(); void color_picker_window(const char* id, Vector4f** color, GUIStuff::Element* b, const ColorSelectorData& colorSelectorData); void color_palette(const char* id, Vector4f* color, const std::function& onChange); void open_world_file(bool isClient, const std::string& netSource, const std::string& serverLocalID); @@ -159,8 +158,6 @@ class Toolbar { bool openedSaveAsMenu = false; } themeData; - bool showPerformance = false; - bool menuPopUpOpen = false; bool optionsMenuOpen = false; bool playerMenuOpen = false; diff --git a/src/main.cpp b/src/main.cpp index a429271..5e51c10 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -547,20 +547,23 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) { mS.m->window.canCreateSurfaces = true; resize_window(mS); - mS.m->set_first_screen(std::make_unique(*mS.m)); - - if(listOfFilesToOpenFromCommand.empty()) { - //mS.m->create_new_tab({ - // .isClient = false - //}); - } + if(mS.m->conf.mobileUI) + mS.m->set_first_screen(std::make_unique(*mS.m)); else { - for(std::filesystem::path& f : listOfFilesToOpenFromCommand) { + mS.m->set_first_screen(std::make_unique(*mS.m)); + if(listOfFilesToOpenFromCommand.empty()) { mS.m->create_new_tab({ - .isClient = false, - .filePathSource = f + .isClient = false }); } + else { + for(std::filesystem::path& f : listOfFilesToOpenFromCommand) { + mS.m->create_new_tab({ + .isClient = false, + .filePathSource = f + }); + } + } } mS.m->update(); // Run update once to make sure that callbacks dont crash