Skip to content

Commit 4404f17

Browse files
author
funkenjaeger
committed
Made axis row height logic consistent across modes, and made max row height a format setting
1 parent 7a0c8f2 commit 4404f17

6 files changed

Lines changed: 73 additions & 4 deletions

File tree

rcp/components/home/dro_mode_layout.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,34 @@
11
from rcp.components.home.dro_coordbar import DroCoordBar
22
from rcp.components.home.mode_layout import ModeLayout
3+
from kivy.uix.widget import Widget
34

45

56
class DroModeLayout(ModeLayout):
6-
"""DRO mode: simplified DroCoordBars filling all space, no bottom bar."""
7+
"""DRO mode: simplified DroCoordBars, no bottom bar."""
78

89
def __init__(self, **kwargs):
910
super().__init__(**kwargs)
11+
1012
self.build_axis_bars()
13+
self.spacer = Widget()
14+
self.add_widget(self.spacer)
15+
16+
self.app.formats.bind(max_row_height=lambda *_: self._update_row_heights())
17+
self.bind(height=self._update_row_heights)
18+
self._update_row_heights()
19+
20+
def _update_row_heights(self, *args):
21+
num_rows = len(self.axis_bars)
22+
if num_rows == 0:
23+
return
24+
25+
row_height = min(self.height / num_rows, self.app.formats.max_row_height)
26+
27+
for bar in self.axis_bars:
28+
bar.size_hint_y = None
29+
bar.height = row_height
30+
31+
# spacer absorbs remaining space (size_hint_y defaults to 1)
1132

1233
def build_axis_bars(self):
1334
for axis_disp in self.app.axes:

rcp/components/home/els_mode_layout.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
ICON_CCW = "\uf0e2" # rotate-left
1616
ICON_STOP = "\uf04d" # stop
1717

18-
MAX_ROW_HEIGHT = 150
1918
LONG_PRESS_THRESHOLD = 1.0
2019

21-
2220
class ElsSpindleInfo(BoxLayout):
2321
"""Displays spindle speed with direction icon and absolute position with zero button."""
2422
spindle_rpm = StringProperty("--")
@@ -99,6 +97,7 @@ def __init__(self, els_bar: ElsBar, **kwargs):
9997
x_axis_index=lambda *a: self.rebuild_axes(),
10098
)
10199

100+
self.app.formats.bind(max_row_height=lambda *_: self._update_row_heights())
102101
self.bind(height=self._update_row_heights)
103102
self._update_row_heights()
104103

@@ -108,7 +107,7 @@ def _update_row_heights(self, *args):
108107
return
109108

110109
available = self.height - self.els_bar.height
111-
row_height = min(available / num_rows, MAX_ROW_HEIGHT)
110+
row_height = min(available / num_rows, self.app.formats.max_row_height)
112111

113112
self.spindle_info.size_hint_y = None
114113
self.spindle_info.height = row_height

rcp/components/home/index_mode_layout.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from rcp.components.home.coordbar import CoordBar
22
from rcp.components.home.mode_layout import ModeLayout
33
from rcp.components.home.servobar import ServoBar
4+
from kivy.uix.widget import Widget
45

56

67
class 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)

rcp/components/home/jog_mode_layout.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from rcp.components.home.coordbar import CoordBar
22
from rcp.components.home.jogbar import JogBar
33
from rcp.components.home.mode_layout import ModeLayout
4+
from kivy.uix.widget import Widget
45

56

67
class JogModeLayout(ModeLayout):
@@ -10,8 +11,14 @@ def __init__(self, **kwargs):
1011
super().__init__(**kwargs)
1112
self.jog_bar = JogBar()
1213
self.build_axis_bars()
14+
self.spacer = Widget()
15+
self.add_widget(self.spacer)
1316
self.add_widget(self.jog_bar)
1417

18+
self.app.formats.bind(max_row_height=lambda *_: self._update_row_heights())
19+
self.bind(height=self._update_row_heights)
20+
self._update_row_heights()
21+
1522
def build_axis_bars(self):
1623
for axis_disp in self.app.axes:
1724
cb = CoordBar(axis=axis_disp)
@@ -22,3 +29,17 @@ def rebuild_axes(self):
2229
self.remove_widget(self.jog_bar)
2330
super().rebuild_axes()
2431
self.add_widget(self.jog_bar)
32+
33+
def _update_row_heights(self, *args):
34+
num_rows = len(self.axis_bars)
35+
if num_rows == 0:
36+
return
37+
38+
available = self.height - self.jog_bar.height
39+
row_height = min(available / num_rows, self.app.formats.max_row_height)
40+
41+
for bar in self.axis_bars:
42+
bar.size_hint_y = None
43+
bar.height = row_height
44+
45+
# spacer absorbs remaining space (size_hint_y defaults to 1)

rcp/components/screens/formats_screen.kv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787
value: root.formats.hide_mouse_cursor
8888
help_file: "hide_mouse_cursor.md"
8989
on_value: root.formats.hide_mouse_cursor = self.value
90+
NumberItem:
91+
name: "Max axis row height (px)"
92+
value: root.formats.max_row_height
93+
on_value: root.formats.max_row_height = self.value
9094

9195
TitleItem:
9296
name: "Sound Settings"

rcp/dispatchers/formats.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class FormatsDispatcher(SavingDispatcher):
5151

5252
hide_mouse_cursor = BooleanProperty(False)
5353

54+
max_row_height = NumericProperty(150)
55+
5456
def __init__(self, **kv):
5557
super().__init__(**kv)
5658
self.angle_speed_format = self.angle_speed_format.replace("RPM", "").replace(" ", "")

0 commit comments

Comments
 (0)