Fixed multiple segfaults
This commit is contained in:
parent
b4c35124c3
commit
2ad5684594
32 changed files with 1035 additions and 1010 deletions
|
|
@ -329,49 +329,50 @@ void DrawingProgram::toolbar_gui() {
|
|||
using namespace ElementHelpers;
|
||||
|
||||
Toolbar& t = world.main.toolbar;
|
||||
t.gui.push_id("Drawing Program Toolbar GUI");
|
||||
t.gui.element<LayoutElement>("Drawing Program Toolbar GUI", [&] {
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)},
|
||||
.padding = CLAY_PADDING_ALL(static_cast<uint16_t>(t.io->theme->padding1 / 2)),
|
||||
.childGap = static_cast<uint16_t>(t.io->theme->childGap1 / 2),
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
||||
},
|
||||
.backgroundColor = convert_vec4<Clay_Color>(t.io->theme->backColor1),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(t.io->theme->windowCorners1)
|
||||
}) {
|
||||
t.gui.new_id("Drawing Program Toolbar GUI", [&] {
|
||||
t.gui.element<LayoutElement>("Drawing Program Toolbar GUI", [&] {
|
||||
CLAY_AUTO_ID({
|
||||
.layout = {
|
||||
.sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)},
|
||||
.padding = CLAY_PADDING_ALL(static_cast<uint16_t>(t.io->theme->padding1 / 2)),
|
||||
.childGap = static_cast<uint16_t>(t.io->theme->childGap1 / 2),
|
||||
.childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
|
||||
.layoutDirection = CLAY_TOP_TO_BOTTOM
|
||||
},
|
||||
.backgroundColor = convert_vec4<Clay_Color>(t.io->theme->backColor1),
|
||||
.cornerRadius = CLAY_CORNER_RADIUS(t.io->theme->windowCorners1)
|
||||
}) {
|
||||
|
||||
auto tool_button = [&](const char* id, const std::string& svgPath, DrawingProgramToolType toolType) {
|
||||
svg_icon_button(t.gui, id, svgPath, {
|
||||
.drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
|
||||
.isSelected = drawTool->get_type() == toolType,
|
||||
.onClick = [&, toolType] {
|
||||
switch_to_tool(toolType);
|
||||
}
|
||||
auto tool_button = [&](const char* id, const std::string& svgPath, DrawingProgramToolType toolType) {
|
||||
svg_icon_button(t.gui, id, svgPath, {
|
||||
.drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
|
||||
.isSelected = drawTool->get_type() == toolType,
|
||||
.onClick = [&, toolType] {
|
||||
switch_to_tool(toolType);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
tool_button("Brush Toolbar Button", "data/icons/brush.svg", DrawingProgramToolType::BRUSH);
|
||||
tool_button("Eraser Toolbar Button", "data/icons/eraser.svg", DrawingProgramToolType::ERASER);
|
||||
tool_button("Line Toolbar Button", "data/icons/line.svg", DrawingProgramToolType::LINE);
|
||||
tool_button("Text Toolbar Button", "data/icons/text.svg", DrawingProgramToolType::TEXTBOX);
|
||||
tool_button("Ellipse Toolbar Button", "data/icons/circle.svg", DrawingProgramToolType::ELLIPSE);
|
||||
tool_button("Rect Toolbar Button", "data/icons/rectangle.svg", DrawingProgramToolType::RECTANGLE);
|
||||
tool_button("RectSelect Toolbar Button", "data/icons/rectselect.svg", DrawingProgramToolType::RECTSELECT);
|
||||
tool_button("LassoSelect Toolbar Button", "data/icons/lassoselect.svg", DrawingProgramToolType::LASSOSELECT);
|
||||
tool_button("Edit Toolbar Button", "data/icons/cursor.svg", DrawingProgramToolType::EDIT);
|
||||
tool_button("Eyedropper Toolbar Button", "data/icons/eyedropper.svg", DrawingProgramToolType::EYEDROPPER);
|
||||
tool_button("Zoom Canvas Toolbar Button", "data/icons/zoom.svg", DrawingProgramToolType::ZOOM);
|
||||
tool_button("Pan Canvas Toolbar Button", "data/icons/hand.svg", DrawingProgramToolType::PAN);
|
||||
|
||||
std::shared_ptr<double> oldRotationAngle = std::make_shared<double>(world.drawData.cam.c.rotation);
|
||||
t.gui.element<RotateWheel>("Canvas Rotate Wheel", &world.drawData.cam.c.rotation, [&, oldRotationAngle] {
|
||||
world.drawData.cam.c.rotate_about(world.drawData.cam.c.from_space(world.main.window.size.cast<float>() * 0.5f), world.drawData.cam.c.rotation - *oldRotationAngle);
|
||||
*oldRotationAngle = world.drawData.cam.c.rotation;
|
||||
});
|
||||
};
|
||||
|
||||
tool_button("Brush Toolbar Button", "data/icons/brush.svg", DrawingProgramToolType::BRUSH);
|
||||
tool_button("Eraser Toolbar Button", "data/icons/eraser.svg", DrawingProgramToolType::ERASER);
|
||||
tool_button("Line Toolbar Button", "data/icons/line.svg", DrawingProgramToolType::LINE);
|
||||
tool_button("Text Toolbar Button", "data/icons/text.svg", DrawingProgramToolType::TEXTBOX);
|
||||
tool_button("Ellipse Toolbar Button", "data/icons/circle.svg", DrawingProgramToolType::ELLIPSE);
|
||||
tool_button("Rect Toolbar Button", "data/icons/rectangle.svg", DrawingProgramToolType::RECTANGLE);
|
||||
tool_button("RectSelect Toolbar Button", "data/icons/rectselect.svg", DrawingProgramToolType::RECTSELECT);
|
||||
tool_button("LassoSelect Toolbar Button", "data/icons/lassoselect.svg", DrawingProgramToolType::LASSOSELECT);
|
||||
tool_button("Edit Toolbar Button", "data/icons/cursor.svg", DrawingProgramToolType::EDIT);
|
||||
tool_button("Eyedropper Toolbar Button", "data/icons/eyedropper.svg", DrawingProgramToolType::EYEDROPPER);
|
||||
tool_button("Zoom Canvas Toolbar Button", "data/icons/zoom.svg", DrawingProgramToolType::ZOOM);
|
||||
tool_button("Pan Canvas Toolbar Button", "data/icons/hand.svg", DrawingProgramToolType::PAN);
|
||||
|
||||
std::shared_ptr<double> oldRotationAngle = std::make_shared<double>(world.drawData.cam.c.rotation);
|
||||
t.gui.element<RotateWheel>("Canvas Rotate Wheel", &world.drawData.cam.c.rotation, [&, oldRotationAngle] {
|
||||
world.drawData.cam.c.rotate_about(world.drawData.cam.c.from_space(world.main.window.size.cast<float>() * 0.5f), world.drawData.cam.c.rotation - *oldRotationAngle);
|
||||
*oldRotationAngle = world.drawData.cam.c.rotation;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -422,9 +423,9 @@ void DrawingProgram::selection_action_menu(Vector2f popupPos) {
|
|||
|
||||
void DrawingProgram::right_click_popup_gui(Vector2f popupPos) {
|
||||
Toolbar& t = world.main.toolbar;
|
||||
t.gui.push_id("Drawing Program right click GUI");
|
||||
drawTool->right_click_popup_gui(popupPos);
|
||||
t.gui.pop_id();
|
||||
t.gui.new_id("Drawing Program right click GUI", [&] {
|
||||
drawTool->right_click_popup_gui(popupPos);
|
||||
});
|
||||
}
|
||||
|
||||
void DrawingProgram::tool_options_gui() {
|
||||
|
|
|
|||
|
|
@ -36,24 +36,24 @@ void DrawingProgramSelection::selection_gui() {
|
|||
using namespace ElementHelpers;
|
||||
|
||||
auto& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("general selection gui");
|
||||
text_label(t.gui, "Select from:");
|
||||
radio_button_selector(t.gui, "layer selector", &drawP.controls.layerSelector, {
|
||||
{"Layer being edited", DrawingProgramLayerManager::LayerSelector::LAYER_BEING_EDITED},
|
||||
{"All visible layers", DrawingProgramLayerManager::LayerSelector::ALL_VISIBLE_LAYERS}
|
||||
});
|
||||
if(is_something_selected()) {
|
||||
left_to_right_line_layout(t.gui, [&]() {
|
||||
//if(t.gui.color_button_big("Stroke Color Button", &strokeColorChangeData.newColor, &strokeColorChangeData.newColor == t.colorRight)) {
|
||||
// if(strokeColorChangeData.newColor.w() == 0.0f)
|
||||
// strokeColorChangeData.newColor.w() = 1.0f;
|
||||
// t.color_selector_right(&strokeColorChangeData.newColor == t.colorRight ? nullptr : &strokeColorChangeData.newColor);
|
||||
//}
|
||||
text_label(t.gui, "Stroke Color");
|
||||
t.gui.new_id("general selection gui", [&] {
|
||||
text_label(t.gui, "Select from:");
|
||||
radio_button_selector(t.gui, "layer selector", &drawP.controls.layerSelector, {
|
||||
{"Layer being edited", DrawingProgramLayerManager::LayerSelector::LAYER_BEING_EDITED},
|
||||
{"All visible layers", DrawingProgramLayerManager::LayerSelector::ALL_VISIBLE_LAYERS}
|
||||
});
|
||||
update_selection_stroke_color();
|
||||
}
|
||||
t.gui.pop_id();
|
||||
if(is_something_selected()) {
|
||||
left_to_right_line_layout(t.gui, [&]() {
|
||||
//if(t.gui.color_button_big("Stroke Color Button", &strokeColorChangeData.newColor, &strokeColorChangeData.newColor == t.colorRight)) {
|
||||
// if(strokeColorChangeData.newColor.w() == 0.0f)
|
||||
// strokeColorChangeData.newColor.w() = 1.0f;
|
||||
// t.color_selector_right(&strokeColorChangeData.newColor == t.colorRight ? nullptr : &strokeColorChangeData.newColor);
|
||||
//}
|
||||
text_label(t.gui, "Stroke Color");
|
||||
});
|
||||
update_selection_stroke_color();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void DrawingProgramSelection::update_selection_stroke_color() {
|
||||
|
|
|
|||
|
|
@ -172,11 +172,11 @@ void BrushTool::gui_toolbox() {
|
|||
using namespace ElementHelpers;
|
||||
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("brush tool");
|
||||
text_label_centered(t.gui, "Brush");
|
||||
checkbox_boolean_field(t.gui, "hasroundcaps", "Round Caps", &drawP.world.main.toolConfig.brush.hasRoundCaps);
|
||||
drawP.world.main.toolConfig.relative_width_gui(drawP, "Size");
|
||||
t.gui.pop_id();
|
||||
t.gui.new_id("brush tool", [&] {
|
||||
text_label_centered(t.gui, "Brush");
|
||||
checkbox_boolean_field(t.gui, "hasroundcaps", "Round Caps", &drawP.world.main.toolConfig.brush.hasRoundCaps);
|
||||
drawP.world.main.toolConfig.relative_width_gui(drawP, "Size");
|
||||
});
|
||||
}
|
||||
|
||||
void BrushTool::right_click_popup_gui(Vector2f popupPos) {
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ void EditTool::gui_toolbox() {
|
|||
if(objInfoBeingEdited)
|
||||
compEditTool->edit_gui(objInfoBeingEdited);
|
||||
else {
|
||||
t.gui.push_id("edit tool");
|
||||
text_label_centered(t.gui, "Edit");
|
||||
t.gui.pop_id();
|
||||
t.gui.new_id("edit tool", [&] {
|
||||
text_label_centered(t.gui, "Edit");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ void BrushEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
|
|||
using namespace ElementHelpers;
|
||||
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("edit tool brush");
|
||||
text_label_centered(t.gui, "Edit Brush Stroke");
|
||||
left_to_right_line_layout(t.gui, [&]() {
|
||||
//if(t.gui.color_button_big("Outline Color", &a.d.color, &a.d.color == t.colorRight))
|
||||
// t.color_selector_right(&a.d.color == t.colorRight ? nullptr : &a.d.color);
|
||||
text_label(t.gui, "Outline Color");
|
||||
t.gui.new_id("edit tool brush", [&] {
|
||||
text_label_centered(t.gui, "Edit Brush Stroke");
|
||||
left_to_right_line_layout(t.gui, [&]() {
|
||||
//if(t.gui.color_button_big("Outline Color", &a.d.color, &a.d.color == t.colorRight))
|
||||
// t.color_selector_right(&a.d.color == t.colorRight ? nullptr : &a.d.color);
|
||||
text_label(t.gui, "Outline Color");
|
||||
});
|
||||
});
|
||||
t.gui.pop_id();
|
||||
}
|
||||
|
||||
void BrushEditTool::edit_start(EditTool& editTool, CanvasComponentContainer::ObjInfo* comp, std::any& prevData) {
|
||||
|
|
|
|||
|
|
@ -23,29 +23,29 @@ void EllipseDrawEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
|
|||
auto& a = static_cast<EllipseCanvasComponent&>(comp->obj->get_comp());
|
||||
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("edit tool ellipse");
|
||||
text_label_centered(t.gui, "Edit Ellipse");
|
||||
radio_button_selector(t.gui, "Fill selector", &a.d.fillStrokeMode, {
|
||||
{"Fill only", 0},
|
||||
{"Outline only", 1},
|
||||
{"Fill and outline", 2}
|
||||
t.gui.new_id("edit tool ellipse", [&] {
|
||||
text_label_centered(t.gui, "Edit Ellipse");
|
||||
radio_button_selector(t.gui, "Fill selector", &a.d.fillStrokeMode, {
|
||||
{"Fill only", 0},
|
||||
{"Outline only", 1},
|
||||
{"Fill and outline", 2}
|
||||
});
|
||||
if(a.d.fillStrokeMode == 0 || a.d.fillStrokeMode == 2) {
|
||||
left_to_right_line_layout(t.gui, [&] {
|
||||
//if(t.gui.color_button_big("Fill Color", &a.d.fillColor, &a.d.fillColor == t.colorRight))
|
||||
// t.color_selector_right(&a.d.fillColor == t.colorRight ? nullptr : &a.d.fillColor);
|
||||
text_label(t.gui, "Fill Color");
|
||||
});
|
||||
}
|
||||
if(a.d.fillStrokeMode == 1 || a.d.fillStrokeMode == 2) {
|
||||
slider_scalar_field(t.gui, "relstrokewidth", "Outline Size", &a.d.strokeWidth, 3.0f, 40.0f);
|
||||
left_to_right_line_layout(t.gui, [&] {
|
||||
//if(t.gui.color_button_big("Outline Color", &a.d.strokeColor, &a.d.strokeColor == t.colorRight))
|
||||
// t.color_selector_right(&a.d.strokeColor == t.colorRight ? nullptr : &a.d.strokeColor);
|
||||
text_label(t.gui, "Outline Color");
|
||||
});
|
||||
}
|
||||
});
|
||||
if(a.d.fillStrokeMode == 0 || a.d.fillStrokeMode == 2) {
|
||||
left_to_right_line_layout(t.gui, [&] {
|
||||
//if(t.gui.color_button_big("Fill Color", &a.d.fillColor, &a.d.fillColor == t.colorRight))
|
||||
// t.color_selector_right(&a.d.fillColor == t.colorRight ? nullptr : &a.d.fillColor);
|
||||
text_label(t.gui, "Fill Color");
|
||||
});
|
||||
}
|
||||
if(a.d.fillStrokeMode == 1 || a.d.fillStrokeMode == 2) {
|
||||
slider_scalar_field(t.gui, "relstrokewidth", "Outline Size", &a.d.strokeWidth, 3.0f, 40.0f);
|
||||
left_to_right_line_layout(t.gui, [&] {
|
||||
//if(t.gui.color_button_big("Outline Color", &a.d.strokeColor, &a.d.strokeColor == t.colorRight))
|
||||
// t.color_selector_right(&a.d.strokeColor == t.colorRight ? nullptr : &a.d.strokeColor);
|
||||
text_label(t.gui, "Outline Color");
|
||||
});
|
||||
}
|
||||
t.gui.pop_id();
|
||||
}
|
||||
|
||||
void EllipseDrawEditTool::edit_start(EditTool& editTool, CanvasComponentContainer::ObjInfo* comp, std::any& prevData) {
|
||||
|
|
|
|||
|
|
@ -51,29 +51,29 @@ void ImageEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
|
|||
|
||||
ImageCanvasComponent& a = static_cast<ImageCanvasComponent&>(comp->obj->get_comp());
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("edit tool image");
|
||||
text_label_centered(t.gui, "File Properties");
|
||||
auto resourceData = drawP.world.netObjMan.get_obj_temporary_ref_from_id<ResourceData>(a.d.imageID);
|
||||
t.gui.new_id("edit tool image", [&] {
|
||||
text_label_centered(t.gui, "File Properties");
|
||||
auto resourceData = drawP.world.netObjMan.get_obj_temporary_ref_from_id<ResourceData>(a.d.imageID);
|
||||
|
||||
if(resourceData) {
|
||||
text_label(t.gui, "Name: " + resourceData->name);
|
||||
text_button(t.gui, "file download", "Download file", {
|
||||
.wide = true,
|
||||
.onClick = [&] {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_browser_file::download(
|
||||
resourceData->name,
|
||||
"application/octet-binary",
|
||||
*resourceData->data
|
||||
);
|
||||
#endif
|
||||
t.open_file_selector("Download File", {{"Any File", "*"}}, [resourceData](const std::filesystem::path& p, const auto& e) {
|
||||
SDL_SaveFile(p.c_str(), resourceData->data->c_str(), resourceData->data->size());
|
||||
}, resourceData->name, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
text_label_centered(t.gui, "Loading resource...");
|
||||
t.gui.pop_id();
|
||||
if(resourceData) {
|
||||
text_label(t.gui, "Name: " + resourceData->name);
|
||||
text_button(t.gui, "file download", "Download file", {
|
||||
.wide = true,
|
||||
.onClick = [&] {
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_browser_file::download(
|
||||
resourceData->name,
|
||||
"application/octet-binary",
|
||||
*resourceData->data
|
||||
);
|
||||
#endif
|
||||
t.open_file_selector("Download File", {{"Any File", "*"}}, [resourceData](const std::filesystem::path& p, const auto& e) {
|
||||
SDL_SaveFile(p.c_str(), resourceData->data->c_str(), resourceData->data->size());
|
||||
}, resourceData->name, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
text_label_centered(t.gui, "Loading resource...");
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,30 +19,30 @@ void RectDrawEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
|
|||
|
||||
auto& a = static_cast<RectangleCanvasComponent&>(comp->obj->get_comp());
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("edit tool rectangle");
|
||||
text_label_centered(t.gui, "Edit Rectangle");
|
||||
slider_scalar_field(t.gui, "relradiuswidth", "Corner Radius", &a.d.cornerRadius, 0.0f, 40.0f);
|
||||
radio_button_selector(t.gui, "Fill selector", &a.d.fillStrokeMode, {
|
||||
{"Fill only", 0},
|
||||
{"Outline only", 1},
|
||||
{"Fill and outline", 2}
|
||||
t.gui.new_id("edit tool rectangle", [&] {
|
||||
text_label_centered(t.gui, "Edit Rectangle");
|
||||
slider_scalar_field(t.gui, "relradiuswidth", "Corner Radius", &a.d.cornerRadius, 0.0f, 40.0f);
|
||||
radio_button_selector(t.gui, "Fill selector", &a.d.fillStrokeMode, {
|
||||
{"Fill only", 0},
|
||||
{"Outline only", 1},
|
||||
{"Fill and outline", 2}
|
||||
});
|
||||
if(a.d.fillStrokeMode == 0 || a.d.fillStrokeMode == 2) {
|
||||
left_to_right_line_layout(t.gui, [&] {
|
||||
//if(t.gui.color_button_big("Fill Color", &a.d.fillColor, &a.d.fillColor == t.colorRight))
|
||||
// t.color_selector_right(&a.d.fillColor == t.colorRight ? nullptr : &a.d.fillColor);
|
||||
text_label(t.gui, "Fill Color");
|
||||
});
|
||||
}
|
||||
if(a.d.fillStrokeMode == 1 || a.d.fillStrokeMode == 2) {
|
||||
slider_scalar_field(t.gui, "relstrokewidth", "Outline Size", &a.d.strokeWidth, 3.0f, 40.0f);
|
||||
left_to_right_line_layout(t.gui, [&] {
|
||||
//if(t.gui.color_button_big("Outline Color", &a.d.strokeColor, &a.d.strokeColor == t.colorRight))
|
||||
// t.color_selector_right(&a.d.strokeColor == t.colorRight ? nullptr : &a.d.strokeColor);
|
||||
text_label(t.gui, "Outline Color");
|
||||
});
|
||||
}
|
||||
});
|
||||
if(a.d.fillStrokeMode == 0 || a.d.fillStrokeMode == 2) {
|
||||
left_to_right_line_layout(t.gui, [&] {
|
||||
//if(t.gui.color_button_big("Fill Color", &a.d.fillColor, &a.d.fillColor == t.colorRight))
|
||||
// t.color_selector_right(&a.d.fillColor == t.colorRight ? nullptr : &a.d.fillColor);
|
||||
text_label(t.gui, "Fill Color");
|
||||
});
|
||||
}
|
||||
if(a.d.fillStrokeMode == 1 || a.d.fillStrokeMode == 2) {
|
||||
slider_scalar_field(t.gui, "relstrokewidth", "Outline Size", &a.d.strokeWidth, 3.0f, 40.0f);
|
||||
left_to_right_line_layout(t.gui, [&] {
|
||||
//if(t.gui.color_button_big("Outline Color", &a.d.strokeColor, &a.d.strokeColor == t.colorRight))
|
||||
// t.color_selector_right(&a.d.strokeColor == t.colorRight ? nullptr : &a.d.strokeColor);
|
||||
text_label(t.gui, "Outline Color");
|
||||
});
|
||||
}
|
||||
t.gui.pop_id();
|
||||
}
|
||||
|
||||
void RectDrawEditTool::edit_start(EditTool& editTool, CanvasComponentContainer::ObjInfo* comp, std::any& prevData) {
|
||||
|
|
|
|||
|
|
@ -33,122 +33,122 @@ void TextBoxEditTool::edit_gui(CanvasComponentContainer::ObjInfo* comp) {
|
|||
|
||||
auto& currentMods = *currentModsPtr;
|
||||
|
||||
t.gui.push_id("edit tool text");
|
||||
text_label_centered(t.gui, "Edit Text");
|
||||
t.gui.new_id("edit tool text", [&] {
|
||||
text_label_centered(t.gui, "Edit Text");
|
||||
|
||||
left_to_right_line_layout(t.gui, [&] {
|
||||
text_label(t.gui, "Font");
|
||||
//if(t.gui.font_picker("font picker", &newFontName)) {
|
||||
// currentMods[TextStyleModifier::ModifierType::FONT_FAMILIES] = std::make_shared<FontFamiliesTextStyleModifier>(std::vector<SkString>{SkString{newFontName.c_str(), newFontName.size()}});
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::FONT_FAMILIES]);});
|
||||
left_to_right_line_layout(t.gui, [&] {
|
||||
text_label(t.gui, "Font");
|
||||
//if(t.gui.font_picker("font picker", &newFontName)) {
|
||||
// currentMods[TextStyleModifier::ModifierType::FONT_FAMILIES] = std::make_shared<FontFamiliesTextStyleModifier>(std::vector<SkString>{SkString{newFontName.c_str(), newFontName.size()}});
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::FONT_FAMILIES]);});
|
||||
//}
|
||||
});
|
||||
|
||||
//left_to_right_line_centered_layout(t.gui, [&] {
|
||||
// if(svg_icon_button("Bold button", "data/icons/RemixIcon/bold.svg", newIsBold)) {
|
||||
// newIsBold = !newIsBold;
|
||||
// currentMods[TextStyleModifier::ModifierType::WEIGHT] = std::make_shared<WeightTextStyleModifier>(newIsBold ? SkFontStyle::Weight::kBold_Weight : SkFontStyle::Weight::kNormal_Weight);
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::WEIGHT]);});
|
||||
// }
|
||||
|
||||
// if(t.gui.svg_icon_button("Italic button", "data/icons/RemixIcon/italic.svg", newIsItalic)) {
|
||||
// newIsItalic = !newIsItalic;
|
||||
// currentMods[TextStyleModifier::ModifierType::SLANT] = std::make_shared<SlantTextStyleModifier>(newIsItalic ? SkFontStyle::Slant::kItalic_Slant : SkFontStyle::Slant::kUpright_Slant);
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::SLANT]);});
|
||||
// }
|
||||
|
||||
// bool decorationEdited = false;
|
||||
// if(t.gui.svg_icon_button("Underline button", "data/icons/RemixIcon/underline.svg", newIsUnderlined)) {
|
||||
// newIsUnderlined = !newIsUnderlined;
|
||||
// decorationEdited = true;
|
||||
// }
|
||||
// if(t.gui.svg_icon_button("Strikethrough button", "data/icons/RemixIcon/strikethrough.svg", newIsLinethrough)) {
|
||||
// newIsLinethrough = !newIsLinethrough;
|
||||
// decorationEdited = true;
|
||||
// }
|
||||
// if(t.gui.svg_icon_button("Overline button", "data/icons/RemixIcon/overline.svg", newIsOverline)) {
|
||||
// newIsOverline = !newIsOverline;
|
||||
// decorationEdited = true;
|
||||
// }
|
||||
// if(decorationEdited) {
|
||||
// currentMods[TextStyleModifier::ModifierType::DECORATION] = std::make_shared<DecorationTextStyleModifier>(get_new_decoration_value());
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::DECORATION]);});
|
||||
// }
|
||||
//});
|
||||
|
||||
//t.gui.left_to_right_line_centered_layout([&]() {
|
||||
// if(t.gui.svg_icon_button("Align left button", "data/icons/RemixIcon/align-left.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kLeft))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kLeft);});
|
||||
// if(t.gui.svg_icon_button("Align center button", "data/icons/RemixIcon/align-center.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kCenter))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kCenter);});
|
||||
// if(t.gui.svg_icon_button("Align right button", "data/icons/RemixIcon/align-right.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kRight))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kRight);});
|
||||
// if(t.gui.svg_icon_button("Align justify button", "data/icons/RemixIcon/align-justify.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kJustify))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kJustify);});
|
||||
// if(t.gui.svg_icon_button("Text direction left", "data/icons/RemixIcon/text-direction-l.svg", currentPStyle.textDirection == skia::textlayout::TextDirection::kLtr))
|
||||
// add_undo([&](){a.textBox->set_text_direction_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextDirection::kLtr);});
|
||||
// if(t.gui.svg_icon_button("Text direction right", "data/icons/RemixIcon/text-direction-r.svg", currentPStyle.textDirection == skia::textlayout::TextDirection::kRtl))
|
||||
// add_undo([&](){a.textBox->set_text_direction_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextDirection::kRtl);});
|
||||
//});
|
||||
|
||||
//if(t.gui.slider_scalar_field<uint32_t>("Font Size Slider", "Font Size", &newFontSize, 3, 100)) {
|
||||
// hold_undo_data("Font Size", a);
|
||||
// currentMods[TextStyleModifier::ModifierType::SIZE] = std::make_shared<SizeTextStyleModifier>(newFontSize);
|
||||
// a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::SIZE]);
|
||||
//}
|
||||
//else
|
||||
// release_undo_data("Font Size");
|
||||
|
||||
//// Text color
|
||||
//t.gui.left_to_right_line_layout([&]() {
|
||||
// if(t.gui.color_button_big("Text Color", &newTextColor, &newTextColor == t.colorRight))
|
||||
// t.color_selector_right(&newTextColor == t.colorRight ? nullptr : &newTextColor);
|
||||
// t.gui.text_label("Text Color");
|
||||
//});
|
||||
|
||||
//if(&newTextColor == t.colorRight)
|
||||
// hold_undo_data("Text Color", a);
|
||||
//else
|
||||
// release_undo_data("Text Color");
|
||||
|
||||
//if((&newTextColor == t.colorRight) && t.isUpdatingColorRight) {
|
||||
// currentMods[TextStyleModifier::ModifierType::COLOR] = std::make_shared<ColorTextStyleModifier>(newTextColor);
|
||||
// a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::COLOR]);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//// Highlight color
|
||||
//t.gui.left_to_right_line_layout([&]() {
|
||||
// if(t.gui.color_button_big("Highlight Color", &newHighlightColor, &newHighlightColor == t.colorRight)) {
|
||||
// if(newHighlightColor.w() == 0.0f) { // Make highlight appear when the button is pressed
|
||||
// newHighlightColor.w() = 1.0f;
|
||||
// currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR]);});
|
||||
// }
|
||||
// t.color_selector_right(&newHighlightColor == t.colorRight ? nullptr : &newHighlightColor);
|
||||
// }
|
||||
// if(newHighlightColor.w() != 0.0f) {
|
||||
// if(t.gui.svg_icon_button("Remove Highlight Color", "data/icons/close.svg")) {
|
||||
// newHighlightColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
// currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR]);});
|
||||
// }
|
||||
// }
|
||||
// t.gui.text_label("Highlight Color");
|
||||
//});
|
||||
|
||||
//if(&newHighlightColor == t.colorRight)
|
||||
// hold_undo_data("Highlight Color", a);
|
||||
//else
|
||||
// release_undo_data("Highlight Color");
|
||||
|
||||
//if((&newHighlightColor == t.colorRight) && t.isUpdatingColorRight) {
|
||||
// currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
||||
// a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR]);
|
||||
//}
|
||||
|
||||
});
|
||||
|
||||
//left_to_right_line_centered_layout(t.gui, [&] {
|
||||
// if(svg_icon_button("Bold button", "data/icons/RemixIcon/bold.svg", newIsBold)) {
|
||||
// newIsBold = !newIsBold;
|
||||
// currentMods[TextStyleModifier::ModifierType::WEIGHT] = std::make_shared<WeightTextStyleModifier>(newIsBold ? SkFontStyle::Weight::kBold_Weight : SkFontStyle::Weight::kNormal_Weight);
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::WEIGHT]);});
|
||||
// }
|
||||
|
||||
// if(t.gui.svg_icon_button("Italic button", "data/icons/RemixIcon/italic.svg", newIsItalic)) {
|
||||
// newIsItalic = !newIsItalic;
|
||||
// currentMods[TextStyleModifier::ModifierType::SLANT] = std::make_shared<SlantTextStyleModifier>(newIsItalic ? SkFontStyle::Slant::kItalic_Slant : SkFontStyle::Slant::kUpright_Slant);
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::SLANT]);});
|
||||
// }
|
||||
|
||||
// bool decorationEdited = false;
|
||||
// if(t.gui.svg_icon_button("Underline button", "data/icons/RemixIcon/underline.svg", newIsUnderlined)) {
|
||||
// newIsUnderlined = !newIsUnderlined;
|
||||
// decorationEdited = true;
|
||||
// }
|
||||
// if(t.gui.svg_icon_button("Strikethrough button", "data/icons/RemixIcon/strikethrough.svg", newIsLinethrough)) {
|
||||
// newIsLinethrough = !newIsLinethrough;
|
||||
// decorationEdited = true;
|
||||
// }
|
||||
// if(t.gui.svg_icon_button("Overline button", "data/icons/RemixIcon/overline.svg", newIsOverline)) {
|
||||
// newIsOverline = !newIsOverline;
|
||||
// decorationEdited = true;
|
||||
// }
|
||||
// if(decorationEdited) {
|
||||
// currentMods[TextStyleModifier::ModifierType::DECORATION] = std::make_shared<DecorationTextStyleModifier>(get_new_decoration_value());
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::DECORATION]);});
|
||||
// }
|
||||
//});
|
||||
|
||||
//t.gui.left_to_right_line_centered_layout([&]() {
|
||||
// if(t.gui.svg_icon_button("Align left button", "data/icons/RemixIcon/align-left.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kLeft))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kLeft);});
|
||||
// if(t.gui.svg_icon_button("Align center button", "data/icons/RemixIcon/align-center.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kCenter))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kCenter);});
|
||||
// if(t.gui.svg_icon_button("Align right button", "data/icons/RemixIcon/align-right.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kRight))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kRight);});
|
||||
// if(t.gui.svg_icon_button("Align justify button", "data/icons/RemixIcon/align-justify.svg", currentPStyle.textAlignment == skia::textlayout::TextAlign::kJustify))
|
||||
// add_undo([&](){a.textBox->set_text_alignment_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextAlign::kJustify);});
|
||||
// if(t.gui.svg_icon_button("Text direction left", "data/icons/RemixIcon/text-direction-l.svg", currentPStyle.textDirection == skia::textlayout::TextDirection::kLtr))
|
||||
// add_undo([&](){a.textBox->set_text_direction_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextDirection::kLtr);});
|
||||
// if(t.gui.svg_icon_button("Text direction right", "data/icons/RemixIcon/text-direction-r.svg", currentPStyle.textDirection == skia::textlayout::TextDirection::kRtl))
|
||||
// add_undo([&](){a.textBox->set_text_direction_between(a.cursor->selectionBeginPos.fParagraphIndex, a.cursor->selectionEndPos.fParagraphIndex, skia::textlayout::TextDirection::kRtl);});
|
||||
//});
|
||||
|
||||
//if(t.gui.slider_scalar_field<uint32_t>("Font Size Slider", "Font Size", &newFontSize, 3, 100)) {
|
||||
// hold_undo_data("Font Size", a);
|
||||
// currentMods[TextStyleModifier::ModifierType::SIZE] = std::make_shared<SizeTextStyleModifier>(newFontSize);
|
||||
// a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::SIZE]);
|
||||
//}
|
||||
//else
|
||||
// release_undo_data("Font Size");
|
||||
|
||||
//// Text color
|
||||
//t.gui.left_to_right_line_layout([&]() {
|
||||
// if(t.gui.color_button_big("Text Color", &newTextColor, &newTextColor == t.colorRight))
|
||||
// t.color_selector_right(&newTextColor == t.colorRight ? nullptr : &newTextColor);
|
||||
// t.gui.text_label("Text Color");
|
||||
//});
|
||||
|
||||
//if(&newTextColor == t.colorRight)
|
||||
// hold_undo_data("Text Color", a);
|
||||
//else
|
||||
// release_undo_data("Text Color");
|
||||
|
||||
//if((&newTextColor == t.colorRight) && t.isUpdatingColorRight) {
|
||||
// currentMods[TextStyleModifier::ModifierType::COLOR] = std::make_shared<ColorTextStyleModifier>(newTextColor);
|
||||
// a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::COLOR]);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//// Highlight color
|
||||
//t.gui.left_to_right_line_layout([&]() {
|
||||
// if(t.gui.color_button_big("Highlight Color", &newHighlightColor, &newHighlightColor == t.colorRight)) {
|
||||
// if(newHighlightColor.w() == 0.0f) { // Make highlight appear when the button is pressed
|
||||
// newHighlightColor.w() = 1.0f;
|
||||
// currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR]);});
|
||||
// }
|
||||
// t.color_selector_right(&newHighlightColor == t.colorRight ? nullptr : &newHighlightColor);
|
||||
// }
|
||||
// if(newHighlightColor.w() != 0.0f) {
|
||||
// if(t.gui.svg_icon_button("Remove Highlight Color", "data/icons/close.svg")) {
|
||||
// newHighlightColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
// currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
||||
// add_undo_if_selecting_area(a, [&]() {a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR]);});
|
||||
// }
|
||||
// }
|
||||
// t.gui.text_label("Highlight Color");
|
||||
//});
|
||||
|
||||
//if(&newHighlightColor == t.colorRight)
|
||||
// hold_undo_data("Highlight Color", a);
|
||||
//else
|
||||
// release_undo_data("Highlight Color");
|
||||
|
||||
//if((&newHighlightColor == t.colorRight) && t.isUpdatingColorRight) {
|
||||
// currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR] = std::make_shared<HighlightColorTextStyleModifier>(newHighlightColor);
|
||||
// a.textBox->set_text_style_modifier_between(a.cursor->selectionBeginPos, a.cursor->selectionEndPos, currentMods[TextStyleModifier::ModifierType::HIGHLIGHT_COLOR]);
|
||||
//}
|
||||
|
||||
//t.gui.pop_id();
|
||||
|
||||
//if(a.textBox->inputChangedTextBox)
|
||||
// set_styles_at_selection(a);
|
||||
|
|
|
|||
|
|
@ -27,16 +27,16 @@ void EllipseDrawTool::gui_toolbox() {
|
|||
Toolbar& t = drawP.world.main.toolbar;
|
||||
auto& toolConfig = drawP.world.main.toolConfig;
|
||||
auto& fillStrokeMode = toolConfig.ellipseDraw.fillStrokeMode;
|
||||
t.gui.push_id("ellipse draw tool");
|
||||
text_label_centered(t.gui, "Draw Ellipse");
|
||||
radio_button_selector(t.gui, "fill type", &fillStrokeMode, {
|
||||
{"Fill only", 0},
|
||||
{"Outline only", 1},
|
||||
{"Fill and Outline", 2}
|
||||
t.gui.new_id("ellipse draw tool", [&] {
|
||||
text_label_centered(t.gui, "Draw Ellipse");
|
||||
radio_button_selector(t.gui, "fill type", &fillStrokeMode, {
|
||||
{"Fill only", 0},
|
||||
{"Outline only", 1},
|
||||
{"Fill and Outline", 2}
|
||||
});
|
||||
if(fillStrokeMode == 1 || fillStrokeMode == 2)
|
||||
toolConfig.relative_width_gui(drawP, "Outline Size");
|
||||
});
|
||||
if(fillStrokeMode == 1 || fillStrokeMode == 2)
|
||||
toolConfig.relative_width_gui(drawP, "Outline Size");
|
||||
t.gui.pop_id();
|
||||
}
|
||||
|
||||
void EllipseDrawTool::input_mouse_button_on_canvas_callback(const InputManager::MouseButtonCallbackArgs& button) {
|
||||
|
|
|
|||
|
|
@ -21,15 +21,15 @@ void EraserTool::gui_toolbox() {
|
|||
using namespace ElementHelpers;
|
||||
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("eraser tool");
|
||||
text_label_centered(t.gui, "Eraser");
|
||||
drawP.world.main.toolConfig.relative_width_gui(drawP, "Size");
|
||||
text_label(t.gui, "Erase from:");
|
||||
radio_button_selector(t.gui, "layer selector", &drawP.controls.layerSelector, {
|
||||
{"Layer being edited", DrawingProgramLayerManager::LayerSelector::LAYER_BEING_EDITED},
|
||||
{"All visible layers", DrawingProgramLayerManager::LayerSelector::ALL_VISIBLE_LAYERS}
|
||||
t.gui.new_id("eraser tool", [&] {
|
||||
text_label_centered(t.gui, "Eraser");
|
||||
drawP.world.main.toolConfig.relative_width_gui(drawP, "Size");
|
||||
text_label(t.gui, "Erase from:");
|
||||
radio_button_selector(t.gui, "layer selector", &drawP.controls.layerSelector, {
|
||||
{"Layer being edited", DrawingProgramLayerManager::LayerSelector::LAYER_BEING_EDITED},
|
||||
{"All visible layers", DrawingProgramLayerManager::LayerSelector::ALL_VISIBLE_LAYERS}
|
||||
});
|
||||
});
|
||||
t.gui.pop_id();
|
||||
}
|
||||
|
||||
void EraserTool::right_click_popup_gui(Vector2f popupPos) {
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ void EyeDropperTool::gui_toolbox() {
|
|||
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
auto& selectingStrokeColor = drawP.world.main.toolConfig.eyeDropper.selectingStrokeColor;
|
||||
t.gui.push_id("Color select tool");
|
||||
text_label_centered(t.gui, "Color Select");
|
||||
t.gui.new_id("Color select tool", [&] {
|
||||
text_label_centered(t.gui, "Color Select");
|
||||
|
||||
radio_button_selector<bool>(t.gui, "Stroke type", &selectingStrokeColor, {
|
||||
{"Stroke Color", true},
|
||||
{"Fill Color", false}
|
||||
radio_button_selector<bool>(t.gui, "Stroke type", &selectingStrokeColor, {
|
||||
{"Stroke Color", true},
|
||||
{"Fill Color", false}
|
||||
});
|
||||
});
|
||||
t.gui.pop_id();
|
||||
}
|
||||
|
||||
void EyeDropperTool::right_click_popup_gui(Vector2f popupPos) {
|
||||
|
|
|
|||
|
|
@ -118,51 +118,51 @@ void GridModifyTool::gui_toolbox() {
|
|||
using namespace ElementHelpers;
|
||||
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("Grid modify tool");
|
||||
text_label_centered(t.gui, "Edit Grid");
|
||||
NetworkingObjects::NetObjTemporaryPtr<WorldGrid> gLock = grid.lock();
|
||||
if(gLock) {
|
||||
WorldGrid& g = *gLock;
|
||||
input_text_field(t.gui, "grid name", "Name", &g.name);
|
||||
checkbox_boolean_field(t.gui, "Visible", "Visible", &g.visible);
|
||||
checkbox_boolean_field(t.gui, "Display in Front", "Display in front of canvas", &g.displayInFront);
|
||||
size_t typeSelected = static_cast<size_t>(g.gridType);
|
||||
std::vector<std::string> listOfGridTypes = {
|
||||
"Circle Points",
|
||||
"Square Points",
|
||||
"Square Lines",
|
||||
"Horizontal Lines"
|
||||
};
|
||||
left_to_right_line_layout(t.gui, [&]() {
|
||||
text_label(t.gui, "Type");
|
||||
t.gui.element<DropDown<size_t>>("filepicker select type", &typeSelected, listOfGridTypes);
|
||||
});
|
||||
g.gridType = static_cast<WorldGrid::GridType>(typeSelected);
|
||||
uint32_t sDiv = g.subdivisions;
|
||||
input_scalar_field<uint32_t>(t.gui, "Subdivisions", "Subdivisions", &sDiv, 1, 10);
|
||||
g.set_subdivisions(sDiv);
|
||||
bool divOut = g.removeDivisionsOutwards;
|
||||
checkbox_boolean_field(t.gui, "Subdivide outwards", "Subdivide when zooming out", &divOut);
|
||||
g.set_remove_divisions_outwards(divOut);
|
||||
left_to_right_line_layout(t.gui, [&]() {
|
||||
//if(t.gui.color_button_big("Grid Color", &g.color, &g.color == t.colorRight))
|
||||
// t.color_selector_right(&g.color == t.colorRight ? nullptr : &g.color);
|
||||
text_label(t.gui, "Grid Color");
|
||||
});
|
||||
bool bounded = g.bounds.has_value();
|
||||
bool prevBoundedValue = bounded;
|
||||
checkbox_boolean_field(t.gui, "Bounded", "Bounded", &bounded);
|
||||
if(bounded && !prevBoundedValue) {
|
||||
SCollision::AABB<WorldScalar> newBounds;
|
||||
newBounds.min = g.offset - drawP.world.drawData.cam.c.dir_from_space(drawP.world.main.window.size.cast<float>() * 0.3f);
|
||||
newBounds.max = g.offset + drawP.world.drawData.cam.c.dir_from_space(drawP.world.main.window.size.cast<float>() * 0.3f);
|
||||
g.bounds = newBounds;
|
||||
t.gui.new_id("Grid modify tool", [&] {
|
||||
text_label_centered(t.gui, "Edit Grid");
|
||||
NetworkingObjects::NetObjTemporaryPtr<WorldGrid> gLock = grid.lock();
|
||||
if(gLock) {
|
||||
WorldGrid& g = *gLock;
|
||||
input_text_field(t.gui, "grid name", "Name", &g.name);
|
||||
checkbox_boolean_field(t.gui, "Visible", "Visible", &g.visible);
|
||||
checkbox_boolean_field(t.gui, "Display in Front", "Display in front of canvas", &g.displayInFront);
|
||||
size_t typeSelected = static_cast<size_t>(g.gridType);
|
||||
std::vector<std::string> listOfGridTypes = {
|
||||
"Circle Points",
|
||||
"Square Points",
|
||||
"Square Lines",
|
||||
"Horizontal Lines"
|
||||
};
|
||||
left_to_right_line_layout(t.gui, [&]() {
|
||||
text_label(t.gui, "Type");
|
||||
t.gui.element<DropDown<size_t>>("filepicker select type", &typeSelected, listOfGridTypes);
|
||||
});
|
||||
g.gridType = static_cast<WorldGrid::GridType>(typeSelected);
|
||||
uint32_t sDiv = g.subdivisions;
|
||||
input_scalar_field<uint32_t>(t.gui, "Subdivisions", "Subdivisions", &sDiv, 1, 10);
|
||||
g.set_subdivisions(sDiv);
|
||||
bool divOut = g.removeDivisionsOutwards;
|
||||
checkbox_boolean_field(t.gui, "Subdivide outwards", "Subdivide when zooming out", &divOut);
|
||||
g.set_remove_divisions_outwards(divOut);
|
||||
left_to_right_line_layout(t.gui, [&]() {
|
||||
//if(t.gui.color_button_big("Grid Color", &g.color, &g.color == t.colorRight))
|
||||
// t.color_selector_right(&g.color == t.colorRight ? nullptr : &g.color);
|
||||
text_label(t.gui, "Grid Color");
|
||||
});
|
||||
bool bounded = g.bounds.has_value();
|
||||
bool prevBoundedValue = bounded;
|
||||
checkbox_boolean_field(t.gui, "Bounded", "Bounded", &bounded);
|
||||
if(bounded && !prevBoundedValue) {
|
||||
SCollision::AABB<WorldScalar> newBounds;
|
||||
newBounds.min = g.offset - drawP.world.drawData.cam.c.dir_from_space(drawP.world.main.window.size.cast<float>() * 0.3f);
|
||||
newBounds.max = g.offset + drawP.world.drawData.cam.c.dir_from_space(drawP.world.main.window.size.cast<float>() * 0.3f);
|
||||
g.bounds = newBounds;
|
||||
}
|
||||
else if(!bounded && prevBoundedValue)
|
||||
g.bounds = std::nullopt;
|
||||
checkbox_boolean_field(t.gui, "Show Coordinates", "Show Coordinates (visible\nwhen canvas isn't rotated)", &g.showCoordinates);
|
||||
}
|
||||
else if(!bounded && prevBoundedValue)
|
||||
g.bounds = std::nullopt;
|
||||
checkbox_boolean_field(t.gui, "Show Coordinates", "Show Coordinates (visible\nwhen canvas isn't rotated)", &g.showCoordinates);
|
||||
}
|
||||
t.gui.pop_id();
|
||||
});
|
||||
}
|
||||
|
||||
void GridModifyTool::right_click_popup_gui(Vector2f popupPos) {
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ DrawingProgramToolType LassoSelectTool::get_type() {
|
|||
|
||||
void LassoSelectTool::gui_toolbox() {
|
||||
auto& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("lasso select tool");
|
||||
GUIStuff::ElementHelpers::text_label_centered(t.gui, "Lasso Select");
|
||||
drawP.selection.selection_gui();
|
||||
t.gui.pop_id();
|
||||
t.gui.new_id("lasso select tool", [&] {
|
||||
GUIStuff::ElementHelpers::text_label_centered(t.gui, "Lasso Select");
|
||||
drawP.selection.selection_gui();
|
||||
});
|
||||
}
|
||||
|
||||
void LassoSelectTool::right_click_popup_gui(Vector2f popupPos) {
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ void LineDrawTool::gui_toolbox() {
|
|||
using namespace ElementHelpers;
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
auto& toolConfig = drawP.world.main.toolConfig;
|
||||
t.gui.push_id("rect draw tool");
|
||||
text_label_centered(t.gui, "Draw Line");
|
||||
toolConfig.relative_width_gui(drawP, "Size");
|
||||
checkbox_boolean_field(t.gui, "hasroundcaps", "Round Caps", &toolConfig.lineDraw.hasRoundCaps);
|
||||
t.gui.pop_id();
|
||||
t.gui.new_id("rect draw tool", [&] {
|
||||
text_label_centered(t.gui, "Draw Line");
|
||||
toolConfig.relative_width_gui(drawP, "Size");
|
||||
checkbox_boolean_field(t.gui, "hasroundcaps", "Round Caps", &toolConfig.lineDraw.hasRoundCaps);
|
||||
});
|
||||
}
|
||||
|
||||
void LineDrawTool::input_mouse_button_on_canvas_callback(const InputManager::MouseButtonCallbackArgs& button) {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ DrawingProgramToolType PanCanvasTool::get_type() {
|
|||
|
||||
void PanCanvasTool::gui_toolbox() {
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("Pan canvas tool");
|
||||
GUIStuff::ElementHelpers::text_label_centered(t.gui, "Pan tool");
|
||||
t.gui.pop_id();
|
||||
t.gui.new_id("Pan canvas tool", [&] {
|
||||
GUIStuff::ElementHelpers::text_label_centered(t.gui, "Pan tool");
|
||||
});
|
||||
}
|
||||
|
||||
void PanCanvasTool::right_click_popup_gui(Vector2f popupPos) {
|
||||
|
|
|
|||
|
|
@ -26,17 +26,17 @@ void RectDrawTool::gui_toolbox() {
|
|||
auto& toolConfig = drawP.world.main.toolConfig;
|
||||
auto& fillStrokeMode = toolConfig.rectDraw.fillStrokeMode;
|
||||
auto& relativeRadiusWidth = toolConfig.rectDraw.relativeRadiusWidth;
|
||||
t.gui.push_id("rect draw tool");
|
||||
text_label_centered(t.gui, "Draw Rectangle");
|
||||
slider_scalar_field(t.gui, "relradiuswidth", "Corner Radius", &relativeRadiusWidth, 0.0f, 40.0f);
|
||||
radio_button_selector(t.gui, "fill type", &fillStrokeMode, {
|
||||
{"Fill only", 0},
|
||||
{"Outline only", 1},
|
||||
{"Fill and Outline", 2}
|
||||
t.gui.new_id("rect draw tool", [&] {
|
||||
text_label_centered(t.gui, "Draw Rectangle");
|
||||
slider_scalar_field(t.gui, "relradiuswidth", "Corner Radius", &relativeRadiusWidth, 0.0f, 40.0f);
|
||||
radio_button_selector(t.gui, "fill type", &fillStrokeMode, {
|
||||
{"Fill only", 0},
|
||||
{"Outline only", 1},
|
||||
{"Fill and Outline", 2}
|
||||
});
|
||||
if(fillStrokeMode == 1 || fillStrokeMode == 2)
|
||||
toolConfig.relative_width_gui(drawP, "Outline Size");
|
||||
});
|
||||
if(fillStrokeMode == 1 || fillStrokeMode == 2)
|
||||
toolConfig.relative_width_gui(drawP, "Outline Size");
|
||||
t.gui.pop_id();
|
||||
}
|
||||
|
||||
void RectDrawTool::input_mouse_button_on_canvas_callback(const InputManager::MouseButtonCallbackArgs& button) {
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@ DrawingProgramToolType RectSelectTool::get_type() {
|
|||
|
||||
void RectSelectTool::gui_toolbox() {
|
||||
auto& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("rectangle select tool");
|
||||
GUIStuff::ElementHelpers::text_label_centered(t.gui, "Rectangle Select");
|
||||
drawP.selection.selection_gui();
|
||||
t.gui.pop_id();
|
||||
t.gui.new_id("rectangle select tool", [&] {
|
||||
GUIStuff::ElementHelpers::text_label_centered(t.gui, "Rectangle Select");
|
||||
drawP.selection.selection_gui();
|
||||
});
|
||||
}
|
||||
|
||||
void RectSelectTool::input_key_callback(const InputManager::KeyCallbackArgs& key) {
|
||||
|
|
|
|||
|
|
@ -58,71 +58,71 @@ void ScreenshotTool::gui_toolbox() {
|
|||
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
auto& screenshotConfig = drawP.world.main.toolConfig.screenshot;
|
||||
t.gui.push_id("screenshot tool");
|
||||
text_label_centered(t.gui, "Screenshot");
|
||||
auto oldImgSize = controls.imageSize;
|
||||
if(controls.selectionMode == ScreenshotControls::SelectionMode::NO_SELECTION)
|
||||
text_label(t.gui, "Select an area on the canvas...");
|
||||
if(controls.selectionMode != ScreenshotControls::SelectionMode::NO_SELECTION && screenshotConfig.selectedType != SCREENSHOT_SVG)
|
||||
input_scalars_field(t.gui, "Image Size", "Image Size", &controls.imageSize, 2, 0, 999999999);
|
||||
if(controls.selectionMode == ScreenshotControls::SelectionMode::SELECTION_EXISTS) {
|
||||
left_to_right_line_layout(t.gui, [&]() {
|
||||
text_label(t.gui, "Image Type");
|
||||
t.gui.element<DropDown<size_t>>("image type select", (size_t*)(&screenshotConfig.selectedType), controls.typeSelections);
|
||||
});
|
||||
if(screenshotConfig.selectedType != SCREENSHOT_SVG)
|
||||
checkbox_boolean_field(t.gui, "Display Grid", "Display Grid", &controls.displayGrid);
|
||||
else
|
||||
text_label(t.gui, "Note: Screenshot will ignore blend\nmodes and layer alpha");
|
||||
if(screenshotConfig.selectedType != 0)
|
||||
checkbox_boolean_field(t.gui, "Transparent Background", "Transparent Background", &controls.transparentBackground);
|
||||
if(controls.imageSize.x() != oldImgSize.x()) {
|
||||
screenshotConfig.setDimensionSize = controls.imageSize.x();
|
||||
screenshotConfig.setDimensionIsX = true;
|
||||
controls.imageSize.y() = controls.imageSize.x() * (controls.rectY2 - controls.rectY1) / (controls.rectX2 - controls.rectX1);
|
||||
}
|
||||
else if(controls.imageSize.y() != oldImgSize.y()) {
|
||||
screenshotConfig.setDimensionSize = controls.imageSize.y();
|
||||
screenshotConfig.setDimensionIsX = false;
|
||||
controls.imageSize.x() = controls.imageSize.y() * (controls.rectX2 - controls.rectX1) / (controls.rectY2 - controls.rectY1);
|
||||
}
|
||||
text_button(t.gui, "Take Screenshot", "Take Screenshot", {
|
||||
.wide = true,
|
||||
.onClick = [&] {
|
||||
controls.selectionMode = ScreenshotControls::SelectionMode::NO_SELECTION;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
take_screenshot("a" + controls.typeSelections[screenshotConfig.selectedType], screenshotConfig.selectedType);
|
||||
#else
|
||||
// We can't actually use the extension from the callback, so we have to set the extension of choice beforehand
|
||||
Toolbar::ExtensionFilter setExtensionFilter;
|
||||
switch(screenshotConfig.selectedType) {
|
||||
case SCREENSHOT_JPG:
|
||||
setExtensionFilter = {"JPEG", "jpg;jpeg"};
|
||||
break;
|
||||
case SCREENSHOT_PNG:
|
||||
setExtensionFilter = {"PNG", "png"};
|
||||
break;
|
||||
case SCREENSHOT_WEBP:
|
||||
setExtensionFilter = {"WEBP", "webp"};
|
||||
break;
|
||||
case SCREENSHOT_SVG:
|
||||
setExtensionFilter = {"SVG", "svg"};
|
||||
break;
|
||||
}
|
||||
t.open_file_selector("Export", {setExtensionFilter}, [setExtensionFilter, w = make_weak_ptr(drawP.world.main.world)](const std::filesystem::path& p, const auto& e) {
|
||||
auto world = w.lock();
|
||||
if(world && world->drawProg.drawTool->get_type() == DrawingProgramToolType::SCREENSHOT) {
|
||||
ScreenshotTool* screenshotTool = static_cast<ScreenshotTool*>(world->drawProg.drawTool.get());
|
||||
screenshotTool->controls.screenshotSavePath = p;
|
||||
screenshotTool->controls.screenshotSaveType = world->main.toolConfig.screenshot.selectedType;
|
||||
screenshotTool->controls.setToTakeScreenshot = true;
|
||||
}
|
||||
}, "screenshot", true);
|
||||
#endif
|
||||
t.gui.new_id("screenshot tool", [&] {
|
||||
text_label_centered(t.gui, "Screenshot");
|
||||
auto oldImgSize = controls.imageSize;
|
||||
if(controls.selectionMode == ScreenshotControls::SelectionMode::NO_SELECTION)
|
||||
text_label(t.gui, "Select an area on the canvas...");
|
||||
if(controls.selectionMode != ScreenshotControls::SelectionMode::NO_SELECTION && screenshotConfig.selectedType != SCREENSHOT_SVG)
|
||||
input_scalars_field(t.gui, "Image Size", "Image Size", &controls.imageSize, 2, 0, 999999999);
|
||||
if(controls.selectionMode == ScreenshotControls::SelectionMode::SELECTION_EXISTS) {
|
||||
left_to_right_line_layout(t.gui, [&]() {
|
||||
text_label(t.gui, "Image Type");
|
||||
t.gui.element<DropDown<size_t>>("image type select", (size_t*)(&screenshotConfig.selectedType), controls.typeSelections);
|
||||
});
|
||||
if(screenshotConfig.selectedType != SCREENSHOT_SVG)
|
||||
checkbox_boolean_field(t.gui, "Display Grid", "Display Grid", &controls.displayGrid);
|
||||
else
|
||||
text_label(t.gui, "Note: Screenshot will ignore blend\nmodes and layer alpha");
|
||||
if(screenshotConfig.selectedType != 0)
|
||||
checkbox_boolean_field(t.gui, "Transparent Background", "Transparent Background", &controls.transparentBackground);
|
||||
if(controls.imageSize.x() != oldImgSize.x()) {
|
||||
screenshotConfig.setDimensionSize = controls.imageSize.x();
|
||||
screenshotConfig.setDimensionIsX = true;
|
||||
controls.imageSize.y() = controls.imageSize.x() * (controls.rectY2 - controls.rectY1) / (controls.rectX2 - controls.rectX1);
|
||||
}
|
||||
});
|
||||
}
|
||||
t.gui.pop_id();
|
||||
else if(controls.imageSize.y() != oldImgSize.y()) {
|
||||
screenshotConfig.setDimensionSize = controls.imageSize.y();
|
||||
screenshotConfig.setDimensionIsX = false;
|
||||
controls.imageSize.x() = controls.imageSize.y() * (controls.rectX2 - controls.rectX1) / (controls.rectY2 - controls.rectY1);
|
||||
}
|
||||
text_button(t.gui, "Take Screenshot", "Take Screenshot", {
|
||||
.wide = true,
|
||||
.onClick = [&] {
|
||||
controls.selectionMode = ScreenshotControls::SelectionMode::NO_SELECTION;
|
||||
#ifdef __EMSCRIPTEN__
|
||||
take_screenshot("a" + controls.typeSelections[screenshotConfig.selectedType], screenshotConfig.selectedType);
|
||||
#else
|
||||
// We can't actually use the extension from the callback, so we have to set the extension of choice beforehand
|
||||
Toolbar::ExtensionFilter setExtensionFilter;
|
||||
switch(screenshotConfig.selectedType) {
|
||||
case SCREENSHOT_JPG:
|
||||
setExtensionFilter = {"JPEG", "jpg;jpeg"};
|
||||
break;
|
||||
case SCREENSHOT_PNG:
|
||||
setExtensionFilter = {"PNG", "png"};
|
||||
break;
|
||||
case SCREENSHOT_WEBP:
|
||||
setExtensionFilter = {"WEBP", "webp"};
|
||||
break;
|
||||
case SCREENSHOT_SVG:
|
||||
setExtensionFilter = {"SVG", "svg"};
|
||||
break;
|
||||
}
|
||||
t.open_file_selector("Export", {setExtensionFilter}, [setExtensionFilter, w = make_weak_ptr(drawP.world.main.world)](const std::filesystem::path& p, const auto& e) {
|
||||
auto world = w.lock();
|
||||
if(world && world->drawProg.drawTool->get_type() == DrawingProgramToolType::SCREENSHOT) {
|
||||
ScreenshotTool* screenshotTool = static_cast<ScreenshotTool*>(world->drawProg.drawTool.get());
|
||||
screenshotTool->controls.screenshotSavePath = p;
|
||||
screenshotTool->controls.screenshotSaveType = world->main.toolConfig.screenshot.selectedType;
|
||||
screenshotTool->controls.setToTakeScreenshot = true;
|
||||
}
|
||||
}, "screenshot", true);
|
||||
#endif
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ScreenshotTool::right_click_popup_gui(Vector2f popupPos) {
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ DrawingProgramToolType TextBoxTool::get_type() {
|
|||
|
||||
void TextBoxTool::gui_toolbox() {
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("textbox tool");
|
||||
GUIStuff::ElementHelpers::text_label_centered(t.gui, "Zoom tool");
|
||||
t.gui.pop_id();
|
||||
t.gui.new_id("textbox tool", [&] {
|
||||
GUIStuff::ElementHelpers::text_label_centered(t.gui, "Zoom tool");
|
||||
});
|
||||
}
|
||||
|
||||
void TextBoxTool::input_mouse_button_on_canvas_callback(const InputManager::MouseButtonCallbackArgs& button) {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ DrawingProgramToolType ZoomCanvasTool::get_type() {
|
|||
|
||||
void ZoomCanvasTool::gui_toolbox() {
|
||||
Toolbar& t = drawP.world.main.toolbar;
|
||||
t.gui.push_id("Zoom canvas tool");
|
||||
GUIStuff::ElementHelpers::text_label_centered(t.gui, "Zoom tool");
|
||||
t.gui.pop_id();
|
||||
t.gui.new_id("Zoom canvas tool", [&] {
|
||||
GUIStuff::ElementHelpers::text_label_centered(t.gui, "Zoom tool");
|
||||
});
|
||||
}
|
||||
|
||||
void ZoomCanvasTool::right_click_popup_gui(Vector2f popupPos) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue