1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 07:00:45 +00:00

Label should respect background/foreground color.

This commit is contained in:
Andreas Kling 2018-10-12 21:00:17 +02:00
parent 1df47d3ed5
commit b5ff34174d
2 changed files with 21 additions and 15 deletions

View File

@ -22,9 +22,9 @@ void Label::setText(String&& text)
void Label::onPaint(PaintEvent&)
{
Painter painter(*this);
painter.fillRect({ 0, 0, width(), height() }, Color(0x0, 0x0, 0x0));
painter.fillRect({ 0, 0, width(), height() }, backgroundColor());
if (!text().isEmpty())
painter.drawText({ 4, 4, width(), height() }, text(), Painter::TextAlignment::TopLeft, Color(0xff, 0xff, 0xff));
painter.drawText({ 4, 4, width(), height() }, text(), Painter::TextAlignment::TopLeft, foregroundColor());
}
void Label::onMouseMove(MouseEvent& event)

View File

@ -44,21 +44,27 @@ int main(int argc, char** argv)
l4->setWindowRelativeRect({ 0, 60, 300, 20 });
l4->setText("!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~");
auto* widgetTestWindow = new Window;
widgetTestWindow->setTitle("Widget test");
widgetTestWindow->setRect({ 20, 40, 100, 100 });
{
auto* widgetTestWindow = new Window;
widgetTestWindow->setTitle("Widget test");
widgetTestWindow->setRect({ 20, 40, 100, 60 });
auto* widgetTestWindowWidget = new Widget;
widgetTestWindowWidget->setWindowRelativeRect({ 0, 0, 100, 100 });
widgetTestWindow->setMainWidget(widgetTestWindowWidget);
auto* b = new Button(widgetTestWindowWidget);
b->setWindowRelativeRect({ 0, 0, 100, 30 });
b->setCaption("Button");
auto* widgetTestWindowWidget = new Widget;
widgetTestWindowWidget->setWindowRelativeRect({ 0, 0, 100, 100 });
widgetTestWindow->setMainWidget(widgetTestWindowWidget);
auto* c = new CheckBox(widgetTestWindowWidget);
c->setWindowRelativeRect({ 0, 30, 100, 30 });
c->setCaption("CheckBox");
auto* l = new Label(widgetTestWindowWidget);
l->setWindowRelativeRect({ 0, 0, 100, 20 });
l->setText("Label");
auto* b = new Button(widgetTestWindowWidget);
b->setWindowRelativeRect({ 0, 20, 100, 20 });
b->setCaption("Button");
auto* c = new CheckBox(widgetTestWindowWidget);
c->setWindowRelativeRect({ 0, 40, 100, 20 });
c->setCaption("CheckBox");
}
auto* win = new Window;
win->setTitle("Console");