mirror of
https://github.com/RGBCube/serenity
synced 2025-06-28 04:02:07 +00:00
Move Widget & friends into LibGUI.
This commit is contained in:
parent
7e5b81fe48
commit
a026da47e7
29 changed files with 73 additions and 551 deletions
35
LibGUI/Label.cpp
Normal file
35
LibGUI/Label.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include "Label.h"
|
||||
#include <SharedGraphics/Painter.h>
|
||||
|
||||
Label::Label(Widget* parent)
|
||||
: Widget(parent)
|
||||
{
|
||||
}
|
||||
|
||||
Label::~Label()
|
||||
{
|
||||
}
|
||||
|
||||
void Label::setText(String&& text)
|
||||
{
|
||||
if (text == m_text)
|
||||
return;
|
||||
m_text = move(text);
|
||||
update();
|
||||
}
|
||||
|
||||
void Label::paintEvent(PaintEvent&)
|
||||
{
|
||||
Painter painter(*this);
|
||||
if (fillWithBackgroundColor())
|
||||
painter.fill_rect({ 0, 0, width(), height() }, backgroundColor());
|
||||
if (!text().is_empty())
|
||||
painter.draw_text({ 4, 4, width(), height() }, text(), Painter::TextAlignment::TopLeft, foregroundColor());
|
||||
}
|
||||
|
||||
void Label::mouseMoveEvent(MouseEvent& event)
|
||||
{
|
||||
dbgprintf("Label::mouseMoveEvent: x=%d, y=%d\n", event.x(), event.y());
|
||||
Widget::mouseMoveEvent(event);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue