keyboard: improve layout and interactions on panels with entry

This commit is contained in:
alfrix authored and Alfredo Monclus committed 2022-07-03 12:03:50 -03:00
1 parent bd03a66dde
commit faf997c7ae
8 files changed
+52 -54

No files matched your search

+1 -2
View File
@@ -12,6 +12,7 @@ class KlippyGtk:
labels = {}
width_ratio = 16
height_ratio = 9.375
keyboard_ratio = .5
def __init__(self, screen, width, height, theme, cursor, fontsize_type):
self.screen = screen
@@ -21,10 +22,8 @@ class KlippyGtk:
if self.screen.vertical_mode:
self.font_ratio = [33, 49]
self.keyboard_ratio = .25
else:
self.font_ratio = [43, 29]
self.keyboard_ratio = .33
self.font_size = int(min(
self.width / self.font_ratio[0],
self.height / self.font_ratio[1]
+15 -19
View File
@@ -69,12 +69,6 @@
</key>
</row>
<row>
<key obey-caps='true'>
<default display="Caps" action="modifier:caps" />
<shifted display="Caps" action="modifier:caps" />
<mod1 display="@" />
<mod2 display="£" />
</key>
<key obey-caps='true'>
<default display="a" />
<shifted display="A" />
@@ -129,10 +123,16 @@
<mod1 display="/" />
<mod2 display="\" />
</key>
<key obey-caps='true'>
<default display="ñ" />
<shifted display="Ñ" />
<mod1 display="@" />
<mod2 display="£" />
</key>
</row>
<row>
<key obey-caps='true'>
<default display="↑" action="modifier:shift" />
<default display="image:shift.png" action="modifier:shift" />
</key>
<key obey-caps='true'>
<default display="z" />
@@ -162,7 +162,7 @@
<default display="b" />
<shifted display="B" />
<mod1 display=";" />
<mod2 display="✓" />
<mod2 display="¿" />
</key>
<key obey-caps='true'>
<default display="n" />
@@ -177,31 +177,27 @@
<mod2 display="]" />
</key>
<key obey-caps='true'>
<default display="⌫" action="backspace" />
<default display="image:arrow.png" action="backspace" />
</key>
</row>
<row>
<key>
<default display="?123" action="modifier:mod1" />
<key width="2000" fill="false">
<default display="123" action="modifier:mod1" />
</key>
<key>
<key width="2000" fill="false">
<default display="=\&lt;" action="modifier:mod2" />
</key>
<key>
<key fill="false">
<default display="," />
<mod2 display="&lt;" />
</key>
<key width="6000" fill="true">
<key width="3000" fill="true">
<default display=" " action="space" />
</key>
<key>
<key fill="false">
<default display="." />
<mod2 display="&gt;" />
</key>
<key width="1000">
<!-- <default display="◀┛" action="return"/> -->
<default display="◀┛" action="return"/>
</key>
</row>
</layout>
+2 -1
View File
@@ -16,6 +16,7 @@ class Keypad(Gtk.Box):
numpad = self._gtk.HomogeneousGrid()
numpad.set_direction(Gtk.TextDirection.LTR)
numpad.get_style_context().add_class('numpad')
keys = [
['1', 'numpad_tleft'],
@@ -48,7 +49,7 @@ class Keypad(Gtk.Box):
self.labels['entry'].props.xalign = 0.5
self.labels['entry'].connect("activate", self.update_entry, "E")
b = self._gtk.ButtonImage('cancel', _('Close'), None, 1)
b = self._gtk.ButtonImage('cancel', _('Close'), None, .66, Gtk.PositionType.LEFT, False)
b.connect("clicked", close_function)
self.add(self.labels['entry'])
+7 -9
View File
@@ -266,19 +266,19 @@ class BedMeshPanel(ScreenPanel):
if "create_profile" not in self.labels:
pl = self._gtk.Label(_("Profile Name:"))
pl.set_hexpand(False)
entry = Gtk.Entry()
entry.set_text('')
entry.set_hexpand(True)
entry.connect("activate", self.create_profile)
entry.connect("focus-in-event", self._show_keyboard)
entry.connect("focus-out-event", self._remove_keyboard)
self.labels['profile_name'] = Gtk.Entry()
self.labels['profile_name'].set_text('')
self.labels['profile_name'].set_hexpand(True)
self.labels['profile_name'].connect("activate", self.create_profile)
self.labels['profile_name'].connect("focus-in-event", self._screen.show_keyboard)
self.labels['profile_name'].grab_focus_without_selecting()
save = self._gtk.ButtonImage("sd", _("Save"), "color3")
save.set_hexpand(False)
save.connect("clicked", self.create_profile)
box = Gtk.HBox()
box.pack_start(entry, True, True, 5)
box.pack_start(self.labels['profile_name'], True, True, 5)
box.pack_start(save, False, False, 5)
self.labels['create_profile'] = Gtk.VBox(spacing=5)
@@ -290,8 +290,6 @@ class BedMeshPanel(ScreenPanel):
self.content.add(self.labels['create_profile'])
self._screen.show_keyboard()
self.labels['profile_name'] = entry
self.labels['profile_name'].grab_focus_without_selecting()
self.show_create = True
def show_mesh(self, widget, profile):
+7 -10
View File
@@ -69,6 +69,7 @@ class ConsolePanel(ScreenPanel):
tv.set_editable(False)
tv.set_cursor_visible(False)
tv.connect("size-allocate", self._autoscroll)
tv.connect("focus-in-event", self._screen.remove_keyboard)
sw.add(tv)
@@ -79,9 +80,10 @@ class ConsolePanel(ScreenPanel):
entry = Gtk.Entry()
entry.set_hexpand(True)
entry.set_vexpand(False)
entry.connect("focus-in-event", self._show_keyboard)
entry.connect("focus-out-event", self._remove_keyboard)
entry.connect("button-press-event", self._screen.show_keyboard)
entry.connect("focus-in-event", self._screen.show_keyboard)
entry.connect("activate", self._send_command)
entry.grab_focus_without_selecting()
enter = self._gtk.ButtonImage("resume", " " + _('Send') + " ", None, .66, Gtk.PositionType.RIGHT, False)
enter.set_hexpand(False)
@@ -98,9 +100,9 @@ class ConsolePanel(ScreenPanel):
})
content_box = Gtk.VBox()
content_box.pack_start(options, False, 0, 5)
content_box.pack_start(options, False, False, 5)
content_box.add(sw)
content_box.pack_end(ebox, False, 0, 0)
content_box.pack_end(ebox, False, False, 0)
self.content.add(content_box)
def clear(self, widget):
@@ -155,15 +157,10 @@ class ConsolePanel(ScreenPanel):
adj = self.labels['sw'].get_vadjustment()
adj.set_value(adj.get_upper() - adj.get_page_size())
def _show_keyboard(self, *args):
self._screen.show_keyboard()
def _remove_keyboard(self, *args):
self._screen.remove_keyboard()
def _send_command(self, *args):
cmd = self.labels['entry'].get_text()
self.labels['entry'].set_text('')
self._screen.remove_keyboard()
self.add_gcode("command", time.time(), cmd)
self._screen._ws.klippy.gcode_script(cmd)
+7 -9
View File
@@ -351,19 +351,19 @@ class NetworkPanel(ScreenPanel):
label = self._gtk.Label("%s %s:" % (_("PSK for"), ssid))
label.set_hexpand(False)
entry = Gtk.Entry()
entry.set_text('')
entry.set_hexpand(True)
entry.connect("activate", self.add_new_network, ssid, True)
entry.connect("focus-in-event", self._show_keyboard)
entry.connect("focus-out-event", self._remove_keyboard)
self.labels['network_psk'] = Gtk.Entry()
self.labels['network_psk'].set_text('')
self.labels['network_psk'].set_hexpand(True)
self.labels['network_psk'].connect("activate", self.add_new_network, ssid, True)
self.labels['network_psk'].connect("focus-in-event", self._screen.show_keyboard)
self.labels['network_psk'].grab_focus_without_selecting()
save = self._gtk.ButtonImage("sd", _("Save"), "color3")
save.set_hexpand(False)
save.connect("clicked", self.add_new_network, ssid, True)
box = Gtk.HBox()
box.pack_start(entry, True, True, 5)
box.pack_start(self.labels['network_psk'], True, True, 5)
box.pack_start(save, False, False, 5)
self.labels['add_network'] = Gtk.VBox(spacing=5)
@@ -375,8 +375,6 @@ class NetworkPanel(ScreenPanel):
self.content.add(self.labels['add_network'])
self._screen.show_keyboard()
self.labels['network_psk'] = entry
self.labels['network_psk'].grab_focus_without_selecting()
self.content.show_all()
self.show_add = True
+4 -3
View File
@@ -1016,7 +1016,7 @@ class KlipperScreen(Gtk.Window):
self.show_panel('job_status', "job_status", "Print Status", 2)
self.base_panel.show_heaters(True)
def show_keyboard(self, widget=None):
def show_keyboard(self, widget=None, event=None):
if self.keyboard is not None:
return
@@ -1038,9 +1038,10 @@ class KlipperScreen(Gtk.Window):
box = Gtk.VBox()
box.set_vexpand(False)
box.set_size_request(self.gtk.get_content_width(), self.gtk.get_keyboard_height())
box.get_style_context().add_class("keyboard_box")
box.add(keyboard)
self.base_panel.get_content().pack_end(box, False, 0, 0)
self.base_panel.get_content().pack_end(box, True, True, 0)
self.show_all()
keyboard.add_id(xid)
@@ -1052,7 +1053,7 @@ class KlipperScreen(Gtk.Window):
"socket": keyboard
}
def remove_keyboard(self, widget=None):
def remove_keyboard(self, widget=None, event=None):
if self.keyboard is None:
return
+9 -1
View File
@@ -101,7 +101,7 @@ switch slider {
entry {
font-size: 1em;
background-color: #20292F;
border: 1em solid #13181C;
border: .2em solid #13181C;
padding: .25em;
}
@@ -278,6 +278,10 @@ trough {
min-height: 2em;
}
.keyboard_box {
margin-top: 42px;
}
.message_popup {
border-bottom: .1em solid white;
}
@@ -294,6 +298,10 @@ trough {
background-color: #9e2f3a;
}
.numpad{
margin-top: 30px;
}
.numpad_tleft {
border: .15em solid white;
border-bottom: 0;