mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:07:46 +00:00
LibGUI+Userland: Add _deprecated
suffix to AbstractButton::{set_,}text
This commit is contained in:
parent
61b49daf0a
commit
d32b052f22
30 changed files with 83 additions and 83 deletions
|
@ -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)
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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({});
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue