1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:57:35 +00:00

Userland: Replace usages of AbstractButton::text_deprecated with text()

This commit is contained in:
Karol Kosek 2023-02-12 11:40:58 +01:00 committed by Linus Groh
parent fca29eae09
commit d32d4029d3
9 changed files with 25 additions and 25 deletions

View file

@ -243,14 +243,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_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);
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);
return;
}
if (text_deprecated().is_empty())
if (text().is_empty())
return;
painter.draw_text(clipped_rect, text_deprecated(), font, text_alignment, palette().color(foreground_role()), Gfx::TextElision::Right, text_wrapping);
painter.draw_text(clipped_rect, text(), font, text_alignment, palette().color(foreground_role()), Gfx::TextElision::Right, text_wrapping);
}
void AbstractButton::change_event(Event& event)

View file

@ -66,12 +66,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_deprecated().is_empty() && !m_icon)
if (text().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_deprecated().is_empty())
if (m_icon && !text().is_empty())
icon_location.set_x(content_rect.x());
if (paint_pressed || is_checked()) {
@ -108,12 +108,12 @@ void Button::paint_event(PaintEvent& event)
m_icon->invert();
}
auto& font = is_checked() ? this->font().bold_variant() : this->font();
if (m_icon && !text_deprecated().is_empty()) {
if (m_icon && !text().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_deprecated()))), font.glyph_height() };
Gfx::IntRect text_rect { 0, 0, static_cast<int>(ceilf(font.width(text()))), 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());
@ -121,7 +121,7 @@ void Button::paint_event(PaintEvent& event)
if (is_focused()) {
Gfx::IntRect focus_rect;
if (m_icon && !text_deprecated().is_empty())
if (m_icon && !text().is_empty())
focus_rect = text_rect.inflated(4, 4);
else
focus_rect = rect().shrunken(8, 8);
@ -279,9 +279,9 @@ Optional<UISize> Button::calculated_min_size() const
{
int horizontal = 0, vertical = 0;
if (!text_deprecated().is_empty()) {
if (!text().is_empty()) {
auto& font = this->font();
horizontal = font.width(text_deprecated()) + 2;
horizontal = font.width(text()) + 2;
vertical = font.glyph_height() + 4; // FIXME: Use actual maximum total height
}

View file

@ -47,7 +47,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_deprecated()));
text_rect.set_width(font().width(text()));
text_rect.set_top(height() / 2 - font().glyph_height() / 2);
text_rect.set_height(font().glyph_height());
@ -90,7 +90,7 @@ void CheckBox::set_autosize(bool autosize)
void CheckBox::size_to_fit()
{
set_fixed_width(s_box_width + font().width(text_deprecated()) + s_horizontal_padding * 2);
set_fixed_width(s_box_width + font().width(text()) + s_horizontal_padding * 2);
}
}

View file

@ -51,7 +51,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_deprecated()))), font().glyph_height() };
Gfx::IntRect text_rect { circle_rect.right() + 7, 0, static_cast<int>(ceilf(font().width(text()))), font().glyph_height() };
text_rect.center_vertically_within(rect());
paint_text(painter, text_rect, font(), Gfx::TextAlignment::TopLeft);
@ -71,7 +71,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_deprecated());
horizontal += font.width(text());
return UISize(horizontal, vertical);
}

View file

@ -104,7 +104,7 @@ void Statusbar::update_segment(size_t index)
DeprecatedString Statusbar::text(size_t index) const
{
return m_segments.at(index).text_deprecated();
return m_segments.at(index).text().to_deprecated_string();
}
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_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);
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);
}
void Statusbar::Segment::mousedown_event(MouseEvent& event)