mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:08:12 +00:00
GLayout: Add a simple spacer concept; dummy item that expands-to-fit.
A spacer can be inserted anywhere in a layout and will simply expand to fill the available space. This is useful for pushing widgets into place. :^)
This commit is contained in:
parent
bd5c79aff2
commit
bffaa5ece6
4 changed files with 39 additions and 7 deletions
|
@ -34,6 +34,9 @@ void GBoxLayout::run(GWidget& widget)
|
|||
dbgprintf("GBoxLayout: Starting with available size: %s\n", available_size.to_string().characters());
|
||||
|
||||
for (auto& entry : m_entries) {
|
||||
if (entry.type == Entry::Type::Spacer) {
|
||||
++number_of_visible_entries;
|
||||
}
|
||||
if (!entry.widget)
|
||||
continue;
|
||||
|
||||
|
@ -84,6 +87,11 @@ void GBoxLayout::run(GWidget& widget)
|
|||
int current_y = margins().top();
|
||||
|
||||
for (auto& entry : m_entries) {
|
||||
if (entry.type == Entry::Type::Spacer) {
|
||||
current_x += automatic_size.width();
|
||||
current_y += automatic_size.height();
|
||||
}
|
||||
|
||||
if (!entry.widget)
|
||||
continue;
|
||||
if (!entry.widget->is_visible())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue