diff --git a/include/ClipBase.h b/include/ClipBase.h index 38994308..c4cd4c46 100644 --- a/include/ClipBase.h +++ b/include/ClipBase.h @@ -61,6 +61,9 @@ namespace openshot { /// Generate JSON for a property Json::Value add_property_json(string name, float value, string type, string memo, bool contains_point, int number_of_points, float min_value, float max_value, InterpolationType intepolation, int closest_point_x, bool readonly); + /// Generate JSON choice for a property (dropdown properties) + Json::Value add_property_choice_json(string name, int value, int selected_value); + public: // Compare a clip using the Position() property diff --git a/src/Clip.cpp b/src/Clip.cpp index 585c1d24..dadf1b10 100644 --- a/src/Clip.cpp +++ b/src/Clip.cpp @@ -553,6 +553,31 @@ string Clip::PropertiesJSON(long int requested_frame) { root["anchor"] = add_property_json("Anchor", anchor, "int", "", false, 0, -1, -1, CONSTANT, -1, false); root["waveform"] = add_property_json("Waveform", waveform, "bool", "", false, 0, -1, -1, CONSTANT, -1, false); + // Add gravity choices (dropdown style) + root["gravity"]["choices"].append(add_property_choice_json("Top Left", GRAVITY_TOP_LEFT, gravity)); + root["gravity"]["choices"].append(add_property_choice_json("Top Center", GRAVITY_TOP, gravity)); + root["gravity"]["choices"].append(add_property_choice_json("Top Right", GRAVITY_TOP_RIGHT, gravity)); + root["gravity"]["choices"].append(add_property_choice_json("Left", GRAVITY_LEFT, gravity)); + root["gravity"]["choices"].append(add_property_choice_json("Center", GRAVITY_CENTER, gravity)); + root["gravity"]["choices"].append(add_property_choice_json("Right", GRAVITY_RIGHT, gravity)); + root["gravity"]["choices"].append(add_property_choice_json("Bottom Left", GRAVITY_BOTTOM_LEFT, gravity)); + root["gravity"]["choices"].append(add_property_choice_json("Bottom Center", GRAVITY_BOTTOM, gravity)); + root["gravity"]["choices"].append(add_property_choice_json("Bottom Right", GRAVITY_BOTTOM_RIGHT, gravity)); + + // Add scale choices (dropdown style) + root["scale"]["choices"].append(add_property_choice_json("Crop", SCALE_CROP, scale)); + root["scale"]["choices"].append(add_property_choice_json("Best Fit", SCALE_FIT, scale)); + root["scale"]["choices"].append(add_property_choice_json("Stretch", SCALE_STRETCH, scale)); + root["scale"]["choices"].append(add_property_choice_json("None", SCALE_NONE, scale)); + + // Add anchor choices (dropdown style) + root["anchor"]["choices"].append(add_property_choice_json("Canvas", ANCHOR_CANVAS, anchor)); + root["anchor"]["choices"].append(add_property_choice_json("Viewport", ANCHOR_VIEWPORT, anchor)); + + // Add waveform choices (dropdown style) + root["waveform"]["choices"].append(add_property_choice_json("Yes", true, waveform)); + root["waveform"]["choices"].append(add_property_choice_json("No", false, waveform)); + // Keyframes root["location_x"] = add_property_json("Location X", location_x.GetValue(requested_frame), "float", "", location_x.Contains(requested_point), location_x.GetCount(), -10000, 10000, location_x.GetClosestPoint(requested_point).interpolation, location_x.GetClosestPoint(requested_point).co.X, false); root["location_y"] = add_property_json("Location Y", location_y.GetValue(requested_frame), "float", "", location_y.Contains(requested_point), location_y.GetCount(), -10000, 10000, location_y.GetClosestPoint(requested_point).interpolation, location_y.GetClosestPoint(requested_point).co.X, false); diff --git a/src/ClipBase.cpp b/src/ClipBase.cpp index 566b7b87..66363284 100644 --- a/src/ClipBase.cpp +++ b/src/ClipBase.cpp @@ -77,7 +77,20 @@ Json::Value ClipBase::add_property_json(string name, float value, string type, s prop["readonly"] = readonly; prop["interpolation"] = intepolation; prop["closest_point_x"] = closest_point_x; + prop["choices"] = Json::Value(Json::arrayValue); // return JsonValue return prop; } + +Json::Value ClipBase::add_property_choice_json(string name, int value, int selected_value) { + + // Create choice + Json::Value new_choice = Json::Value(Json::objectValue); + new_choice["name"] = name; + new_choice["value"] = value; + new_choice["selected"] = (value == selected_value); + + // return JsonValue + return new_choice; +} \ No newline at end of file diff --git a/src/KeyFrame.cpp b/src/KeyFrame.cpp index 75623dba..ab58096e 100644 --- a/src/KeyFrame.cpp +++ b/src/KeyFrame.cpp @@ -377,7 +377,6 @@ void Keyframe::SetJsonValue(Json::Value root) { if (!root["Auto_Handle_Percentage"].isNull()) Auto_Handle_Percentage = root["Auto_Handle_Percentage"].asBool(); - } // Get the fraction that represents how many times this value is repeated in the curve @@ -534,9 +533,12 @@ void Keyframe::Process() { #pragma omp critical (keyframe_process) { // only process if needed - if (needs_update && Points.size() > 0) + if (needs_update && Points.size() == 0) { + // Clear all values + Values.clear(); + } + else if (needs_update && Points.size() > 0) { - // Clear all values Values.clear(); diff --git a/src/bindings/python/openshot.i b/src/bindings/python/openshot.i index b12a0777..347fb264 100644 --- a/src/bindings/python/openshot.i +++ b/src/bindings/python/openshot.i @@ -65,6 +65,7 @@ #include "../../../include/EffectBase.h" #include "../../../include/Effects.h" #include "../../../include/EffectInfo.h" +#include "../../../include/Enums.h" #include "../../../include/Exceptions.h" #include "../../../include/FFmpegReader.h" #include "../../../include/FFmpegWriter.h" @@ -112,6 +113,7 @@ %include "../../../include/EffectBase.h" %include "../../../include/Effects.h" %include "../../../include/EffectInfo.h" +%include "../../../include/Enums.h" %include "../../../include/Exceptions.h" %include "../../../include/FFmpegReader.h" %include "../../../include/FFmpegWriter.h" diff --git a/src/bindings/ruby/openshot.i b/src/bindings/ruby/openshot.i index 52488d4f..4264462c 100644 --- a/src/bindings/ruby/openshot.i +++ b/src/bindings/ruby/openshot.i @@ -71,6 +71,7 @@ namespace tr1 #include "../../../include/EffectBase.h" #include "../../../include/Effects.h" #include "../../../include/EffectInfo.h" +#include "../../../include/Enums.h" #include "../../../include/Exceptions.h" #include "../../../include/FFmpegReader.h" #include "../../../include/FFmpegWriter.h" @@ -118,6 +119,7 @@ namespace tr1 %include "../../../include/EffectBase.h" %include "../../../include/Effects.h" %include "../../../include/EffectInfo.h" +%include "../../../include/Enums.h" %include "../../../include/Exceptions.h" %include "../../../include/FFmpegReader.h" %include "../../../include/FFmpegWriter.h" diff --git a/src/effects/Brightness.cpp b/src/effects/Brightness.cpp index 59526e04..247bec49 100644 --- a/src/effects/Brightness.cpp +++ b/src/effects/Brightness.cpp @@ -30,13 +30,9 @@ using namespace openshot; /// Blank constructor, useful when using Json to load the effect properties -Brightness::Brightness() { +Brightness::Brightness() : brightness(0.0), contrast(3.0) { // Init effect properties init_effect_details(); - - // Init curves - brightness = Keyframe(0.0); - contrast = Keyframe(3.0); } // Default constructor diff --git a/src/effects/ChromaKey.cpp b/src/effects/ChromaKey.cpp index e8d43c79..2a8467f2 100644 --- a/src/effects/ChromaKey.cpp +++ b/src/effects/ChromaKey.cpp @@ -30,7 +30,7 @@ using namespace openshot; /// Blank constructor, useful when using Json to load the effect properties -ChromaKey::ChromaKey() : fuzz(0.0) { +ChromaKey::ChromaKey() : fuzz(5.0) { // Init default color color = Color(); diff --git a/src/effects/Deinterlace.cpp b/src/effects/Deinterlace.cpp index df3ff5d4..25e42872 100644 --- a/src/effects/Deinterlace.cpp +++ b/src/effects/Deinterlace.cpp @@ -161,6 +161,10 @@ string Deinterlace::PropertiesJSON(long int requested_frame) { root["duration"] = add_property_json("Duration", Duration(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, true); root["isOdd"] = add_property_json("Is Odd Frame", isOdd, "bool", "", false, 0, 0, 1, CONSTANT, -1, true); + // Add Is Odd Frame choices (dropdown style) + root["isOdd"]["choices"].append(add_property_choice_json("Yes", true, isOdd)); + root["isOdd"]["choices"].append(add_property_choice_json("No", false, isOdd)); + // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Mask.cpp b/src/effects/Mask.cpp index 8389eadd..b2775000 100644 --- a/src/effects/Mask.cpp +++ b/src/effects/Mask.cpp @@ -280,6 +280,10 @@ string Mask::PropertiesJSON(long int requested_frame) { root["duration"] = add_property_json("Duration", Duration(), "float", "", false, 0, 0, 1000 * 60 * 30, CONSTANT, -1, true); root["replace_image"] = add_property_json("Replace Image", replace_image, "bool", "", false, 0, 0, 1, CONSTANT, -1, false); + // Add replace_image choices (dropdown style) + 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)); + // Keyframes root["brightness"] = add_property_json("Brightness", brightness.GetValue(requested_frame), "float", "", brightness.Contains(requested_point), brightness.GetCount(), -10000, 10000, brightness.GetClosestPoint(requested_point).interpolation, brightness.GetClosestPoint(requested_point).co.X, false); root["contrast"] = add_property_json("Contrast", contrast.GetValue(requested_frame), "float", "", contrast.Contains(requested_point), contrast.GetCount(), -10000, 10000, contrast.GetClosestPoint(requested_point).interpolation, contrast.GetClosestPoint(requested_point).co.X, false); diff --git a/src/effects/Saturation.cpp b/src/effects/Saturation.cpp index ff789d17..7a404901 100644 --- a/src/effects/Saturation.cpp +++ b/src/effects/Saturation.cpp @@ -30,12 +30,9 @@ using namespace openshot; /// Blank constructor, useful when using Json to load the effect properties -Saturation::Saturation() { +Saturation::Saturation() : saturation(1.0) { // Init effect properties init_effect_details(); - - // Init curves - saturation = Keyframe(1.0); } // Default constructor