You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Added dropdown choices into JSON properties, so a UI can correctly list the options for certain properties. Fixed a bug when deleting all Points from a Keyframe, and added some missing Enums from the Python/Ruby bindings.
This commit is contained in:
@@ -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
|
||||
|
||||
25
src/Clip.cpp
25
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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user