From dd027c058383be93435f6dc669fecb6169b3f921 Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Thu, 24 Feb 2022 16:00:51 -0300 Subject: [PATCH] Vertical mode (#480) --- ks_includes/KlippyGtk.py | 15 ++++- panels/base_panel.py | 123 +++++++++++++++++++++++++++++---------- panels/extrude.py | 24 +++++--- panels/fine_tune.py | 41 +++++++++---- panels/job_status.py | 8 ++- panels/main_menu.py | 27 +++++++-- panels/menu.py | 17 ++++-- panels/move.py | 38 ++++++++---- panels/printer_select.py | 8 ++- panels/temperature.py | 35 ++++++++--- panels/zcalibrate.py | 24 +++++--- screen.py | 4 ++ 12 files changed, 274 insertions(+), 90 deletions(-) diff --git a/ks_includes/KlippyGtk.py b/ks_includes/KlippyGtk.py index 210cb79c..c73260f2 100644 --- a/ks_includes/KlippyGtk.py +++ b/ks_includes/KlippyGtk.py @@ -11,7 +11,6 @@ klipperscreendir = pathlib.Path(__file__).parent.resolve().parent class KlippyGtk: labels = {} - font_ratio = [43, 29] keyboard_ratio = .22 width_ratio = 16 height_ratio = 9.375 @@ -21,6 +20,10 @@ class KlippyGtk: self.width = width self.height = height self.theme = theme + if self.screen.vertical_mode: + self.font_ratio = [33, 49] + else: + self.font_ratio = [43, 29] self.font_size = int(min( self.width / self.font_ratio[0], self.height / self.font_ratio[1] @@ -32,7 +35,12 @@ class KlippyGtk: self.header_size = int(round((self.width / self.width_ratio) / 1.33)) self.img_width = int(round(self.width / self.width_ratio)) self.img_height = int(round(self.height / self.height_ratio)) - self.action_bar_width = int(self.width * .1) + if self.screen.vertical_mode: + self.action_bar_width = int(self.width) + self.action_bar_height = int(self.height * .1) + else: + self.action_bar_width = int(self.width * .1) + self.action_bar_height = int(self.height) self.header_image_scale_width = 1.2 self.header_image_scale_height = 1.4 self.cursor = cursor @@ -49,6 +57,9 @@ class KlippyGtk: def get_action_bar_width(self): return self.action_bar_width + def get_action_bar_height(self): + return self.action_bar_height + def get_content_width(self): return self.width - self.action_bar_width diff --git a/panels/base_panel.py b/panels/base_panel.py index bd629002..cbcb11b6 100644 --- a/panels/base_panel.py +++ b/panels/base_panel.py @@ -29,9 +29,10 @@ class BasePanel(ScreenPanel): self.layout.set_size(self._screen.width, self._screen.height) action_bar_width = self._gtk.get_action_bar_width() if action_bar is True else 0 + action_bar_height = self._gtk.get_action_bar_height() if action_bar is True else 0 self.control_grid = self._gtk.HomogeneousGrid() - self.control_grid.set_size_request(action_bar_width - 2, self._screen.height) + self.control_grid.set_size_request(action_bar_width, action_bar_height) self.control_grid.get_style_context().add_class('action_bar') button_scale = self._gtk.get_header_image_scale() @@ -69,9 +70,14 @@ class BasePanel(ScreenPanel): for i in range(button_range): self.control['space%s' % i] = Gtk.Label("") - self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1) - - self.control_grid.attach(self.control['estop'], 0, 4, 1, 1) + if self._screen.vertical_mode: + self.control_grid.attach(self.control['space%s' % i], i, 0, 1, 1) + else: + self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1) + if self._screen.vertical_mode: + self.control_grid.attach(self.control['estop'], 4, 0, 1, 1) + else: + self.control_grid.attach(self.control['estop'], 0, 4, 1, 1) try: env = Environment(extensions=["jinja2.ext.i18n"]) @@ -82,7 +88,10 @@ class BasePanel(ScreenPanel): logging.debug("Error parsing jinja for title: %s" % title) self.titlelbl = Gtk.Label() - self.titlelbl.set_size_request(self._screen.width - action_bar_width, self.title_spacing) + if self._screen.vertical_mode: + self.titlelbl.set_size_request(self._screen.width, self.title_spacing) + else: + self.titlelbl.set_size_request(self._screen.width - action_bar_width, self.title_spacing) self.titlelbl.set_hexpand(True) self.titlelbl.set_halign(Gtk.Align.CENTER) self.titlelbl.set_valign(Gtk.Align.CENTER) @@ -90,11 +99,18 @@ class BasePanel(ScreenPanel): self.hmargin = 5 self.content = Gtk.VBox(spacing=0) - self.content.set_size_request(self._screen.width - action_bar_width - self.hmargin, - self._screen.height - self.title_spacing) + if self._screen.vertical_mode: + self.content.set_size_request(self._screen.width - self.hmargin * 2, + self._screen.height - self.title_spacing - action_bar_height) + else: + self.content.set_size_request(self._screen.width - action_bar_width - self.hmargin, + self._screen.height - self.title_spacing) if action_bar is True: - self.layout.put(self.control_grid, 0, 0) + if self._screen.vertical_mode: + self.layout.put(self.control_grid, 0, self._screen.height - action_bar_height) + else: + self.layout.put(self.control_grid, 0, 0) self.control['time_box'] = Gtk.Box() self.control['time_box'].set_halign(Gtk.Align.END) @@ -109,10 +125,16 @@ class BasePanel(ScreenPanel): self.control['temp_box'].set_vexpand(True) self.control['temp_box'].set_size_request(0, self.title_spacing) - self.layout.put(self.control['temp_box'], action_bar_width, 0) - self.layout.put(self.titlelbl, action_bar_width, 0) - self.layout.put(self.control['time_box'], action_bar_width, 0) - self.layout.put(self.content, action_bar_width + self.hmargin, self.title_spacing) + if self._screen.vertical_mode: + self.layout.put(self.control['temp_box'], 0, 0) + self.layout.put(self.titlelbl, 0, 0) + self.layout.put(self.control['time_box'], 0, 0) + self.layout.put(self.content, self.hmargin, self.title_spacing) + else: + self.layout.put(self.control['temp_box'], action_bar_width, 0) + self.layout.put(self.titlelbl, action_bar_width, 0) + self.layout.put(self.control['time_box'], action_bar_width, 0) + self.layout.put(self.content, action_bar_width + self.hmargin, self.title_spacing) def initialize(self, panel_name): # Create gtk items here @@ -200,13 +222,21 @@ class BasePanel(ScreenPanel): if show is True and self.buttons_showing['back'] is False: self.control_grid.remove(self.control_grid.get_child_at(0, 0)) self.control_grid.attach(self.control['back'], 0, 0, 1, 1) - self.control_grid.remove(self.control_grid.get_child_at(0, 1)) - self.control_grid.attach(self.control['home'], 0, 1, 1, 1) + if self._screen.vertical_mode: + self.control_grid.remove(self.control_grid.get_child_at(1, 0)) + self.control_grid.attach(self.control['home'], 1, 0, 1, 1) + else: + self.control_grid.remove(self.control_grid.get_child_at(0, 1)) + self.control_grid.attach(self.control['home'], 0, 1, 1, 1) self.buttons_showing['back'] = True elif show is False and self.buttons_showing['back'] is True: for i in range(0, 2): - self.control_grid.remove(self.control_grid.get_child_at(0, i)) - self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1) + if self._screen.vertical_mode: + self.control_grid.remove(self.control_grid.get_child_at(i, 0)) + self.control_grid.attach(self.control['space%s' % i], i, 0, 1, 1) + else: + self.control_grid.remove(self.control_grid.get_child_at(0, i)) + self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1) self.buttons_showing['back'] = False self.control_grid.show() @@ -216,26 +246,46 @@ class BasePanel(ScreenPanel): if show is True and self.buttons_showing['macros_shortcut'] is False: if len(self._config.get_printers()) > 1 and mod_row is True: - self.control_grid.insert_row(self.locations['macro_shortcut']) + if self._screen.vertical_mode: + self.control_grid.insert_column(self.locations['macro_shortcut']) + else: + self.control_grid.insert_row(self.locations['macro_shortcut']) else: - self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut'])) + if self._screen.vertical_mode: + self.control_grid.remove(self.control_grid.get_child_at(self.locations['macro_shortcut'], 0)) + else: + self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut'])) if 'space%s' % self.locations['macro_shortcut'] in self.control: self.control_grid.remove(self.control['space%s' % self.locations['macro_shortcut']]) - self.control_grid.attach(self.control['macro_shortcut'], 0, self.locations['macro_shortcut'], 1, 1) + if self._screen.vertical_mode: + self.control_grid.attach(self.control['macro_shortcut'], self.locations['macro_shortcut'], 0, 1, 1) + else: + self.control_grid.attach(self.control['macro_shortcut'], 0, self.locations['macro_shortcut'], 1, 1) self.buttons_showing['macros_shortcut'] = True elif show is not True and self.buttons_showing['macros_shortcut'] is True: if ('space%s' % self.locations['macro_shortcut']) not in self.control: self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("") if len(self._config.get_printers()) > 1 and mod_row is True: - self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut'])) + if self._screen.vertical_mode: + self.control_grid.remove(self.control_grid.get_child_at(self.locations['macro_shortcut'], 0)) + self.control_grid.remove_column(self.locations['macro_shortcut']) + else: + self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut'])) + self.control_grid.remove_row(self.locations['macro_shortcut']) self.control_grid.remove(self.control['macro_shortcut']) - self.control_grid.remove_row(self.locations['macro_shortcut']) else: - self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut'])) + if self._screen.vertical_mode: + self.control_grid.remove(self.control_grid.get_child_at(self.locations['macro_shortcut'], 0)) + else: + self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['macro_shortcut'])) if ('space%s' % self.locations['macro_shortcut']) not in self.control: self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("") - self.control_grid.attach(self.control['space%s' % self.locations['macro_shortcut']], - 0, self.locations['macro_shortcut'], 1, 1) + if self._screen.vertical_mode: + self.control_grid.attach(self.control['space%s' % self.locations['macro_shortcut']], + self.locations['macro_shortcut'], 0, 1, 1) + else: + self.control_grid.attach(self.control['space%s' % self.locations['macro_shortcut']], + 0, self.locations['macro_shortcut'], 1, 1) self.buttons_showing['macros_shortcut'] = False self._screen.show_all() @@ -245,14 +295,24 @@ class BasePanel(ScreenPanel): if show and self.buttons_showing['printer_select'] is False: logging.info("Turning on printer_select button") - self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['printer_select'])) - self.control_grid.attach(self.control['printer_select'], 0, self.locations['printer_select'], 1, 1) + if self._screen.vertical_mode: + self.control_grid.remove(self.control_grid.get_child_at(self.locations['printer_select'], 0)) + self.control_grid.attach(self.control['printer_select'], self.locations['printer_select'], 0, 1, 1) + else: + self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['printer_select'])) + self.control_grid.attach(self.control['printer_select'], 0, self.locations['printer_select'], 1, 1) self.buttons_showing['printer_select'] = True elif show is False and self.buttons_showing['printer_select']: logging.info("Turning off printer_select button") - self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['printer_select'])) - self.control_grid.attach(self.control['space%s' % self.locations['printer_select']], - 0, self.locations['printer_select'], 1, 1) + if self._screen.vertical_mode: + self.control_grid.remove(self.control_grid.get_child_at(self.locations['printer_select'], 0)) + self.control_grid.attach(self.control['space%s' % self.locations['printer_select']], + self.locations['printer_select'], 0, 1, 1) + else: + self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['printer_select'])) + self.control_grid.attach(self.control['space%s' % self.locations['printer_select']], + 0, self.locations['printer_select'], 1, 1) + self.buttons_showing['printer_select'] = False self._screen.show_all() @@ -269,7 +329,10 @@ class BasePanel(ScreenPanel): def show_back_buttons(self): self.control_grid.attach(self.control['back'], 0, 0, 1, 1) - self.control_grid.attach(self.control['home'], 0, 1, 1, 1) + if self._screen.vertical_mode: + self.control_grid.attach(self.control['home'], 1, 0, 1, 1) + else: + self.control_grid.attach(self.control['home'], 0, 1, 1, 1) def update_time(self): now = datetime.datetime.now() diff --git a/panels/extrude.py b/panels/extrude.py index d1112b91..6eec28ce 100644 --- a/panels/extrude.py +++ b/panels/extrude.py @@ -44,7 +44,7 @@ class ExtrudePanel(ScreenPanel): "panel": "temperature" }) - extgrid = Gtk.Grid() + extgrid = self._gtk.HomogeneousGrid() self.current_extruder = self._printer.get_stat("toolhead", "extruder") for i, extruder in enumerate(self._printer.get_tools()): self.labels[extruder] = self._gtk.ButtonImage("extruder-%s" % i, _("Tool") + " %s" % str(i)) @@ -57,10 +57,16 @@ class ExtrudePanel(ScreenPanel): extgrid.attach(self.labels['temperature'], i+1, 0, 1, 1) grid.attach(extgrid, 0, 0, 4, 1) - grid.attach(self.labels['extrude'], 0, 1, 1, 1) - grid.attach(self.labels['load'], 1, 1, 1, 1) - grid.attach(self.labels['unload'], 2, 1, 1, 1) - grid.attach(self.labels['retract'], 3, 1, 1, 1) + if self._screen.vertical_mode: + grid.attach(self.labels['extrude'], 0, 1, 2, 1) + grid.attach(self.labels['retract'], 2, 1, 2, 1) + grid.attach(self.labels['load'], 0, 2, 2, 1) + grid.attach(self.labels['unload'], 2, 2, 2, 1) + else: + grid.attach(self.labels['extrude'], 0, 1, 1, 1) + grid.attach(self.labels['load'], 1, 1, 1, 1) + grid.attach(self.labels['unload'], 2, 1, 1, 1) + grid.attach(self.labels['retract'], 3, 1, 1, 1) distgrid = Gtk.Grid() j = 0 @@ -112,8 +118,12 @@ class ExtrudePanel(ScreenPanel): speedbox.add(speedgrid) grid.set_column_homogeneous(True) - grid.attach(distbox, 0, 2, 2, 1) - grid.attach(speedbox, 2, 2, 2, 1) + if self._screen.vertical_mode: + grid.attach(distbox, 0, 3, 4, 1) + grid.attach(speedbox, 0, 4, 4, 1) + else: + grid.attach(distbox, 0, 2, 2, 1) + grid.attach(speedbox, 2, 2, 2, 1) self.content.add(grid) diff --git a/panels/fine_tune.py b/panels/fine_tune.py index 3d07b45b..d741019f 100644 --- a/panels/fine_tune.py +++ b/panels/fine_tune.py @@ -51,8 +51,12 @@ class FineTunePanel(ScreenPanel): self.labels['z-'].connect("clicked", self.change_babystepping, "-") grid.attach(self.labels['z+'], 0, 0, 1, 1) - grid.attach(self.labels['zoffset'], 0, 1, 1, 1) - grid.attach(self.labels['z-'], 0, 2, 1, 1) + if self._screen.vertical_mode: + grid.attach(self.labels['zoffset'], 2, 0, 1, 1) + grid.attach(self.labels['z-'], 1, 0, 1, 1) + else: + grid.attach(self.labels['zoffset'], 0, 1, 1, 1) + grid.attach(self.labels['z-'], 0, 2, 1, 1) self.labels['speed+'] = self._gtk.ButtonImage("speed+", _("Speed +"), "color3") self.labels['speed+'].connect("clicked", self.change_speed, "+") @@ -60,9 +64,14 @@ class FineTunePanel(ScreenPanel): self.labels['speedfactor'].get_style_context().add_class('temperature_entry') self.labels['speed-'] = self._gtk.ButtonImage("speed-", _("Speed -"), "color3") self.labels['speed-'].connect("clicked", self.change_speed, "-") - grid.attach(self.labels['speed+'], 1, 0, 1, 1) - grid.attach(self.labels['speedfactor'], 1, 1, 1, 1) - grid.attach(self.labels['speed-'], 1, 2, 1, 1) + if self._screen.vertical_mode: + grid.attach(self.labels['speed+'], 1, 2, 1, 1) + grid.attach(self.labels['speedfactor'], 2, 2, 1, 1) + grid.attach(self.labels['speed-'], 0, 2, 1, 1) + else: + grid.attach(self.labels['speed+'], 1, 0, 1, 1) + grid.attach(self.labels['speedfactor'], 1, 1, 1, 1) + grid.attach(self.labels['speed-'], 1, 2, 1, 1) self.labels['extrude+'] = self._gtk.ButtonImage("flow+", _("Extrusion +"), "color4") self.labels['extrude+'].connect("clicked", self.change_extrusion, "+") @@ -70,10 +79,14 @@ class FineTunePanel(ScreenPanel): self.labels['extrudefactor'].get_style_context().add_class('temperature_entry') self.labels['extrude-'] = self._gtk.ButtonImage("flow-", _("Extrusion -"), "color4") self.labels['extrude-'].connect("clicked", self.change_extrusion, "-") - grid.attach(self.labels['extrude+'], 2, 0, 1, 1) - grid.attach(self.labels['extrudefactor'], 2, 1, 1, 1) - grid.attach(self.labels['extrude-'], 2, 2, 1, 1) - + if self._screen.vertical_mode: + grid.attach(self.labels['extrude+'], 1, 3, 1, 1) + grid.attach(self.labels['extrudefactor'], 2, 3, 1, 1) + grid.attach(self.labels['extrude-'], 0, 3, 1, 1) + else: + grid.attach(self.labels['extrude+'], 2, 0, 1, 1) + grid.attach(self.labels['extrudefactor'], 2, 1, 1, 1) + grid.attach(self.labels['extrude-'], 2, 2, 1, 1) # babystepping grid bsgrid = Gtk.Grid() @@ -92,7 +105,10 @@ class FineTunePanel(ScreenPanel): ctx.add_class("distbutton_active") bsgrid.attach(self.labels[i], j, 0, 1, 1) j += 1 - grid.attach(bsgrid, 0, 3, 1, 1) + if self._screen.vertical_mode: + grid.attach(bsgrid, 0, 1, 3, 1) + else: + grid.attach(bsgrid, 0, 3, 1, 1) # Grid for percentage deltgrid = Gtk.Grid() @@ -114,7 +130,10 @@ class FineTunePanel(ScreenPanel): self.labels["1"].set_active(True) - grid.attach(deltgrid, 1, 3, 2, 1) + if self._screen.vertical_mode: + grid.attach(deltgrid, 0, 4, 3, 1) + else: + grid.attach(deltgrid, 1, 3, 2, 1) # self.panel = grid self.content.add(grid) diff --git a/panels/job_status.py b/panels/job_status.py index 97a02da7..598a999f 100644 --- a/panels/job_status.py +++ b/panels/job_status.py @@ -190,8 +190,12 @@ class JobStatusPanel(ScreenPanel): self.labels['i2_box'].get_style_context().add_class("printing-info-box") self.labels['i2_box'].set_valign(Gtk.Align.CENTER) self.labels['info_grid'] = self._gtk.HomogeneousGrid() - self.labels['info_grid'].attach(self.labels['i1_box'], 0, 0, 2, 1) - self.labels['info_grid'].attach(self.labels['i2_box'], 2, 0, 3, 1) + if self._screen.vertical_mode: + self.labels['info_grid'].attach(self.labels['i1_box'], 0, 0, 1, 1) + self.labels['info_grid'].attach(self.labels['i2_box'], 0, 1, 1, 1) + else: + self.labels['info_grid'].attach(self.labels['i1_box'], 0, 0, 2, 1) + self.labels['info_grid'].attach(self.labels['i2_box'], 2, 0, 3, 1) grid.attach(overlay, 0, 0, 1, 1) grid.attach(fi_box, 1, 0, 3, 1) diff --git a/panels/main_menu.py b/panels/main_menu.py index fac234d5..217e8aa8 100644 --- a/panels/main_menu.py +++ b/panels/main_menu.py @@ -39,7 +39,10 @@ class MainPanel(MenuPanel): leftpanel = self.create_left_panel() grid.attach(leftpanel, 0, 0, 1, 1) self.labels['menu'] = self.arrangeMenuItems(items, 2, True) - grid.attach(self.labels['menu'], 1, 0, 1, 1) + if self._screen.vertical_mode: + grid.attach(self.labels['menu'], 0, 1, 1, 1) + else: + grid.attach(self.labels['menu'], 1, 0, 1, 1) self.grid = grid @@ -238,7 +241,11 @@ class MainPanel(MenuPanel): for d in self._printer.get_temp_store_devices(): if self.add_device(d): i += 1 - graph_height = max(0, self._screen.height - (i * 5 * self._gtk.get_font_size())) + if self._screen.vertical_mode: + aux = 1.38 + else: + aux = 1 + graph_height = max(0, self._screen.height / aux - (i * 5 * self._gtk.get_font_size())) self.labels['da'].set_size_request(0, graph_height) return box @@ -261,8 +268,12 @@ class MainPanel(MenuPanel): self.devices[self.active_heater]['name'].get_style_context().remove_class("active_device") self.active_heater = None - self.grid.remove_column(1) - self.grid.attach(self.labels['menu'], 1, 0, 1, 1) + if self._screen.vertical_mode: + self.grid.remove_row(1) + self.grid.attach(self.labels['menu'], 0, 1, 1, 1) + else: + self.grid.remove_column(1) + self.grid.attach(self.labels['menu'], 1, 0, 1, 1) self.grid.show_all() def on_popover_clicked(self, widget, device): @@ -316,8 +327,12 @@ class MainPanel(MenuPanel): self.labels["keypad"] = Keypad(self._screen, self.change_target_temp, self.hide_numpad) self.labels["keypad"].clear() - self.grid.remove_column(1) - self.grid.attach(self.labels["keypad"], 1, 0, 1, 1) + if self._screen.vertical_mode: + self.grid.remove_row(1) + self.grid.attach(self.labels["keypad"], 0, 1, 1, 1) + else: + self.grid.remove_column(1) + self.grid.attach(self.labels["keypad"], 1, 0, 1, 1) self.grid.show_all() self.labels['popover'].popdown() diff --git a/panels/menu.py b/panels/menu.py index d100d945..04f70bd6 100644 --- a/panels/menu.py +++ b/panels/menu.py @@ -53,14 +53,21 @@ class MenuPanel(ScreenPanel): # Arrange 3 x 2 columns = 3 - col = i % columns - row = int(i/columns) - width = 1 + if self._screen.vertical_mode: + row = i % columns + col = int(i/columns) + else: + col = i % columns + row = int(i/columns) + width = height = 1 if expandLast is True and i+1 == length and length % 2 == 1: - width = 2 + if self._screen.vertical_mode: + height = 2 + else: + width = 2 - self.grid.attach(self.labels[key], col, row, width, 1) + self.grid.attach(self.labels[key], col, row, width, height) i += 1 return self.grid diff --git a/panels/move.py b/panels/move.py index 555107da..41191c69 100644 --- a/panels/move.py +++ b/panels/move.py @@ -52,16 +52,31 @@ class MovePanel(ScreenPanel): self.labels['quad_gantry_level'] = self._gtk.ButtonImage("z-tilt", _("Quad Gantry Level"), "color4") self.labels['quad_gantry_level'].connect("clicked", self.quad_gantry_level) - if self._screen.lang_ltr: - grid.attach(self.labels['x+'], 2, 1, 1, 1) - grid.attach(self.labels['x-'], 0, 1, 1, 1) + if self._screen.vertical_mode: + if self._screen.lang_ltr: + grid.attach(self.labels['x+'], 2, 1, 1, 1) + grid.attach(self.labels['x-'], 0, 1, 1, 1) + grid.attach(self.labels['z+'], 2, 2, 1, 1) + grid.attach(self.labels['z-'], 0, 2, 1, 1) + else: + grid.attach(self.labels['x+'], 0, 1, 1, 1) + grid.attach(self.labels['x-'], 2, 1, 1, 1) + grid.attach(self.labels['z+'], 0, 2, 1, 1) + grid.attach(self.labels['z-'], 2, 2, 1, 1) + grid.attach(self.labels['y+'], 1, 0, 1, 1) + grid.attach(self.labels['y-'], 1, 1, 1, 1) + else: - grid.attach(self.labels['x+'], 0, 1, 1, 1) - grid.attach(self.labels['x-'], 2, 1, 1, 1) - grid.attach(self.labels['y+'], 1, 0, 1, 1) - grid.attach(self.labels['y-'], 1, 1, 1, 1) - grid.attach(self.labels['z+'], 3, 0, 1, 1) - grid.attach(self.labels['z-'], 3, 1, 1, 1) + if self._screen.lang_ltr: + grid.attach(self.labels['x+'], 2, 1, 1, 1) + grid.attach(self.labels['x-'], 0, 1, 1, 1) + else: + grid.attach(self.labels['x+'], 0, 1, 1, 1) + grid.attach(self.labels['x-'], 2, 1, 1, 1) + grid.attach(self.labels['y+'], 1, 0, 1, 1) + grid.attach(self.labels['y-'], 1, 1, 1, 1) + grid.attach(self.labels['z+'], 3, 0, 1, 1) + grid.attach(self.labels['z-'], 3, 1, 1, 1) grid.attach(self.labels['home'], 0, 0, 1, 1) @@ -107,7 +122,10 @@ class MovePanel(ScreenPanel): box.pack_start(self.labels['move_dist'], True, True, 0) box.pack_start(distgrid, True, True, 0) - grid.attach(box, 0, 2, 4, 1) + if self._screen.vertical_mode: + grid.attach(box, 0, 3, 3, 1) + else: + grid.attach(box, 0, 2, 4, 1) self.content.add(grid) diff --git a/panels/printer_select.py b/panels/printer_select.py index 6bb950c6..a3889e2d 100644 --- a/panels/printer_select.py +++ b/panels/printer_select.py @@ -38,6 +38,10 @@ class PrinterSelect(ScreenPanel): name = list(printer)[0] self.labels[name] = self._gtk.ButtonImage("extruder", name, "color%s" % (1 + i % 4)) self.labels[name].connect("clicked", self._screen.connect_printer_widget, name) - col = i % columns - row = int(i/columns) + if self._screen.vertical_mode: + row = i % columns + col = int(i/columns) + else: + col = i % columns + row = int(i/columns) grid.attach(self.labels[name], col, row, 1, 1) diff --git a/panels/temperature.py b/panels/temperature.py index 681c7dff..c26d5fde 100644 --- a/panels/temperature.py +++ b/panels/temperature.py @@ -39,7 +39,10 @@ class TemperaturePanel(ScreenPanel): self.select_heater(None, h) else: self.show_preheat = False - self.grid.attach(self.create_right_panel(), 1, 0, 1, 1) + if self._screen.vertical_mode: + self.grid.attach(self.create_right_panel(), 0, 1, 1, 1) + else: + self.grid.attach(self.create_right_panel(), 1, 0, 1, 1) self.content.add(self.grid) self.layout.show_all() @@ -64,8 +67,12 @@ class TemperaturePanel(ScreenPanel): def switch_preheat_adjust(self, widget): self.show_preheat ^= True - self.grid.remove_column(1) - self.grid.attach(self.create_right_panel(), 1, 0, 1, 1) + if self._screen.vertical_mode: + self.grid.remove_row(1) + self.grid.attach(self.create_right_panel(), 0, 1, 1, 1) + else: + self.grid.remove_column(1) + self.grid.attach(self.create_right_panel(), 1, 0, 1, 1) self.grid.show_all() def preheat(self): @@ -430,7 +437,11 @@ class TemperaturePanel(ScreenPanel): for d in self._printer.get_temp_store_devices(): if self.add_device(d): i += 1 - graph_height = max(0, self._screen.height - (i * 5 * self._gtk.get_font_size())) + if self._screen.vertical_mode: + aux = 1.38 + else: + aux = 1 + graph_height = max(0, self._screen.height / aux - (i * 5 * self._gtk.get_font_size())) self.labels['da'].set_size_request(0, graph_height) return box @@ -454,8 +465,12 @@ class TemperaturePanel(ScreenPanel): self.devices[self.active_heater]['name'].get_style_context().remove_class("button_active") self.active_heater = None - self.grid.remove_column(1) - self.grid.attach(self.create_right_panel(), 1, 0, 1, 1) + if self._screen.vertical_mode: + self.grid.remove_row(1) + self.grid.attach(self.create_right_panel(), 0, 1, 1, 1) + else: + self.grid.remove_column(1) + self.grid.attach(self.create_right_panel(), 1, 0, 1, 1) self.grid.show_all() def on_popover_clicked(self, widget, device): @@ -508,8 +523,12 @@ class TemperaturePanel(ScreenPanel): self.labels["keypad"] = Keypad(self._screen, self.change_target_temp, self.hide_numpad) self.labels["keypad"].clear() - self.grid.remove_column(1) - self.grid.attach(self.labels["keypad"], 1, 0, 1, 1) + if self._screen.vertical_mode: + self.grid.remove_row(1) + self.grid.attach(self.labels["keypad"], 0, 1, 1, 1) + else: + self.grid.remove_column(1) + self.grid.attach(self.labels["keypad"], 1, 0, 1, 1) self.grid.show_all() self.labels['popover'].popdown() diff --git a/panels/zcalibrate.py b/panels/zcalibrate.py index 794b5f5c..31f76d24 100644 --- a/panels/zcalibrate.py +++ b/panels/zcalibrate.py @@ -76,13 +76,23 @@ class ZCalibratePanel(ScreenPanel): distances.pack_start(distgrid, True, True, 0) grid.set_column_homogeneous(True) - grid.attach(self.widgets['zpos'], 0, 0, 1, 1) - grid.attach(self.widgets['start'], 1, 0, 1, 1) - grid.attach(pos, 1, 1, 1, 1) - grid.attach(self.widgets['zneg'], 0, 1, 1, 1) - grid.attach(self.widgets['complete'], 2, 0, 1, 1) - grid.attach(distances, 0, 2, 3, 1) - grid.attach(self.widgets['cancel'], 2, 1, 1, 1) + if self._screen.vertical_mode: + grid.attach(self.widgets['zpos'], 0, 1, 1, 1) + grid.attach(self.widgets['zneg'], 0, 2, 1, 1) + grid.attach(self.widgets['start'], 0, 0, 1, 1) + grid.attach(pos, 1, 0, 1, 1) + grid.attach(self.widgets['complete'], 1, 1, 1, 1) + grid.attach(self.widgets['cancel'], 1, 2, 1, 1) + grid.attach(distances, 0, 3, 2, 1) + else: + grid.attach(self.widgets['zpos'], 0, 0, 1, 1) + grid.attach(self.widgets['zneg'], 0, 1, 1, 1) + grid.attach(self.widgets['start'], 1, 0, 1, 1) + grid.attach(pos, 1, 1, 1, 1) + grid.attach(self.widgets['complete'], 2, 0, 1, 1) + grid.attach(self.widgets['cancel'], 2, 1, 1, 1) + grid.attach(distances, 0, 2, 3, 1) + self.buttons_not_calibrating() self.content.add(grid) diff --git a/screen.py b/screen.py index 3fa9dfaf..f938f4ca 100644 --- a/screen.py +++ b/screen.py @@ -120,6 +120,10 @@ class KlipperScreen(Gtk.Window): self.height = self._config.get_main_config().getint("height", monitor.get_geometry().height) self.set_default_size(self.width, self.height) self.set_resizable(False) + if self.width < self.height: + self.vertical_mode = True + else: + self.vertical_mode = False logging.info("Screen resolution: %sx%s" % (self.width, self.height)) self.theme = self._config.get_main_config_option('theme') self.show_cursor = self._config.get_main_config().getboolean("show_cursor", fallback=False)