mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +00:00
PixelPaint: Extract common scope code into a generic ScopeWidget
When we add more scopes, this will facilitate code sharing.
This commit is contained in:
parent
8b60305698
commit
fe88fd22fa
5 changed files with 86 additions and 45 deletions
41
Userland/Applications/PixelPaint/ScopeWidget.cpp
Normal file
41
Userland/Applications/PixelPaint/ScopeWidget.cpp
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2022, kleines Filmröllchen <filmroellchen@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "ScopeWidget.h"
|
||||
#include "Layer.h"
|
||||
|
||||
namespace PixelPaint {
|
||||
|
||||
ScopeWidget::~ScopeWidget()
|
||||
{
|
||||
if (m_image)
|
||||
m_image->remove_client(*this);
|
||||
}
|
||||
|
||||
void ScopeWidget::set_image(Image* image)
|
||||
{
|
||||
if (m_image == image)
|
||||
return;
|
||||
if (m_image)
|
||||
m_image->remove_client(*this);
|
||||
m_image = image;
|
||||
if (m_image)
|
||||
m_image->add_client(*this);
|
||||
|
||||
image_changed();
|
||||
update();
|
||||
}
|
||||
|
||||
void ScopeWidget::set_color_at_mouseposition(Color color)
|
||||
{
|
||||
if (m_color_at_mouseposition == color)
|
||||
return;
|
||||
|
||||
m_color_at_mouseposition = color;
|
||||
update();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue