diff options
author | Karol Kosek <krkk@serenityos.org> | 2023-02-12 11:13:18 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-02-13 00:45:09 +0000 |
commit | d32b052f22d3b1ffbf009d5de17572f381cd87fa (patch) | |
tree | 1c7d13a32501208d6e1594ac38d51d2b21ce6c11 /Userland/Libraries | |
parent | 61b49daf0acd3b3511521eb8eb494d5c57610b62 (diff) | |
download | serenity-d32b052f22d3b1ffbf009d5de17572f381cd87fa.zip |
LibGUI+Userland: Add `_deprecated` suffix to AbstractButton::{set_,}text
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/AbstractButton.cpp | 14 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/AbstractButton.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Action.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Breadcrumbbar.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Button.cpp | 14 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/CheckBox.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/ColorPicker.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/FilePicker.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/IncrementalSearchBanner.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/InputBox.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/MessageBox.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/RadioButton.cpp | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Statusbar.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Toolbar.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp | 4 |
15 files changed, 43 insertions, 43 deletions
diff --git a/Userland/Libraries/LibGUI/AbstractButton.cpp b/Userland/Libraries/LibGUI/AbstractButton.cpp index c66cd8ee01..9eb76abf2d 100644 --- a/Userland/Libraries/LibGUI/AbstractButton.cpp +++ b/Userland/Libraries/LibGUI/AbstractButton.cpp @@ -17,7 +17,7 @@ namespace GUI { AbstractButton::AbstractButton(DeprecatedString text) { - set_text(move(text)); + set_text_deprecated(move(text)); set_focus_policy(GUI::FocusPolicy::StrongFocus); set_background_role(Gfx::ColorRole::Button); @@ -28,13 +28,13 @@ AbstractButton::AbstractButton(DeprecatedString text) click(); }; - REGISTER_STRING_PROPERTY("text", text, set_text); + REGISTER_STRING_PROPERTY("text", text_deprecated, set_text_deprecated); REGISTER_BOOL_PROPERTY("checked", is_checked, set_checked); REGISTER_BOOL_PROPERTY("checkable", is_checkable, set_checkable); REGISTER_BOOL_PROPERTY("exclusive", is_exclusive, set_exclusive); } -void AbstractButton::set_text(DeprecatedString text) +void AbstractButton::set_text_deprecated(DeprecatedString text) { if (m_text == text) return; @@ -238,14 +238,14 @@ void AbstractButton::paint_text(Painter& painter, Gfx::IntRect const& rect, Gfx: auto clipped_rect = rect.intersected(this->rect()); if (!is_enabled()) { - painter.draw_text(clipped_rect.translated(1, 1), text(), font, text_alignment, palette().disabled_text_back(), Gfx::TextElision::Right, text_wrapping); - painter.draw_text(clipped_rect, text(), font, text_alignment, palette().disabled_text_front(), Gfx::TextElision::Right, text_wrapping); + painter.draw_text(clipped_rect.translated(1, 1), text_deprecated(), font, text_alignment, palette().disabled_text_back(), Gfx::TextElision::Right, text_wrapping); + painter.draw_text(clipped_rect, text_deprecated(), font, text_alignment, palette().disabled_text_front(), Gfx::TextElision::Right, text_wrapping); return; } - if (text().is_empty()) + if (text_deprecated().is_empty()) return; - painter.draw_text(clipped_rect, text(), font, text_alignment, palette().color(foreground_role()), Gfx::TextElision::Right, text_wrapping); + painter.draw_text(clipped_rect, text_deprecated(), font, text_alignment, palette().color(foreground_role()), Gfx::TextElision::Right, text_wrapping); } void AbstractButton::change_event(Event& event) diff --git a/Userland/Libraries/LibGUI/AbstractButton.h b/Userland/Libraries/LibGUI/AbstractButton.h index 890d5f7c62..c24ab8a83b 100644 --- a/Userland/Libraries/LibGUI/AbstractButton.h +++ b/Userland/Libraries/LibGUI/AbstractButton.h @@ -20,8 +20,8 @@ public: Function<void(bool)> on_checked; - virtual void set_text(DeprecatedString); - DeprecatedString const& text() const { return m_text; } + virtual void set_text_deprecated(DeprecatedString); + DeprecatedString const& text_deprecated() const { return m_text; } bool is_exclusive() const { return m_exclusive; } void set_exclusive(bool b) { m_exclusive = b; } diff --git a/Userland/Libraries/LibGUI/Action.cpp b/Userland/Libraries/LibGUI/Action.cpp index a454e9a752..95d56aabba 100644 --- a/Userland/Libraries/LibGUI/Action.cpp +++ b/Userland/Libraries/LibGUI/Action.cpp @@ -289,7 +289,7 @@ void Action::set_text(DeprecatedString text) return; m_text = move(text); for_each_toolbar_button([&](auto& button) { - button.set_text(m_text); + button.set_text_deprecated(m_text); }); for_each_menu_item([&](auto& menu_item) { menu_item.update_from_action({}); diff --git a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp index ad16f33126..bbb274afc3 100644 --- a/Userland/Libraries/LibGUI/Breadcrumbbar.cpp +++ b/Userland/Libraries/LibGUI/Breadcrumbbar.cpp @@ -75,7 +75,7 @@ void Breadcrumbbar::append_segment(DeprecatedString text, Gfx::Bitmap const* ico { auto& button = add<BreadcrumbButton>(); button.set_button_style(Gfx::ButtonStyle::Coolbar); - button.set_text(text); + button.set_text_deprecated(text); button.set_icon(icon); button.set_tooltip(move(tooltip)); button.set_focus_policy(FocusPolicy::TabFocus); diff --git a/Userland/Libraries/LibGUI/Button.cpp b/Userland/Libraries/LibGUI/Button.cpp index 439a28faf4..eccd73cc23 100644 --- a/Userland/Libraries/LibGUI/Button.cpp +++ b/Userland/Libraries/LibGUI/Button.cpp @@ -61,12 +61,12 @@ void Button::paint_event(PaintEvent& event) Gfx::StylePainter::paint_button(painter, rect(), palette(), m_button_style, paint_pressed, is_hovered(), is_checked(), is_enabled(), is_focused(), is_default() && !another_button_has_focus()); - if (text().is_empty() && !m_icon) + if (text_deprecated().is_empty() && !m_icon) return; auto content_rect = rect().shrunken(8, 2); auto icon_location = m_icon ? content_rect.center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2)) : Gfx::IntPoint(); - if (m_icon && !text().is_empty()) + if (m_icon && !text_deprecated().is_empty()) icon_location.set_x(content_rect.x()); if (paint_pressed || is_checked()) { @@ -103,12 +103,12 @@ void Button::paint_event(PaintEvent& event) m_icon->invert(); } auto& font = is_checked() ? this->font().bold_variant() : this->font(); - if (m_icon && !text().is_empty()) { + if (m_icon && !text_deprecated().is_empty()) { content_rect.translate_by(m_icon->width() + icon_spacing(), 0); content_rect.set_width(content_rect.width() - m_icon->width() - icon_spacing()); } - Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), font.glyph_height() }; + Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text_deprecated()))), font.glyph_height() }; if (text_rect.width() > content_rect.width()) text_rect.set_width(content_rect.width()); text_rect.align_within(content_rect, text_alignment()); @@ -116,7 +116,7 @@ void Button::paint_event(PaintEvent& event) if (is_focused()) { Gfx::IntRect focus_rect; - if (m_icon && !text().is_empty()) + if (m_icon && !text_deprecated().is_empty()) focus_rect = text_rect.inflated(4, 4); else focus_rect = rect().shrunken(8, 8); @@ -274,9 +274,9 @@ Optional<UISize> Button::calculated_min_size() const { int horizontal = 0, vertical = 0; - if (!text().is_empty()) { + if (!text_deprecated().is_empty()) { auto& font = this->font(); - horizontal = font.width(text()) + 2; + horizontal = font.width(text_deprecated()) + 2; vertical = font.glyph_height() + 4; // FIXME: Use actual maximum total height } diff --git a/Userland/Libraries/LibGUI/CheckBox.cpp b/Userland/Libraries/LibGUI/CheckBox.cpp index 64f62d7de9..bc99c52268 100644 --- a/Userland/Libraries/LibGUI/CheckBox.cpp +++ b/Userland/Libraries/LibGUI/CheckBox.cpp @@ -42,7 +42,7 @@ void CheckBox::paint_event(PaintEvent& event) auto text_rect = rect(); if (m_checkbox_position == CheckBoxPosition::Left) text_rect.set_left(s_box_width + s_horizontal_padding); - text_rect.set_width(font().width(text())); + text_rect.set_width(font().width(text_deprecated())); text_rect.set_top(height() / 2 - font().glyph_height() / 2); text_rect.set_height(font().glyph_height()); @@ -85,7 +85,7 @@ void CheckBox::set_autosize(bool autosize) void CheckBox::size_to_fit() { - set_fixed_width(s_box_width + font().width(text()) + s_horizontal_padding * 2); + set_fixed_width(s_box_width + font().width(text_deprecated()) + s_horizontal_padding * 2); } } diff --git a/Userland/Libraries/LibGUI/ColorPicker.cpp b/Userland/Libraries/LibGUI/ColorPicker.cpp index ad1364e7cd..68d1dbe01d 100644 --- a/Userland/Libraries/LibGUI/ColorPicker.cpp +++ b/Userland/Libraries/LibGUI/ColorPicker.cpp @@ -234,14 +234,14 @@ void ColorPicker::build_ui() button_container.layout()->add_spacer(); auto& ok_button = button_container.add<DialogButton>(); - ok_button.set_text("OK"); + ok_button.set_text_deprecated("OK"); ok_button.on_click = [this](auto) { done(ExecResult::OK); }; ok_button.set_default(true); auto& cancel_button = button_container.add<DialogButton>(); - cancel_button.set_text("Cancel"); + cancel_button.set_text_deprecated("Cancel"); cancel_button.on_click = [this](auto) { done(ExecResult::Cancel); }; diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index c69a823bef..ee4203659f 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -217,14 +217,14 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, StringView filename, St }; auto& ok_button = *widget->find_descendant_of_type_named<GUI::Button>("ok_button"); - ok_button.set_text(ok_button_name(m_mode)); + ok_button.set_text_deprecated(ok_button_name(m_mode)); ok_button.on_click = [this](auto) { on_file_return(); }; ok_button.set_enabled(m_mode == Mode::OpenFolder || !m_filename_textbox->text().is_empty()); auto& cancel_button = *widget->find_descendant_of_type_named<GUI::Button>("cancel_button"); - cancel_button.set_text("Cancel"); + cancel_button.set_text_deprecated("Cancel"); cancel_button.on_click = [this](auto) { done(ExecResult::Cancel); }; diff --git a/Userland/Libraries/LibGUI/IncrementalSearchBanner.cpp b/Userland/Libraries/LibGUI/IncrementalSearchBanner.cpp index a1524c2b1f..cbdc5b3d18 100644 --- a/Userland/Libraries/LibGUI/IncrementalSearchBanner.cpp +++ b/Userland/Libraries/LibGUI/IncrementalSearchBanner.cpp @@ -37,7 +37,7 @@ IncrementalSearchBanner::IncrementalSearchBanner(TextEditor& editor) }; m_close_button = find_descendant_of_type_named<Button>("incremental_search_banner_close_button"); - m_close_button->set_text("\xE2\x9D\x8C"); + m_close_button->set_text_deprecated("\xE2\x9D\x8C"); m_close_button->on_click = [this](auto) { hide(); }; diff --git a/Userland/Libraries/LibGUI/InputBox.cpp b/Userland/Libraries/LibGUI/InputBox.cpp index dde63448dd..b1948c35ef 100644 --- a/Userland/Libraries/LibGUI/InputBox.cpp +++ b/Userland/Libraries/LibGUI/InputBox.cpp @@ -107,7 +107,7 @@ void InputBox::build() button_container_inner.layout()->add_spacer(); m_ok_button = button_container_inner.add<DialogButton>(); - m_ok_button->set_text("OK"); + m_ok_button->set_text_deprecated("OK"); m_ok_button->on_click = [this](auto) { dbgln("GUI::InputBox: OK button clicked"); done(ExecResult::OK); @@ -115,7 +115,7 @@ void InputBox::build() m_ok_button->set_default(true); m_cancel_button = button_container_inner.add<DialogButton>(); - m_cancel_button->set_text("Cancel"); + m_cancel_button->set_text_deprecated("Cancel"); m_cancel_button->on_click = [this](auto) { dbgln("GUI::InputBox: Cancel button clicked"); done(ExecResult::Cancel); diff --git a/Userland/Libraries/LibGUI/MessageBox.cpp b/Userland/Libraries/LibGUI/MessageBox.cpp index ace4b8fcd9..1017d540da 100644 --- a/Userland/Libraries/LibGUI/MessageBox.cpp +++ b/Userland/Libraries/LibGUI/MessageBox.cpp @@ -49,9 +49,9 @@ Dialog::ExecResult MessageBox::ask_about_unsaved_changes(Window* parent_window, if (parent_window) box->set_icon(parent_window->icon()); - box->m_yes_button->set_text(path.is_empty() ? "Save As..." : "Save"); - box->m_no_button->set_text("Discard"); - box->m_cancel_button->set_text("Cancel"); + box->m_yes_button->set_text_deprecated(path.is_empty() ? "Save As..." : "Save"); + box->m_no_button->set_text_deprecated("Discard"); + box->m_cancel_button->set_text_deprecated("Cancel"); return box->exec(); } @@ -154,7 +154,7 @@ void MessageBox::build() auto add_button = [&](DeprecatedString label, ExecResult result) -> GUI::Button& { auto& button = button_container.add<Button>(); button.set_fixed_width(button_width); - button.set_text(label); + button.set_text_deprecated(label); button.on_click = [this, label, result](auto) { done(result); }; diff --git a/Userland/Libraries/LibGUI/RadioButton.cpp b/Userland/Libraries/LibGUI/RadioButton.cpp index f49ba66591..0c860c9a79 100644 --- a/Userland/Libraries/LibGUI/RadioButton.cpp +++ b/Userland/Libraries/LibGUI/RadioButton.cpp @@ -46,7 +46,7 @@ void RadioButton::paint_event(PaintEvent& event) Gfx::StylePainter::paint_radio_button(painter, circle_rect, palette(), is_checked(), is_being_pressed()); - Gfx::IntRect text_rect { circle_rect.right() + 7, 0, static_cast<int>(ceilf(font().width(text()))), font().glyph_height() }; + Gfx::IntRect text_rect { circle_rect.right() + 7, 0, static_cast<int>(ceilf(font().width(text_deprecated()))), font().glyph_height() }; text_rect.center_vertically_within(rect()); paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft); @@ -66,7 +66,7 @@ Optional<UISize> RadioButton::calculated_min_size() const int horizontal = 2 + 7, vertical = 0; auto& font = this->font(); vertical = max(font.glyph_height(), circle_size().height()); - horizontal += font.width(text()); + horizontal += font.width(text_deprecated()); return UISize(horizontal, vertical); } diff --git a/Userland/Libraries/LibGUI/Statusbar.cpp b/Userland/Libraries/LibGUI/Statusbar.cpp index bcc1f82454..73c2d0450a 100644 --- a/Userland/Libraries/LibGUI/Statusbar.cpp +++ b/Userland/Libraries/LibGUI/Statusbar.cpp @@ -86,7 +86,7 @@ void Statusbar::update_segment(size_t index) if (!text(i).is_empty()) m_segments[i].set_visible(true); } - segment.set_text(segment.restored_text()); + segment.set_text_deprecated(segment.restored_text()); segment.set_frame_shape(Gfx::FrameShape::Panel); if (segment.mode() != Segment::Mode::Proportional) segment.set_fixed_width(segment.restored_width()); @@ -95,7 +95,7 @@ void Statusbar::update_segment(size_t index) if (!m_segments[i].is_clickable()) m_segments[i].set_visible(false); } - segment.set_text(segment.override_text()); + segment.set_text_deprecated(segment.override_text()); segment.set_frame_shape(Gfx::FrameShape::NoFrame); if (segment.mode() != Segment::Mode::Proportional) segment.set_fixed_width(SpecialDimension::Grow); @@ -104,7 +104,7 @@ void Statusbar::update_segment(size_t index) DeprecatedString Statusbar::text(size_t index) const { - return m_segments.at(index).text(); + return m_segments.at(index).text_deprecated(); } void Statusbar::set_text(DeprecatedString text) @@ -157,8 +157,8 @@ void Statusbar::Segment::paint_event(PaintEvent& event) if (is_clickable()) Button::paint_event(event); - else if (!text().is_empty()) - painter.draw_text(rect().shrunken(font().max_glyph_width(), 0), text(), text_alignment(), palette().color(foreground_role()), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap); + else if (!text_deprecated().is_empty()) + painter.draw_text(rect().shrunken(font().max_glyph_width(), 0), text_deprecated(), text_alignment(), palette().color(foreground_role()), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap); } void Statusbar::Segment::mousedown_event(MouseEvent& event) diff --git a/Userland/Libraries/LibGUI/Toolbar.cpp b/Userland/Libraries/LibGUI/Toolbar.cpp index 16eaf772d3..360632c756 100644 --- a/Userland/Libraries/LibGUI/Toolbar.cpp +++ b/Userland/Libraries/LibGUI/Toolbar.cpp @@ -56,18 +56,18 @@ private: if (action.icon()) set_icon(action.icon()); else - set_text(action.text()); + set_text_deprecated(action.text()); set_button_style(Gfx::ButtonStyle::Coolbar); } - virtual void set_text(DeprecatedString text) override + virtual void set_text_deprecated(DeprecatedString text) override { auto const* action = this->action(); VERIFY(action); set_tooltip(tooltip(*action)); if (!action->icon()) - Button::set_text(move(text)); + Button::set_text_deprecated(move(text)); } DeprecatedString tooltip(Action const& action) const diff --git a/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp b/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp index 4654af9f4d..bd27698c3b 100644 --- a/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp +++ b/Userland/Libraries/LibGUI/Wizards/WizardDialog.cpp @@ -122,9 +122,9 @@ void WizardDialog::update_navigation() m_back_button->set_enabled(m_page_stack.size() > 1); if (has_pages()) { m_next_button->set_enabled(current_page().is_final_page() || current_page().can_go_next()); - m_next_button->set_text(current_page().is_final_page() ? "Finish" : "Next >"); + m_next_button->set_text_deprecated(current_page().is_final_page() ? "Finish" : "Next >"); } else { - m_next_button->set_text("Next >"); + m_next_button->set_text_deprecated("Next >"); m_next_button->set_enabled(false); } } |