Skip to content

Commit

Permalink
strech all flexible wigets, not just dividers
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Rino <bruno.rino@gmail.com>
  • Loading branch information
bruno-rino committed Aug 2, 2022
1 parent e258c3e commit efb50ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/cocoa/toga_cocoa/widgets/divider.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from travertino.size import at_least

from toga_cocoa.libs import NSBox, NSBoxType

from .base import Widget
Expand All @@ -16,9 +18,9 @@ def rehint(self):

if self.interface.direction == self.interface.VERTICAL:
self.interface.intrinsic.width = content_size.width
self.interface.intrinsic.height = 0
self.interface.intrinsic.height = at_least(content_size.height)
else:
self.interface.intrinsic.width = 0
self.interface.intrinsic.width = at_least(content_size.width)
self.interface.intrinsic.height = content_size.height

def set_direction(self, value):
Expand Down
10 changes: 5 additions & 5 deletions src/core/toga/style/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)
from travertino.declaration import BaseStyle, Choices
from travertino.layout import BaseBox
from travertino.size import BaseIntrinsicSize
from travertino.size import BaseIntrinsicSize, at_least

from toga.fonts import SYSTEM_DEFAULT_FONT_SIZE, Font

Expand Down Expand Up @@ -321,9 +321,9 @@ def _layout_row_children(self, node, available_width, available_height, scale):
)
height = max(height, child_height)

# Pass 4: set vertical position of each child.
# Pass 4: set vertical position of each child, and extend flexible children to the full height.
for child in node.children:
if not self.height and not child.intrinsic.height:
if child.style.flex or type(child.intrinsic.height) is at_least:
child.layout.content_height = (
height
- scale(child.style.padding_top)
Expand Down Expand Up @@ -467,9 +467,9 @@ def _layout_column_children(self, node, available_width, available_height, scale
)
width = max(width, child_width)

# Pass 4: set horizontal position of each child.
# Pass 4: set horizontal position of each child, and extend flexible children to full width.
for child in node.children:
if not self.width and not child.intrinsic.width:
if child.style.flex or type(child.intrinsic.width) is at_least:
child.layout.content_width = (
width
- scale(child.style.padding_left)
Expand Down

0 comments on commit efb50ef

Please sign in to comment.