Skip to content

Commit

Permalink
Working on Winforms, Android and iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Mar 2, 2023
1 parent 9f65938 commit a1d1439
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions android/src/toga_android/widgets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ def insert_child(self, index, child):
def remove_child(self, child):
child.container = None

def refresh(self):
self.rehint()

def rehint(self):
pass

Expand Down
5 changes: 5 additions & 0 deletions android/src/toga_android/widgets/box.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from travertino.constants import TRANSPARENT
from travertino.size import at_least

from ..colors import native_color
from ..libs.activity import MainActivity
Expand Down Expand Up @@ -27,3 +28,7 @@ def set_background_color(self, value):
self.native.setBackgroundColor(
native_color(TRANSPARENT if (value is None) else value)
)

def rehint(self):
self.interface.intrinsic.width = at_least(0)
self.interface.intrinsic.height = at_least(0)
4 changes: 3 additions & 1 deletion examples/resize/src/resize/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def on_change_text(self, panel, width, height, flex):
setattr_if_changed(self.text_label.style, "flex", flex)

def on_change_style(self, panel, width, height, flex):
INCREMENT = 50
# Increment should be large enough that the minimum window width can be determined
# by either the buttons or the labels, depending on the labels' size.
INCREMENT = 60
setattr_if_changed(self.style_label.style, "width", width * INCREMENT)
setattr_if_changed(self.style_label.style, "height", height * INCREMENT)
setattr_if_changed(self.style_label.style, "flex", flex)
Expand Down
3 changes: 3 additions & 0 deletions iOS/src/toga_iOS/widgets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,8 @@ def add_constraints(self):
self.constraints = Constraints(self)
self.native.translatesAutoresizingMaskIntoConstraints = False

def refresh(self):
self.rehint()

def rehint(self):
pass
5 changes: 5 additions & 0 deletions iOS/src/toga_iOS/widgets/box.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from rubicon.objc import objc_method, objc_property
from travertino.size import at_least

from toga_iOS.colors import native_color
from toga_iOS.libs import UIColor, UIView
Expand Down Expand Up @@ -37,3 +38,7 @@ def set_background_color(self, value):
self.native.backgroundColor = UIColor.systemBackgroundColor() # iOS 13+
except AttributeError:
self.native.backgroundColor = UIColor.whiteColor

def rehint(self):
self.interface.intrinsic.width = at_least(0)
self.interface.intrinsic.height = at_least(0)
3 changes: 3 additions & 0 deletions winforms/src/toga_winforms/widgets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,8 @@ def insert_child(self, index, child):
def remove_child(self, child):
child.container = None

def refresh(self):
self.rehint()

def rehint(self):
pass
5 changes: 5 additions & 0 deletions winforms/src/toga_winforms/widgets/box.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from travertino.constants import TRANSPARENT
from travertino.size import at_least

from toga_winforms.colors import native_color
from toga_winforms.libs import Point, Size, WinForms
Expand Down Expand Up @@ -36,3 +37,7 @@ def set_background_color(self, value):
self.native.BackColor = native_color(value)
else:
self.native.BackColor = native_color(TRANSPARENT)

def rehint(self):
self.interface.intrinsic.width = at_least(0)
self.interface.intrinsic.height = at_least(0)

0 comments on commit a1d1439

Please sign in to comment.