Skip to content

Commit

Permalink
Improved the experimental visualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
kesac committed Nov 15, 2024
2 parents e04ca4b + 2684a9a commit ac5f565
Show file tree
Hide file tree
Showing 18 changed files with 746 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
/Syllabore/.vs/
/Syllabore/Syllabore.Example/bin/Debug/net7.0
/Syllabore/Syllabore.Tests/bin/Debug/net5.0
/Syllabore/Syllabore.Visualizer/.vs/ProjectEvaluation
8 changes: 8 additions & 0 deletions Syllabore/Syllabore.Visualizer/EditorLabelGray.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[gd_resource type="LabelSettings" load_steps=2 format=3 uid="uid://bk6ghtaibqhya"]

[ext_resource type="FontFile" uid="uid://dpthqbkpqte48" path="res://Fonts/Kenney Pixel.ttf" id="1_g83er"]

[resource]
font = ExtResource("1_g83er")
font_size = 18
font_color = Color(0.509804, 0.509804, 0.509804, 1)
25 changes: 25 additions & 0 deletions Syllabore/Syllabore.Visualizer/Fonts/FontLicense.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
The license for the files '../Fonts/Kenney Mini.ttf'
and '../Fonts/Kenney Pixel.ttf' is provided below.

---

Font package (free)

Created/distributed by Kenney (www.kenney.nl)

------------------------------

License: (Creative Commons Zero, CC0)
http://creativecommons.org/publicdomain/zero/1.0/

This content is free to use in personal, educational and commercial projects.
Support us by crediting (Kenney or www.kenney.nl), this is not mandatory.

------------------------------

Donate: http://support.kenney.nl
Request: http://request.kenney.nl
Patreon: http://patreon.com/kenney/

Follow on Twitter for updates:
@KenneyNL
Binary file not shown.
33 changes: 33 additions & 0 deletions Syllabore/Syllabore.Visualizer/Fonts/Kenney Mini.ttf.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[remap]

importer="font_data_dynamic"
type="FontFile"
uid="uid://8dcyb60yu3ub"
path="res://.godot/imported/Kenney Mini.ttf-cae9f4188ec099302813ee760aa78bae.fontdata"

[deps]

source_file="res://Fonts/Kenney Mini.ttf"
dest_files=["res://.godot/imported/Kenney Mini.ttf-cae9f4188ec099302813ee760aa78bae.fontdata"]

[params]

Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}
Binary file not shown.
33 changes: 33 additions & 0 deletions Syllabore/Syllabore.Visualizer/Fonts/Kenney Pixel.ttf.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[remap]

importer="font_data_dynamic"
type="FontFile"
uid="uid://dpthqbkpqte48"
path="res://.godot/imported/Kenney Pixel.ttf-81d50fd9036595aeb2ef7347717d979e.fontdata"

[deps]

source_file="res://Fonts/Kenney Pixel.ttf"
dest_files=["res://.godot/imported/Kenney Pixel.ttf-81d50fd9036595aeb2ef7347717d979e.fontdata"]

[params]

Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}
89 changes: 89 additions & 0 deletions Syllabore/Syllabore.Visualizer/GraphemeEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using Godot;
using System;

public partial class GraphemeEditor : Control
{
public event Action GraphemeEditorChanged;

protected virtual void OnGraphemeEditorChanged()
{
GraphemeEditorChanged?.Invoke();
}

protected virtual void OnVSliderChanged(float value)
{
this.UpdatePercentageLabel(value);
GraphemeEditorChanged?.Invoke();
}

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

public string LabelText
{
get
{
return this.GetNode<Label>("LeftPanel/Label").Text;
}
set
{
this.GetNode<Label>("LeftPanel/Label").Text = value;
}
}

public string Text
{
get
{
return this.GetNode<TextEdit>("LeftPanel/TextEdit").Text;
}
set
{

this.GetNode<TextEdit>("LeftPanel/TextEdit").Text = value;
}
}

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
{
var vSlider = this.GetNode<VSlider>("RightPanel/VSlider");
return vSlider.Value / vSlider.MaxValue; // Normalize to [0,1]
}
set
{
var vSlider = this.GetNode<VSlider>("RightPanel/VSlider");
this.GetNode<VSlider>("RightPanel/VSlider").Value = value * vSlider.MaxValue; // Normalize to [0,100]
this.UpdatePercentageLabel(value * vSlider.MaxValue);
}
}

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}%";
}
}
88 changes: 88 additions & 0 deletions Syllabore/Syllabore.Visualizer/GraphemeEditor.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
[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
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -940.0
offset_bottom = -700.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_7by6n")

[node name="LeftPanel" type="Panel" parent="."]
layout_mode = 0
offset_right = 170.0
offset_bottom = 70.0

[node name="Label" type="Label" parent="LeftPanel"]
layout_mode = 0
offset_left = 26.0
offset_top = 2.0
offset_right = 166.0
offset_bottom = 25.0
text = "Grapheme Label"
label_settings = ExtResource("1_886yt")
vertical_alignment = 1

[node name="TextEdit" type="TextEdit" parent="LeftPanel"]
layout_mode = 0
offset_left = 5.0
offset_top = 25.0
offset_right = 165.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 = 70.0

[node name="VSlider" type="VSlider" parent="RightPanel"]
layout_mode = 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 = 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
offset_right = 74.0
offset_bottom = 25.0
text = "Probability"
label_settings = ExtResource("1_886yt")
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"]
15 changes: 15 additions & 0 deletions Syllabore/Syllabore.Visualizer/ITemporalController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Syllabore.Visualizer
{
public interface ITemporalController
{
public bool IsSlowed { get; set; }
public bool IsPaused { get; set; }

}
}
Loading

0 comments on commit ac5f565

Please sign in to comment.