LibGUI: Fix const-correctness issues
This commit is contained in:
parent
bfe081caad
commit
faa1a09042
Notes:
sideshowbarker
2024-07-17 23:00:03 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/faa1a09042 Pull-request: https://github.com/SerenityOS/serenity/pull/17557 Reviewed-by: https://github.com/linusg
44 changed files with 180 additions and 183 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -31,7 +31,7 @@ private:
|
|||
AboutDialog(StringView name, StringView version, Gfx::Bitmap const* icon = nullptr, Window* parent_window = nullptr);
|
||||
|
||||
DeprecatedString m_name;
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap const> m_icon;
|
||||
DeprecatedString m_version_string;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ void AbstractThemePreview::load_theme_bitmaps()
|
|||
load_bitmap(m_preview_palette.tooltip_shadow_path(), m_last_tooltip_shadow_path, m_tooltip_shadow);
|
||||
}
|
||||
|
||||
void AbstractThemePreview::set_preview_palette(Gfx::Palette const& palette)
|
||||
void AbstractThemePreview::set_preview_palette(Gfx::Palette& palette)
|
||||
{
|
||||
m_preview_palette = palette;
|
||||
palette_changed();
|
||||
|
|
|
@ -22,8 +22,8 @@ class AbstractThemePreview : public GUI::Frame {
|
|||
public:
|
||||
virtual ~AbstractThemePreview() override = default;
|
||||
|
||||
Gfx::Palette const& preview_palette() const { return m_preview_palette; }
|
||||
void set_preview_palette(Gfx::Palette const&);
|
||||
Gfx::Palette& preview_palette() { return m_preview_palette; }
|
||||
void set_preview_palette(Gfx::Palette&);
|
||||
ErrorOr<void> set_theme_from_file(StringView path, NonnullOwnPtr<Core::File>);
|
||||
void set_theme(Core::AnonymousBuffer const&);
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ void AbstractView::notify_selection_changed(Badge<ModelSelection>)
|
|||
update();
|
||||
}
|
||||
|
||||
NonnullRefPtr<Gfx::Font> AbstractView::font_for_index(ModelIndex const& index) const
|
||||
NonnullRefPtr<Gfx::Font const> AbstractView::font_for_index(ModelIndex const& index) const
|
||||
{
|
||||
if (!model())
|
||||
return font();
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
|
||||
void notify_selection_changed(Badge<ModelSelection>);
|
||||
|
||||
NonnullRefPtr<Gfx::Font> font_for_index(ModelIndex const&) const;
|
||||
NonnullRefPtr<Gfx::Font const> font_for_index(ModelIndex const&) const;
|
||||
|
||||
void set_key_column_and_sort_order(int column, SortOrder);
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ private:
|
|||
float m_max_scale { 10.0f };
|
||||
float m_scale { 1.0f };
|
||||
|
||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> m_saved_cursor { Gfx::StandardCursor::None };
|
||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> m_saved_cursor { Gfx::StandardCursor::None };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -18,7 +18,7 @@ NonnullRefPtr<Action> Action::create(DeprecatedString text, Function<void(Action
|
|||
return adopt_ref(*new Action(move(text), move(callback), parent));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), move(icon), move(callback), parent));
|
||||
}
|
||||
|
@ -33,12 +33,12 @@ NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shor
|
|||
return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(callback), parent));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(icon), move(callback), parent));
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, Function<v
|
|||
return adopt_ref(*new Action(move(text), move(callback), parent, true));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), move(icon), move(callback), parent, true));
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, Shortcut c
|
|||
return adopt_ref(*new Action(move(text), shortcut, move(callback), parent, true));
|
||||
}
|
||||
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
NonnullRefPtr<Action> Action::create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent)
|
||||
{
|
||||
return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent, true));
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ Action::Action(DeprecatedString text, Function<void(Action&)> on_activation_call
|
|||
{
|
||||
}
|
||||
|
||||
Action::Action(DeprecatedString text, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable)
|
||||
Action::Action(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable)
|
||||
: Action(move(text), Shortcut {}, Shortcut {}, move(icon), move(on_activation_callback), parent, checkable)
|
||||
{
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ Action::Action(DeprecatedString text, Shortcut const& shortcut, Shortcut const&
|
|||
{
|
||||
}
|
||||
|
||||
Action::Action(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable)
|
||||
Action::Action(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> on_activation_callback, Core::Object* parent, bool checkable)
|
||||
: Core::Object(parent)
|
||||
, on_activation(move(on_activation_callback))
|
||||
, m_text(move(text))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -66,15 +66,15 @@ public:
|
|||
ApplicationGlobal,
|
||||
};
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
static NonnullRefPtr<Action> create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
|
||||
static ErrorOr<NonnullRefPtr<Action>> try_create_checkable(DeprecatedString text, Shortcut const& shortcut, Function<void(Action&)> callback, Core::Object* parent = nullptr);
|
||||
|
||||
|
@ -135,8 +135,8 @@ private:
|
|||
Action(DeprecatedString, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Shortcut const&, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Shortcut const&, Shortcut const&, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Shortcut const&, Shortcut const&, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, RefPtr<Gfx::Bitmap> icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, Shortcut const&, Shortcut const&, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
Action(DeprecatedString, RefPtr<Gfx::Bitmap const> icon, Function<void(Action&)> = nullptr, Core::Object* = nullptr, bool checkable = false);
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_toolbar_button(Callback);
|
||||
|
@ -145,7 +145,7 @@ private:
|
|||
|
||||
DeprecatedString m_text;
|
||||
DeprecatedString m_status_tip;
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap const> m_icon;
|
||||
Shortcut m_shortcut;
|
||||
Shortcut m_alternate_shortcut;
|
||||
bool m_enabled { true };
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -211,7 +211,7 @@ void Application::set_system_palette(Core::AnonymousBuffer& buffer)
|
|||
m_palette = m_system_palette;
|
||||
}
|
||||
|
||||
void Application::set_palette(Palette const& palette)
|
||||
void Application::set_palette(Palette& palette)
|
||||
{
|
||||
m_palette = palette.impl();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
void show_tooltip(DeprecatedString, Widget const* tooltip_source_widget);
|
||||
void show_tooltip_immediately(DeprecatedString, Widget const* tooltip_source_widget);
|
||||
void hide_tooltip();
|
||||
Widget* tooltip_source_widget() { return m_tooltip_source_widget; };
|
||||
Widget const* tooltip_source_widget() { return m_tooltip_source_widget; };
|
||||
|
||||
bool quit_when_last_window_deleted() const { return m_quit_when_last_window_deleted; }
|
||||
void set_quit_when_last_window_deleted(bool b) { m_quit_when_last_window_deleted = b; }
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
Vector<DeprecatedString> const& args() const { return m_args; }
|
||||
|
||||
Gfx::Palette palette() const;
|
||||
void set_palette(Gfx::Palette const&);
|
||||
void set_palette(Gfx::Palette&);
|
||||
|
||||
void set_system_palette(Core::AnonymousBuffer&);
|
||||
|
||||
|
@ -110,7 +110,7 @@ private:
|
|||
RefPtr<Core::Timer> m_tooltip_show_timer;
|
||||
RefPtr<Core::Timer> m_tooltip_hide_timer;
|
||||
RefPtr<TooltipWindow> m_tooltip_window;
|
||||
RefPtr<Widget> m_tooltip_source_widget;
|
||||
RefPtr<Widget const> m_tooltip_source_widget;
|
||||
WeakPtr<Window> m_active_window;
|
||||
bool m_quit_when_last_window_deleted { true };
|
||||
bool m_focus_debugging_enabled { false };
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -178,7 +178,7 @@ void Button::set_action(Action& action)
|
|||
set_checked(action.is_checked());
|
||||
}
|
||||
|
||||
void Button::set_icon(RefPtr<Gfx::Bitmap> icon)
|
||||
void Button::set_icon(RefPtr<Gfx::Bitmap const> icon)
|
||||
{
|
||||
if (m_icon == icon)
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -28,10 +28,9 @@ public:
|
|||
|
||||
virtual ~Button() override;
|
||||
|
||||
void set_icon(RefPtr<Gfx::Bitmap>);
|
||||
void set_icon(RefPtr<Gfx::Bitmap const>);
|
||||
void set_icon_from_path(DeprecatedString const&);
|
||||
Gfx::Bitmap const* icon() const { return m_icon.ptr(); }
|
||||
Gfx::Bitmap* icon() { return m_icon.ptr(); }
|
||||
|
||||
void set_text_alignment(Gfx::TextAlignment text_alignment) { m_text_alignment = text_alignment; }
|
||||
Gfx::TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
|
@ -78,7 +77,7 @@ protected:
|
|||
private:
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap const> m_icon;
|
||||
RefPtr<GUI::Menu> m_menu;
|
||||
Gfx::ButtonStyle m_button_style { Gfx::ButtonStyle::Normal };
|
||||
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
|
||||
|
|
|
@ -59,7 +59,7 @@ RefPtr<Gfx::Bitmap> Desktop::wallpaper_bitmap() const
|
|||
return ConnectionToWindowServer::the().get_wallpaper().bitmap();
|
||||
}
|
||||
|
||||
bool Desktop::set_wallpaper(RefPtr<Gfx::Bitmap> wallpaper_bitmap, Optional<DeprecatedString> path)
|
||||
bool Desktop::set_wallpaper(RefPtr<Gfx::Bitmap const> wallpaper_bitmap, Optional<DeprecatedString> path)
|
||||
{
|
||||
if (m_is_setting_desktop_wallpaper)
|
||||
return false;
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
DeprecatedString wallpaper_path() const;
|
||||
RefPtr<Gfx::Bitmap> wallpaper_bitmap() const;
|
||||
bool set_wallpaper(RefPtr<Gfx::Bitmap> wallpaper_bitmap, Optional<DeprecatedString> path);
|
||||
bool set_wallpaper(RefPtr<Gfx::Bitmap const> wallpaper_bitmap, Optional<DeprecatedString> path);
|
||||
|
||||
void set_system_effects(Vector<bool> effects) { m_system_effects = { effects }; };
|
||||
SystemEffects const& system_effects() const { return m_system_effects; }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -46,7 +46,7 @@ static constexpr auto s_emoji_groups = Array {
|
|||
EmojiCateogry { Unicode::EmojiGroup::SerenityOS, 0x10CD0B },
|
||||
};
|
||||
|
||||
static void resize_bitmap_if_needed(RefPtr<Gfx::Bitmap>& bitmap)
|
||||
static void resize_bitmap_if_needed(RefPtr<Gfx::Bitmap const>& bitmap)
|
||||
{
|
||||
constexpr int max_icon_size = 12;
|
||||
|
||||
|
@ -74,7 +74,7 @@ private:
|
|||
if (m_first_paint_event) {
|
||||
m_first_paint_event = false;
|
||||
|
||||
RefPtr<Gfx::Bitmap> bitmap = Gfx::Emoji::emoji_for_code_points(m_emoji_code_points);
|
||||
RefPtr<Gfx::Bitmap const> bitmap = Gfx::Emoji::emoji_for_code_points(m_emoji_code_points);
|
||||
VERIFY(bitmap);
|
||||
|
||||
resize_bitmap_if_needed(bitmap);
|
||||
|
@ -113,7 +113,7 @@ EmojiInputDialog::EmojiInputDialog(Window* parent_window)
|
|||
auto name = Unicode::emoji_group_to_string(category.group);
|
||||
auto tooltip = name.replace("&"sv, "&&"sv, ReplaceMode::FirstOnly);
|
||||
|
||||
RefPtr<Gfx::Bitmap> bitmap = Gfx::Emoji::emoji_for_code_point(category.emoji_code_point);
|
||||
RefPtr<Gfx::Bitmap const> bitmap = Gfx::Emoji::emoji_for_code_point(category.emoji_code_point);
|
||||
VERIFY(bitmap);
|
||||
resize_bitmap_if_needed(bitmap);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
DropEvent::DropEvent(Gfx::IntPoint position, DeprecatedString const& text, NonnullRefPtr<Core::MimeData> mime_data)
|
||||
DropEvent::DropEvent(Gfx::IntPoint position, DeprecatedString const& text, NonnullRefPtr<Core::MimeData const> mime_data)
|
||||
: Event(Event::Drop)
|
||||
, m_position(position)
|
||||
, m_text(text)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -229,7 +229,7 @@ public:
|
|||
Gfx::Bitmap const* bitmap() const { return m_bitmap; }
|
||||
|
||||
private:
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
RefPtr<Gfx::Bitmap const> m_bitmap;
|
||||
};
|
||||
|
||||
class WMWorkspaceChangedEvent : public WMEvent {
|
||||
|
@ -477,7 +477,7 @@ private:
|
|||
|
||||
class DropEvent final : public Event {
|
||||
public:
|
||||
DropEvent(Gfx::IntPoint, DeprecatedString const& text, NonnullRefPtr<Core::MimeData> mime_data);
|
||||
DropEvent(Gfx::IntPoint, DeprecatedString const& text, NonnullRefPtr<Core::MimeData const> mime_data);
|
||||
|
||||
~DropEvent() = default;
|
||||
|
||||
|
@ -488,7 +488,7 @@ public:
|
|||
private:
|
||||
Gfx::IntPoint m_position;
|
||||
DeprecatedString m_text;
|
||||
NonnullRefPtr<Core::MimeData> m_mime_data;
|
||||
NonnullRefPtr<Core::MimeData const> m_mime_data;
|
||||
};
|
||||
|
||||
class ThemeChangeEvent final : public Event {
|
||||
|
|
|
@ -205,7 +205,7 @@ Icon FileIconProvider::icon_for_executable(DeprecatedString const& path)
|
|||
for (auto const& icon_section : icon_sections) {
|
||||
auto section = image.lookup_section(icon_section.section_name);
|
||||
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
RefPtr<Gfx::Bitmap const> bitmap;
|
||||
if (!section.has_value()) {
|
||||
bitmap = s_executable_icon.bitmap_for_size(icon_section.image_size);
|
||||
} else {
|
||||
|
|
|
@ -19,7 +19,7 @@ class FontPicker final : public GUI::Dialog {
|
|||
public:
|
||||
virtual ~FontPicker() override = default;
|
||||
|
||||
RefPtr<Gfx::Font> font() const { return m_font; }
|
||||
RefPtr<Gfx::Font const> font() const { return m_font; }
|
||||
void set_font(Gfx::Font const*);
|
||||
|
||||
private:
|
||||
|
@ -29,7 +29,7 @@ private:
|
|||
|
||||
bool const m_fixed_width_only;
|
||||
|
||||
RefPtr<Gfx::Font> m_font;
|
||||
RefPtr<Gfx::Font const> m_font;
|
||||
|
||||
RefPtr<ListView> m_family_list_view;
|
||||
RefPtr<ListView> m_variant_list_view;
|
||||
|
|
|
@ -152,7 +152,7 @@ public:
|
|||
class Object : public ValueNode {
|
||||
public:
|
||||
Object() = default;
|
||||
Object(DeprecatedString name, NonnullRefPtrVector<Node> properties, NonnullRefPtrVector<Node> sub_objects)
|
||||
Object(DeprecatedString name, NonnullRefPtrVector<Node const> properties, NonnullRefPtrVector<Node const> sub_objects)
|
||||
: m_properties(move(properties))
|
||||
, m_sub_objects(move(sub_objects))
|
||||
, m_name(move(name))
|
||||
|
@ -164,13 +164,13 @@ public:
|
|||
StringView name() const { return m_name; }
|
||||
void set_name(DeprecatedString name) { m_name = move(name); }
|
||||
|
||||
ErrorOr<void> add_sub_object_child(NonnullRefPtr<Node> child)
|
||||
ErrorOr<void> add_sub_object_child(NonnullRefPtr<Node const> child)
|
||||
{
|
||||
VERIFY(is<Object>(child.ptr()) || is<Comment>(child.ptr()));
|
||||
return m_sub_objects.try_append(move(child));
|
||||
}
|
||||
|
||||
ErrorOr<void> add_property_child(NonnullRefPtr<Node> child)
|
||||
ErrorOr<void> add_property_child(NonnullRefPtr<Node const> child)
|
||||
{
|
||||
VERIFY(is<KeyValuePair>(child.ptr()) || is<Comment>(child.ptr()));
|
||||
return m_properties.try_append(move(child));
|
||||
|
@ -178,7 +178,7 @@ public:
|
|||
|
||||
// Does not return key-value pair `layout: ...`!
|
||||
template<typename Callback>
|
||||
void for_each_property(Callback callback)
|
||||
void for_each_property(Callback callback) const
|
||||
{
|
||||
for (auto const& child : m_properties) {
|
||||
if (is<KeyValuePair>(child)) {
|
||||
|
@ -190,52 +190,51 @@ public:
|
|||
}
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_child_object(Callback callback)
|
||||
void for_each_child_object(Callback callback) const
|
||||
{
|
||||
for (NonnullRefPtr<Node> child : m_sub_objects) {
|
||||
for (NonnullRefPtr<Node const> child : m_sub_objects) {
|
||||
// doesn't capture layout as intended, as that's behind a kv-pair
|
||||
if (is<Object>(child.ptr())) {
|
||||
auto object = static_ptr_cast<Object>(child);
|
||||
auto object = static_ptr_cast<Object const>(child);
|
||||
callback(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<FallibleFunction<NonnullRefPtr<Object>> Callback>
|
||||
ErrorOr<void> try_for_each_child_object(Callback callback)
|
||||
ErrorOr<void> try_for_each_child_object(Callback callback) const
|
||||
{
|
||||
for (NonnullRefPtr<Node> child : m_sub_objects) {
|
||||
for (auto const& child : m_sub_objects) {
|
||||
// doesn't capture layout as intended, as that's behind a kv-pair
|
||||
if (is<Object>(child.ptr())) {
|
||||
auto object = static_ptr_cast<Object>(child);
|
||||
TRY(callback(object));
|
||||
if (is<Object>(child)) {
|
||||
TRY(callback(static_cast<Object const&>(child)));
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
RefPtr<Object> layout_object() const
|
||||
RefPtr<Object const> layout_object() const
|
||||
{
|
||||
for (NonnullRefPtr<Node> child : m_properties) {
|
||||
if (is<KeyValuePair>(child.ptr())) {
|
||||
auto property = static_ptr_cast<KeyValuePair>(child);
|
||||
if (property->key() == "layout") {
|
||||
VERIFY(is<Object>(property->value().ptr()));
|
||||
return static_ptr_cast<Object>(property->value());
|
||||
for (auto const& child : m_properties) {
|
||||
if (is<KeyValuePair>(child)) {
|
||||
auto const& property = static_cast<KeyValuePair const&>(child);
|
||||
if (property.key() == "layout") {
|
||||
VERIFY(is<Object>(property.value().ptr()));
|
||||
return static_cast<Object const&>(*property.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<ValueNode> get_property(StringView property_name)
|
||||
RefPtr<ValueNode const> get_property(StringView property_name) const
|
||||
{
|
||||
for (NonnullRefPtr<Node> child : m_properties) {
|
||||
if (is<KeyValuePair>(child.ptr())) {
|
||||
auto property = static_ptr_cast<KeyValuePair>(child);
|
||||
if (property->key() == property_name)
|
||||
return property->value();
|
||||
for (auto const& child : m_properties) {
|
||||
if (is<KeyValuePair>(child)) {
|
||||
auto const& property = static_cast<KeyValuePair const&>(child);
|
||||
if (property.key() == property_name)
|
||||
return property.value();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -275,9 +274,9 @@ public:
|
|||
|
||||
private:
|
||||
// Properties and comments
|
||||
NonnullRefPtrVector<Node> m_properties;
|
||||
NonnullRefPtrVector<Node const> m_properties;
|
||||
// Sub objects and comments
|
||||
NonnullRefPtrVector<Node> m_sub_objects;
|
||||
NonnullRefPtrVector<Node const> m_sub_objects;
|
||||
DeprecatedString m_name {};
|
||||
};
|
||||
|
||||
|
@ -285,14 +284,14 @@ class GMLFile : public Node {
|
|||
public:
|
||||
virtual ~GMLFile() override = default;
|
||||
|
||||
ErrorOr<void> add_child(NonnullRefPtr<Node> child)
|
||||
ErrorOr<void> add_child(NonnullRefPtr<Node const> child)
|
||||
{
|
||||
if (!has_main_class()) {
|
||||
if (is<Comment>(child.ptr())) {
|
||||
return m_leading_comments.try_append(*static_ptr_cast<Comment>(child));
|
||||
return m_leading_comments.try_append(*static_ptr_cast<Comment const>(child));
|
||||
}
|
||||
if (is<Object>(child.ptr())) {
|
||||
m_main_class = static_ptr_cast<Object>(child);
|
||||
m_main_class = static_ptr_cast<Object const>(child);
|
||||
return {};
|
||||
}
|
||||
return Error::from_string_literal("Unexpected data before main class");
|
||||
|
@ -300,18 +299,18 @@ public:
|
|||
// After the main class, only comments are allowed.
|
||||
if (!is<Comment>(child.ptr()))
|
||||
return Error::from_string_literal("Data not allowed after main class");
|
||||
return m_trailing_comments.try_append(*static_ptr_cast<Comment>(child));
|
||||
return m_trailing_comments.try_append(*static_ptr_cast<Comment const>(child));
|
||||
}
|
||||
|
||||
bool has_main_class() const { return m_main_class != nullptr; }
|
||||
|
||||
NonnullRefPtrVector<Comment> leading_comments() const { return m_leading_comments; }
|
||||
Object& main_class()
|
||||
NonnullRefPtrVector<Comment const> leading_comments() const { return m_leading_comments; }
|
||||
Object const& main_class() const
|
||||
{
|
||||
VERIFY(!m_main_class.is_null());
|
||||
return *m_main_class.ptr();
|
||||
}
|
||||
NonnullRefPtrVector<Comment> trailing_comments() const { return m_trailing_comments; }
|
||||
NonnullRefPtrVector<Comment const> trailing_comments() const { return m_trailing_comments; }
|
||||
|
||||
virtual void format(StringBuilder& builder, size_t indentation, [[maybe_unused]] bool is_inline) const override
|
||||
{
|
||||
|
@ -329,9 +328,9 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
NonnullRefPtrVector<Comment> m_leading_comments;
|
||||
RefPtr<Object> m_main_class;
|
||||
NonnullRefPtrVector<Comment> m_trailing_comments;
|
||||
NonnullRefPtrVector<Comment const> m_leading_comments;
|
||||
RefPtr<Object const> m_main_class;
|
||||
NonnullRefPtrVector<Comment const> m_trailing_comments;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ static ErrorOr<NonnullRefPtr<Object>> parse_gml_object(Queue<Token>& tokens)
|
|||
else if (peek() == Token::Type::JsonValue)
|
||||
value = TRY(try_make_ref_counted<JsonValueNode>(TRY(JsonValueNode::from_string(tokens.dequeue().m_view))));
|
||||
|
||||
auto property = TRY(try_make_ref_counted<KeyValuePair>(property_name.m_view, value.release_nonnull()));
|
||||
auto property = TRY(try_make_ref_counted<KeyValuePair const>(property_name.m_view, value.release_nonnull()));
|
||||
TRY(object->add_property_child(property));
|
||||
} else if (peek() == Token::Type::Comment) {
|
||||
pending_comments.append(TRY(Node::from_token<Comment>(tokens.dequeue())));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Julius Heijmen <julius.heijmen@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -26,7 +26,7 @@ Icon::Icon(Icon const& other)
|
|||
{
|
||||
}
|
||||
|
||||
Icon::Icon(RefPtr<Gfx::Bitmap>&& bitmap)
|
||||
Icon::Icon(RefPtr<Gfx::Bitmap const>&& bitmap)
|
||||
: Icon()
|
||||
{
|
||||
if (bitmap) {
|
||||
|
@ -36,7 +36,7 @@ Icon::Icon(RefPtr<Gfx::Bitmap>&& bitmap)
|
|||
}
|
||||
}
|
||||
|
||||
Icon::Icon(RefPtr<Gfx::Bitmap>&& bitmap1, RefPtr<Gfx::Bitmap>&& bitmap2)
|
||||
Icon::Icon(RefPtr<Gfx::Bitmap const>&& bitmap1, RefPtr<Gfx::Bitmap const>&& bitmap2)
|
||||
: Icon(move(bitmap1))
|
||||
{
|
||||
if (bitmap2) {
|
||||
|
@ -64,7 +64,7 @@ Gfx::Bitmap const* IconImpl::bitmap_for_size(int size) const
|
|||
return best_fit;
|
||||
}
|
||||
|
||||
void IconImpl::set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap)
|
||||
void IconImpl::set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap const>&& bitmap)
|
||||
{
|
||||
if (!bitmap) {
|
||||
m_bitmaps.remove(size);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Julius Heijmen <julius.heijmen@gmail.com>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
|
@ -21,7 +21,7 @@ public:
|
|||
~IconImpl() = default;
|
||||
|
||||
Gfx::Bitmap const* bitmap_for_size(int) const;
|
||||
void set_bitmap_for_size(int, RefPtr<Gfx::Bitmap>&&);
|
||||
void set_bitmap_for_size(int, RefPtr<Gfx::Bitmap const>&&);
|
||||
|
||||
Vector<int> sizes() const
|
||||
{
|
||||
|
@ -33,14 +33,14 @@ public:
|
|||
|
||||
private:
|
||||
IconImpl() = default;
|
||||
HashMap<int, RefPtr<Gfx::Bitmap>> m_bitmaps;
|
||||
HashMap<int, RefPtr<Gfx::Bitmap const>> m_bitmaps;
|
||||
};
|
||||
|
||||
class Icon {
|
||||
public:
|
||||
Icon();
|
||||
explicit Icon(RefPtr<Gfx::Bitmap>&&);
|
||||
explicit Icon(RefPtr<Gfx::Bitmap>&&, RefPtr<Gfx::Bitmap>&&);
|
||||
explicit Icon(RefPtr<Gfx::Bitmap const>&&);
|
||||
explicit Icon(RefPtr<Gfx::Bitmap const>&&, RefPtr<Gfx::Bitmap const>&&);
|
||||
explicit Icon(IconImpl const&);
|
||||
Icon(Icon const&);
|
||||
~Icon() = default;
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
}
|
||||
|
||||
Gfx::Bitmap const* bitmap_for_size(int size) const { return m_impl->bitmap_for_size(size); }
|
||||
void set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap>&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); }
|
||||
void set_bitmap_for_size(int size, RefPtr<Gfx::Bitmap const>&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); }
|
||||
|
||||
IconImpl const& impl() const { return *m_impl; }
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ public:
|
|||
virtual ~ImageWidget() override = default;
|
||||
|
||||
void set_bitmap(Gfx::Bitmap const*);
|
||||
Gfx::Bitmap* bitmap() { return m_bitmap.ptr(); }
|
||||
Gfx::Bitmap const* bitmap() const { return m_bitmap.ptr(); }
|
||||
|
||||
void set_should_stretch(bool value) { m_should_stretch = value; }
|
||||
|
@ -43,7 +42,7 @@ protected:
|
|||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
private:
|
||||
RefPtr<Gfx::Bitmap> m_bitmap;
|
||||
RefPtr<Gfx::Bitmap const> m_bitmap;
|
||||
bool m_should_stretch { false };
|
||||
bool m_auto_resize { false };
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -25,7 +25,6 @@ public:
|
|||
void set_icon(Gfx::Bitmap const*);
|
||||
void set_icon_from_path(DeprecatedString const&);
|
||||
Gfx::Bitmap const* icon() const { return m_icon.ptr(); }
|
||||
Gfx::Bitmap* icon() { return m_icon.ptr(); }
|
||||
|
||||
Gfx::TextAlignment text_alignment() const { return m_text_alignment; }
|
||||
void set_text_alignment(Gfx::TextAlignment text_alignment) { m_text_alignment = text_alignment; }
|
||||
|
@ -54,7 +53,7 @@ private:
|
|||
void size_to_fit();
|
||||
|
||||
DeprecatedString m_text;
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap const> m_icon;
|
||||
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
|
||||
Gfx::TextWrapping m_text_wrapping { Gfx::TextWrapping::Wrap };
|
||||
bool m_should_stretch_icon { false };
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -74,7 +74,7 @@ private:
|
|||
|
||||
int m_menu_id { -1 };
|
||||
DeprecatedString m_name;
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap const> m_icon;
|
||||
NonnullOwnPtrVector<MenuItem> m_items;
|
||||
WeakPtr<Action> m_current_default_action;
|
||||
bool m_visible { false };
|
||||
|
|
|
@ -100,7 +100,7 @@ WeakPtr<PersistentHandle> Model::register_persistent_index(Badge<PersistentModel
|
|||
RefPtr<Core::MimeData> Model::mime_data(ModelSelection const& selection) const
|
||||
{
|
||||
auto mime_data = Core::MimeData::construct();
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
RefPtr<Gfx::Bitmap const> bitmap;
|
||||
|
||||
StringBuilder text_builder;
|
||||
StringBuilder data_builder;
|
||||
|
|
|
@ -57,7 +57,7 @@ private:
|
|||
bool m_title_dirty;
|
||||
DeprecatedString m_text;
|
||||
bool m_text_dirty;
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap const> m_icon;
|
||||
bool m_icon_dirty;
|
||||
|
||||
bool m_destroyed { false };
|
||||
|
|
|
@ -31,7 +31,7 @@ private:
|
|||
|
||||
DeprecatedString m_window_title;
|
||||
String m_button_label;
|
||||
RefPtr<Gfx::Bitmap> m_window_icon;
|
||||
RefPtr<Gfx::Bitmap const> m_window_icon;
|
||||
RefPtr<TableView> m_table_view;
|
||||
RefPtr<RunningProcessesModel> m_process_model;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ private:
|
|||
struct Process {
|
||||
pid_t pid;
|
||||
uid_t uid;
|
||||
RefPtr<Gfx::Bitmap> icon;
|
||||
RefPtr<Gfx::Bitmap const> icon;
|
||||
DeprecatedString name;
|
||||
};
|
||||
Vector<Process> m_processes;
|
||||
|
|
|
@ -102,32 +102,32 @@ void ScrollableContainerWidget::set_widget(GUI::Widget* widget)
|
|||
update_widget_position();
|
||||
}
|
||||
|
||||
ErrorOr<void> ScrollableContainerWidget::load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, UnregisteredChildHandler unregistered_child_handler)
|
||||
ErrorOr<void> ScrollableContainerWidget::load_from_gml_ast(NonnullRefPtr<GUI::GML::Node const> ast, UnregisteredChildHandler unregistered_child_handler)
|
||||
{
|
||||
if (is<GUI::GML::GMLFile>(ast.ptr()))
|
||||
return load_from_gml_ast(static_ptr_cast<GUI::GML::GMLFile>(ast)->main_class(), unregistered_child_handler);
|
||||
return load_from_gml_ast(static_cast<GUI::GML::GMLFile const&>(*ast).main_class(), unregistered_child_handler);
|
||||
|
||||
VERIFY(is<GUI::GML::Object>(ast.ptr()));
|
||||
auto object = static_ptr_cast<GUI::GML::Object>(ast);
|
||||
auto const& object = static_cast<GUI::GML::Object const&>(*ast);
|
||||
|
||||
object->for_each_property([&](auto key, auto value) {
|
||||
object.for_each_property([&](auto key, auto value) {
|
||||
set_property(key, value);
|
||||
});
|
||||
|
||||
auto content_widget_value = object->get_property("content_widget"sv);
|
||||
auto content_widget_value = object.get_property("content_widget"sv);
|
||||
if (!content_widget_value.is_null() && !is<GUI::GML::Object>(content_widget_value.ptr())) {
|
||||
return Error::from_string_literal("ScrollableContainerWidget content_widget is not an object");
|
||||
}
|
||||
|
||||
auto has_children = false;
|
||||
object->for_each_child_object([&](auto) { has_children = true; });
|
||||
object.for_each_child_object([&](auto) { has_children = true; });
|
||||
if (has_children) {
|
||||
return Error::from_string_literal("Children specified for ScrollableContainerWidget, but only 1 widget as content_widget is supported");
|
||||
}
|
||||
|
||||
if (!content_widget_value.is_null() && is<GUI::GML::Object>(content_widget_value.ptr())) {
|
||||
auto content_widget = static_ptr_cast<GUI::GML::Object>(content_widget_value);
|
||||
auto class_name = content_widget->name();
|
||||
auto const& content_widget = static_cast<GUI::GML::Object const&>(*content_widget_value);
|
||||
auto class_name = content_widget.name();
|
||||
|
||||
RefPtr<Core::Object> child;
|
||||
if (auto* registration = Core::ObjectClassRegistration::find(class_name)) {
|
||||
|
@ -139,7 +139,7 @@ ErrorOr<void> ScrollableContainerWidget::load_from_gml_ast(NonnullRefPtr<GUI::GM
|
|||
return Error::from_string_literal("Unable to construct a Widget class for ScrollableContainerWidget content_widget property");
|
||||
auto widget_ptr = verify_cast<GUI::Widget>(child.ptr());
|
||||
set_widget(widget_ptr);
|
||||
TRY(static_ptr_cast<Widget>(child)->load_from_gml_ast(content_widget.release_nonnull(), unregistered_child_handler));
|
||||
TRY(static_cast<Widget&>(*child).load_from_gml_ast(content_widget, unregistered_child_handler));
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
|
@ -30,7 +30,7 @@ private:
|
|||
void update_widget_size();
|
||||
void update_widget_position();
|
||||
void update_widget_min_size();
|
||||
virtual ErrorOr<void> load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, UnregisteredChildHandler) override;
|
||||
virtual ErrorOr<void> load_from_gml_ast(NonnullRefPtr<GUI::GML::Node const> ast, UnregisteredChildHandler) override;
|
||||
|
||||
ScrollableContainerWidget();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
|
||||
* Copyright (c) 2022, Cameron Youell <cameronyouell@gmail.com>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -148,7 +148,7 @@ private:
|
|||
struct TabData {
|
||||
int width(Gfx::Font const&) const;
|
||||
DeprecatedString title;
|
||||
RefPtr<Gfx::Bitmap> icon;
|
||||
RefPtr<Gfx::Bitmap const> icon;
|
||||
Widget* widget { nullptr };
|
||||
bool modified { false };
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, networkException <networkexception@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
|
@ -562,12 +562,12 @@ void TextEditor::paint_event(PaintEvent& event)
|
|||
auto unspanned_color = palette().color(is_enabled() ? foreground_role() : Gfx::ColorRole::DisabledText);
|
||||
if (is_displayonly() && is_focused())
|
||||
unspanned_color = palette().color(is_enabled() ? Gfx::ColorRole::SelectionText : Gfx::ColorRole::DisabledText);
|
||||
RefPtr<Gfx::Font> unspanned_font = this->font();
|
||||
RefPtr<Gfx::Font const> unspanned_font = this->font();
|
||||
|
||||
size_t next_column = 0;
|
||||
Gfx::IntRect span_rect = { visual_line_rect.location(), { 0, line_height() } };
|
||||
|
||||
auto draw_text_helper = [&](size_t start, size_t end, RefPtr<Gfx::Font>& font, Gfx::TextAttributes text_attributes) {
|
||||
auto draw_text_helper = [&](size_t start, size_t end, RefPtr<Gfx::Font const>& font, Gfx::TextAttributes text_attributes) {
|
||||
size_t length = end - start;
|
||||
if (length == 0)
|
||||
return;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
* Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
*
|
||||
|
@ -438,7 +438,7 @@ private:
|
|||
|
||||
Gfx::IntPoint m_last_mousemove_position;
|
||||
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap const> m_icon;
|
||||
|
||||
bool m_text_is_secret { false };
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -33,7 +33,7 @@ Gfx::IntRect Tray::Item::rect(Tray const& tray) const
|
|||
};
|
||||
}
|
||||
|
||||
size_t Tray::add_item(DeprecatedString text, RefPtr<Gfx::Bitmap> bitmap, DeprecatedString custom_data)
|
||||
size_t Tray::add_item(DeprecatedString text, RefPtr<Gfx::Bitmap const> bitmap, DeprecatedString custom_data)
|
||||
{
|
||||
auto new_index = m_items.size();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -18,7 +18,7 @@ class Tray : public GUI::Frame {
|
|||
public:
|
||||
virtual ~Tray() override = default;
|
||||
|
||||
size_t add_item(DeprecatedString text, RefPtr<Gfx::Bitmap>, DeprecatedString custom_data);
|
||||
size_t add_item(DeprecatedString text, RefPtr<Gfx::Bitmap const>, DeprecatedString custom_data);
|
||||
|
||||
void set_item_checked(size_t index, bool);
|
||||
|
||||
|
@ -39,7 +39,7 @@ private:
|
|||
|
||||
struct Item {
|
||||
DeprecatedString text;
|
||||
RefPtr<Gfx::Bitmap> bitmap;
|
||||
RefPtr<Gfx::Bitmap const> bitmap;
|
||||
DeprecatedString custom_data;
|
||||
size_t index { 0 };
|
||||
Gfx::IntRect rect(Tray const&) const;
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
requires(IsBaseOf<Node, NodeType>)
|
||||
{
|
||||
auto node = adopt_ref(*new NodeType(move(text), move(icon), this, forward<Args>(args)...));
|
||||
m_child_nodes.append(*static_cast<Node const*>(node.ptr()));
|
||||
m_child_nodes.append(*static_cast<Node*>(node.ptr()));
|
||||
return node;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
requires(IsBaseOf<Node, NodeType>)
|
||||
{
|
||||
auto node = adopt_ref(*new NodeType(move(text), move(icon), nullptr, forward<Args>(args)...));
|
||||
m_nodes.append(*static_cast<Node const*>(node.ptr()));
|
||||
m_nodes.append(*static_cast<Node*>(node.ptr()));
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace Detail {
|
|||
struct Boolean {
|
||||
bool value;
|
||||
};
|
||||
using VariantUnderlyingType = AK::Variant<Empty, Boolean, float, i32, i64, u32, u64, DeprecatedString, Color, Gfx::IntPoint, Gfx::IntSize, Gfx::IntRect, Gfx::TextAlignment, Gfx::ColorRole, Gfx::AlignmentRole, Gfx::FlagRole, Gfx::MetricRole, Gfx::PathRole, NonnullRefPtr<Gfx::Bitmap>, NonnullRefPtr<Gfx::Font>, GUI::Icon>;
|
||||
using VariantUnderlyingType = AK::Variant<Empty, Boolean, float, i32, i64, u32, u64, DeprecatedString, Color, Gfx::IntPoint, Gfx::IntSize, Gfx::IntRect, Gfx::TextAlignment, Gfx::ColorRole, Gfx::AlignmentRole, Gfx::FlagRole, Gfx::MetricRole, Gfx::PathRole, NonnullRefPtr<Gfx::Bitmap const>, NonnullRefPtr<Gfx::Font const>, GUI::Icon>;
|
||||
}
|
||||
|
||||
class Variant : public Detail::VariantUnderlyingType {
|
||||
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
template<OneOfIgnoringCV<Gfx::Bitmap, Gfx::Font> T>
|
||||
Variant(T const& value)
|
||||
: Variant(NonnullRefPtr<RemoveCV<T>>(value))
|
||||
: Variant(NonnullRefPtr<RemoveCV<T> const>(value))
|
||||
{
|
||||
}
|
||||
template<OneOfIgnoringCV<Gfx::Bitmap, Gfx::Font> T>
|
||||
|
@ -77,13 +77,13 @@ public:
|
|||
bool is_u64() const { return has<u64>(); }
|
||||
bool is_float() const { return has<float>(); }
|
||||
bool is_string() const { return has<DeprecatedString>(); }
|
||||
bool is_bitmap() const { return has<NonnullRefPtr<Gfx::Bitmap>>(); }
|
||||
bool is_bitmap() const { return has<NonnullRefPtr<Gfx::Bitmap const>>(); }
|
||||
bool is_color() const { return has<Color>(); }
|
||||
bool is_icon() const { return has<GUI::Icon>(); }
|
||||
bool is_point() const { return has<Gfx::IntPoint>(); }
|
||||
bool is_size() const { return has<Gfx::IntSize>(); }
|
||||
bool is_rect() const { return has<Gfx::IntRect>(); }
|
||||
bool is_font() const { return has<NonnullRefPtr<Gfx::Font>>(); }
|
||||
bool is_font() const { return has<NonnullRefPtr<Gfx::Font const>>(); }
|
||||
bool is_text_alignment() const { return has<Gfx::TextAlignment>(); }
|
||||
bool is_color_role() const { return has<Gfx::ColorRole>(); }
|
||||
bool is_alignment_role() const { return has<Gfx::AlignmentRole>(); }
|
||||
|
@ -103,7 +103,7 @@ public:
|
|||
[](Gfx::IntPoint const& v) { return !v.is_zero(); },
|
||||
[](OneOf<Gfx::IntRect, Gfx::IntSize> auto const& v) { return !v.is_empty(); },
|
||||
[](Enum auto const&) { return true; },
|
||||
[](OneOf<float, DeprecatedString, Color, NonnullRefPtr<Gfx::Font>, NonnullRefPtr<Gfx::Bitmap>, GUI::Icon> auto const&) { return true; });
|
||||
[](OneOf<float, DeprecatedString, Color, NonnullRefPtr<Gfx::Font const>, NonnullRefPtr<Gfx::Bitmap const>, GUI::Icon> auto const&) { return true; });
|
||||
}
|
||||
|
||||
i32 as_i32() const { return get<i32>(); }
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
return v.to_int<T>().value_or(0);
|
||||
},
|
||||
[](Enum auto const&) -> T { return 0; },
|
||||
[](OneOf<Gfx::IntPoint, Gfx::IntRect, Gfx::IntSize, Color, NonnullRefPtr<Gfx::Font>, NonnullRefPtr<Gfx::Bitmap>, GUI::Icon> auto const&) -> T { return 0; });
|
||||
[](OneOf<Gfx::IntPoint, Gfx::IntRect, Gfx::IntSize, Color, NonnullRefPtr<Gfx::Font const>, NonnullRefPtr<Gfx::Bitmap const>, GUI::Icon> auto const&) -> T { return 0; });
|
||||
}
|
||||
|
||||
i32 to_i32() const { return to_integer<i32>(); }
|
||||
|
@ -144,10 +144,10 @@ public:
|
|||
Gfx::IntSize as_size() const { return get<Gfx::IntSize>(); }
|
||||
Gfx::IntRect as_rect() const { return get<Gfx::IntRect>(); }
|
||||
DeprecatedString as_string() const { return get<DeprecatedString>(); }
|
||||
Gfx::Bitmap const& as_bitmap() const { return *get<NonnullRefPtr<Gfx::Bitmap>>(); }
|
||||
Gfx::Bitmap const& as_bitmap() const { return *get<NonnullRefPtr<Gfx::Bitmap const>>(); }
|
||||
GUI::Icon as_icon() const { return get<GUI::Icon>(); }
|
||||
Color as_color() const { return get<Color>(); }
|
||||
Gfx::Font const& as_font() const { return *get<NonnullRefPtr<Gfx::Font>>(); }
|
||||
Gfx::Font const& as_font() const { return *get<NonnullRefPtr<Gfx::Font const>>(); }
|
||||
|
||||
Gfx::TextAlignment to_text_alignment(Gfx::TextAlignment default_value) const
|
||||
{
|
||||
|
@ -211,8 +211,8 @@ public:
|
|||
[](Gfx::FlagRole v) { return DeprecatedString::formatted("Gfx::FlagRole::{}", Gfx::to_string(v)); },
|
||||
[](Gfx::MetricRole v) { return DeprecatedString::formatted("Gfx::MetricRole::{}", Gfx::to_string(v)); },
|
||||
[](Gfx::PathRole v) { return DeprecatedString::formatted("Gfx::PathRole::{}", Gfx::to_string(v)); },
|
||||
[](NonnullRefPtr<Gfx::Font> const& font) { return DeprecatedString::formatted("[Font: {}]", font->name()); },
|
||||
[](NonnullRefPtr<Gfx::Bitmap> const&) -> DeprecatedString { return "[Gfx::Bitmap]"; },
|
||||
[](NonnullRefPtr<Gfx::Font const> const& font) { return DeprecatedString::formatted("[Font: {}]", font->name()); },
|
||||
[](NonnullRefPtr<Gfx::Bitmap const> const&) -> DeprecatedString { return "[Gfx::Bitmap]"; },
|
||||
[](GUI::Icon const&) -> DeprecatedString { return "[GUI::Icon]"; },
|
||||
[](Detail::Boolean v) { return DeprecatedString::formatted("{}", v.value); },
|
||||
[](auto const& v) { return DeprecatedString::formatted("{}", v); });
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
|
@ -1042,7 +1042,7 @@ Vector<Widget&> Widget::child_widgets() const
|
|||
return widgets;
|
||||
}
|
||||
|
||||
void Widget::set_palette(Palette const& palette)
|
||||
void Widget::set_palette(Palette& palette)
|
||||
{
|
||||
m_palette = palette.impl();
|
||||
update();
|
||||
|
@ -1126,14 +1126,14 @@ Gfx::IntRect Widget::children_clip_rect() const
|
|||
return rect();
|
||||
}
|
||||
|
||||
void Widget::set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> cursor)
|
||||
void Widget::set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> cursor)
|
||||
{
|
||||
auto const& are_cursors_the_same = [](AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const& a, AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const& b) {
|
||||
if (a.has<Gfx::StandardCursor>() != b.has<Gfx::StandardCursor>())
|
||||
auto const& are_cursors_the_same = [](auto const& a, auto const& b) {
|
||||
if (a.template has<Gfx::StandardCursor>() != b.template has<Gfx::StandardCursor>())
|
||||
return false;
|
||||
if (a.has<Gfx::StandardCursor>())
|
||||
return a.get<Gfx::StandardCursor>() == b.get<Gfx::StandardCursor>();
|
||||
return a.get<NonnullRefPtr<Gfx::Bitmap>>().ptr() == b.get<NonnullRefPtr<Gfx::Bitmap>>().ptr();
|
||||
if (a.template has<Gfx::StandardCursor>())
|
||||
return a.template get<Gfx::StandardCursor>() == b.template get<Gfx::StandardCursor>();
|
||||
return a.template get<NonnullRefPtr<Gfx::Bitmap const>>().ptr() == b.template get<NonnullRefPtr<Gfx::Bitmap const>>().ptr();
|
||||
};
|
||||
|
||||
if (are_cursors_the_same(m_override_cursor, cursor))
|
||||
|
@ -1159,19 +1159,19 @@ ErrorOr<void> Widget::load_from_gml(StringView gml_string, UnregisteredChildHand
|
|||
return load_from_gml_ast(value, unregistered_child_handler);
|
||||
}
|
||||
|
||||
ErrorOr<void> Widget::load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, UnregisteredChildHandler unregistered_child_handler)
|
||||
ErrorOr<void> Widget::load_from_gml_ast(NonnullRefPtr<GUI::GML::Node const> ast, UnregisteredChildHandler unregistered_child_handler)
|
||||
{
|
||||
if (is<GUI::GML::GMLFile>(ast.ptr()))
|
||||
return load_from_gml_ast(static_ptr_cast<GUI::GML::GMLFile>(ast)->main_class(), unregistered_child_handler);
|
||||
return load_from_gml_ast(static_cast<GUI::GML::GMLFile const&>(*ast).main_class(), unregistered_child_handler);
|
||||
|
||||
VERIFY(is<GUI::GML::Object>(ast.ptr()));
|
||||
auto object = static_ptr_cast<GUI::GML::Object>(ast);
|
||||
auto const& object = static_cast<GUI::GML::Object const&>(*ast);
|
||||
|
||||
object->for_each_property([&](auto key, auto value) {
|
||||
object.for_each_property([&](auto key, auto value) {
|
||||
set_property(key, value);
|
||||
});
|
||||
|
||||
auto layout = object->layout_object();
|
||||
auto layout = object.layout_object();
|
||||
if (!layout.is_null()) {
|
||||
auto class_name = layout->name();
|
||||
if (class_name.is_null()) {
|
||||
|
@ -1198,8 +1198,8 @@ ErrorOr<void> Widget::load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, Unreg
|
|||
|
||||
auto& widget_class = *Core::ObjectClassRegistration::find("GUI::Widget"sv);
|
||||
bool is_tab_widget = is<TabWidget>(*this);
|
||||
TRY(object->try_for_each_child_object([&](auto child_data) -> ErrorOr<void> {
|
||||
auto class_name = child_data->name();
|
||||
TRY(object.try_for_each_child_object([&](auto const& child_data) -> ErrorOr<void> {
|
||||
auto class_name = child_data.name();
|
||||
|
||||
// It is very questionable if this pseudo object should exist, but it works fine like this for now.
|
||||
if (class_name == "GUI::Layout::Spacer") {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -332,7 +332,7 @@ public:
|
|||
void do_layout();
|
||||
|
||||
Gfx::Palette palette() const;
|
||||
void set_palette(Gfx::Palette const&);
|
||||
void set_palette(Gfx::Palette&);
|
||||
|
||||
DeprecatedString title() const;
|
||||
void set_title(DeprecatedString);
|
||||
|
@ -349,8 +349,8 @@ public:
|
|||
|
||||
virtual Gfx::IntRect children_clip_rect() const;
|
||||
|
||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const& override_cursor() const { return m_override_cursor; }
|
||||
void set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>>);
|
||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> const& override_cursor() const { return m_override_cursor; }
|
||||
void set_override_cursor(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>>);
|
||||
|
||||
using UnregisteredChildHandler = ErrorOr<NonnullRefPtr<Core::Object>>(DeprecatedString const&);
|
||||
ErrorOr<void> load_from_gml(StringView);
|
||||
|
@ -363,7 +363,7 @@ public:
|
|||
bool has_pending_drop() const;
|
||||
|
||||
// In order for others to be able to call this, it needs to be public.
|
||||
virtual ErrorOr<void> load_from_gml_ast(NonnullRefPtr<GUI::GML::Node> ast, UnregisteredChildHandler);
|
||||
virtual ErrorOr<void> load_from_gml_ast(NonnullRefPtr<GUI::GML::Node const> ast, UnregisteredChildHandler);
|
||||
|
||||
ErrorOr<void> add_spacer();
|
||||
|
||||
|
@ -439,7 +439,7 @@ private:
|
|||
Gfx::IntRect m_relative_rect;
|
||||
Gfx::ColorRole m_background_role;
|
||||
Gfx::ColorRole m_foreground_role;
|
||||
NonnullRefPtr<Gfx::Font> m_font;
|
||||
NonnullRefPtr<Gfx::Font const> m_font;
|
||||
DeprecatedString m_tooltip;
|
||||
|
||||
UISize m_min_size { SpecialDimension::Shrink };
|
||||
|
@ -464,7 +464,7 @@ private:
|
|||
Vector<WeakPtr<Widget>> m_focus_delegators;
|
||||
FocusPolicy m_focus_policy { FocusPolicy::NoFocus };
|
||||
|
||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> m_override_cursor { Gfx::StandardCursor::None };
|
||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> m_override_cursor { Gfx::StandardCursor::None };
|
||||
};
|
||||
|
||||
inline Widget* Widget::parent_widget()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -336,13 +336,13 @@ void Window::make_window_manager(unsigned event_mask)
|
|||
GUI::ConnectionToWindowManagerServer::the().async_set_manager_window(m_window_id);
|
||||
}
|
||||
|
||||
bool Window::are_cursors_the_same(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const& left, AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const& right) const
|
||||
bool Window::are_cursors_the_same(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> const& left, AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> const& right) const
|
||||
{
|
||||
if (left.has<Gfx::StandardCursor>() != right.has<Gfx::StandardCursor>())
|
||||
return false;
|
||||
if (left.has<Gfx::StandardCursor>())
|
||||
return left.get<Gfx::StandardCursor>() == right.get<Gfx::StandardCursor>();
|
||||
return left.get<NonnullRefPtr<Gfx::Bitmap>>().ptr() == right.get<NonnullRefPtr<Gfx::Bitmap>>().ptr();
|
||||
return left.get<NonnullRefPtr<Gfx::Bitmap const>>().ptr() == right.get<NonnullRefPtr<Gfx::Bitmap const>>().ptr();
|
||||
}
|
||||
|
||||
void Window::set_cursor(Gfx::StandardCursor cursor)
|
||||
|
@ -353,7 +353,7 @@ void Window::set_cursor(Gfx::StandardCursor cursor)
|
|||
update_cursor();
|
||||
}
|
||||
|
||||
void Window::set_cursor(NonnullRefPtr<Gfx::Bitmap> cursor)
|
||||
void Window::set_cursor(NonnullRefPtr<Gfx::Bitmap const> cursor)
|
||||
{
|
||||
if (are_cursors_the_same(m_cursor, cursor))
|
||||
return;
|
||||
|
@ -987,11 +987,12 @@ void Window::set_icon(Gfx::Bitmap const* icon)
|
|||
|
||||
Gfx::IntSize icon_size = icon ? icon->size() : Gfx::IntSize(16, 16);
|
||||
|
||||
m_icon = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, icon_size).release_value_but_fixme_should_propagate_errors();
|
||||
auto new_icon = Gfx::Bitmap::create(Gfx::BitmapFormat::BGRA8888, icon_size).release_value_but_fixme_should_propagate_errors();
|
||||
if (icon) {
|
||||
Painter painter(*m_icon);
|
||||
Painter painter(*new_icon);
|
||||
painter.blit({ 0, 0 }, *icon, icon->rect());
|
||||
}
|
||||
m_icon = move(new_icon);
|
||||
|
||||
apply_icon();
|
||||
}
|
||||
|
@ -1252,7 +1253,7 @@ void Window::update_cursor()
|
|||
auto new_cursor = m_cursor;
|
||||
|
||||
auto is_usable_cursor = [](auto& cursor) {
|
||||
return cursor.template has<NonnullRefPtr<Gfx::Bitmap>>() || cursor.template get<Gfx::StandardCursor>() != Gfx::StandardCursor::None;
|
||||
return cursor.template has<NonnullRefPtr<Gfx::Bitmap const>>() || cursor.template get<Gfx::StandardCursor>() != Gfx::StandardCursor::None;
|
||||
};
|
||||
|
||||
// NOTE: If there's an automatic cursor tracking widget, we retain its cursor until tracking stops.
|
||||
|
@ -1268,8 +1269,8 @@ void Window::update_cursor()
|
|||
return;
|
||||
m_effective_cursor = new_cursor;
|
||||
|
||||
if (new_cursor.has<NonnullRefPtr<Gfx::Bitmap>>())
|
||||
ConnectionToWindowServer::the().async_set_window_custom_cursor(m_window_id, new_cursor.get<NonnullRefPtr<Gfx::Bitmap>>()->to_shareable_bitmap());
|
||||
if (new_cursor.has<NonnullRefPtr<Gfx::Bitmap const>>())
|
||||
ConnectionToWindowServer::the().async_set_window_custom_cursor(m_window_id, new_cursor.get<NonnullRefPtr<Gfx::Bitmap const>>()->to_shareable_bitmap());
|
||||
else
|
||||
ConnectionToWindowServer::the().async_set_window_cursor(m_window_id, (u32)new_cursor.get<Gfx::StandardCursor>());
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -183,7 +183,7 @@ public:
|
|||
void set_resize_aspect_ratio(Optional<Gfx::IntSize> const& ratio);
|
||||
|
||||
void set_cursor(Gfx::StandardCursor);
|
||||
void set_cursor(NonnullRefPtr<Gfx::Bitmap>);
|
||||
void set_cursor(NonnullRefPtr<Gfx::Bitmap const>);
|
||||
|
||||
void set_icon(Gfx::Bitmap const*);
|
||||
void apply_icon();
|
||||
|
@ -270,7 +270,7 @@ private:
|
|||
void flip(Vector<Gfx::IntRect, 32> const& dirty_rects);
|
||||
void force_update();
|
||||
|
||||
bool are_cursors_the_same(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const&, AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> const&) const;
|
||||
bool are_cursors_the_same(AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> const&, AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> const&) const;
|
||||
|
||||
WeakPtr<Widget> m_previously_focused_widget;
|
||||
|
||||
|
@ -279,7 +279,7 @@ private:
|
|||
|
||||
NonnullRefPtr<Menubar> m_menubar;
|
||||
|
||||
RefPtr<Gfx::Bitmap> m_icon;
|
||||
RefPtr<Gfx::Bitmap const> m_icon;
|
||||
int m_window_id { 0 };
|
||||
float m_opacity_when_windowless { 1.0f };
|
||||
float m_alpha_hit_threshold { 0.0f };
|
||||
|
@ -296,8 +296,8 @@ private:
|
|||
Gfx::IntSize m_base_size;
|
||||
WindowType m_window_type { WindowType::Normal };
|
||||
WindowMode m_window_mode { WindowMode::Modeless };
|
||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> m_cursor { Gfx::StandardCursor::None };
|
||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap>> m_effective_cursor { Gfx::StandardCursor::None };
|
||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> m_cursor { Gfx::StandardCursor::None };
|
||||
AK::Variant<Gfx::StandardCursor, NonnullRefPtr<Gfx::Bitmap const>> m_effective_cursor { Gfx::StandardCursor::None };
|
||||
bool m_has_alpha_channel { false };
|
||||
bool m_double_buffering_enabled { true };
|
||||
bool m_resizable { true };
|
||||
|
|
Loading…
Add table
Reference in a new issue