mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Label should respect background/foreground color.
This commit is contained in:
parent
1df47d3ed5
commit
b5ff34174d
|
@ -22,9 +22,9 @@ void Label::setText(String&& text)
|
||||||
void Label::onPaint(PaintEvent&)
|
void Label::onPaint(PaintEvent&)
|
||||||
{
|
{
|
||||||
Painter painter(*this);
|
Painter painter(*this);
|
||||||
painter.fillRect({ 0, 0, width(), height() }, Color(0x0, 0x0, 0x0));
|
painter.fillRect({ 0, 0, width(), height() }, backgroundColor());
|
||||||
if (!text().isEmpty())
|
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)
|
void Label::onMouseMove(MouseEvent& event)
|
||||||
|
|
|
@ -44,21 +44,27 @@ int main(int argc, char** argv)
|
||||||
l4->setWindowRelativeRect({ 0, 60, 300, 20 });
|
l4->setWindowRelativeRect({ 0, 60, 300, 20 });
|
||||||
l4->setText("!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~");
|
l4->setText("!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~");
|
||||||
|
|
||||||
|
{
|
||||||
auto* widgetTestWindow = new Window;
|
auto* widgetTestWindow = new Window;
|
||||||
widgetTestWindow->setTitle("Widget test");
|
widgetTestWindow->setTitle("Widget test");
|
||||||
widgetTestWindow->setRect({ 20, 40, 100, 100 });
|
widgetTestWindow->setRect({ 20, 40, 100, 60 });
|
||||||
|
|
||||||
auto* widgetTestWindowWidget = new Widget;
|
auto* widgetTestWindowWidget = new Widget;
|
||||||
widgetTestWindowWidget->setWindowRelativeRect({ 0, 0, 100, 100 });
|
widgetTestWindowWidget->setWindowRelativeRect({ 0, 0, 100, 100 });
|
||||||
widgetTestWindow->setMainWidget(widgetTestWindowWidget);
|
widgetTestWindow->setMainWidget(widgetTestWindowWidget);
|
||||||
|
|
||||||
|
auto* l = new Label(widgetTestWindowWidget);
|
||||||
|
l->setWindowRelativeRect({ 0, 0, 100, 20 });
|
||||||
|
l->setText("Label");
|
||||||
|
|
||||||
auto* b = new Button(widgetTestWindowWidget);
|
auto* b = new Button(widgetTestWindowWidget);
|
||||||
b->setWindowRelativeRect({ 0, 0, 100, 30 });
|
b->setWindowRelativeRect({ 0, 20, 100, 20 });
|
||||||
b->setCaption("Button");
|
b->setCaption("Button");
|
||||||
|
|
||||||
auto* c = new CheckBox(widgetTestWindowWidget);
|
auto* c = new CheckBox(widgetTestWindowWidget);
|
||||||
c->setWindowRelativeRect({ 0, 30, 100, 30 });
|
c->setWindowRelativeRect({ 0, 40, 100, 20 });
|
||||||
c->setCaption("CheckBox");
|
c->setCaption("CheckBox");
|
||||||
|
}
|
||||||
|
|
||||||
auto* win = new Window;
|
auto* win = new Window;
|
||||||
win->setTitle("Console");
|
win->setTitle("Console");
|
||||||
|
|
Loading…
Reference in a new issue