-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimelineFunctionContainer.cs
More file actions
76 lines (63 loc) · 1.69 KB
/
TimelineFunctionContainer.cs
File metadata and controls
76 lines (63 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using Godot;
using Sonification;
public partial class TimelineFunctionContainer : Control
{
[Export]
Label? startLabel;
[Export]
Label? endLabel;
[Export]
LaTeXButton? latex;
[Export]
PanelContainer? panel;
private StyleBox? pausedBox = (StyleBox) GD.Load("res://FunctionPaused.tres");
private StyleBox? playingBox = (StyleBox) GD.Load("res://FunctionPlaying.tres");
public LowerTimeline? Timeline { get; set; }
public Function? Function { get; set; }
public string LatexString
{
set
{
latex!.LatexExpression = value;
latex.QueueRedraw();
}
}
public void Initialize(Function func, LowerTimeline timeline)
{
Function = func;
startLabel!.Text = func.StartTime.ToString();
endLabel!.Text = func.EndTime.ToString();
LatexString = func.FunctionAST!.Latex;
Timeline = timeline;
}
void Delete()
{
if(Timeline!.IsPlaying) return;
QueueFree();
}
public override Variant _GetDragData(Vector2 atPosition)
{
if(Timeline!.IsPlaying) return new Variant();
SetDragPreview((Control)Duplicate());
QueueFree();
return Function!;
}
private void ChangePausedToPlaying()
{
// Load playing theme.
panel!.RemoveThemeStyleboxOverride("Paused");
panel!.AddThemeStyleboxOverride("panel", playingBox);
}
private void ChangePlayingToPaused()
{
// Load paused theme.
panel!.RemoveThemeStyleboxOverride("Playing");
panel!.AddThemeStyleboxOverride("panel", pausedBox);
}
public override void _Process(double delta)
{
StyleBox box = panel!.GetThemeStylebox("panel");
if(Function!.IsProcessing() && box.ResourceName.Equals("Paused")) ChangePausedToPlaying();
else if(!Function!.IsProcessing() && box.ResourceName.Equals("Playing")) ChangePlayingToPaused();
}
}