diff --git a/ks_includes/KlippyGtk.py b/ks_includes/KlippyGtk.py index 5487aa95..89373a33 100644 --- a/ks_includes/KlippyGtk.py +++ b/ks_includes/KlippyGtk.py @@ -38,6 +38,7 @@ class KlippyGtk: self.font_size_type = screen._config.get_main_config().get("font_size", "medium") self.width = screen.width self.height = screen.height + self.ultra_tall = (self.height / self.width) >= 3 self.font_ratio = [33, 49] if self.screen.vertical_mode else [43, 29] self.font_size = min(self.width / self.font_ratio[0], self.height / self.font_ratio[1]) self.img_scale = self.font_size * 2 @@ -76,7 +77,7 @@ class KlippyGtk: self.content_height = self.height - self.titlebar_height self.keyboard_height = self.content_height * 0.5 - if (self.height / self.width) >= 3: # Ultra-tall + if self.ultra_tall: self.keyboard_height = self.keyboard_height * 0.5 self.color_list = {} # This is set by screen.py init_style() diff --git a/panels/main_menu.py b/panels/main_menu.py index 77955697..402ca092 100644 --- a/panels/main_menu.py +++ b/panels/main_menu.py @@ -37,7 +37,7 @@ class Panel(MenuPanel): self.main_menu.attach(scroll, 1, 0, 1, 1) self.content.add(self.main_menu) - def update_graph_visibility(self): + def update_graph_visibility(self, force_hide=False): if self.left_panel is None: logging.info("No left panel") return @@ -52,7 +52,7 @@ class Panel(MenuPanel): self.devices[device]['name'].get_style_context().add_class("graph_label") else: self.devices[device]['name'].get_style_context().remove_class("graph_label") - if count > 0: + if count > 0 and not force_hide: if self.labels['da'] not in self.left_panel: self.left_panel.add(self.labels['da']) self.labels['da'].queue_draw() @@ -243,11 +243,17 @@ class Panel(MenuPanel): self.active_heater = None if self._screen.vertical_mode: - self.main_menu.remove_row(1) - self.main_menu.attach(self.labels['menu'], 0, 1, 1, 1) + if not self._gtk.ultra_tall: + self.update_graph_visibility(force_hide=False) + top = self.main_menu.get_child_at(0, 0) + bottom = self.main_menu.get_child_at(0, 2) + self.main_menu.remove(top) + self.main_menu.remove(bottom) + self.main_menu.attach(top, 0, 0, 1, 3) + self.main_menu.attach(self.labels["menu"], 0, 3, 1, 2) else: self.main_menu.remove_column(1) - self.main_menu.attach(self.labels['menu'], 1, 0, 1, 1) + self.main_menu.attach(self.labels["menu"], 1, 0, 1, 1) self.main_menu.show_all() self.numpad_visible = False self._screen.base_panel.set_control_sensitive(False, control='back') @@ -279,8 +285,14 @@ class Panel(MenuPanel): self.labels["keypad"].clear() if self._screen.vertical_mode: - self.main_menu.remove_row(1) - self.main_menu.attach(self.labels["keypad"], 0, 1, 1, 1) + if not self._gtk.ultra_tall: + self.update_graph_visibility(force_hide=True) + top = self.main_menu.get_child_at(0, 0) + bottom = self.main_menu.get_child_at(0, 3) + self.main_menu.remove(top) + self.main_menu.remove(bottom) + self.main_menu.attach(top, 0, 0, 1, 2) + self.main_menu.attach(self.labels["keypad"], 0, 2, 1, 2) else: self.main_menu.remove_column(1) self.main_menu.attach(self.labels["keypad"], 1, 0, 1, 1) diff --git a/panels/temperature.py b/panels/temperature.py index ff732d31..b2a27b99 100644 --- a/panels/temperature.py +++ b/panels/temperature.py @@ -188,7 +188,7 @@ class Panel(ScreenPanel): self._screen.show_popup_message(_("Unknown Heater") + " " + heater) logging.info(f"Setting {heater} to {target}") - def update_graph_visibility(self): + def update_graph_visibility(self, force_hide=False): count = 0 for device in self.devices: visible = self._config.get_config().getboolean( @@ -205,7 +205,7 @@ class Panel(ScreenPanel): self.devices[device]["name_button"].get_style_context().remove_class( "graph_label" ) - if count > 0: + if count > 0 and not force_hide: if self.labels["da"] not in self.left_panel: self.left_panel.add(self.labels["da"]) self.labels["da"].queue_draw() @@ -553,8 +553,14 @@ class Panel(ScreenPanel): ) if self._screen.vertical_mode: - self.grid.remove_row(1) - self.grid.attach(self.create_right_panel(), 0, 1, 1, 1) + if not self._gtk.ultra_tall: + self.update_graph_visibility(force_hide=False) + top = self.grid.get_child_at(0, 0) + bottom = self.grid.get_child_at(0, 2) + self.grid.remove(top) + self.grid.remove(bottom) + self.grid.attach(top, 0, 0, 1, 3) + self.grid.attach(self.create_right_panel(), 0, 3, 1, 2) else: self.grid.remove_column(1) self.grid.attach(self.create_right_panel(), 1, 0, 1, 1) @@ -616,8 +622,14 @@ class Panel(ScreenPanel): self.labels["keypad"].clear() if self._screen.vertical_mode: - self.grid.remove_row(1) - self.grid.attach(self.labels["keypad"], 0, 1, 1, 1) + if not self._gtk.ultra_tall: + self.update_graph_visibility(force_hide=True) + top = self.grid.get_child_at(0, 0) + bottom = self.grid.get_child_at(0, 3) + self.grid.remove(top) + self.grid.remove(bottom) + self.grid.attach(top, 0, 0, 1, 2) + self.grid.attach(self.labels["keypad"], 0, 2, 1, 2) else: self.grid.remove_column(1) self.grid.attach(self.labels["keypad"], 1, 0, 1, 1)