@@ -557,8 +557,8 @@ def _constrain(
557557
558558 region = region .translate_inside (
559559 constrain_region .shrink (styles .margin ),
560- constrain_x == "inside " ,
561- constrain_y == "inside " ,
560+ constrain_x != "none " ,
561+ constrain_y != "none " ,
562562 )
563563
564564 return region
@@ -697,13 +697,12 @@ def add_widget(
697697
698698 widget_order = order + ((layer_index , z , layer_order ),)
699699
700- if overlay and (
701- sub_widget .styles .constrain_x != "none"
702- or sub_widget .styles .constrain_y != "none"
703- ):
704- widget_region = self ._constrain (
705- sub_widget .styles , widget_region , no_clip
706- )
700+ if overlay :
701+ has_rule = sub_widget .styles .has_rule
702+ if has_rule ("constrain_x" ) or has_rule ("constrain_y" ):
703+ widget_region = self ._constrain (
704+ sub_widget .styles , widget_region , no_clip
705+ )
707706
708707 if widget ._cover_widget is None :
709708 add_widget (
@@ -752,16 +751,16 @@ def add_widget(
752751
753752 widget_region = region + layout_offset
754753
755- if widget ._absolute_offset is not None :
754+ if widget .absolute_offset is not None :
756755 margin = styles .margin
757756 widget_region = widget_region .reset_offset .translate (
758- widget ._absolute_offset + margin .top_left
757+ widget .absolute_offset + margin .top_left
759758 )
760759 widget_region = widget_region .translate (
761760 styles .offset .resolve (widget_region .grow (margin ).size , size )
762761 )
763-
764- if styles . constrain_x != "none" or styles . constrain_y != "none" :
762+ has_rule = styles . has_rule
763+ if has_rule ( " constrain_x" ) or has_rule ( " constrain_y" ) :
765764 widget_region = self ._constrain (styles , widget_region , no_clip )
766765
767766 map [widget ._render_widget ] = _MapGeometry (
0 commit comments