Added new clip method that returns all properties for a given frame in JSON.

This commit is contained in:
Jonathan Thomas
2015-02-09 22:41:42 -06:00
parent 5290d0177b
commit 5145abdacb
4 changed files with 78 additions and 0 deletions

View File

@@ -522,6 +522,57 @@ string Clip::Json() {
return JsonValue().toStyledString();
}
// Get all properties for a specific frame
string Clip::PropertiesJSON(int requested_frame) {
// Requested Point
Point requested_point(requested_frame, requested_frame);
// Generate JSON properties list
Json::Value root;
root["id"] = add_property_json("ID", 0.0, "string", Id(), false, -1, -1, true);
root["position"] = add_property_json("Position", Position(), "int", "", false, 0, 1000 * 60 * 30, false);
root["layer"] = add_property_json("Layer", Layer(), "int", "", false, 0, 1000, false);
root["start"] = add_property_json("Start", Start(), "float", "", false, 0, 1000 * 60 * 30, false);
root["end"] = add_property_json("End", End(), "float", "", false, 0, 1000 * 60 * 30, false);
root["duration"] = add_property_json("Duration", Duration(), "float", "", false, 0, 1000 * 60 * 30, false);
root["gravity"] = add_property_json("Gravity", gravity, "int", "", false, -1, -1, false);
root["scale"] = add_property_json("Scale", scale, "int", "", false, -1, -1, false);
root["anchor"] = add_property_json("Anchor", anchor, "int", "", false, -1, -1, false);
root["waveform"] = add_property_json("Waveform", waveform, "int", "", false, -1, -1, false);
// Keyframes
root["location_x"] = add_property_json("Location X", location_x.GetValue(requested_frame), "float", "", location_x.Contains(requested_point), -10000, 10000, false);
root["location_y"] = add_property_json("Location Y", location_y.GetValue(requested_frame), "float", "", location_y.Contains(requested_point), -10000, 10000, false);
root["scale_x"] = add_property_json("Scale X", scale_x.GetValue(requested_frame), "float", "", scale_x.Contains(requested_point), 0.0, 100.0, false);
root["scale_y"] = add_property_json("Scale Y", scale_y.GetValue(requested_frame), "float", "", scale_y.Contains(requested_point), 0.0, 100.0, false);
root["alpha"] = add_property_json("Alpha", alpha.GetValue(requested_frame), "float", "", alpha.Contains(requested_point), 0.0, 1.0, false);
root["rotation"] = add_property_json("Rotation", rotation.GetValue(requested_frame), "float", "", rotation.Contains(requested_point), -10000, 10000, false);
root["volume"] = add_property_json("Volume", volume.GetValue(requested_frame), "float", "", volume.Contains(requested_point), 0.0, 1.0, false);
root["time"] = add_property_json("Time", time.GetValue(requested_frame), "float", "", time.Contains(requested_point), 0.0, 1000 * 60 * 30, false);
// Return formatted string
return root.toStyledString();
}
// Generate JSON for a property
Json::Value Clip::add_property_json(string name, float value, string type, string memo, bool contains_point, float min_value, float max_value, bool readonly) {
// Create JSON Object
Json::Value prop = Json::Value(Json::objectValue);
prop["name"] = name;
prop["value"] = value;
prop["memo"] = memo;
prop["type"] = value;
prop["min"] = min_value;
prop["max"] = max_value;
prop["keyframe"] = contains_point;
prop["readonly"] = max_value;
// return JsonValue
return prop;
}
// Generate Json::JsonValue for this object
Json::Value Clip::JsonValue() {