mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
LibGUI: Allow specifying GButton text alignment.
This commit is contained in:
parent
1374195a0d
commit
89c544d97b
Notes:
sideshowbarker
2024-07-19 14:49:38 +09:00
Author: https://github.com/awesomekling
Commit: 89c544d97b
2 changed files with 7 additions and 2 deletions
|
@ -37,7 +37,7 @@ void GButton::paint_event(GPaintEvent& event)
|
|||
StylePainter::paint_button(painter, rect(), m_button_style, m_being_pressed, m_hovered, m_checkable && m_checked);
|
||||
|
||||
if (!caption().is_empty() || m_icon) {
|
||||
auto content_rect = rect();
|
||||
auto content_rect = rect().shrunken(10, 2);
|
||||
auto icon_location = m_icon ? content_rect.center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2)) : Point();
|
||||
if (m_being_pressed) {
|
||||
content_rect.move_by(1, 1);
|
||||
|
@ -46,7 +46,7 @@ void GButton::paint_event(GPaintEvent& event)
|
|||
if (m_icon)
|
||||
painter.blit(icon_location, *m_icon, m_icon->rect());
|
||||
auto& font = (m_checkable && m_checked) ? Font::default_bold_font() : this->font();
|
||||
painter.draw_text(content_rect, caption(), font, TextAlignment::Center, Color::Black);
|
||||
painter.draw_text(content_rect, caption(), font, text_alignment(), Color::Black);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue