mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 19:25:07 +00:00
Add a little About app and hook it up to the system menu's "About..." entry.
Added icons and customizable text alignment to GLabel.
This commit is contained in:
parent
d6326d6c2e
commit
d74b131c27
11 changed files with 118 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "GLabel.h"
|
||||
#include <SharedGraphics/Painter.h>
|
||||
#include <SharedGraphics/GraphicsBitmap.h>
|
||||
|
||||
GLabel::GLabel(GWidget* parent)
|
||||
: GWidget(parent)
|
||||
|
@ -10,6 +11,11 @@ GLabel::~GLabel()
|
|||
{
|
||||
}
|
||||
|
||||
void GLabel::set_icon(RetainPtr<GraphicsBitmap>&& icon)
|
||||
{
|
||||
m_icon = move(icon);
|
||||
}
|
||||
|
||||
void GLabel::set_text(String&& text)
|
||||
{
|
||||
if (text == m_text)
|
||||
|
@ -18,11 +24,15 @@ void GLabel::set_text(String&& text)
|
|||
update();
|
||||
}
|
||||
|
||||
void GLabel::paint_event(GPaintEvent& event)
|
||||
void GLabel::paint_event(GPaintEvent&)
|
||||
{
|
||||
Painter painter(*this);
|
||||
if (fill_with_background_color())
|
||||
painter.fill_rect({ 0, 0, width(), height() }, background_color());
|
||||
if (m_icon) {
|
||||
auto icon_location = rect().center().translated(-(m_icon->width() / 2), -(m_icon->height() / 2));
|
||||
painter.blit_with_alpha(icon_location, *m_icon, m_icon->rect());
|
||||
}
|
||||
if (!text().is_empty())
|
||||
painter.draw_text({ 4, 4, width(), height() }, text(), TextAlignment::TopLeft, foreground_color());
|
||||
painter.draw_text({ 0, 0, width(), height() }, text(), m_text_alignment, foreground_color());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue