clean up keyboard

This commit is contained in:
Crispy 2022-01-20 17:57:21 +01:00
parent be9ceeef9c
commit 8725763124
7 changed files with 34 additions and 15 deletions

View file

@ -3,6 +3,7 @@
[node name="KeyRow" type="HBoxContainer"]
margin_right = 230.0
margin_bottom = 128.0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}

Binary file not shown.

Binary file not shown.

View file

@ -7,11 +7,15 @@ const OVERLAY_PROPERTIES = {
export var key_size := 120
export var key_row : PackedScene
export var key_button : PackedScene
export var row_container_path : NodePath
var row_container
var keymap := {}
var toggle_keys := []
func _ready():
row_container = get_node(row_container_path)
load_keys("res://overlay_resources/keyboard/layouts/layout_se.json")
@ -27,7 +31,7 @@ func load_keys(fp: String):
func apply_keys():
for row in keymap.rows:
var row_box = key_row.instance()
$PanelContainer/CenterContainer/VBoxContainer.add_child(row_box)
row_container.add_child(row_box)
for key in row.keys:
var btn = key_button.instance()
@ -59,11 +63,11 @@ func apply_keys():
row_box.add_child(gapbox)
# vertical gaps
if row.has("gap"):
if row.has("gap") and row.gap > 0:
var gapbox = Control.new()
gapbox.rect_min_size.y = row.gap * key_size
gapbox.name = "Gap"
$PanelContainer/CenterContainer/VBoxContainer.add_child(gapbox)
row_container.add_child(gapbox)
func key_toggled(state, code):

View file

@ -56,8 +56,7 @@
},
{
"keycode": "F12",
"display": "F12",
"gap": 0.5
"display": "F12"
}
]
},

View file

@ -15,25 +15,40 @@ __meta__ = {
}
key_row = ExtResource( 3 )
key_button = ExtResource( 4 )
row_container_path = NodePath("CenterContainer/PanelContainer/RowContainer")
[node name="PanelContainer" type="PanelContainer" parent="."]
margin_right = 1024.0
margin_bottom = 16.0
[node name="CenterContainer" type="CenterContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 8.0
margin_top = 8.0
margin_right = 8.0
margin_bottom = 8.0
size_flags_horizontal = 0
size_flags_vertical = 0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="CenterContainer" type="CenterContainer" parent="PanelContainer"]
[node name="PanelContainer" type="PanelContainer" parent="CenterContainer"]
margin_left = 1016.0
margin_top = 1016.0
margin_right = 1032.0
margin_bottom = 1032.0
size_flags_horizontal = 0
size_flags_vertical = 0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="RowContainer" type="VBoxContainer" parent="CenterContainer/PanelContainer"]
margin_left = 8.0
margin_top = 8.0
margin_right = 1016.0
margin_right = 8.0
margin_bottom = 8.0
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer/CenterContainer"]
margin_left = 504.0
margin_right = 504.0
size_flags_horizontal = 0
size_flags_vertical = 0
alignment = 1
__meta__ = {
"_edit_use_anchors_": false
}