More android UI improvements

This commit is contained in:
Yousef Khadadeh 2026-05-14 20:21:45 +03:00
parent c083ccc1a9
commit 6921f57cfe
21 changed files with 196 additions and 104 deletions

View file

@ -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) {

View file

@ -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;

View file

@ -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) {

View file

@ -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();

View file

@ -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();
}
}

View file

@ -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,