Separating safe window area from window area
This commit is contained in:
parent
97d299a346
commit
b1f6f04d37
18 changed files with 121 additions and 102 deletions
|
|
@ -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<void()>& innerContent) {
|
||||
using namespace GUIStuff;
|
||||
using namespace ElementHelpers;
|
||||
|
||||
GUIStuff::GUIManager& gui = world.main.g.gui;
|
||||
|
||||
gui.set_z_index(-1, [&] {
|
||||
gui.element<PositionAdjustingPopupMenu>("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<Clay_Color>(gui.io.theme->backColor1),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(gui.io.theme->windowCorners1)
|
||||
}) {
|
||||
innerContent();
|
||||
}
|
||||
}, LayoutElement::Callbacks{
|
||||
.mouseButton = [&](LayoutElement* l, const InputManager::MouseButtonCallbackArgs& button) {
|
||||
|
|
|
|||
|
|
@ -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<void()>& innerContent);
|
||||
void popup_menu_action_button(const char* id, const char* text, const std::function<void()>& onClick);
|
||||
void rebuild_cache();
|
||||
|
||||
|
|
|
|||
|
|
@ -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<TextBoxCanvasComponent&>(comp->obj->get_comp());
|
||||
|
||||
gui.set_z_index(-1, [&] {
|
||||
gui.element<PositionAdjustingPopupMenu>("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);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue