mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 22:48:11 +00:00
Intense hacking on Widgets.
This commit is contained in:
parent
8c84f9749e
commit
6f37429f57
20 changed files with 290 additions and 5 deletions
|
@ -12,6 +12,13 @@ Widget::~Widget()
|
|||
{
|
||||
}
|
||||
|
||||
void Widget::setRect(const Rect& rect)
|
||||
{
|
||||
// FIXME: Make some kind of event loop driven ResizeEvent?
|
||||
m_rect = rect;
|
||||
update();
|
||||
}
|
||||
|
||||
void Widget::event(Event& event)
|
||||
{
|
||||
switch (event.type()) {
|
||||
|
@ -36,8 +43,13 @@ void Widget::event(Event& event)
|
|||
}
|
||||
}
|
||||
|
||||
void Widget::onPaint(PaintEvent&)
|
||||
void Widget::onPaint(PaintEvent& event)
|
||||
{
|
||||
printf("Widget::onPaint :)\n");
|
||||
for (auto* ch : children()) {
|
||||
auto* child = (Widget*)ch;
|
||||
child->onPaint(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::onShow(ShowEvent&)
|
||||
|
@ -74,3 +86,15 @@ void Widget::update()
|
|||
EventLoop::main().postEvent(this, make<PaintEvent>());
|
||||
}
|
||||
|
||||
Widget::HitTestResult Widget::hitTest(int x, int y)
|
||||
{
|
||||
// FIXME: Care about z-order.
|
||||
for (auto* ch : children()) {
|
||||
auto* child = (Widget*)ch;
|
||||
if (child->rect().contains(x, y)) {
|
||||
return child->hitTest(x - child->rect().x(), y - child->rect().y());
|
||||
}
|
||||
}
|
||||
return { this, x, y };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue