mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-07 19:57:45 +03:00
67596d9546
Since this code needs to look at a bunch of ImageEditor state anyway, it makes more sense for it to live in ImageEditor.
45 lines
767 B
C++
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();
|
|
}
|
|
}
|
|
|
|
}
|