11from rcp .components .home .coordbar import CoordBar
22from rcp .components .home .mode_layout import ModeLayout
33from rcp .components .home .servobar import ServoBar
4+ from kivy .uix .widget import Widget
45
56
67class IndexModeLayout (ModeLayout ):
@@ -9,9 +10,16 @@ class IndexModeLayout(ModeLayout):
910 def __init__ (self , ** kwargs ):
1011 super ().__init__ (** kwargs )
1112 self .servo_bar = ServoBar ()
13+ self .spacer = Widget ()
14+
1215 self .build_axis_bars ()
16+ self .add_widget (self .spacer )
1317 self .add_widget (self .servo_bar )
1418
19+ self .app .formats .bind (max_row_height = lambda * _ : self ._update_row_heights ())
20+ self .bind (height = self ._update_row_heights )
21+ self ._update_row_heights ()
22+
1523 def build_axis_bars (self ):
1624 for axis_disp in self .app .axes :
1725 cb = CoordBar (axis = axis_disp )
@@ -22,3 +30,17 @@ def rebuild_axes(self):
2230 self .remove_widget (self .servo_bar )
2331 super ().rebuild_axes ()
2432 self .add_widget (self .servo_bar )
33+
34+ def _update_row_heights (self , * args ):
35+ num_rows = len (self .axis_bars )
36+ if num_rows == 0 :
37+ return
38+
39+ available = self .height - self .servo_bar .height
40+ row_height = min (available / num_rows , self .app .formats .max_row_height )
41+
42+ for bar in self .axis_bars :
43+ bar .size_hint_y = None
44+ bar .height = row_height
45+
46+ # spacer absorbs remaining space (size_hint_y defaults to 1)
0 commit comments