Skip to content

Commit

Permalink
GraphemeEditors can now enable or disable the grapheme pool they control
Browse files Browse the repository at this point in the history
  • Loading branch information
kesac committed Jun 16, 2024
1 parent 2852644 commit abb0197
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 14 deletions.
26 changes: 26 additions & 0 deletions Syllabore/Syllabore.Visualizer/GraphemeEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ protected virtual void OnVSliderChanged(float value)
GraphemeEditorChanged?.Invoke();
}

protected virtual void OnCheckBoxToggled(bool buttonPressed)
{
this.UpdateEnabledStatus();
this.GetNode<CheckBox>("LeftPanel/CheckBox").ReleaseFocus();
GraphemeEditorChanged?.Invoke();
}

public string LabelText
{
get
Expand All @@ -41,6 +48,19 @@ public string Text
}
}

public bool Enabled
{
get
{
return this.GetNode<CheckBox>("LeftPanel/CheckBox").ButtonPressed;
}
set
{
this.GetNode<CheckBox>("LeftPanel/CheckBox").ButtonPressed = value;
this.UpdateEnabledStatus();
}
}

public double Probability
{
get
Expand All @@ -56,6 +76,12 @@ public double Probability
}
}

public void UpdateEnabledStatus()
{
this.GetNode<TextEdit>("LeftPanel/TextEdit").Editable = this.Enabled;
this.GetNode<VSlider>("RightPanel/VSlider").Editable = this.Enabled;
}

private void UpdatePercentageLabel(double value)
{
this.GetNode<Label>("RightPanel/PercentageLabel").Text = $"{(int)value}%";
Expand Down
43 changes: 29 additions & 14 deletions Syllabore/Syllabore.Visualizer/GraphemeEditor.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://dfh0hshtdjms1"]
[gd_scene load_steps=5 format=3 uid="uid://dfh0hshtdjms1"]

[ext_resource type="Script" path="res://GraphemeEditor.cs" id="1_7by6n"]
[ext_resource type="LabelSettings" uid="uid://bk6ghtaibqhya" path="res://EditorLabelGray.tres" id="1_886yt"]
[ext_resource type="FontFile" uid="uid://8dcyb60yu3ub" path="res://Fonts/Kenney Mini.ttf" id="3_5e4ym"]

[sub_resource type="LabelSettings" id="LabelSettings_yvqpb"]
font = ExtResource("3_5e4ym")

[node name="GraphemeEditor" type="Control"]
layout_mode = 3
Expand All @@ -17,11 +21,11 @@ script = ExtResource("1_7by6n")
[node name="LeftPanel" type="Panel" parent="."]
layout_mode = 0
offset_right = 170.0
offset_bottom = 75.0
offset_bottom = 70.0

[node name="Label" type="Label" parent="LeftPanel"]
layout_mode = 0
offset_left = 8.0
offset_left = 26.0
offset_top = 2.0
offset_right = 166.0
offset_bottom = 25.0
Expand All @@ -31,34 +35,44 @@ vertical_alignment = 1

[node name="TextEdit" type="TextEdit" parent="LeftPanel"]
layout_mode = 0
offset_left = 6.0
offset_left = 5.0
offset_top = 25.0
offset_right = 165.0
offset_bottom = 69.0
offset_bottom = 62.0

[node name="CheckBox" type="CheckBox" parent="LeftPanel"]
layout_mode = 0
offset_top = 2.0
offset_right = 24.0
offset_bottom = 26.0

[node name="RightPanel" type="Panel" parent="."]
layout_mode = 0
offset_left = 177.0
offset_right = 252.0
offset_bottom = 75.0
offset_bottom = 70.0

[node name="VSlider" type="VSlider" parent="RightPanel"]
layout_mode = 0
offset_left = 47.0
offset_top = 28.0
offset_right = 73.0
offset_bottom = 64.0
offset_left = 1.0
offset_top = 5.0
offset_right = 27.0
offset_bottom = 62.0
value = 100.0

[node name="PercentageLabel" type="Label" parent="RightPanel"]
layout_mode = 0
offset_left = 7.0
offset_top = 28.0
offset_right = 49.0
offset_bottom = 64.0
offset_left = 25.0
offset_top = 9.0
offset_right = 67.0
offset_bottom = 61.0
text = "100%"
label_settings = SubResource("LabelSettings_yvqpb")
horizontal_alignment = 1
vertical_alignment = 1

[node name="Label" type="Label" parent="RightPanel"]
visible = false
layout_mode = 0
offset_left = 1.0
offset_top = 2.0
Expand All @@ -70,4 +84,5 @@ horizontal_alignment = 1
vertical_alignment = 1

[connection signal="text_changed" from="LeftPanel/TextEdit" to="." method="OnGraphemeEditorChanged"]
[connection signal="toggled" from="LeftPanel/CheckBox" to="." method="OnCheckBoxToggled"]
[connection signal="value_changed" from="RightPanel/VSlider" to="." method="OnVSliderChanged"]

0 comments on commit abb0197

Please sign in to comment.