ladybird/Userland/Applications/PixelPaint/Selection.cpp
Andreas Kling 67596d9546 PixelPaint: Move "marching ants" painting logic to ImageEditor
Since this code needs to look at a bunch of ImageEditor state anyway,
it makes more sense for it to live in ImageEditor.
2022-08-26 01:04:52 +02:00

45 lines
767 B
C++

/*
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "Selection.h"
#include "ImageEditor.h"
#include <LibGfx/Painter.h>
namespace PixelPaint {
Selection::Selection(ImageEditor& editor)
: m_editor(editor)
{
}
void Selection::clear()
{
m_mask = {};
m_editor.update();
}
void Selection::merge(Mask const& mask, MergeMode mode)
{
switch (mode) {
case MergeMode::Set:
m_mask = mask;
break;
case MergeMode::Add:
m_mask.add(mask);
break;
case MergeMode::Subtract:
m_mask.subtract(mask);
break;
case MergeMode::Intersect:
m_mask.intersect(mask);
break;
default:
VERIFY_NOT_REACHED();
}
}
}