| 614 | }; |
| 615 | |
| 616 | tools::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 |
no test coverage detected