mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 17:15:08 +00:00
LibGUI: Use TextElision::Right for GButton captions.
This commit is contained in:
parent
4533539e8a
commit
82b02ed82b
1 changed files with 13 additions and 11 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "GButton.h"
|
||||
#include <LibGUI/GPainter.h>
|
||||
#include <SharedGraphics/StylePainter.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
||||
//#define GBUTTON_DEBUG
|
||||
|
||||
|
@ -36,18 +37,19 @@ 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().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);
|
||||
icon_location.move_by(1, 1);
|
||||
}
|
||||
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, text_alignment(), Color::Black);
|
||||
if (m_caption.is_empty() && !m_icon)
|
||||
return;
|
||||
|
||||
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);
|
||||
icon_location.move_by(1, 1);
|
||||
}
|
||||
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, m_caption, font, text_alignment(), Color::Black, TextElision::Right);
|
||||
}
|
||||
|
||||
void GButton::mousemove_event(GMouseEvent& event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue