mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:37:36 +00:00
PixelPaint: Make the ImageEditor known throughout the Filter Gallery
This commit is contained in:
parent
f47026b1d6
commit
ddaf496aa0
5 changed files with 16 additions and 8 deletions
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace PixelPaint {
|
namespace PixelPaint {
|
||||||
|
|
||||||
FilterGallery::FilterGallery(GUI::Window* parent_window)
|
FilterGallery::FilterGallery(GUI::Window* parent_window, ImageEditor* editor)
|
||||||
: GUI::Dialog(parent_window)
|
: GUI::Dialog(parent_window)
|
||||||
{
|
{
|
||||||
set_title("Filter Gallery");
|
set_title("Filter Gallery");
|
||||||
|
@ -33,7 +33,7 @@ FilterGallery::FilterGallery(GUI::Window* parent_window)
|
||||||
VERIFY(apply_button);
|
VERIFY(apply_button);
|
||||||
VERIFY(cancel_button);
|
VERIFY(cancel_button);
|
||||||
|
|
||||||
auto filter_model = FilterModel::create();
|
auto filter_model = FilterModel::create(editor);
|
||||||
filter_tree->set_model(filter_model);
|
filter_tree->set_model(filter_model);
|
||||||
filter_tree->expand_tree();
|
filter_tree->expand_tree();
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "ImageEditor.h"
|
||||||
#include <LibGUI/Dialog.h>
|
#include <LibGUI/Dialog.h>
|
||||||
|
|
||||||
namespace PixelPaint {
|
namespace PixelPaint {
|
||||||
|
@ -14,7 +15,7 @@ class FilterGallery final : public GUI::Dialog {
|
||||||
C_OBJECT(FilterGallery);
|
C_OBJECT(FilterGallery);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FilterGallery(GUI::Window* parent_window);
|
FilterGallery(GUI::Window* parent_window, ImageEditor*);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "FilterModel.h"
|
#include "FilterModel.h"
|
||||||
|
#include "FilterParams.h"
|
||||||
|
#include "Layer.h"
|
||||||
#include <LibGUI/FileIconProvider.h>
|
#include <LibGUI/FileIconProvider.h>
|
||||||
|
#include <LibGfx/Filters/LaplacianFilter.h>
|
||||||
|
|
||||||
namespace PixelPaint {
|
namespace PixelPaint {
|
||||||
FilterModel::FilterModel()
|
FilterModel::FilterModel(ImageEditor* editor)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto filter_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png").release_value_but_fixme_should_propagate_errors();
|
auto filter_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png").release_value_but_fixme_should_propagate_errors();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "ImageEditor.h"
|
||||||
#include <AK/NonnullRefPtr.h>
|
#include <AK/NonnullRefPtr.h>
|
||||||
#include <LibGUI/Model.h>
|
#include <LibGUI/Model.h>
|
||||||
|
|
||||||
|
@ -53,9 +54,9 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static NonnullRefPtr<FilterModel> create()
|
static NonnullRefPtr<FilterModel> create(ImageEditor* editor)
|
||||||
{
|
{
|
||||||
return adopt_ref(*new FilterModel());
|
return adopt_ref(*new FilterModel(editor));
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~FilterModel() override {};
|
virtual ~FilterModel() override {};
|
||||||
|
@ -67,7 +68,7 @@ public:
|
||||||
virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FilterModel();
|
FilterModel(ImageEditor* editor);
|
||||||
|
|
||||||
NonnullRefPtrVector<FilterInfo> m_filters;
|
NonnullRefPtrVector<FilterInfo> m_filters;
|
||||||
GUI::Icon m_filter_icon;
|
GUI::Icon m_filter_icon;
|
||||||
|
|
|
@ -590,7 +590,10 @@ void MainWidget::initialize_menubar(GUI::Window& window)
|
||||||
auto& filter_menu = window.add_menu("&Filter");
|
auto& filter_menu = window.add_menu("&Filter");
|
||||||
|
|
||||||
filter_menu.add_action(GUI::Action::create("Filter &Gallery", [&](auto&) {
|
filter_menu.add_action(GUI::Action::create("Filter &Gallery", [&](auto&) {
|
||||||
auto dialog = PixelPaint::FilterGallery::construct(&window);
|
auto* editor = current_image_editor();
|
||||||
|
if (!editor)
|
||||||
|
return;
|
||||||
|
auto dialog = PixelPaint::FilterGallery::construct(&window, editor);
|
||||||
if (dialog->exec() != GUI::Dialog::ExecOK)
|
if (dialog->exec() != GUI::Dialog::ExecOK)
|
||||||
return;
|
return;
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue