slimmer topbar buttons fixes #1006

This commit is contained in:
alfrix 2023-06-09 18:23:10 -03:00
parent f0a33bd360
commit f7c12867d5
4 changed files with 43 additions and 29 deletions

View File

@ -29,39 +29,25 @@ class ConsolePanel(ScreenPanel):
self.autoscroll = True self.autoscroll = True
self.hidetemps = True self.hidetemps = True
o1_lbl = Gtk.Label(_("Auto-scroll")) o1_button = self._gtk.Button("arrow-down", _("Auto-scroll") + " ", None, self.bts, Gtk.PositionType.RIGHT, 1)
o1_switch = Gtk.Switch() o1_button.get_style_context().add_class("button_active")
o1_switch.set_active(self.autoscroll) o1_button.get_style_context().add_class("buttons_slim")
o1_switch.connect("notify::active", self.set_autoscroll) o1_button.connect("clicked", self.set_autoscroll)
o2_lbl = Gtk.Label(_("Hide temp.")) o2_button = self._gtk.Button("heat-up", _("Hide temp.") + " ", None, self.bts, Gtk.PositionType.RIGHT, 1)
o2_switch = Gtk.Switch() o2_button.get_style_context().add_class("button_active")
o2_switch.set_active(self.hidetemps) o2_button.get_style_context().add_class("buttons_slim")
o2_switch.connect("notify::active", self.hide_temps) o2_button.connect("clicked", self.hide_temps)
if self._screen.vertical_mode:
o1_lbl.set_halign(Gtk.Align.CENTER)
o2_lbl.set_halign(Gtk.Align.CENTER)
else:
o1_lbl.set_halign(Gtk.Align.END)
o2_lbl.set_halign(Gtk.Align.END)
o3_button = self._gtk.Button("refresh", _('Clear') + " ", None, self.bts, Gtk.PositionType.RIGHT, 1) o3_button = self._gtk.Button("refresh", _('Clear') + " ", None, self.bts, Gtk.PositionType.RIGHT, 1)
o3_button.get_style_context().add_class("buttons_slim")
o3_button.connect("clicked", self.clear) o3_button.connect("clicked", self.clear)
options = Gtk.Grid() options = Gtk.Grid()
options.set_vexpand(False) options.set_vexpand(False)
if self._screen.vertical_mode: options.attach(o1_button, 0, 0, 1, 1)
options.attach(o1_lbl, 0, 0, 1, 1) options.attach(o2_button, 1, 0, 1, 1)
options.attach(o1_switch, 0, 1, 1, 1) options.attach(o3_button, 2, 0, 1, 1)
options.attach(o2_lbl, 1, 0, 1, 1)
options.attach(o2_switch, 1, 1, 1, 1)
options.attach(o3_button, 3, 0, 1, 2)
else:
options.attach(o1_lbl, 0, 0, 1, 1)
options.attach(o1_switch, 1, 0, 1, 1)
options.attach(o2_lbl, 2, 0, 1, 1)
options.attach(o2_switch, 3, 0, 1, 1)
options.attach(o3_button, 4, 0, 1, 1)
sw = Gtk.ScrolledWindow() sw = Gtk.ScrolledWindow()
sw.set_hexpand(True) sw.set_hexpand(True)
@ -90,6 +76,8 @@ class ConsolePanel(ScreenPanel):
entry.grab_focus_without_selecting() entry.grab_focus_without_selecting()
enter = self._gtk.Button("resume", " " + _('Send') + " ", None, .66, Gtk.PositionType.RIGHT, 1) enter = self._gtk.Button("resume", " " + _('Send') + " ", None, .66, Gtk.PositionType.RIGHT, 1)
enter.get_style_context().add_class("buttons_slim")
enter.set_hexpand(False) enter.set_hexpand(False)
enter.connect("clicked", self._send_command) enter.connect("clicked", self._send_command)
@ -150,11 +138,20 @@ class ConsolePanel(ScreenPanel):
if action == "notify_gcode_response": if action == "notify_gcode_response":
self.add_gcode("response", time.time(), data) self.add_gcode("response", time.time(), data)
def hide_temps(self, *args): def hide_temps(self, widget):
self.hidetemps ^= True self.hidetemps ^= True
self.toggle_active_class(widget, self.hidetemps)
def set_autoscroll(self, *args): def set_autoscroll(self, widget):
self.autoscroll ^= True self.autoscroll ^= True
self.toggle_active_class(widget, self.autoscroll)
@staticmethod
def toggle_active_class(widget, cond):
if cond:
widget.get_style_context().add_class("button_active")
else:
widget.get_style_context().remove_class("button_active")
def _autoscroll(self, *args): def _autoscroll(self, *args):
if self.autoscroll: if self.autoscroll:

View File

@ -19,11 +19,13 @@ class MacroPanel(ScreenPanel):
self.sort_btn = self._gtk.Button("arrow-up", _("Name"), "color1", self.bts, Gtk.PositionType.RIGHT, 1) self.sort_btn = self._gtk.Button("arrow-up", _("Name"), "color1", self.bts, Gtk.PositionType.RIGHT, 1)
self.sort_btn.connect("clicked", self.change_sort) self.sort_btn.connect("clicked", self.change_sort)
self.sort_btn.set_hexpand(True) self.sort_btn.set_hexpand(True)
self.sort_btn.get_style_context().add_class("buttons_slim")
self.options = {} self.options = {}
self.macros = {} self.macros = {}
self.menu = ['macros_menu'] self.menu = ['macros_menu']
adjust = self._gtk.Button("settings", " " + _("Settings"), "color2", self.bts, Gtk.PositionType.LEFT, 1) adjust = self._gtk.Button("settings", " " + _("Settings"), "color2", self.bts, Gtk.PositionType.LEFT, 1)
adjust.get_style_context().add_class("buttons_slim")
adjust.connect("clicked", self.load_menu, 'options', _("Settings")) adjust.connect("clicked", self.load_menu, 'options', _("Settings"))
adjust.set_hexpand(False) adjust.set_hexpand(False)

View File

@ -45,12 +45,14 @@ class PrintPanel(ScreenPanel):
sbox.set_vexpand(False) sbox.set_vexpand(False)
for i, (name, val) in enumerate(self.sort_items.items(), start=1): for i, (name, val) in enumerate(self.sort_items.items(), start=1):
s = self._gtk.Button(None, val, f"color{i % 4}", .5, Gtk.PositionType.RIGHT, 1) s = self._gtk.Button(None, val, f"color{i % 4}", .5, Gtk.PositionType.RIGHT, 1)
s.get_style_context().add_class("buttons_slim")
if name == self.sort_current[0]: if name == self.sort_current[0]:
s.set_image(self._gtk.Image(self.sort_icon[self.sort_current[1]], self._gtk.img_scale * self.bts)) s.set_image(self._gtk.Image(self.sort_icon[self.sort_current[1]], self._gtk.img_scale * self.bts))
s.connect("clicked", self.change_sort, name) s.connect("clicked", self.change_sort, name)
self.labels[f'sort_{name}'] = s self.labels[f'sort_{name}'] = s
sbox.add(s) sbox.add(s)
refresh = self._gtk.Button("refresh", style="color4", scale=self.bts) refresh = self._gtk.Button("refresh", style="color4", scale=self.bts)
refresh.get_style_context().add_class("buttons_slim")
refresh.connect('clicked', self._refresh_files) refresh.connect('clicked', self._refresh_files)
sbox.add(refresh) sbox.add(refresh)
sbox.set_hexpand(True) sbox.set_hexpand(True)

View File

@ -159,8 +159,14 @@ trough progress.left {
border: 0px; border: 0px;
} }
scale {
margin-bottom: 0;
margin-top: 0;
padding-bottom: 0;
padding-top: 0;
}
scale mark { scale mark {
margin-top: 1em;
color: white; color: white;
} }
@ -549,6 +555,13 @@ popover button {
background-color: darkred; background-color: darkred;
} }
.buttons_slim, .buttons_slim label {
margin-top: 0;
margin-bottom: 0;
padding-top: 0;
padding-bottom: 0;
}
/* Hardcoded values until creation of dynamic CSS updates */ /* Hardcoded values until creation of dynamic CSS updates */
.graph_label_hidden {padding-left: .9em;} /* .4em on top of normal button padding */ .graph_label_hidden {padding-left: .9em;} /* .4em on top of normal button padding */
.graph_label_extruder {border-left-width: .4em; border-left-style: solid;} .graph_label_extruder {border-left-width: .4em; border-left-style: solid;}