diff --git a/Userland/Libraries/LibGUI/AboutDialog.h b/Userland/Libraries/LibGUI/AboutDialog.h index 92c2f4b2335..93290749b14 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.h +++ b/Userland/Libraries/LibGUI/AboutDialog.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * 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 m_icon; + RefPtr m_icon; DeprecatedString m_version_string; }; } diff --git a/Userland/Libraries/LibGUI/AbstractThemePreview.cpp b/Userland/Libraries/LibGUI/AbstractThemePreview.cpp index e3c65230483..11a2f427085 100644 --- a/Userland/Libraries/LibGUI/AbstractThemePreview.cpp +++ b/Userland/Libraries/LibGUI/AbstractThemePreview.cpp @@ -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(); diff --git a/Userland/Libraries/LibGUI/AbstractThemePreview.h b/Userland/Libraries/LibGUI/AbstractThemePreview.h index 203c4084064..a73300b2383 100644 --- a/Userland/Libraries/LibGUI/AbstractThemePreview.h +++ b/Userland/Libraries/LibGUI/AbstractThemePreview.h @@ -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 set_theme_from_file(StringView path, NonnullOwnPtr); void set_theme(Core::AnonymousBuffer const&); diff --git a/Userland/Libraries/LibGUI/AbstractView.cpp b/Userland/Libraries/LibGUI/AbstractView.cpp index ddb67526258..26aa2320e39 100644 --- a/Userland/Libraries/LibGUI/AbstractView.cpp +++ b/Userland/Libraries/LibGUI/AbstractView.cpp @@ -221,7 +221,7 @@ void AbstractView::notify_selection_changed(Badge) update(); } -NonnullRefPtr AbstractView::font_for_index(ModelIndex const& index) const +NonnullRefPtr AbstractView::font_for_index(ModelIndex const& index) const { if (!model()) return font(); diff --git a/Userland/Libraries/LibGUI/AbstractView.h b/Userland/Libraries/LibGUI/AbstractView.h index 38860be327d..1ff695f3f02 100644 --- a/Userland/Libraries/LibGUI/AbstractView.h +++ b/Userland/Libraries/LibGUI/AbstractView.h @@ -109,7 +109,7 @@ public: void notify_selection_changed(Badge); - NonnullRefPtr font_for_index(ModelIndex const&) const; + NonnullRefPtr font_for_index(ModelIndex const&) const; void set_key_column_and_sort_order(int column, SortOrder); diff --git a/Userland/Libraries/LibGUI/AbstractZoomPanWidget.h b/Userland/Libraries/LibGUI/AbstractZoomPanWidget.h index 4de8f29a339..3c079ddf81d 100644 --- a/Userland/Libraries/LibGUI/AbstractZoomPanWidget.h +++ b/Userland/Libraries/LibGUI/AbstractZoomPanWidget.h @@ -78,7 +78,7 @@ private: float m_max_scale { 10.0f }; float m_scale { 1.0f }; - AK::Variant> m_saved_cursor { Gfx::StandardCursor::None }; + AK::Variant> m_saved_cursor { Gfx::StandardCursor::None }; }; } diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index 07fbdb41f7d..04a34d1a1b8 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ NonnullRefPtr Action::create(DeprecatedString text, Function Action::create(DeprecatedString text, RefPtr icon, Function callback, Core::Object* parent) +NonnullRefPtr Action::create(DeprecatedString text, RefPtr icon, Function callback, Core::Object* parent) { return adopt_ref(*new Action(move(text), move(icon), move(callback), parent)); } @@ -33,12 +33,12 @@ NonnullRefPtr Action::create(DeprecatedString text, Shortcut const& shor return adopt_ref(*new Action(move(text), shortcut, alternate_shortcut, move(callback), parent)); } -NonnullRefPtr Action::create(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::Object* parent) +NonnullRefPtr Action::create(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::Object* parent) { return adopt_ref(*new Action(move(text), shortcut, Shortcut {}, move(icon), move(callback), parent)); } -NonnullRefPtr Action::create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function callback, Core::Object* parent) +NonnullRefPtr Action::create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function 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::create_checkable(DeprecatedString text, Function Action::create_checkable(DeprecatedString text, RefPtr icon, Function callback, Core::Object* parent) +NonnullRefPtr Action::create_checkable(DeprecatedString text, RefPtr icon, Function callback, Core::Object* parent) { return adopt_ref(*new Action(move(text), move(icon), move(callback), parent, true)); } @@ -58,7 +58,7 @@ NonnullRefPtr Action::create_checkable(DeprecatedString text, Shortcut c return adopt_ref(*new Action(move(text), shortcut, move(callback), parent, true)); } -NonnullRefPtr Action::create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::Object* parent) +NonnullRefPtr Action::create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function 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 on_activation_call { } -Action::Action(DeprecatedString text, RefPtr icon, Function on_activation_callback, Core::Object* parent, bool checkable) +Action::Action(DeprecatedString text, RefPtr icon, Function 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 icon, Function on_activation_callback, Core::Object* parent, bool checkable) +Action::Action(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function on_activation_callback, Core::Object* parent, bool checkable) : Core::Object(parent) , on_activation(move(on_activation_callback)) , m_text(move(text)) diff --git a/Userland/Libraries/LibGUI/Action.h b/Userland/Libraries/LibGUI/Action.h index f5e615048c3..8225977b7ca 100644 --- a/Userland/Libraries/LibGUI/Action.h +++ b/Userland/Libraries/LibGUI/Action.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -66,15 +66,15 @@ public: ApplicationGlobal, }; static NonnullRefPtr create(DeprecatedString text, Function callback, Core::Object* parent = nullptr); - static NonnullRefPtr create(DeprecatedString text, RefPtr icon, Function callback, Core::Object* parent = nullptr); + static NonnullRefPtr create(DeprecatedString text, RefPtr icon, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create(DeprecatedString text, Shortcut const& shortcut, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, Function callback, Core::Object* parent = nullptr); - static NonnullRefPtr create(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::Object* parent = nullptr); - static NonnullRefPtr create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function callback, Core::Object* parent = nullptr); + static NonnullRefPtr create(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::Object* parent = nullptr); + static NonnullRefPtr create(DeprecatedString text, Shortcut const& shortcut, Shortcut const& alternate_shortcut, RefPtr icon, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create_checkable(DeprecatedString text, Function callback, Core::Object* parent = nullptr); - static NonnullRefPtr create_checkable(DeprecatedString text, RefPtr icon, Function callback, Core::Object* parent = nullptr); + static NonnullRefPtr create_checkable(DeprecatedString text, RefPtr icon, Function callback, Core::Object* parent = nullptr); static NonnullRefPtr create_checkable(DeprecatedString text, Shortcut const& shortcut, Function callback, Core::Object* parent = nullptr); - static NonnullRefPtr create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::Object* parent = nullptr); + static NonnullRefPtr create_checkable(DeprecatedString text, Shortcut const& shortcut, RefPtr icon, Function callback, Core::Object* parent = nullptr); static ErrorOr> try_create_checkable(DeprecatedString text, Shortcut const& shortcut, Function callback, Core::Object* parent = nullptr); @@ -135,8 +135,8 @@ private: Action(DeprecatedString, Function = nullptr, Core::Object* = nullptr, bool checkable = false); Action(DeprecatedString, Shortcut const&, Function = nullptr, Core::Object* = nullptr, bool checkable = false); Action(DeprecatedString, Shortcut const&, Shortcut const&, Function = nullptr, Core::Object* = nullptr, bool checkable = false); - Action(DeprecatedString, Shortcut const&, Shortcut const&, RefPtr icon, Function = nullptr, Core::Object* = nullptr, bool checkable = false); - Action(DeprecatedString, RefPtr icon, Function = nullptr, Core::Object* = nullptr, bool checkable = false); + Action(DeprecatedString, Shortcut const&, Shortcut const&, RefPtr icon, Function = nullptr, Core::Object* = nullptr, bool checkable = false); + Action(DeprecatedString, RefPtr icon, Function = nullptr, Core::Object* = nullptr, bool checkable = false); template void for_each_toolbar_button(Callback); @@ -145,7 +145,7 @@ private: DeprecatedString m_text; DeprecatedString m_status_tip; - RefPtr m_icon; + RefPtr m_icon; Shortcut m_shortcut; Shortcut m_alternate_shortcut; bool m_enabled { true }; diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index 1abb2074369..7fc73b965b8 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * * 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(); } diff --git a/Userland/Libraries/LibGUI/Application.h b/Userland/Libraries/LibGUI/Application.h index b538f14f1e6..5f03f68cf4f 100644 --- a/Userland/Libraries/LibGUI/Application.h +++ b/Userland/Libraries/LibGUI/Application.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * * 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 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 m_tooltip_show_timer; RefPtr m_tooltip_hide_timer; RefPtr m_tooltip_window; - RefPtr m_tooltip_source_widget; + RefPtr m_tooltip_source_widget; WeakPtr m_active_window; bool m_quit_when_last_window_deleted { true }; bool m_focus_debugging_enabled { false }; diff --git a/Userland/Libraries/LibGUI/Button.cpp b/Userland/Libraries/LibGUI/Button.cpp index e75938da564..87913e6c15c 100644 --- a/Userland/Libraries/LibGUI/Button.cpp +++ b/Userland/Libraries/LibGUI/Button.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * * 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 icon) +void Button::set_icon(RefPtr icon) { if (m_icon == icon) return; diff --git a/Userland/Libraries/LibGUI/Button.h b/Userland/Libraries/LibGUI/Button.h index b91f92ad972..69365179631 100644 --- a/Userland/Libraries/LibGUI/Button.h +++ b/Userland/Libraries/LibGUI/Button.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -28,10 +28,9 @@ public: virtual ~Button() override; - void set_icon(RefPtr); + void set_icon(RefPtr); 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 m_icon; + RefPtr m_icon; RefPtr m_menu; Gfx::ButtonStyle m_button_style { Gfx::ButtonStyle::Normal }; Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center }; diff --git a/Userland/Libraries/LibGUI/Desktop.cpp b/Userland/Libraries/LibGUI/Desktop.cpp index 19ae39f5539..980c6fdff60 100644 --- a/Userland/Libraries/LibGUI/Desktop.cpp +++ b/Userland/Libraries/LibGUI/Desktop.cpp @@ -59,7 +59,7 @@ RefPtr Desktop::wallpaper_bitmap() const return ConnectionToWindowServer::the().get_wallpaper().bitmap(); } -bool Desktop::set_wallpaper(RefPtr wallpaper_bitmap, Optional path) +bool Desktop::set_wallpaper(RefPtr wallpaper_bitmap, Optional path) { if (m_is_setting_desktop_wallpaper) return false; diff --git a/Userland/Libraries/LibGUI/Desktop.h b/Userland/Libraries/LibGUI/Desktop.h index fd2c2726ed4..e1e18065c32 100644 --- a/Userland/Libraries/LibGUI/Desktop.h +++ b/Userland/Libraries/LibGUI/Desktop.h @@ -33,7 +33,7 @@ public: DeprecatedString wallpaper_path() const; RefPtr wallpaper_bitmap() const; - bool set_wallpaper(RefPtr wallpaper_bitmap, Optional path); + bool set_wallpaper(RefPtr wallpaper_bitmap, Optional path); void set_system_effects(Vector effects) { m_system_effects = { effects }; }; SystemEffects const& system_effects() const { return m_system_effects; } diff --git a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp index b0a12d8777a..c4f694afb8b 100644 --- a/Userland/Libraries/LibGUI/EmojiInputDialog.cpp +++ b/Userland/Libraries/LibGUI/EmojiInputDialog.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2020-2023, Andreas Kling * Copyright (c) 2022, Linus Groh * * 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& bitmap) +static void resize_bitmap_if_needed(RefPtr& bitmap) { constexpr int max_icon_size = 12; @@ -74,7 +74,7 @@ private: if (m_first_paint_event) { m_first_paint_event = false; - RefPtr bitmap = Gfx::Emoji::emoji_for_code_points(m_emoji_code_points); + RefPtr 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 bitmap = Gfx::Emoji::emoji_for_code_point(category.emoji_code_point); + RefPtr bitmap = Gfx::Emoji::emoji_for_code_point(category.emoji_code_point); VERIFY(bitmap); resize_bitmap_if_needed(bitmap); diff --git a/Userland/Libraries/LibGUI/Event.cpp b/Userland/Libraries/LibGUI/Event.cpp index c109b09519d..549e393f811 100644 --- a/Userland/Libraries/LibGUI/Event.cpp +++ b/Userland/Libraries/LibGUI/Event.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020-2021, Andreas Kling + * Copyright (c) 2020-2023, Andreas Kling * 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 mime_data) +DropEvent::DropEvent(Gfx::IntPoint position, DeprecatedString const& text, NonnullRefPtr mime_data) : Event(Event::Drop) , m_position(position) , m_text(text) diff --git a/Userland/Libraries/LibGUI/Event.h b/Userland/Libraries/LibGUI/Event.h index 9b64b72b042..1902889a062 100644 --- a/Userland/Libraries/LibGUI/Event.h +++ b/Userland/Libraries/LibGUI/Event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * 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 m_bitmap; + RefPtr m_bitmap; }; class WMWorkspaceChangedEvent : public WMEvent { @@ -477,7 +477,7 @@ private: class DropEvent final : public Event { public: - DropEvent(Gfx::IntPoint, DeprecatedString const& text, NonnullRefPtr mime_data); + DropEvent(Gfx::IntPoint, DeprecatedString const& text, NonnullRefPtr mime_data); ~DropEvent() = default; @@ -488,7 +488,7 @@ public: private: Gfx::IntPoint m_position; DeprecatedString m_text; - NonnullRefPtr m_mime_data; + NonnullRefPtr m_mime_data; }; class ThemeChangeEvent final : public Event { diff --git a/Userland/Libraries/LibGUI/FileIconProvider.cpp b/Userland/Libraries/LibGUI/FileIconProvider.cpp index 74a331b1035..d0f603ac75e 100644 --- a/Userland/Libraries/LibGUI/FileIconProvider.cpp +++ b/Userland/Libraries/LibGUI/FileIconProvider.cpp @@ -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 bitmap; + RefPtr bitmap; if (!section.has_value()) { bitmap = s_executable_icon.bitmap_for_size(icon_section.image_size); } else { diff --git a/Userland/Libraries/LibGUI/FontPicker.h b/Userland/Libraries/LibGUI/FontPicker.h index 2d3e4d15fb3..96d500839fb 100644 --- a/Userland/Libraries/LibGUI/FontPicker.h +++ b/Userland/Libraries/LibGUI/FontPicker.h @@ -19,7 +19,7 @@ class FontPicker final : public GUI::Dialog { public: virtual ~FontPicker() override = default; - RefPtr font() const { return m_font; } + RefPtr font() const { return m_font; } void set_font(Gfx::Font const*); private: @@ -29,7 +29,7 @@ private: bool const m_fixed_width_only; - RefPtr m_font; + RefPtr m_font; RefPtr m_family_list_view; RefPtr m_variant_list_view; diff --git a/Userland/Libraries/LibGUI/GML/AST.h b/Userland/Libraries/LibGUI/GML/AST.h index 9c8d8acd309..dded956b395 100644 --- a/Userland/Libraries/LibGUI/GML/AST.h +++ b/Userland/Libraries/LibGUI/GML/AST.h @@ -152,7 +152,7 @@ public: class Object : public ValueNode { public: Object() = default; - Object(DeprecatedString name, NonnullRefPtrVector properties, NonnullRefPtrVector sub_objects) + Object(DeprecatedString name, NonnullRefPtrVector properties, NonnullRefPtrVector 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 add_sub_object_child(NonnullRefPtr child) + ErrorOr add_sub_object_child(NonnullRefPtr child) { VERIFY(is(child.ptr()) || is(child.ptr())); return m_sub_objects.try_append(move(child)); } - ErrorOr add_property_child(NonnullRefPtr child) + ErrorOr add_property_child(NonnullRefPtr child) { VERIFY(is(child.ptr()) || is(child.ptr())); return m_properties.try_append(move(child)); @@ -178,7 +178,7 @@ public: // Does not return key-value pair `layout: ...`! template - void for_each_property(Callback callback) + void for_each_property(Callback callback) const { for (auto const& child : m_properties) { if (is(child)) { @@ -190,52 +190,51 @@ public: } template - void for_each_child_object(Callback callback) + void for_each_child_object(Callback callback) const { - for (NonnullRefPtr child : m_sub_objects) { + for (NonnullRefPtr child : m_sub_objects) { // doesn't capture layout as intended, as that's behind a kv-pair if (is(child.ptr())) { - auto object = static_ptr_cast(child); + auto object = static_ptr_cast(child); callback(object); } } } template> Callback> - ErrorOr try_for_each_child_object(Callback callback) + ErrorOr try_for_each_child_object(Callback callback) const { - for (NonnullRefPtr 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(child.ptr())) { - auto object = static_ptr_cast(child); - TRY(callback(object)); + if (is(child)) { + TRY(callback(static_cast(child))); } } return {}; } - RefPtr layout_object() const + RefPtr layout_object() const { - for (NonnullRefPtr child : m_properties) { - if (is(child.ptr())) { - auto property = static_ptr_cast(child); - if (property->key() == "layout") { - VERIFY(is(property->value().ptr())); - return static_ptr_cast(property->value()); + for (auto const& child : m_properties) { + if (is(child)) { + auto const& property = static_cast(child); + if (property.key() == "layout") { + VERIFY(is(property.value().ptr())); + return static_cast(*property.value()); } } } return nullptr; } - RefPtr get_property(StringView property_name) + RefPtr get_property(StringView property_name) const { - for (NonnullRefPtr child : m_properties) { - if (is(child.ptr())) { - auto property = static_ptr_cast(child); - if (property->key() == property_name) - return property->value(); + for (auto const& child : m_properties) { + if (is(child)) { + auto const& property = static_cast(child); + if (property.key() == property_name) + return property.value(); } } return nullptr; @@ -275,9 +274,9 @@ public: private: // Properties and comments - NonnullRefPtrVector m_properties; + NonnullRefPtrVector m_properties; // Sub objects and comments - NonnullRefPtrVector m_sub_objects; + NonnullRefPtrVector m_sub_objects; DeprecatedString m_name {}; }; @@ -285,14 +284,14 @@ class GMLFile : public Node { public: virtual ~GMLFile() override = default; - ErrorOr add_child(NonnullRefPtr child) + ErrorOr add_child(NonnullRefPtr child) { if (!has_main_class()) { if (is(child.ptr())) { - return m_leading_comments.try_append(*static_ptr_cast(child)); + return m_leading_comments.try_append(*static_ptr_cast(child)); } if (is(child.ptr())) { - m_main_class = static_ptr_cast(child); + m_main_class = static_ptr_cast(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(child.ptr())) return Error::from_string_literal("Data not allowed after main class"); - return m_trailing_comments.try_append(*static_ptr_cast(child)); + return m_trailing_comments.try_append(*static_ptr_cast(child)); } bool has_main_class() const { return m_main_class != nullptr; } - NonnullRefPtrVector leading_comments() const { return m_leading_comments; } - Object& main_class() + NonnullRefPtrVector leading_comments() const { return m_leading_comments; } + Object const& main_class() const { VERIFY(!m_main_class.is_null()); return *m_main_class.ptr(); } - NonnullRefPtrVector trailing_comments() const { return m_trailing_comments; } + NonnullRefPtrVector 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 m_leading_comments; - RefPtr m_main_class; - NonnullRefPtrVector m_trailing_comments; + NonnullRefPtrVector m_leading_comments; + RefPtr m_main_class; + NonnullRefPtrVector m_trailing_comments; }; } diff --git a/Userland/Libraries/LibGUI/GML/Parser.cpp b/Userland/Libraries/LibGUI/GML/Parser.cpp index 270bf984dde..18f93109f4c 100644 --- a/Userland/Libraries/LibGUI/GML/Parser.cpp +++ b/Userland/Libraries/LibGUI/GML/Parser.cpp @@ -82,7 +82,7 @@ static ErrorOr> parse_gml_object(Queue& tokens) else if (peek() == Token::Type::JsonValue) value = TRY(try_make_ref_counted(TRY(JsonValueNode::from_string(tokens.dequeue().m_view)))); - auto property = TRY(try_make_ref_counted(property_name.m_view, value.release_nonnull())); + auto property = TRY(try_make_ref_counted(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(tokens.dequeue()))); diff --git a/Userland/Libraries/LibGUI/Icon.cpp b/Userland/Libraries/LibGUI/Icon.cpp index fd9c5575f5e..e2a8c6637aa 100644 --- a/Userland/Libraries/LibGUI/Icon.cpp +++ b/Userland/Libraries/LibGUI/Icon.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * Copyright (c) 2021, Julius Heijmen * * SPDX-License-Identifier: BSD-2-Clause @@ -26,7 +26,7 @@ Icon::Icon(Icon const& other) { } -Icon::Icon(RefPtr&& bitmap) +Icon::Icon(RefPtr&& bitmap) : Icon() { if (bitmap) { @@ -36,7 +36,7 @@ Icon::Icon(RefPtr&& bitmap) } } -Icon::Icon(RefPtr&& bitmap1, RefPtr&& bitmap2) +Icon::Icon(RefPtr&& bitmap1, RefPtr&& 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&& bitmap) +void IconImpl::set_bitmap_for_size(int size, RefPtr&& bitmap) { if (!bitmap) { m_bitmaps.remove(size); diff --git a/Userland/Libraries/LibGUI/Icon.h b/Userland/Libraries/LibGUI/Icon.h index b11cbcf42be..111e0cf7bab 100644 --- a/Userland/Libraries/LibGUI/Icon.h +++ b/Userland/Libraries/LibGUI/Icon.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * Copyright (c) 2021, Julius Heijmen * 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&&); + void set_bitmap_for_size(int, RefPtr&&); Vector sizes() const { @@ -33,14 +33,14 @@ public: private: IconImpl() = default; - HashMap> m_bitmaps; + HashMap> m_bitmaps; }; class Icon { public: Icon(); - explicit Icon(RefPtr&&); - explicit Icon(RefPtr&&, RefPtr&&); + explicit Icon(RefPtr&&); + explicit Icon(RefPtr&&, RefPtr&&); 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&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); } + void set_bitmap_for_size(int size, RefPtr&& bitmap) { m_impl->set_bitmap_for_size(size, move(bitmap)); } IconImpl const& impl() const { return *m_impl; } diff --git a/Userland/Libraries/LibGUI/ImageWidget.h b/Userland/Libraries/LibGUI/ImageWidget.h index 80669ee51bf..967bb192471 100644 --- a/Userland/Libraries/LibGUI/ImageWidget.h +++ b/Userland/Libraries/LibGUI/ImageWidget.h @@ -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 m_bitmap; + RefPtr m_bitmap; bool m_should_stretch { false }; bool m_auto_resize { false }; diff --git a/Userland/Libraries/LibGUI/Label.h b/Userland/Libraries/LibGUI/Label.h index d7c915c5ab3..a80217ba300 100644 --- a/Userland/Libraries/LibGUI/Label.h +++ b/Userland/Libraries/LibGUI/Label.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * 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 m_icon; + RefPtr m_icon; Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center }; Gfx::TextWrapping m_text_wrapping { Gfx::TextWrapping::Wrap }; bool m_should_stretch_icon { false }; diff --git a/Userland/Libraries/LibGUI/Menu.h b/Userland/Libraries/LibGUI/Menu.h index 7f0da099378..f95b7db9898 100644 --- a/Userland/Libraries/LibGUI/Menu.h +++ b/Userland/Libraries/LibGUI/Menu.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -74,7 +74,7 @@ private: int m_menu_id { -1 }; DeprecatedString m_name; - RefPtr m_icon; + RefPtr m_icon; NonnullOwnPtrVector m_items; WeakPtr m_current_default_action; bool m_visible { false }; diff --git a/Userland/Libraries/LibGUI/Model.cpp b/Userland/Libraries/LibGUI/Model.cpp index 401c76b98cb..8280093b92a 100644 --- a/Userland/Libraries/LibGUI/Model.cpp +++ b/Userland/Libraries/LibGUI/Model.cpp @@ -100,7 +100,7 @@ WeakPtr Model::register_persistent_index(Badge Model::mime_data(ModelSelection const& selection) const { auto mime_data = Core::MimeData::construct(); - RefPtr bitmap; + RefPtr bitmap; StringBuilder text_builder; StringBuilder data_builder; diff --git a/Userland/Libraries/LibGUI/Notification.h b/Userland/Libraries/LibGUI/Notification.h index 42fac9fbe55..b5f200c9cb7 100644 --- a/Userland/Libraries/LibGUI/Notification.h +++ b/Userland/Libraries/LibGUI/Notification.h @@ -57,7 +57,7 @@ private: bool m_title_dirty; DeprecatedString m_text; bool m_text_dirty; - RefPtr m_icon; + RefPtr m_icon; bool m_icon_dirty; bool m_destroyed { false }; diff --git a/Userland/Libraries/LibGUI/ProcessChooser.h b/Userland/Libraries/LibGUI/ProcessChooser.h index 5c7e79eef37..64e67a7292d 100644 --- a/Userland/Libraries/LibGUI/ProcessChooser.h +++ b/Userland/Libraries/LibGUI/ProcessChooser.h @@ -31,7 +31,7 @@ private: DeprecatedString m_window_title; String m_button_label; - RefPtr m_window_icon; + RefPtr m_window_icon; RefPtr m_table_view; RefPtr m_process_model; diff --git a/Userland/Libraries/LibGUI/RunningProcessesModel.h b/Userland/Libraries/LibGUI/RunningProcessesModel.h index 43fbaaef50d..9d0fe48e778 100644 --- a/Userland/Libraries/LibGUI/RunningProcessesModel.h +++ b/Userland/Libraries/LibGUI/RunningProcessesModel.h @@ -38,7 +38,7 @@ private: struct Process { pid_t pid; uid_t uid; - RefPtr icon; + RefPtr icon; DeprecatedString name; }; Vector m_processes; diff --git a/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp b/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp index f7110fb9889..9ecb198e7db 100644 --- a/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp +++ b/Userland/Libraries/LibGUI/ScrollableContainerWidget.cpp @@ -102,32 +102,32 @@ void ScrollableContainerWidget::set_widget(GUI::Widget* widget) update_widget_position(); } -ErrorOr ScrollableContainerWidget::load_from_gml_ast(NonnullRefPtr ast, UnregisteredChildHandler unregistered_child_handler) +ErrorOr ScrollableContainerWidget::load_from_gml_ast(NonnullRefPtr ast, UnregisteredChildHandler unregistered_child_handler) { if (is(ast.ptr())) - return load_from_gml_ast(static_ptr_cast(ast)->main_class(), unregistered_child_handler); + return load_from_gml_ast(static_cast(*ast).main_class(), unregistered_child_handler); VERIFY(is(ast.ptr())); - auto object = static_ptr_cast(ast); + auto const& object = static_cast(*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(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(content_widget_value.ptr())) { - auto content_widget = static_ptr_cast(content_widget_value); - auto class_name = content_widget->name(); + auto const& content_widget = static_cast(*content_widget_value); + auto class_name = content_widget.name(); RefPtr child; if (auto* registration = Core::ObjectClassRegistration::find(class_name)) { @@ -139,7 +139,7 @@ ErrorOr ScrollableContainerWidget::load_from_gml_ast(NonnullRefPtr(child.ptr()); set_widget(widget_ptr); - TRY(static_ptr_cast(child)->load_from_gml_ast(content_widget.release_nonnull(), unregistered_child_handler)); + TRY(static_cast(*child).load_from_gml_ast(content_widget, unregistered_child_handler)); } return {}; diff --git a/Userland/Libraries/LibGUI/ScrollableContainerWidget.h b/Userland/Libraries/LibGUI/ScrollableContainerWidget.h index ef0e4e7ac97..0b6f2f5ea23 100644 --- a/Userland/Libraries/LibGUI/ScrollableContainerWidget.h +++ b/Userland/Libraries/LibGUI/ScrollableContainerWidget.h @@ -30,7 +30,7 @@ private: void update_widget_size(); void update_widget_position(); void update_widget_min_size(); - virtual ErrorOr load_from_gml_ast(NonnullRefPtr ast, UnregisteredChildHandler) override; + virtual ErrorOr load_from_gml_ast(NonnullRefPtr ast, UnregisteredChildHandler) override; ScrollableContainerWidget(); diff --git a/Userland/Libraries/LibGUI/TabWidget.cpp b/Userland/Libraries/LibGUI/TabWidget.cpp index 4e3301f196e..4c068b994f4 100644 --- a/Userland/Libraries/LibGUI/TabWidget.cpp +++ b/Userland/Libraries/LibGUI/TabWidget.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * Copyright (c) 2021, Peter Elliott * Copyright (c) 2022, Cameron Youell * Copyright (c) 2022, the SerenityOS developers. diff --git a/Userland/Libraries/LibGUI/TabWidget.h b/Userland/Libraries/LibGUI/TabWidget.h index 835d29d04ba..9e18e51403e 100644 --- a/Userland/Libraries/LibGUI/TabWidget.h +++ b/Userland/Libraries/LibGUI/TabWidget.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * 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 icon; + RefPtr icon; Widget* widget { nullptr }; bool modified { false }; }; diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 95b61fb2748..43088e7b6bd 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * Copyright (c) 2021, networkException * Copyright (c) 2022, the SerenityOS developers. * Copyright (c) 2023, Sam Atkins @@ -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 unspanned_font = this->font(); + RefPtr 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& font, Gfx::TextAttributes text_attributes) { + auto draw_text_helper = [&](size_t start, size_t end, RefPtr& font, Gfx::TextAttributes text_attributes) { size_t length = end - start; if (length == 0) return; diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h index 9e7b2903815..903dbd90467 100644 --- a/Userland/Libraries/LibGUI/TextEditor.h +++ b/Userland/Libraries/LibGUI/TextEditor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * Copyright (c) 2022, the SerenityOS developers. * Copyright (c) 2023, Sam Atkins * @@ -438,7 +438,7 @@ private: Gfx::IntPoint m_last_mousemove_position; - RefPtr m_icon; + RefPtr m_icon; bool m_text_is_secret { false }; diff --git a/Userland/Libraries/LibGUI/Tray.cpp b/Userland/Libraries/LibGUI/Tray.cpp index dccfc5d223a..d91cc3655d0 100644 --- a/Userland/Libraries/LibGUI/Tray.cpp +++ b/Userland/Libraries/LibGUI/Tray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Andreas Kling + * Copyright (c) 2021-2023, Andreas Kling * 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 bitmap, DeprecatedString custom_data) +size_t Tray::add_item(DeprecatedString text, RefPtr bitmap, DeprecatedString custom_data) { auto new_index = m_items.size(); diff --git a/Userland/Libraries/LibGUI/Tray.h b/Userland/Libraries/LibGUI/Tray.h index 239fd4bd2cb..ef0e2eba408 100644 --- a/Userland/Libraries/LibGUI/Tray.h +++ b/Userland/Libraries/LibGUI/Tray.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Andreas Kling + * Copyright (c) 2021-2023, Andreas Kling * 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, DeprecatedString custom_data); + size_t add_item(DeprecatedString text, RefPtr, DeprecatedString custom_data); void set_item_checked(size_t index, bool); @@ -39,7 +39,7 @@ private: struct Item { DeprecatedString text; - RefPtr bitmap; + RefPtr bitmap; DeprecatedString custom_data; size_t index { 0 }; Gfx::IntRect rect(Tray const&) const; diff --git a/Userland/Libraries/LibGUI/TreeViewModel.h b/Userland/Libraries/LibGUI/TreeViewModel.h index fcbf143c141..6021fbf519f 100644 --- a/Userland/Libraries/LibGUI/TreeViewModel.h +++ b/Userland/Libraries/LibGUI/TreeViewModel.h @@ -49,7 +49,7 @@ public: requires(IsBaseOf) { auto node = adopt_ref(*new NodeType(move(text), move(icon), this, forward(args)...)); - m_child_nodes.append(*static_cast(node.ptr())); + m_child_nodes.append(*static_cast(node.ptr())); return node; } @@ -77,7 +77,7 @@ public: requires(IsBaseOf) { auto node = adopt_ref(*new NodeType(move(text), move(icon), nullptr, forward(args)...)); - m_nodes.append(*static_cast(node.ptr())); + m_nodes.append(*static_cast(node.ptr())); return node; } diff --git a/Userland/Libraries/LibGUI/Variant.h b/Userland/Libraries/LibGUI/Variant.h index 2b4adc15595..7de0dda2676 100644 --- a/Userland/Libraries/LibGUI/Variant.h +++ b/Userland/Libraries/LibGUI/Variant.h @@ -21,7 +21,7 @@ namespace Detail { struct Boolean { bool value; }; -using VariantUnderlyingType = AK::Variant, NonnullRefPtr, GUI::Icon>; +using VariantUnderlyingType = AK::Variant, NonnullRefPtr, GUI::Icon>; } class Variant : public Detail::VariantUnderlyingType { @@ -57,7 +57,7 @@ public: template T> Variant(T const& value) - : Variant(NonnullRefPtr>(value)) + : Variant(NonnullRefPtr const>(value)) { } template T> @@ -77,13 +77,13 @@ public: bool is_u64() const { return has(); } bool is_float() const { return has(); } bool is_string() const { return has(); } - bool is_bitmap() const { return has>(); } + bool is_bitmap() const { return has>(); } bool is_color() const { return has(); } bool is_icon() const { return has(); } bool is_point() const { return has(); } bool is_size() const { return has(); } bool is_rect() const { return has(); } - bool is_font() const { return has>(); } + bool is_font() const { return has>(); } bool is_text_alignment() const { return has(); } bool is_color_role() const { return has(); } bool is_alignment_role() const { return has(); } @@ -103,7 +103,7 @@ public: [](Gfx::IntPoint const& v) { return !v.is_zero(); }, [](OneOf auto const& v) { return !v.is_empty(); }, [](Enum auto const&) { return true; }, - [](OneOf, NonnullRefPtr, GUI::Icon> auto const&) { return true; }); + [](OneOf, NonnullRefPtr, GUI::Icon> auto const&) { return true; }); } i32 as_i32() const { return get(); } @@ -126,7 +126,7 @@ public: return v.to_int().value_or(0); }, [](Enum auto const&) -> T { return 0; }, - [](OneOf, NonnullRefPtr, GUI::Icon> auto const&) -> T { return 0; }); + [](OneOf, NonnullRefPtr, GUI::Icon> auto const&) -> T { return 0; }); } i32 to_i32() const { return to_integer(); } @@ -144,10 +144,10 @@ public: Gfx::IntSize as_size() const { return get(); } Gfx::IntRect as_rect() const { return get(); } DeprecatedString as_string() const { return get(); } - Gfx::Bitmap const& as_bitmap() const { return *get>(); } + Gfx::Bitmap const& as_bitmap() const { return *get>(); } GUI::Icon as_icon() const { return get(); } Color as_color() const { return get(); } - Gfx::Font const& as_font() const { return *get>(); } + Gfx::Font const& as_font() const { return *get>(); } 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 const& font) { return DeprecatedString::formatted("[Font: {}]", font->name()); }, - [](NonnullRefPtr const&) -> DeprecatedString { return "[Gfx::Bitmap]"; }, + [](NonnullRefPtr const& font) { return DeprecatedString::formatted("[Font: {}]", font->name()); }, + [](NonnullRefPtr 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); }); diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp index ce16af49ce6..f08a80f0245 100644 --- a/Userland/Libraries/LibGUI/Widget.cpp +++ b/Userland/Libraries/LibGUI/Widget.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * Copyright (c) 2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause @@ -1042,7 +1042,7 @@ Vector 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> cursor) +void Widget::set_override_cursor(AK::Variant> cursor) { - auto const& are_cursors_the_same = [](AK::Variant> const& a, AK::Variant> const& b) { - if (a.has() != b.has()) + auto const& are_cursors_the_same = [](auto const& a, auto const& b) { + if (a.template has() != b.template has()) return false; - if (a.has()) - return a.get() == b.get(); - return a.get>().ptr() == b.get>().ptr(); + if (a.template has()) + return a.template get() == b.template get(); + return a.template get>().ptr() == b.template get>().ptr(); }; if (are_cursors_the_same(m_override_cursor, cursor)) @@ -1159,19 +1159,19 @@ ErrorOr Widget::load_from_gml(StringView gml_string, UnregisteredChildHand return load_from_gml_ast(value, unregistered_child_handler); } -ErrorOr Widget::load_from_gml_ast(NonnullRefPtr ast, UnregisteredChildHandler unregistered_child_handler) +ErrorOr Widget::load_from_gml_ast(NonnullRefPtr ast, UnregisteredChildHandler unregistered_child_handler) { if (is(ast.ptr())) - return load_from_gml_ast(static_ptr_cast(ast)->main_class(), unregistered_child_handler); + return load_from_gml_ast(static_cast(*ast).main_class(), unregistered_child_handler); VERIFY(is(ast.ptr())); - auto object = static_ptr_cast(ast); + auto const& object = static_cast(*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 Widget::load_from_gml_ast(NonnullRefPtr ast, Unreg auto& widget_class = *Core::ObjectClassRegistration::find("GUI::Widget"sv); bool is_tab_widget = is(*this); - TRY(object->try_for_each_child_object([&](auto child_data) -> ErrorOr { - auto class_name = child_data->name(); + TRY(object.try_for_each_child_object([&](auto const& child_data) -> ErrorOr { + 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") { diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index 75d723467c0..f49eea7db14 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * * 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> const& override_cursor() const { return m_override_cursor; } - void set_override_cursor(AK::Variant>); + AK::Variant> const& override_cursor() const { return m_override_cursor; } + void set_override_cursor(AK::Variant>); using UnregisteredChildHandler = ErrorOr>(DeprecatedString const&); ErrorOr 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 load_from_gml_ast(NonnullRefPtr ast, UnregisteredChildHandler); + virtual ErrorOr load_from_gml_ast(NonnullRefPtr ast, UnregisteredChildHandler); ErrorOr add_spacer(); @@ -439,7 +439,7 @@ private: Gfx::IntRect m_relative_rect; Gfx::ColorRole m_background_role; Gfx::ColorRole m_foreground_role; - NonnullRefPtr m_font; + NonnullRefPtr m_font; DeprecatedString m_tooltip; UISize m_min_size { SpecialDimension::Shrink }; @@ -464,7 +464,7 @@ private: Vector> m_focus_delegators; FocusPolicy m_focus_policy { FocusPolicy::NoFocus }; - AK::Variant> m_override_cursor { Gfx::StandardCursor::None }; + AK::Variant> m_override_cursor { Gfx::StandardCursor::None }; }; inline Widget* Widget::parent_widget() diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index b41686fbc1d..519c6e54eea 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * * 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> const& left, AK::Variant> const& right) const +bool Window::are_cursors_the_same(AK::Variant> const& left, AK::Variant> const& right) const { if (left.has() != right.has()) return false; if (left.has()) return left.get() == right.get(); - return left.get>().ptr() == right.get>().ptr(); + return left.get>().ptr() == right.get>().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 cursor) +void Window::set_cursor(NonnullRefPtr 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>() || cursor.template get() != Gfx::StandardCursor::None; + return cursor.template has>() || cursor.template get() != 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>()) - ConnectionToWindowServer::the().async_set_window_custom_cursor(m_window_id, new_cursor.get>()->to_shareable_bitmap()); + if (new_cursor.has>()) + ConnectionToWindowServer::the().async_set_window_custom_cursor(m_window_id, new_cursor.get>()->to_shareable_bitmap()); else ConnectionToWindowServer::the().async_set_window_cursor(m_window_id, (u32)new_cursor.get()); } diff --git a/Userland/Libraries/LibGUI/Window.h b/Userland/Libraries/LibGUI/Window.h index fbf1b552eaa..335f9dd0d17 100644 --- a/Userland/Libraries/LibGUI/Window.h +++ b/Userland/Libraries/LibGUI/Window.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2021, Andreas Kling + * Copyright (c) 2018-2023, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -183,7 +183,7 @@ public: void set_resize_aspect_ratio(Optional const& ratio); void set_cursor(Gfx::StandardCursor); - void set_cursor(NonnullRefPtr); + void set_cursor(NonnullRefPtr); void set_icon(Gfx::Bitmap const*); void apply_icon(); @@ -270,7 +270,7 @@ private: void flip(Vector const& dirty_rects); void force_update(); - bool are_cursors_the_same(AK::Variant> const&, AK::Variant> const&) const; + bool are_cursors_the_same(AK::Variant> const&, AK::Variant> const&) const; WeakPtr m_previously_focused_widget; @@ -279,7 +279,7 @@ private: NonnullRefPtr m_menubar; - RefPtr m_icon; + RefPtr 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> m_cursor { Gfx::StandardCursor::None }; - AK::Variant> m_effective_cursor { Gfx::StandardCursor::None }; + AK::Variant> m_cursor { Gfx::StandardCursor::None }; + AK::Variant> m_effective_cursor { Gfx::StandardCursor::None }; bool m_has_alpha_channel { false }; bool m_double_buffering_enabled { true }; bool m_resizable { true };