2020-08-21 20:36:20 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
2022-04-29 14:07:06 +03:00
|
|
|
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
2021-12-18 01:59:01 +03:00
|
|
|
* Copyright (c) 2021, Antonio Di Stefano <tonio9681@gmail.com>
|
2022-02-10 22:28:48 +03:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-08-21 20:36:20 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-21 20:36:20 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-04-02 04:24:51 +03:00
|
|
|
#include <LibGUI/AbstractThemePreview.h>
|
2022-09-26 15:58:00 +03:00
|
|
|
#include <LibGUI/Application.h>
|
2022-09-26 15:57:11 +03:00
|
|
|
#include <LibGUI/ColorFilterer.h>
|
2020-08-21 20:36:20 +03:00
|
|
|
#include <LibGUI/Frame.h>
|
2021-10-27 14:23:27 +03:00
|
|
|
#include <LibGfx/Bitmap.h>
|
2021-12-18 01:59:01 +03:00
|
|
|
#include <LibGfx/Filters/ColorBlindnessFilter.h>
|
2020-08-21 20:36:20 +03:00
|
|
|
#include <LibGfx/Palette.h>
|
|
|
|
|
|
|
|
namespace ThemeEditor {
|
|
|
|
|
2020-08-23 15:02:04 +03:00
|
|
|
class MiniWidgetGallery;
|
|
|
|
|
2022-09-26 15:57:11 +03:00
|
|
|
class PreviewWidget final
|
|
|
|
: public GUI::AbstractThemePreview
|
|
|
|
, public GUI::ColorFilterer {
|
2022-12-30 15:13:23 +03:00
|
|
|
C_OBJECT_ABSTRACT(PreviewWidget);
|
2020-08-21 20:36:20 +03:00
|
|
|
|
|
|
|
public:
|
2022-12-30 15:13:23 +03:00
|
|
|
static ErrorOr<NonnullRefPtr<PreviewWidget>> try_create();
|
2022-02-10 22:28:48 +03:00
|
|
|
virtual ~PreviewWidget() override = default;
|
2020-08-21 20:36:20 +03:00
|
|
|
|
2022-09-26 15:57:11 +03:00
|
|
|
virtual void set_color_filter(OwnPtr<Gfx::ColorBlindnessFilter>) override;
|
2021-12-18 01:59:01 +03:00
|
|
|
|
2020-08-21 20:36:20 +03:00
|
|
|
private:
|
2022-12-30 15:13:23 +03:00
|
|
|
PreviewWidget();
|
2020-08-21 20:36:20 +03:00
|
|
|
|
2022-04-02 04:24:51 +03:00
|
|
|
virtual void paint_preview(GUI::PaintEvent&) override;
|
2021-12-18 01:59:01 +03:00
|
|
|
virtual void second_paint_event(GUI::PaintEvent&) override;
|
2020-08-23 15:02:04 +03:00
|
|
|
virtual void resize_event(GUI::ResizeEvent&) override;
|
2022-04-29 14:07:06 +03:00
|
|
|
virtual void palette_changed() override;
|
2020-08-21 20:36:20 +03:00
|
|
|
|
2022-04-28 22:40:41 +03:00
|
|
|
void paint_hightlight_window();
|
2022-04-28 21:06:26 +03:00
|
|
|
void update_preview_window_locations();
|
|
|
|
|
|
|
|
Gfx::IntRect m_active_window_rect;
|
|
|
|
Gfx::IntRect m_inactive_window_rect;
|
2022-04-28 22:40:41 +03:00
|
|
|
Gfx::IntRect m_highlight_window_rect;
|
2022-04-28 21:06:26 +03:00
|
|
|
|
2021-12-18 01:59:01 +03:00
|
|
|
OwnPtr<Gfx::ColorBlindnessFilter> m_color_filter = nullptr;
|
2020-08-23 15:02:04 +03:00
|
|
|
RefPtr<MiniWidgetGallery> m_gallery;
|
2020-08-21 20:36:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|