| 91 | |
| 92 | public: |
| 93 | ToolLoopBase(Editor* editor, |
| 94 | Layer* layer, |
| 95 | tools::Tool* tool, |
| 96 | std::shared_ptr<tools::Ink> ink, |
| 97 | Document* document, |
| 98 | tools::ToolLoop::Button button, |
| 99 | const app::Color& fgColor, |
| 100 | const app::Color& bgColor) |
| 101 | : m_editor(editor) |
| 102 | , m_tool(tool) |
| 103 | , m_brush(App::instance()->contextBar()->activeBrush(m_tool)) |
| 104 | , m_document(document) |
| 105 | , m_sprite(editor->sprite()) |
| 106 | , m_layer(layer) |
| 107 | , m_frame(editor->frame()) |
| 108 | , m_rgbMap(nullptr) |
| 109 | , m_docPref(Preferences::instance().document(m_document)) |
| 110 | , m_toolPref(Preferences::instance().tool(m_tool)) |
| 111 | , m_opacity(m_toolPref.opacity()) |
| 112 | , m_tolerance(m_toolPref.tolerance()) |
| 113 | , m_contiguous(m_toolPref.contiguous()) |
| 114 | , m_button(button) |
| 115 | , m_ink(ink->clone()) |
| 116 | , m_controller(m_tool->getController(m_button)) |
| 117 | , m_pointShape(m_tool->getPointShape(m_button)) |
| 118 | , m_intertwine(m_tool->getIntertwine(m_button)) |
| 119 | , m_tracePolicy(m_tool->getTracePolicy(m_button)) |
| 120 | , m_symmetry(nullptr) |
| 121 | , m_colorTarget(m_layer ? ColorTarget(m_layer): |
| 122 | ColorTarget(ColorTarget::BackgroundLayer, |
| 123 | m_sprite->pixelFormat(), |
| 124 | m_sprite->transparentColor())) |
| 125 | , m_fgColor(color_utils::color_for_target_mask(fgColor, m_colorTarget)) |
| 126 | , m_bgColor(color_utils::color_for_target_mask(bgColor, m_colorTarget)) |
| 127 | , m_primaryColor(button == tools::ToolLoop::Left ? m_fgColor: m_bgColor) |
| 128 | , m_secondaryColor(button == tools::ToolLoop::Left ? m_bgColor: m_fgColor) |
| 129 | { |
| 130 | tools::FreehandAlgorithm algorithm = m_toolPref.freehandAlgorithm(); |
| 131 | |
| 132 | if (m_tracePolicy == tools::TracePolicy::Accumulate || |
| 133 | m_tracePolicy == tools::TracePolicy::AccumulateUpdateLast) { |
| 134 | tools::ToolBox* toolbox = App::instance()->toolBox(); |
| 135 | |
| 136 | switch (algorithm) { |
| 137 | case tools::FreehandAlgorithm::PIXEL_PERFECT: |
| 138 | if (m_toolPref.brush.size() == 1) { |
| 139 | m_intertwine = toolbox->getIntertwinerById(tools::WellKnownIntertwiners::AsPixelPerfect); |
| 140 | m_tracePolicy = tools::TracePolicy::AccumulateUpdateLast; |
| 141 | break; |
| 142 | } |
| 143 | [[fallthrough]]; |
| 144 | case tools::FreehandAlgorithm::DEFAULT: |
| 145 | m_intertwine = toolbox->getIntertwinerById(tools::WellKnownIntertwiners::AsLines); |
| 146 | m_tracePolicy = tools::TracePolicy::Accumulate; |
| 147 | break; |
| 148 | case tools::FreehandAlgorithm::DOTS: |
| 149 | m_intertwine = toolbox->getIntertwinerById(tools::WellKnownIntertwiners::None); |
| 150 | m_tracePolicy = tools::TracePolicy::Accumulate; |
nothing calls this directly
no test coverage detected