Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto dimensions #527

Merged
merged 24 commits into from
May 20, 2022
Merged

Auto dimensions #527

merged 24 commits into from
May 20, 2022

Conversation

willmcgugan
Copy link
Collaborator

@willmcgugan willmcgugan commented May 18, 2022

  • Fixes for nested containers and auto dimensions
  • Deferred layout to Screen.on_idle to avoid unnecessary layouts
  • Fix for log events arriving after app shutdown

There's a lack of tests here for the box model / layout system here. Please let that slide just now. I have a feeling there will be more changes required, and I don't yet have a good enough understanding of the various CSS rule interactions.

@willmcgugan willmcgugan marked this pull request as draft May 18, 2022 14:49
def arrange(
self, parent: Widget, size: Size, scroll: Offset
) -> tuple[list[WidgetPlacement], set[Widget]]:
def arrange(self, parent: Widget, size: Size) -> ArrangeResult:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped scroll parameter which wasn't used. Added a type alias for the return type.

@willmcgugan willmcgugan marked this pull request as ready for review May 19, 2022 10:46
olivierphi
olivierphi previously approved these changes May 19, 2022
Copy link

@olivierphi olivierphi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid the layout and geometry updates themselves are still a bit too obscure for me to do any relevant feedback at this point, so as often I was only able to leave some pretty picky-and-useless ones that's you're totally free to ignore, sorry 😅

sandbox/auto_test.css Outdated Show resolved Hide resolved
for task in self._child_tasks:
task.cancel()
await task
self._child_tasks.clear()
if self._task is not None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be worth doing this only if the task is not done yet? 🙂 i.e.

if self._task is not None and not self._task.done():

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not much point, if the task is done, awaiting it is essentially a no-op.

@@ -59,7 +59,7 @@ def get_auto_height(container: Size, parent: Size) -> int:
box_model = get_box_model(
styles, Size(60, 20), Size(80, 24), get_auto_width, get_auto_height
)
assert box_model == BoxModel(Size(60, 20), Spacing(1, 2, 3, 4))
assert box_model == BoxModel(Size(54, 16), Spacing(1, 2, 3, 4))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure that I understand this correctly... The returned box model now shrinks the available space of a widget according to its margin, right? 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

except Exception:
pass
except Exception as error:
self.on_exception(error)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bunch of errors related to log getting called after the App has shutdown, which were previously hidden.

for task in self._child_tasks:
task.cancel()
await task
self._child_tasks.clear()
if self._task is not None:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not much point, if the task is done, awaiting it is essentially a no-op.

@@ -59,7 +59,7 @@ def get_auto_height(container: Size, parent: Size) -> int:
box_model = get_box_model(
styles, Size(60, 20), Size(80, 24), get_auto_width, get_auto_height
)
assert box_model == BoxModel(Size(60, 20), Spacing(1, 2, 3, 4))
assert box_model == BoxModel(Size(54, 16), Spacing(1, 2, 3, 4))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

@willmcgugan willmcgugan merged commit fe99c72 into css May 20, 2022
@willmcgugan willmcgugan deleted the auto-dimensions branch May 20, 2022 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants