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

Method ToolLoopImpl

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

Source from the content-addressed store, hash-verified

281
282public:
283 ToolLoopImpl(Editor* editor,
284 Layer* layer,
285 Context* context,
286 tools::Tool* tool,
287 std::shared_ptr<tools::Ink> ink,
288 Document* document,
289 tools::ToolLoop::Button button,
290 const app::Color& fgColor,
291 const app::Color& bgColor)
292 : ToolLoopBase(editor, layer, tool, ink, document,
293 button, fgColor, bgColor)
294 , m_context(context)
295 , m_canceled(false)
296 , m_transaction(m_context,
297 m_tool->getText().c_str(),
298 ((getInk()->isSelection() ||
299 getInk()->isEyedropper() ||
300 getInk()->isScrollMovement() ||
301 getInk()->isSlice() ||
302 getInk()->isZoom()) ? DoesntModifyDocument:
303 ModifyDocument))
304 , m_expandCelCanvas(nullptr)
305 , m_floodfillSrcImage(nullptr)
306 {
307 ASSERT(m_context->activeDocument() == m_editor->document());
308
309 if (m_pointShape->isFloodFill()) {
310 // Prepare a special image for floodfill when it's configured to
311 // stop using all visible layers.
312 if (m_toolPref.floodfill.referTo() == gen::FillReferTo::ALL_LAYERS) {
313 m_floodfillSrcImage = Image::create(m_sprite->pixelFormat(),
314 m_sprite->width(),
315 m_sprite->height());
316
317 m_floodfillSrcImage->clear(m_sprite->transparentColor());
318
319 render::Render().renderSprite(
320 m_floodfillSrcImage,
321 m_sprite,
322 m_frame,
323 gfx::Clip(m_sprite->bounds()),
324 render::Zoom(1, 1));
325 }
326 else {
327 auto cel = m_layer->cel(m_frame);
328 if (cel && (cel->x() != 0 || cel->y() != 0)) {
329 m_floodfillSrcImage = Image::create(m_sprite->pixelFormat(),
330 m_sprite->width(),
331 m_sprite->height());
332 m_floodfillSrcImage->clear(m_sprite->transparentColor());
333 copy_image(m_floodfillSrcImage, cel->image(), cel->x(), cel->y());
334 }
335 }
336 }
337
338 m_expandCelCanvas = new ExpandCelCanvas(
339 editor->getSite(),
340 layer,

Callers

nothing calls this directly

Calls 15

RenderClass · 0.85
PointClass · 0.85
transparentColorMethod · 0.80
renderSpriteMethod · 0.80
modeMethod · 0.80
getFillMethod · 0.80
isMaskVisibleMethod · 0.80
getCelMethod · 0.80
maskMethod · 0.80
ZoomClass · 0.70
FlagsEnum · 0.70
ClipClass · 0.50

Tested by

no test coverage detected