More android UI improvements
This commit is contained in:
parent
c083ccc1a9
commit
6921f57cfe
21 changed files with 196 additions and 104 deletions
1
assets/data/icons/RemixIcon/bring-to-front.svg
Normal file
1
assets/data/icons/RemixIcon/bring-to-front.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M11 3C11.5523 3 12 3.44772 12 4V6H17C17.5523 6 18 6.44772 18 7V12H20C20.5523 12 21 12.4477 21 13V20C21 20.5523 20.5523 21 20 21H13C12.4477 21 12 20.5523 12 20V18H7C6.44772 18 6 17.5523 6 17V12H4C3.44772 12 3 11.5523 3 11V4C3 3.44772 3.44772 3 4 3H11ZM16 8H8V16H16V8Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 370 B |
1
assets/data/icons/RemixIcon/clipboard-line.svg
Normal file
1
assets/data/icons/RemixIcon/clipboard-line.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M7 4V2H17V4H20.0066C20.5552 4 21 4.44495 21 4.9934V21.0066C21 21.5552 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5551 3 21.0066V4.9934C3 4.44476 3.44495 4 3.9934 4H7ZM7 6H5V20H19V6H17V8H7V6ZM9 4V6H15V4H9Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 310 B |
1
assets/data/icons/RemixIcon/scissors-line.svg
Normal file
1
assets/data/icons/RemixIcon/scissors-line.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M9.44618 8.02867L12 10.5825L18.7279 3.85457C19.509 3.07352 20.7753 3.07352 21.5563 3.85457L9.44618 15.9647C9.79807 16.5603 10 17.2549 10 17.9967C10 20.2058 8.20914 21.9967 6 21.9967C3.79086 21.9967 2 20.2058 2 17.9967C2 15.7876 3.79086 13.9967 6 13.9967C6.74181 13.9967 7.43645 14.1986 8.03197 14.5505L10.5858 11.9967L8.03197 9.44289C7.43645 9.79478 6.74181 9.9967 6 9.9967C3.79086 9.9967 2 8.20584 2 5.9967C2 3.78756 3.79086 1.9967 6 1.9967C8.20914 1.9967 10 3.78756 10 5.9967C10 6.73851 9.79807 7.43316 9.44618 8.02867ZM14.8255 13.408L21.5563 20.1388C20.7753 20.9199 19.509 20.9199 18.7279 20.1388L13.4113 14.8222L14.8255 13.408ZM7.41421 16.5825C7.05228 16.2206 6.55228 15.9967 6 15.9967C4.89543 15.9967 4 16.8921 4 17.9967C4 19.1013 4.89543 19.9967 6 19.9967C7.10457 19.9967 8 19.1013 8 17.9967C8 17.4444 7.77614 16.9444 7.41421 16.5825ZM7.41421 7.41092C7.77614 7.04899 8 6.54899 8 5.9967C8 4.89213 7.10457 3.9967 6 3.9967C4.89543 3.9967 4 4.89213 4 5.9967C4 7.10127 4.89543 7.9967 6 7.9967C6.55228 7.9967 7.05228 7.77285 7.41421 7.41092Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
1
assets/data/icons/RemixIcon/send-to-back.svg
Normal file
1
assets/data/icons/RemixIcon/send-to-back.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M11 3C11.5523 3 12 3.44772 12 4V6H17C17.5523 6 18 6.44772 18 7V12H20C20.5523 12 21 12.4477 21 13V20C21 20.5523 20.5523 21 20 21H13C12.4477 21 12 20.5523 12 20V18H7C6.44772 18 6 17.5523 6 17V12H4C3.44772 12 3 11.5523 3 11V4C3 3.44772 3.44772 3 4 3H11ZM16 8H12V11C12 11.5523 11.5523 12 11 12H8V16H12V13C12 12.4477 12.4477 12 13 12H16V8Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 438 B |
|
|
@ -23,6 +23,7 @@
|
|||
#include "MainProgram.hpp"
|
||||
#include <SDL3/SDL_system.h>
|
||||
#include <string>
|
||||
#include <Helpers/Logger.hpp>
|
||||
#include <modules/skunicode/include/SkUnicode.h>
|
||||
#include <modules/skunicode/include/SkUnicode_icu.h>
|
||||
#include "NetThreadManager.hpp"
|
||||
|
|
@ -96,6 +97,7 @@ namespace AndroidJNICalls {
|
|||
}
|
||||
|
||||
void startNetworkService() {
|
||||
Logger::get().log("INFO", "[AndroidJNICalls::startNetworkService] Start service");
|
||||
JNIEnv* env = static_cast<JNIEnv*>(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<JNIEnv*>(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
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@
|
|||
#include "MainProgram.hpp"
|
||||
#include "ScaleUpCanvas.hpp"
|
||||
|
||||
#include <modules/skparagraph/src/ParagraphBuilderImpl.h>
|
||||
#include <modules/skparagraph/include/ParagraphStyle.h>
|
||||
#include <modules/skparagraph/include/FontCollection.h>
|
||||
#include <modules/skparagraph/include/TextStyle.h>
|
||||
#include <modules/skunicode/include/SkUnicode_icu.h>
|
||||
|
||||
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<skia::textlayout::Paragraph> 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<float>::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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<void()>& 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) {
|
||||
|
|
|
|||
|
|
@ -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<DrawingProgramToolBase> drawTool;
|
||||
private:
|
||||
void process_transform_message(const std::vector<std::pair<NetworkingObjects::NetObjID, CoordSpaceHelper>>& transforms);
|
||||
|
|
@ -154,7 +156,6 @@ class DrawingProgram {
|
|||
};
|
||||
std::vector<DroppedDownloadingFile> droppedDownloadingFiles;
|
||||
|
||||
|
||||
std::optional<Vector2f> rightClickPopupLocation;
|
||||
|
||||
uint32_t nextID = 0;
|
||||
|
|
|
|||
|
|
@ -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<LayoutElement>("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<Clay_Color>(gui.io.theme->backColor1),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(gui.io.theme->windowCorners1)
|
||||
}) {
|
||||
gui.clipping_element<ScrollArea>("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) {
|
||||
|
|
|
|||
|
|
@ -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<float>& cC, DrawingProgramLayerManager::LayerSelector layerSelector, bool frontObjectOnly);
|
||||
void remove_from_cam_coord_collider_to_selection(const SCollision::ColliderCollection<float>& 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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ void TextBoxEditTool::phone_gui_tool_specific_bottom_toolbar(PhoneDrawingProgram
|
|||
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
||||
}
|
||||
}) {
|
||||
gui.element<LayoutElement>("bottom toolbar", [&](LayoutElement*, const Clay_ElementId& lId) {
|
||||
gui.element<LayoutElement>("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<Clay_Color>(io.theme->backColor1),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(io.theme->windowCorners1)
|
||||
}) {
|
||||
gui.clipping_element<ScrollArea>("tools scroll", ScrollArea::Options{
|
||||
gui.clipping_element<ScrollArea>("text tools scroll", ScrollArea::Options{
|
||||
.scrollHorizontal = true,
|
||||
.clipHorizontal = true,
|
||||
.scrollbarX = ScrollArea::ScrollbarType::NONE,
|
||||
|
|
|
|||
|
|
@ -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(...) {}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <optional>
|
||||
|
||||
#include <Helpers/Logger.hpp>
|
||||
#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) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "NetThreadManager.hpp"
|
||||
#include <Helpers/Networking/NetLibrary.hpp>
|
||||
#include <Helpers/Logger.hpp>
|
||||
#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<std::thread>([&]{ 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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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<Clay_Color>(color_mul_alpha(io.theme->backColor1, 0.7f)),
|
||||
}) {
|
||||
text_label(gui, "Undo queue");
|
||||
std::vector<std::string> 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<Clay_Color>(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<int>(gui, "image load max threads", "Maximum image loading threads", &ImageResourceDisplay::IMAGE_LOAD_THREAD_COUNT_MAX, 1, 10000);
|
||||
text_label_light(gui, "Cache related settings");
|
||||
|
|
|
|||
|
|
@ -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<void()>& 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;
|
||||
|
|
|
|||
23
src/main.cpp
23
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<FileSelectScreen>(*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<FileSelectScreen>(*mS.m));
|
||||
else {
|
||||
for(std::filesystem::path& f : listOfFilesToOpenFromCommand) {
|
||||
mS.m->set_first_screen(std::make_unique<DesktopDrawingProgramScreen>(*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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue