-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathScriptExpression.h
57 lines (40 loc) · 1.54 KB
/
ScriptExpression.h
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
/*
==============================================================================
Expression.h
Created: 20 Feb 2017 5:01:11pm
Author: Ben
==============================================================================
*/
#pragma once
class ScriptExpression :
public juce::Thread,
public EngineListener,
public ScriptTarget::ScriptTargetListener,
public Inspectable::InspectableListener,
public ParameterListener
{
public:
ScriptExpression(Parameter* attachedParam = nullptr);
~ScriptExpression();
enum ExpressionState { EXPRESSION_LOADED, EXPRESSION_ERROR, EXPRESSION_EMPTY, EXPRESSION_CLEAR };
ExpressionState state;
std::unique_ptr<juce::JavascriptEngine> scriptEngine;
Parameter* attachedParam;
juce::String expression;
juce::var currentValue;
juce::Array<juce::WeakReference<Parameter>> linkedParameters;
void setExpression(const juce::String &expression);
void evaluate(bool resetListeners = false);
void buildEnvironment();
void setState(ExpressionState newState);
void scriptObjectUpdated(ScriptTarget *) override;
void fileLoaded() override;
juce::Array<Parameter *> getParameterReferencesInExpression();
void inspectableDestroyed(Inspectable * i) override;
void parameterValueChanged(Parameter * p) override;
juce::ListenerList<ExpressionListener> expressionListeners;
void addExpressionListener(ExpressionListener* newListener) { expressionListeners.add(newListener); }
void removeExpressionListener(ExpressionListener* listener) { expressionListeners.remove(listener); }
// Inherited via Timer
virtual void run() override;
};