PixelPaint: Create Filter base class

All the filters will need a wrapper around them, and this is going to be
their base class
This commit is contained in:
Tobias Christiansen 2022-01-02 16:25:54 +01:00 committed by Andreas Kling
parent 0334783cf0
commit 5cf0357be1
3 changed files with 62 additions and 0 deletions

View file

@ -17,6 +17,7 @@ set(SOURCES
FilterGallery.cpp
FilterGalleryGML.h
FilterModel.cpp
Filters/Filter.cpp
Image.cpp
ImageEditor.cpp
Layer.cpp

View file

@ -0,0 +1,28 @@
/*
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "Filter.h"
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Label.h>
namespace PixelPaint {
RefPtr<GUI::Widget> Filter::get_settings_widget()
{
if (!m_settings_widget) {
m_settings_widget = GUI::Widget::construct();
m_settings_widget->set_layout<GUI::VerticalBoxLayout>();
auto& name_label = m_settings_widget->add<GUI::Label>(filter_name());
name_label.set_text_alignment(Gfx::TextAlignment::TopLeft);
m_settings_widget->add<GUI::Widget>();
}
return m_settings_widget.ptr();
}
}

View file

@ -0,0 +1,33 @@
/*
* Copyright (c) 2022, Tobias Christiansen <tobyase@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include "../ImageEditor.h"
#include "../Layer.h"
#include <LibGUI/Widget.h>
namespace PixelPaint {
class Filter {
public:
virtual void apply() const = 0;
virtual RefPtr<GUI::Widget> get_settings_widget();
virtual StringView filter_name() = 0;
virtual ~Filter() {};
Filter(ImageEditor* editor)
: m_editor(editor) {};
protected:
ImageEditor* m_editor { nullptr };
StringView m_filter_name;
RefPtr<GUI::Widget> m_settings_widget { nullptr };
};
}