You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Refactor base JSON properties into EffectBase - to reduce duplication in code
This commit is contained in:
@@ -175,6 +175,25 @@ Json::Value EffectBase::JsonInfo() const {
|
||||
return root;
|
||||
}
|
||||
|
||||
// Get all properties for a specific frame
|
||||
Json::Value EffectBase::BasePropertiesJSON(int64_t requested_frame) const {
|
||||
// Generate JSON properties list
|
||||
Json::Value root;
|
||||
root["id"] = add_property_json("ID", 0.0, "string", Id(), NULL, -1, -1, true, requested_frame);
|
||||
root["position"] = add_property_json("Position", Position(), "float", "", NULL, 0, 30 * 60 * 60 * 48, false, requested_frame);
|
||||
root["layer"] = add_property_json("Track", Layer(), "int", "", NULL, 0, 20, false, requested_frame);
|
||||
root["start"] = add_property_json("Start", Start(), "float", "", NULL, 0, 30 * 60 * 60 * 48, false, requested_frame);
|
||||
root["end"] = add_property_json("End", End(), "float", "", NULL, 0, 30 * 60 * 60 * 48, false, requested_frame);
|
||||
root["duration"] = add_property_json("Duration", Duration(), "float", "", NULL, 0, 30 * 60 * 60 * 48, true, requested_frame);
|
||||
root["apply_before_clip"] = add_property_json("Apply Before Clip Keyframes", info.apply_before_clip, "int", "", NULL, 0, 1, false, requested_frame);
|
||||
|
||||
// Add replace_image choices (dropdown style)
|
||||
root["apply_before_clip"]["choices"].append(add_property_choice_json("Yes", true, info.apply_before_clip));
|
||||
root["apply_before_clip"]["choices"].append(add_property_choice_json("No", false, info.apply_before_clip));
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
/// Parent clip object of this reader (which can be unparented and NULL)
|
||||
openshot::ClipBase* EffectBase::ParentClip() {
|
||||
return clip;
|
||||
|
||||
@@ -106,7 +106,11 @@ namespace openshot
|
||||
return;
|
||||
};
|
||||
|
||||
Json::Value JsonInfo() const; ///< Generate JSON object of meta data / info
|
||||
/// Generate JSON object of meta data / info
|
||||
Json::Value JsonInfo() const;
|
||||
|
||||
/// Generate JSON object of base properties (recommended to be used by all effects)
|
||||
Json::Value BasePropertiesJSON(int64_t requested_frame) const;
|
||||
|
||||
/// Get the order that this effect should be executed.
|
||||
int Order() const { return order; }
|
||||
|
||||
@@ -255,17 +255,10 @@ void Mask::SetJsonValue(const Json::Value root) {
|
||||
std::string Mask::PropertiesJSON(int64_t requested_frame) const {
|
||||
|
||||
// Generate JSON properties list
|
||||
Json::Value root;
|
||||
root["id"] = add_property_json("ID", 0.0, "string", Id(), NULL, -1, -1, true, requested_frame);
|
||||
root["position"] = add_property_json("Position", Position(), "float", "", NULL, 0, 30 * 60 * 60 * 48, false, requested_frame);
|
||||
root["layer"] = add_property_json("Track", Layer(), "int", "", NULL, 0, 20, false, requested_frame);
|
||||
root["start"] = add_property_json("Start", Start(), "float", "", NULL, 0, 30 * 60 * 60 * 48, false, requested_frame);
|
||||
root["end"] = add_property_json("End", End(), "float", "", NULL, 0, 30 * 60 * 60 * 48, false, requested_frame);
|
||||
root["duration"] = add_property_json("Duration", Duration(), "float", "", NULL, 0, 30 * 60 * 60 * 48, true, requested_frame);
|
||||
root["replace_image"] = add_property_json("Replace Image", replace_image, "int", "", NULL, 0, 1, false, requested_frame);
|
||||
root["apply_before_clip"] = add_property_json("Apply Before Clip Keyframes", info.apply_before_clip, "int", "", NULL, 0, 1, false, requested_frame);
|
||||
Json::Value root = BasePropertiesJSON(requested_frame);
|
||||
|
||||
// Add replace_image choices (dropdown style)
|
||||
root["replace_image"] = add_property_json("Replace Image", replace_image, "int", "", NULL, 0, 1, false, requested_frame);
|
||||
root["replace_image"]["choices"].append(add_property_choice_json("Yes", true, replace_image));
|
||||
root["replace_image"]["choices"].append(add_property_choice_json("No", false, replace_image));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user