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

Method ToolLoopBase

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

Source from the content-addressed store, hash-verified

91
92public:
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;

Callers

nothing calls this directly

Calls 15

instanceFunction · 0.85
ColorTargetClass · 0.85
inkHasOpacityFunction · 0.85
activeBrushMethod · 0.80
contextBarMethod · 0.80
transparentColorMethod · 0.80
toolBoxMethod · 0.80
getIntertwinerByIdMethod · 0.80
modeMethod · 0.80
spriteMethod · 0.45
frameMethod · 0.45
documentMethod · 0.45

Tested by

no test coverage detected