MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / create_tool_loop_preview

Function create_tool_loop_preview

src/app/ui/editor/tool_loop_impl.cpp:616–651  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

614};
615
616tools::ToolLoop* create_tool_loop_preview(
617 Editor* editor, Image* image,
618 const gfx::Point& celOrigin)
619{
620 tools::Tool* current_tool = editor->getCurrentEditorTool();
621 std::shared_ptr<tools::Ink> current_ink = editor->getCurrentEditorInk();
622 if (!current_tool || !current_ink)
623 return nullptr;
624
625 Layer* layer = editor->layer();
626 if (!layer ||
627 !layer->isVisible() ||
628 !layer->isEditable()) {
629 return nullptr;
630 }
631
632 // Get fg/bg colors
633 ColorBar* colorbar = ColorBar::instance();
634 app::Color fg = colorbar->getFgColor();
635 app::Color bg = colorbar->getBgColor();
636 if (!fg.isValid() || !bg.isValid())
637 return nullptr;
638
639 // Create the new tool loop
640 try {
641 return new PreviewToolLoopImpl(
642 editor,
643 current_tool,
644 current_ink,
645 editor->document(),
646 fg, bg, image, celOrigin);
647 }
648 catch (const std::exception&) {
649 return nullptr;
650 }
651}
652
653//////////////////////////////////////////////////////////////////////
654

Callers 1

showMethod · 0.85

Calls 10

instanceFunction · 0.85
getCurrentEditorToolMethod · 0.80
getCurrentEditorInkMethod · 0.80
layerMethod · 0.45
isVisibleMethod · 0.45
isEditableMethod · 0.45
getFgColorMethod · 0.45
getBgColorMethod · 0.45
isValidMethod · 0.45
documentMethod · 0.45

Tested by

no test coverage detected