summaryrefslogtreecommitdiff
path: root/rotord
diff options
context:
space:
mode:
Diffstat (limited to 'rotord')
-rw-r--r--rotord/src/graph.cpp9
-rw-r--r--rotord/src/nodes_drawing.h2
-rw-r--r--rotord/src/rotor.h43
3 files changed, 52 insertions, 2 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp
index ebfcece..cc624a8 100644
--- a/rotord/src/graph.cpp
+++ b/rotord/src/graph.cpp
@@ -344,6 +344,15 @@ bool Graph::parseJson(string &data,string &media_path){
}
attr->init(vals);
}
+ if (attr->type=="lyrics"){
+ std::map<float,std::pair<string,float> > lyrics;
+ for (auto k:jnodes[i]["attributes"][m]["value"]){
+ if (k.size()>2&&k[0].isString()&&k[1].isNumeric()&&k[2].isNumeric()) {
+ lyrics[k[1].asFloat()]=std::make_pair(k[0].asString(),k[2].asFloat());
+ }
+ }
+ ((Lyrics_attribute*)attr)->init(lyrics);
+ }
node->init_attribute(attribute);
//cerr << "Rotor: setting attribute '"<<attribute<<"' of "<<nodeID<<" type "<<attr->type<<" to "<<val<<endl;
cerr << "Rotor: setting attribute '"<<attribute<<"' of "<<nodeID<<" type "<<attr->type<<" to "<<val<<endl;
diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h
index c2d79e6..914f064 100644
--- a/rotord/src/nodes_drawing.h
+++ b/rotord/src/nodes_drawing.h
@@ -116,7 +116,7 @@ namespace Rotor {
Lyrics(){
title="Lyrics text";
description="Draws lyrics text";
- create_attribute("lyrics","Lyrics to draw","Lyrics","hello, world!");
+ create_empty_attribute("lyrics","Lyrics to draw","Lyrics","lyrics");
NODEID="ac4318b8-4de9-11e3-b2eb-74d02b29f6a6";
};
Lyrics(map<string,string> &settings):Lyrics() {
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index a2c33d2..1c8e992 100644
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -209,9 +209,24 @@ namespace Rotor {
float get(const Time_spec& time);
string type;
};
+ /*
+ tributes want to be extended beyond the original vision of a string that can be interpreted in different ways
+ could be a template?
+ typedef attribute<int32_t> intattribute;
+ could be a subclass ie
+ attributes=vector<attribute*>
+ class lyrics_attribute : public attribut
+ if(<dynamic_cast>(lyrics_attribute)attributes["lyrics"]) {
+ thislyric=(lyrics_attribute)attributes["lyrics"].findkey(1);
+ }
+
+ 1) generic way to define and use attributes of different types
+
+ */
class Attribute{ //description of a static attribute which can be an enumerated string array
public:
virtual ~Attribute(){};
+ Attribute(){};
Attribute(const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={},std::string _type="string"): description(_desc),title(_title),value(_value),intVal(0),type(_type){
vals=_vals;
init(_value);
@@ -236,6 +251,27 @@ namespace Rotor {
std::vector<std::string> vals;
};
+ class Lyrics_attribute: public Attribute{ //description of a static attribute which can be an enumerated string array
+ public:
+ virtual ~Lyrics_attribute(){};
+ Lyrics_attribute(const string &_desc,const string &_title){
+ description=_desc;
+ title=_title;
+ type="lyrics";
+ };
+ void init(const std::map<float,std::pair<string,float> > _lyrics){
+ lyrics=_lyrics;
+ for (auto l:lyrics){
+ cerr<<l.first<<":"<<l.second.first<<" ("<<l.second.second<<")"<<endl;
+ }
+ }
+ const string &get_lyric(const Time_spec &time){
+
+ }
+ private:
+ std::map<float,std::pair<string,float> > lyrics;
+
+ };
class Node{
public:
Node(){duplicate_inputs=false;};
@@ -258,6 +294,11 @@ namespace Rotor {
if (_vals.size()&&_type!="array") _type="enum"; //hack for incomplete attribute types
attributes[_attr]=new Attribute(_desc,_title,_value,_vals,_type);
};
+ void create_empty_attribute(const string &_attr,const string &_desc,const string &_title,const string &_type="string") {
+ //initialiser without initialisation
+ if (_type=="lyrics") attributes[_attr]=new Lyrics_attribute(_desc,_title);
+ else attributes[_attr]=new Attribute(_desc,_title,"",{},_type);
+ };
void create_attribute(string *alias,const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector<std::string> _vals={},std::string _type="string") {
create_attribute(_attr,_desc,_title,_value,_vals,_type);
alias=&(attributes[_attr]->value);
@@ -396,7 +437,7 @@ namespace Rotor {
Video_cycler(){
create_image_input("Image input","Image input");
create_signal_input("Selector","Selector input");
- create_attribute("mode","Cycling mode {cut|mix}","Mode","cut",{"cut","mix"});
+ create_attribute("mode","Cycling mode","Mode","cut",{"cut","mix"});
create_attribute("length_mode","Transition length mode","Length mode","seconds",{"seconds","fraction"});
create_attribute("time_mode","Time mode","time mode","absolute",{"absolute","relative"});
create_parameter("transition_length","number","transition length","Transition length",-1.0f,0.0f,0.0f);