void SetMaskPosition::setMaskPosition(const gfx::Point& pos) { Doc* doc = document(); doc->mask()->setOrigin(pos.x, pos.y); doc->resetTransformation(); doc->notifySelectionChanged(); }
void ClearMask::clear() { Cel* cel = this->cel(); Image* image = m_dstImage->image(); Doc* doc = static_cast<Doc*>(cel->document()); Mask* mask = doc->mask(); doc::algorithm::fill_selection(image, m_offset, mask, m_bgcolor); }
void ReselectMask::onUndo() { Doc* doc = document(); m_oldMask.reset(doc->isMaskVisible() ? new Mask(*doc->mask()): nullptr); doc->setMaskVisible(false); doc->notifySelectionChanged(); }
ClearMask::ClearMask(Cel* cel) : WithCel(cel) { Doc* doc = static_cast<Doc*>(cel->document()); // If the mask is empty or is not visible then we have to clear the // entire image in the cel. if (!doc->isMaskVisible()) { m_seq.add(new cmd::ClearCel(cel)); return; } Image* image = cel->image(); assert(image); if (!image) return; Mask* mask = doc->mask(); m_offset = mask->bounds().origin() - cel->position(); gfx::Rect bounds = image->bounds().createIntersection( gfx::Rect( m_offset.x, m_offset.y, mask->bounds().w, mask->bounds().h)); if (bounds.isEmpty()) return; m_dstImage.reset(new WithImage(image)); m_bgcolor = doc->bgColor(cel->layer()); m_boundsX = bounds.x; m_boundsY = bounds.y; m_copy.reset(crop_image(image, bounds.x, bounds.y, bounds.w, bounds.h, m_bgcolor)); }