Vertical mode (#480)

This commit is contained in:
Alfredo Monclus 2022-02-24 16:00:51 -03:00 committed by GitHub
parent 3c1110d730
commit dd027c0583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 274 additions and 90 deletions

View File

@ -11,7 +11,6 @@ klipperscreendir = pathlib.Path(__file__).parent.resolve().parent
class KlippyGtk: class KlippyGtk:
labels = {} labels = {}
font_ratio = [43, 29]
keyboard_ratio = .22 keyboard_ratio = .22
width_ratio = 16 width_ratio = 16
height_ratio = 9.375 height_ratio = 9.375
@ -21,6 +20,10 @@ class KlippyGtk:
self.width = width self.width = width
self.height = height self.height = height
self.theme = theme 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.font_size = int(min(
self.width / self.font_ratio[0], self.width / self.font_ratio[0],
self.height / self.font_ratio[1] 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.header_size = int(round((self.width / self.width_ratio) / 1.33))
self.img_width = int(round(self.width / self.width_ratio)) self.img_width = int(round(self.width / self.width_ratio))
self.img_height = int(round(self.height / self.height_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_width = 1.2
self.header_image_scale_height = 1.4 self.header_image_scale_height = 1.4
self.cursor = cursor self.cursor = cursor
@ -49,6 +57,9 @@ class KlippyGtk:
def get_action_bar_width(self): def get_action_bar_width(self):
return self.action_bar_width return self.action_bar_width
def get_action_bar_height(self):
return self.action_bar_height
def get_content_width(self): def get_content_width(self):
return self.width - self.action_bar_width return self.width - self.action_bar_width

View File

@ -29,9 +29,10 @@ class BasePanel(ScreenPanel):
self.layout.set_size(self._screen.width, self._screen.height) 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_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 = 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') self.control_grid.get_style_context().add_class('action_bar')
button_scale = self._gtk.get_header_image_scale() button_scale = self._gtk.get_header_image_scale()
@ -69,9 +70,14 @@ class BasePanel(ScreenPanel):
for i in range(button_range): for i in range(button_range):
self.control['space%s' % i] = Gtk.Label("") self.control['space%s' % i] = Gtk.Label("")
self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1) if self._screen.vertical_mode:
self.control_grid.attach(self.control['space%s' % i], i, 0, 1, 1)
self.control_grid.attach(self.control['estop'], 0, 4, 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: try:
env = Environment(extensions=["jinja2.ext.i18n"]) env = Environment(extensions=["jinja2.ext.i18n"])
@ -82,7 +88,10 @@ class BasePanel(ScreenPanel):
logging.debug("Error parsing jinja for title: %s" % title) logging.debug("Error parsing jinja for title: %s" % title)
self.titlelbl = Gtk.Label() 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_hexpand(True)
self.titlelbl.set_halign(Gtk.Align.CENTER) self.titlelbl.set_halign(Gtk.Align.CENTER)
self.titlelbl.set_valign(Gtk.Align.CENTER) self.titlelbl.set_valign(Gtk.Align.CENTER)
@ -90,11 +99,18 @@ class BasePanel(ScreenPanel):
self.hmargin = 5 self.hmargin = 5
self.content = Gtk.VBox(spacing=0) self.content = Gtk.VBox(spacing=0)
self.content.set_size_request(self._screen.width - action_bar_width - self.hmargin, if self._screen.vertical_mode:
self._screen.height - self.title_spacing) 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: 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'] = Gtk.Box()
self.control['time_box'].set_halign(Gtk.Align.END) 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_vexpand(True)
self.control['temp_box'].set_size_request(0, self.title_spacing) self.control['temp_box'].set_size_request(0, self.title_spacing)
self.layout.put(self.control['temp_box'], action_bar_width, 0) if self._screen.vertical_mode:
self.layout.put(self.titlelbl, action_bar_width, 0) self.layout.put(self.control['temp_box'], 0, 0)
self.layout.put(self.control['time_box'], action_bar_width, 0) self.layout.put(self.titlelbl, 0, 0)
self.layout.put(self.content, action_bar_width + self.hmargin, self.title_spacing) 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): def initialize(self, panel_name):
# Create gtk items here # Create gtk items here
@ -200,13 +222,21 @@ class BasePanel(ScreenPanel):
if show is True and self.buttons_showing['back'] is False: 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.remove(self.control_grid.get_child_at(0, 0))
self.control_grid.attach(self.control['back'], 0, 0, 1, 1) self.control_grid.attach(self.control['back'], 0, 0, 1, 1)
self.control_grid.remove(self.control_grid.get_child_at(0, 1)) if self._screen.vertical_mode:
self.control_grid.attach(self.control['home'], 0, 1, 1, 1) 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 self.buttons_showing['back'] = True
elif show is False and self.buttons_showing['back'] is True: elif show is False and self.buttons_showing['back'] is True:
for i in range(0, 2): for i in range(0, 2):
self.control_grid.remove(self.control_grid.get_child_at(0, i)) if self._screen.vertical_mode:
self.control_grid.attach(self.control['space%s' % i], 0, i, 1, 1) 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.buttons_showing['back'] = False
self.control_grid.show() self.control_grid.show()
@ -216,26 +246,46 @@ class BasePanel(ScreenPanel):
if show is True and self.buttons_showing['macros_shortcut'] is False: if show is True and self.buttons_showing['macros_shortcut'] is False:
if len(self._config.get_printers()) > 1 and mod_row is True: 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: 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: 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.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 self.buttons_showing['macros_shortcut'] = True
elif show is not True and self.buttons_showing['macros_shortcut'] is 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: if ('space%s' % self.locations['macro_shortcut']) not in self.control:
self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("") self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("")
if len(self._config.get_printers()) > 1 and mod_row is True: 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(self.control['macro_shortcut'])
self.control_grid.remove_row(self.locations['macro_shortcut'])
else: 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: if ('space%s' % self.locations['macro_shortcut']) not in self.control:
self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("") self.control['space%s' % self.locations['macro_shortcut']] = Gtk.Label("")
self.control_grid.attach(self.control['space%s' % self.locations['macro_shortcut']], if self._screen.vertical_mode:
0, self.locations['macro_shortcut'], 1, 1) 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.buttons_showing['macros_shortcut'] = False
self._screen.show_all() self._screen.show_all()
@ -245,14 +295,24 @@ class BasePanel(ScreenPanel):
if show and self.buttons_showing['printer_select'] is False: if show and self.buttons_showing['printer_select'] is False:
logging.info("Turning on printer_select button") logging.info("Turning on printer_select button")
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['printer_select'])) if self._screen.vertical_mode:
self.control_grid.attach(self.control['printer_select'], 0, self.locations['printer_select'], 1, 1) 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 self.buttons_showing['printer_select'] = True
elif show is False and self.buttons_showing['printer_select']: elif show is False and self.buttons_showing['printer_select']:
logging.info("Turning off printer_select button") logging.info("Turning off printer_select button")
self.control_grid.remove(self.control_grid.get_child_at(0, self.locations['printer_select'])) if self._screen.vertical_mode:
self.control_grid.attach(self.control['space%s' % self.locations['printer_select']], self.control_grid.remove(self.control_grid.get_child_at(self.locations['printer_select'], 0))
0, self.locations['printer_select'], 1, 1) 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.buttons_showing['printer_select'] = False
self._screen.show_all() self._screen.show_all()
@ -269,7 +329,10 @@ class BasePanel(ScreenPanel):
def show_back_buttons(self): def show_back_buttons(self):
self.control_grid.attach(self.control['back'], 0, 0, 1, 1) 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): def update_time(self):
now = datetime.datetime.now() now = datetime.datetime.now()

View File

@ -44,7 +44,7 @@ class ExtrudePanel(ScreenPanel):
"panel": "temperature" "panel": "temperature"
}) })
extgrid = Gtk.Grid() extgrid = self._gtk.HomogeneousGrid()
self.current_extruder = self._printer.get_stat("toolhead", "extruder") self.current_extruder = self._printer.get_stat("toolhead", "extruder")
for i, extruder in enumerate(self._printer.get_tools()): for i, extruder in enumerate(self._printer.get_tools()):
self.labels[extruder] = self._gtk.ButtonImage("extruder-%s" % i, _("Tool") + " %s" % str(i)) 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) extgrid.attach(self.labels['temperature'], i+1, 0, 1, 1)
grid.attach(extgrid, 0, 0, 4, 1) grid.attach(extgrid, 0, 0, 4, 1)
grid.attach(self.labels['extrude'], 0, 1, 1, 1) if self._screen.vertical_mode:
grid.attach(self.labels['load'], 1, 1, 1, 1) grid.attach(self.labels['extrude'], 0, 1, 2, 1)
grid.attach(self.labels['unload'], 2, 1, 1, 1) grid.attach(self.labels['retract'], 2, 1, 2, 1)
grid.attach(self.labels['retract'], 3, 1, 1, 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() distgrid = Gtk.Grid()
j = 0 j = 0
@ -112,8 +118,12 @@ class ExtrudePanel(ScreenPanel):
speedbox.add(speedgrid) speedbox.add(speedgrid)
grid.set_column_homogeneous(True) grid.set_column_homogeneous(True)
grid.attach(distbox, 0, 2, 2, 1) if self._screen.vertical_mode:
grid.attach(speedbox, 2, 2, 2, 1) 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) self.content.add(grid)

View File

@ -51,8 +51,12 @@ class FineTunePanel(ScreenPanel):
self.labels['z-'].connect("clicked", self.change_babystepping, "-") self.labels['z-'].connect("clicked", self.change_babystepping, "-")
grid.attach(self.labels['z+'], 0, 0, 1, 1) grid.attach(self.labels['z+'], 0, 0, 1, 1)
grid.attach(self.labels['zoffset'], 0, 1, 1, 1) if self._screen.vertical_mode:
grid.attach(self.labels['z-'], 0, 2, 1, 1) 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+'] = self._gtk.ButtonImage("speed+", _("Speed +"), "color3")
self.labels['speed+'].connect("clicked", self.change_speed, "+") 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['speedfactor'].get_style_context().add_class('temperature_entry')
self.labels['speed-'] = self._gtk.ButtonImage("speed-", _("Speed -"), "color3") self.labels['speed-'] = self._gtk.ButtonImage("speed-", _("Speed -"), "color3")
self.labels['speed-'].connect("clicked", self.change_speed, "-") self.labels['speed-'].connect("clicked", self.change_speed, "-")
grid.attach(self.labels['speed+'], 1, 0, 1, 1) if self._screen.vertical_mode:
grid.attach(self.labels['speedfactor'], 1, 1, 1, 1) grid.attach(self.labels['speed+'], 1, 2, 1, 1)
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+'] = self._gtk.ButtonImage("flow+", _("Extrusion +"), "color4")
self.labels['extrude+'].connect("clicked", self.change_extrusion, "+") 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['extrudefactor'].get_style_context().add_class('temperature_entry')
self.labels['extrude-'] = self._gtk.ButtonImage("flow-", _("Extrusion -"), "color4") self.labels['extrude-'] = self._gtk.ButtonImage("flow-", _("Extrusion -"), "color4")
self.labels['extrude-'].connect("clicked", self.change_extrusion, "-") self.labels['extrude-'].connect("clicked", self.change_extrusion, "-")
grid.attach(self.labels['extrude+'], 2, 0, 1, 1) if self._screen.vertical_mode:
grid.attach(self.labels['extrudefactor'], 2, 1, 1, 1) grid.attach(self.labels['extrude+'], 1, 3, 1, 1)
grid.attach(self.labels['extrude-'], 2, 2, 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 # babystepping grid
bsgrid = Gtk.Grid() bsgrid = Gtk.Grid()
@ -92,7 +105,10 @@ class FineTunePanel(ScreenPanel):
ctx.add_class("distbutton_active") ctx.add_class("distbutton_active")
bsgrid.attach(self.labels[i], j, 0, 1, 1) bsgrid.attach(self.labels[i], j, 0, 1, 1)
j += 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 # Grid for percentage
deltgrid = Gtk.Grid() deltgrid = Gtk.Grid()
@ -114,7 +130,10 @@ class FineTunePanel(ScreenPanel):
self.labels["1"].set_active(True) 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.panel = grid
self.content.add(grid) self.content.add(grid)

View File

@ -190,8 +190,12 @@ class JobStatusPanel(ScreenPanel):
self.labels['i2_box'].get_style_context().add_class("printing-info-box") self.labels['i2_box'].get_style_context().add_class("printing-info-box")
self.labels['i2_box'].set_valign(Gtk.Align.CENTER) self.labels['i2_box'].set_valign(Gtk.Align.CENTER)
self.labels['info_grid'] = self._gtk.HomogeneousGrid() self.labels['info_grid'] = self._gtk.HomogeneousGrid()
self.labels['info_grid'].attach(self.labels['i1_box'], 0, 0, 2, 1) if self._screen.vertical_mode:
self.labels['info_grid'].attach(self.labels['i2_box'], 2, 0, 3, 1) 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(overlay, 0, 0, 1, 1)
grid.attach(fi_box, 1, 0, 3, 1) grid.attach(fi_box, 1, 0, 3, 1)

View File

@ -39,7 +39,10 @@ class MainPanel(MenuPanel):
leftpanel = self.create_left_panel() leftpanel = self.create_left_panel()
grid.attach(leftpanel, 0, 0, 1, 1) grid.attach(leftpanel, 0, 0, 1, 1)
self.labels['menu'] = self.arrangeMenuItems(items, 2, True) 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 self.grid = grid
@ -238,7 +241,11 @@ class MainPanel(MenuPanel):
for d in self._printer.get_temp_store_devices(): for d in self._printer.get_temp_store_devices():
if self.add_device(d): if self.add_device(d):
i += 1 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) self.labels['da'].set_size_request(0, graph_height)
return box return box
@ -261,8 +268,12 @@ class MainPanel(MenuPanel):
self.devices[self.active_heater]['name'].get_style_context().remove_class("active_device") self.devices[self.active_heater]['name'].get_style_context().remove_class("active_device")
self.active_heater = None self.active_heater = None
self.grid.remove_column(1) if self._screen.vertical_mode:
self.grid.attach(self.labels['menu'], 1, 0, 1, 1) 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() self.grid.show_all()
def on_popover_clicked(self, widget, device): 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"] = Keypad(self._screen, self.change_target_temp, self.hide_numpad)
self.labels["keypad"].clear() self.labels["keypad"].clear()
self.grid.remove_column(1) if self._screen.vertical_mode:
self.grid.attach(self.labels["keypad"], 1, 0, 1, 1) 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.grid.show_all()
self.labels['popover'].popdown() self.labels['popover'].popdown()

View File

@ -53,14 +53,21 @@ class MenuPanel(ScreenPanel):
# Arrange 3 x 2 # Arrange 3 x 2
columns = 3 columns = 3
col = i % columns if self._screen.vertical_mode:
row = int(i/columns) row = i % columns
width = 1 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: 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 i += 1
return self.grid return self.grid

View File

@ -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'] = self._gtk.ButtonImage("z-tilt", _("Quad Gantry Level"), "color4")
self.labels['quad_gantry_level'].connect("clicked", self.quad_gantry_level) self.labels['quad_gantry_level'].connect("clicked", self.quad_gantry_level)
if self._screen.lang_ltr: if self._screen.vertical_mode:
grid.attach(self.labels['x+'], 2, 1, 1, 1) if self._screen.lang_ltr:
grid.attach(self.labels['x-'], 0, 1, 1, 1) 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: else:
grid.attach(self.labels['x+'], 0, 1, 1, 1) if self._screen.lang_ltr:
grid.attach(self.labels['x-'], 2, 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['x-'], 0, 1, 1, 1)
grid.attach(self.labels['y-'], 1, 1, 1, 1) else:
grid.attach(self.labels['z+'], 3, 0, 1, 1) grid.attach(self.labels['x+'], 0, 1, 1, 1)
grid.attach(self.labels['z-'], 3, 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) 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(self.labels['move_dist'], True, True, 0)
box.pack_start(distgrid, 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) self.content.add(grid)

View File

@ -38,6 +38,10 @@ class PrinterSelect(ScreenPanel):
name = list(printer)[0] name = list(printer)[0]
self.labels[name] = self._gtk.ButtonImage("extruder", name, "color%s" % (1 + i % 4)) self.labels[name] = self._gtk.ButtonImage("extruder", name, "color%s" % (1 + i % 4))
self.labels[name].connect("clicked", self._screen.connect_printer_widget, name) self.labels[name].connect("clicked", self._screen.connect_printer_widget, name)
col = i % columns if self._screen.vertical_mode:
row = int(i/columns) row = i % columns
col = int(i/columns)
else:
col = i % columns
row = int(i/columns)
grid.attach(self.labels[name], col, row, 1, 1) grid.attach(self.labels[name], col, row, 1, 1)

View File

@ -39,7 +39,10 @@ class TemperaturePanel(ScreenPanel):
self.select_heater(None, h) self.select_heater(None, h)
else: else:
self.show_preheat = False 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.content.add(self.grid)
self.layout.show_all() self.layout.show_all()
@ -64,8 +67,12 @@ class TemperaturePanel(ScreenPanel):
def switch_preheat_adjust(self, widget): def switch_preheat_adjust(self, widget):
self.show_preheat ^= True self.show_preheat ^= True
self.grid.remove_column(1) if self._screen.vertical_mode:
self.grid.attach(self.create_right_panel(), 1, 0, 1, 1) 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() self.grid.show_all()
def preheat(self): def preheat(self):
@ -430,7 +437,11 @@ class TemperaturePanel(ScreenPanel):
for d in self._printer.get_temp_store_devices(): for d in self._printer.get_temp_store_devices():
if self.add_device(d): if self.add_device(d):
i += 1 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) self.labels['da'].set_size_request(0, graph_height)
return box return box
@ -454,8 +465,12 @@ class TemperaturePanel(ScreenPanel):
self.devices[self.active_heater]['name'].get_style_context().remove_class("button_active") self.devices[self.active_heater]['name'].get_style_context().remove_class("button_active")
self.active_heater = None self.active_heater = None
self.grid.remove_column(1) if self._screen.vertical_mode:
self.grid.attach(self.create_right_panel(), 1, 0, 1, 1) 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() self.grid.show_all()
def on_popover_clicked(self, widget, device): 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"] = Keypad(self._screen, self.change_target_temp, self.hide_numpad)
self.labels["keypad"].clear() self.labels["keypad"].clear()
self.grid.remove_column(1) if self._screen.vertical_mode:
self.grid.attach(self.labels["keypad"], 1, 0, 1, 1) 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.grid.show_all()
self.labels['popover'].popdown() self.labels['popover'].popdown()

View File

@ -76,13 +76,23 @@ class ZCalibratePanel(ScreenPanel):
distances.pack_start(distgrid, True, True, 0) distances.pack_start(distgrid, True, True, 0)
grid.set_column_homogeneous(True) grid.set_column_homogeneous(True)
grid.attach(self.widgets['zpos'], 0, 0, 1, 1) if self._screen.vertical_mode:
grid.attach(self.widgets['start'], 1, 0, 1, 1) grid.attach(self.widgets['zpos'], 0, 1, 1, 1)
grid.attach(pos, 1, 1, 1, 1) grid.attach(self.widgets['zneg'], 0, 2, 1, 1)
grid.attach(self.widgets['zneg'], 0, 1, 1, 1) grid.attach(self.widgets['start'], 0, 0, 1, 1)
grid.attach(self.widgets['complete'], 2, 0, 1, 1) grid.attach(pos, 1, 0, 1, 1)
grid.attach(distances, 0, 2, 3, 1) grid.attach(self.widgets['complete'], 1, 1, 1, 1)
grid.attach(self.widgets['cancel'], 2, 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.buttons_not_calibrating()
self.content.add(grid) self.content.add(grid)

View File

@ -120,6 +120,10 @@ class KlipperScreen(Gtk.Window):
self.height = self._config.get_main_config().getint("height", monitor.get_geometry().height) self.height = self._config.get_main_config().getint("height", monitor.get_geometry().height)
self.set_default_size(self.width, self.height) self.set_default_size(self.width, self.height)
self.set_resizable(False) 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)) logging.info("Screen resolution: %sx%s" % (self.width, self.height))
self.theme = self._config.get_main_config_option('theme') self.theme = self._config.get_main_config_option('theme')
self.show_cursor = self._config.get_main_config().getboolean("show_cursor", fallback=False) self.show_cursor = self._config.get_main_config().getboolean("show_cursor", fallback=False)