apply gaps when loading keyboard layout

This commit is contained in:
Crispy 2022-01-19 21:15:32 +01:00
parent 710b418970
commit 899a3dce3d
5 changed files with 32 additions and 41 deletions

View file

@ -9,4 +9,3 @@ rect_min_size = Vector2( 128, 128 )
anchor_right = 1.0
anchor_bottom = 1.0
align = 1
valign = 1

View file

@ -42,35 +42,22 @@ func apply_keys():
row_box.add_child(btn)
btn.connect("pressed", self, "key_pressed", [key.keycode])
#TODO gaps
# horizontal gaps
if key.has("gap"):
var gapbox = Control.new()
gapbox.rect_min_size.x = key.gap * key_size
gapbox.name = "Gap"
row_box.add_child(gapbox)
# vertical gaps
if row.has("gap"):
var gapbox = Control.new()
gapbox.rect_min_size.y = row.gap * key_size
gapbox.name = "Gap"
$PanelContainer/CenterContainer/VBoxContainer.add_child(gapbox)
func key_pressed(code, toggle=false):
GDVK.press(code)
func _on_KeyO_pressed():
GDVK.press("O")
func _on_KeyE_pressed():
GDVK.key_down("SHIFT")
GDVK.press("1")
GDVK.key_up("SHIFT")
func _on_KeyH_pressed():
GDVK.press("H")
pass # Replace with function body.
func _on_KeyL_pressed():
GDVK.press("L")
pass # Replace with function body.
func _on_KeyCaps_pressed():
GDVK.press("CAPSLOCK")
pass # Replace with function body.

View file

@ -267,8 +267,8 @@
},
{
"keycode": "SHIFT",
"display": "SHIFT",
"width": 2.5
"display": "Shift",
"width": 2.75
}
]
},
@ -282,28 +282,28 @@
},
{
"keycode": "SUPER",
"display": "Super",
"width": 1.5
"display": "Sup",
"width": 1.25
},
{
"keycode": "ALT",
"display": "Alt",
"width": 1.5
"width": 1.25
},
{
"keycode": "SPACE",
"display": "",
"width": 5.5
"width": 5.75
},
{
"keycode": "ALT",
"display": "Alt Gr(!)",
"width": 1.5
"display": "Alt",
"width": 1.25
},
{
"keycode": "SUPER",
"display": "Super",
"width": 1.5
"display": "Sup",
"width": 1.25
},
{
"keycode": "MENU",

View file

@ -17,8 +17,10 @@ key_row = ExtResource( 3 )
key_button = ExtResource( 4 )
[node name="PanelContainer" type="PanelContainer" parent="."]
anchor_right = 1.0
margin_right = 1024.0
margin_bottom = 16.0
size_flags_horizontal = 0
size_flags_vertical = 0
__meta__ = {
"_edit_use_anchors_": false
}
@ -26,9 +28,12 @@ __meta__ = {
[node name="CenterContainer" type="CenterContainer" parent="PanelContainer"]
margin_left = 8.0
margin_top = 8.0
margin_right = 2040.0
margin_right = 1016.0
margin_bottom = 8.0
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/CenterContainer"]
margin_left = 1016.0
margin_right = 1016.0
margin_left = 504.0
margin_right = 504.0
size_flags_horizontal = 0
size_flags_vertical = 0
alignment = 1