MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / toolbar_gui

Method toolbar_gui

src/DrawingProgram/DrawingProgram.cpp:369–424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367}
368
369void DrawingProgram::toolbar_gui(Toolbar& t) {
370 using namespace GUIStuff;
371 using namespace ElementHelpers;
372
373 GUIManager& gui = world.main.g.gui;
374 auto& io = gui.io;
375
376 gui.new_id("Drawing Program Toolbar GUI", [&] {
377 gui.element<LayoutElement>("Drawing Program Toolbar GUI", [&] (LayoutElement*, const Clay_ElementId& lId) {
378 CLAY(lId, {
379 .layout = {
380 .sizing = {.width = CLAY_SIZING_FIT(0), .height = CLAY_SIZING_FIT(0)},
381 .padding = CLAY_PADDING_ALL(static_cast<uint16_t>(io.theme->padding1 / 2)),
382 .childGap = static_cast<uint16_t>(io.theme->childGap1 / 2),
383 .childAlignment = { .x = CLAY_ALIGN_X_CENTER, .y = CLAY_ALIGN_Y_TOP},
384 .layoutDirection = CLAY_TOP_TO_BOTTOM
385 },
386 .backgroundColor = convert_vec4<Clay_Color>(io.theme->backColor1),
387 .cornerRadius = CLAY_CORNER_RADIUS(io.theme->windowCorners1)
388 }) {
389
390 auto tool_button = [&](const char* id, const std::string& svgPath, DrawingProgramToolType toolType) {
391 svg_icon_button(gui, id, svgPath, {
392 .drawType = SelectableButton::DrawType::TRANSPARENT_ALL,
393 .isSelected = drawTool->get_type() == toolType,
394 .onClick = [&, toolType] {
395 switch_to_tool(toolType);
396 }
397 });
398 };
399
400 tool_button("Brush Toolbar Button", "data/icons/brush.svg", DrawingProgramToolType::BRUSH);
401 tool_button("Eraser Toolbar Button", "data/icons/eraser.svg", DrawingProgramToolType::ERASER);
402 tool_button("Line Toolbar Button", "data/icons/line.svg", DrawingProgramToolType::LINE);
403 tool_button("Text Toolbar Button", "data/icons/text.svg", DrawingProgramToolType::TEXTBOX);
404 tool_button("Ellipse Toolbar Button", "data/icons/circle.svg", DrawingProgramToolType::ELLIPSE);
405 tool_button("Rect Toolbar Button", "data/icons/rectangle.svg", DrawingProgramToolType::RECTANGLE);
406 tool_button("RectSelect Toolbar Button", "data/icons/rectselect.svg", DrawingProgramToolType::RECTSELECT);
407 tool_button("LassoSelect Toolbar Button", "data/icons/lassoselect.svg", DrawingProgramToolType::LASSOSELECT);
408 tool_button("Edit Toolbar Button", "data/icons/cursor.svg", DrawingProgramToolType::EDIT);
409 tool_button("Eyedropper Toolbar Button", "data/icons/eyedropper.svg", DrawingProgramToolType::EYEDROPPER);
410 tool_button("Zoom Canvas Toolbar Button", "data/icons/zoom.svg", DrawingProgramToolType::ZOOM);
411 tool_button("Pan Canvas Toolbar Button", "data/icons/hand.svg", DrawingProgramToolType::PAN);
412
413 std::shared_ptr<double> newRotationAngle = std::make_shared<double>(world.drawData.cam.c.rotation);
414 gui.element<RotateWheel>("Canvas Rotate Wheel", newRotationAngle.get(), [&, newRotationAngle] {
415 world.drawData.cam.c.rotate_about(world.drawData.cam.c.from_space(world.main.window.size.cast<float>() * 0.5f), *newRotationAngle - world.drawData.cam.c.rotation);
416 *newRotationAngle = world.drawData.cam.c.rotation;
417 });
418
419 t.color_button_left("Foreground color", &world.main.toolConfig.globalConf.foregroundColor);
420 t.color_button_left("Background color", &world.main.toolConfig.globalConf.backgroundColor);
421 }
422 });
423 });
424}
425
426void DrawingProgram::right_click_popup_gui(Toolbar& t) {

Callers 1

drawing_program_guiMethod · 0.80

Calls 7

svg_icon_buttonFunction · 0.85
new_idMethod · 0.80
color_button_leftMethod · 0.80
get_typeMethod · 0.45
getMethod · 0.45
rotate_aboutMethod · 0.45
from_spaceMethod · 0.45

Tested by

no test coverage detected