mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 14:05:08 +00:00
LibGUI: More work on GInputBox.
- If the GInputBox has a parent and the parent is a GWindow, center the input box window within the parent window. This looks quite nice. - Stop processing events in a nested event loop immediately after it's been asked to quit. - Fix GWidget::parent_widget() behavior for non-widget parents.
This commit is contained in:
parent
a6538feed1
commit
f88e550998
9 changed files with 74 additions and 34 deletions
|
@ -14,13 +14,25 @@ GDialog::~GDialog()
|
|||
|
||||
int GDialog::exec()
|
||||
{
|
||||
GEventLoop loop;
|
||||
ASSERT(!m_event_loop);
|
||||
m_event_loop = make<GEventLoop>();
|
||||
if (parent() && parent()->is_window()) {
|
||||
auto& parent_window = *static_cast<GWindow*>(parent());
|
||||
auto new_rect = rect();
|
||||
new_rect.center_within(parent_window.rect());
|
||||
set_rect(new_rect);
|
||||
}
|
||||
show();
|
||||
return loop.exec();
|
||||
auto result = m_event_loop->exec();
|
||||
m_event_loop = nullptr;
|
||||
dbgprintf("event loop returned with result %d\n", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void GDialog::done(int result)
|
||||
{
|
||||
ASSERT(m_event_loop);
|
||||
m_result = result;
|
||||
GEventLoop::current().quit(result);
|
||||
dbgprintf("quit event loop with result %d\n", result);
|
||||
m_event_loop->quit(result);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue