Skip to content

Commit

Permalink
Make 'weak' the default for Component hug preferences.
Browse files Browse the repository at this point in the history
We can revisit this once Components have a more robust way of supplying
their size preferences.
  • Loading branch information
jwiggins authored and brett-patterson committed Jun 25, 2014
1 parent e172410 commit ba3c47a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions enable/coordinate_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ class CoordinateBox(HasTraits):
layout_size_hint = Tuple(0.0, 0.0)

# How strongly a layout box hugs it's width hint.
hug_width = ConstraintPolicyEnum('strong')
hug_width = ConstraintPolicyEnum('weak')

# How strongly a layout box hugs it's height hint.
hug_height = ConstraintPolicyEnum('strong')
hug_height = ConstraintPolicyEnum('weak')

# How strongly a layout box resists clipping its contents.
resist_width = ConstraintPolicyEnum('strong')
Expand Down
17 changes: 7 additions & 10 deletions examples/enable/constraints_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,20 @@ class Demo(HasTraits):
def _canvas_default(self):
parent = ConstraintsContainer(bounds=(500,500), padding=20)

hugs = {'hug_width':'weak', 'hug_height':'weak'}
one = Component(id="r", bgcolor=0xFF0000, **hugs)
two = Component(id="g", bgcolor=0x00FF00, **hugs)
three = Component(id="b", bgcolor=0x0000FF, **hugs)
one = Component(id="r", bgcolor=0xFF0000)
two = Component(id="g", bgcolor=0x00FF00)
three = Component(id="b", bgcolor=0x0000FF)

parent.add(one, two, three, self.child_canvas)
return parent

def _child_canvas_default(self):
parent = ConstraintsContainer(id="child", share_layout=self.share_layout)

hugs = {'hug_width':'weak', 'hug_height':'weak'}
one = Component(id="c", bgcolor=0x00FFFF, **hugs)
two = Component(id="m", bgcolor=0xFF00FF, **hugs)
three = Component(id="y", bgcolor=0xFFFF00, **hugs)
four = Component(id="k", bgcolor=0x000000, **hugs)
one = Component(id="c", bgcolor=0x00FFFF)
two = Component(id="m", bgcolor=0xFF00FF)
three = Component(id="y", bgcolor=0xFFFF00)
four = Component(id="k", bgcolor=0x000000)

parent.add(one, two, three, four)
return parent
Expand All @@ -80,7 +78,6 @@ def _constraints_def_changed(self):
y = components[2]
k = components[3]


try:
new_cns = eval(self.constraints_def)
except Exception, ex:
Expand Down

0 comments on commit ba3c47a

Please sign in to comment.