2013-12-06 00:40:26 -06:00
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
* @brief Source file for EffectBase class
|
|
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
|
|
|
|
*
|
|
|
|
|
* @section LICENSE
|
|
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* Copyright (c) 2008-2014 OpenShot Studios, LLC
|
|
|
|
|
* <http://www.openshotstudios.com/>. This file is part of
|
|
|
|
|
* OpenShot Library (libopenshot), an open-source project dedicated to
|
|
|
|
|
* delivering high quality video editing and animation solutions to the
|
|
|
|
|
* world. For more information visit <http://www.openshot.org/>.
|
2013-12-06 00:40:26 -06:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* OpenShot Library (libopenshot) is free software: you can redistribute it
|
2014-07-11 16:52:14 -05:00
|
|
|
* and/or modify it under the terms of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* as published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
2013-12-06 00:40:26 -06:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* OpenShot Library (libopenshot) is distributed in the hope that it will be
|
|
|
|
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2014-07-11 16:52:14 -05:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-12-06 00:40:26 -06:00
|
|
|
*
|
2014-07-11 16:52:14 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
2013-12-06 00:40:26 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "../include/ClipBase.h"
|
|
|
|
|
|
|
|
|
|
using namespace openshot;
|
|
|
|
|
|
|
|
|
|
// Generate Json::JsonValue for this object
|
|
|
|
|
Json::Value ClipBase::JsonValue() {
|
|
|
|
|
|
|
|
|
|
// Create root json object
|
|
|
|
|
Json::Value root;
|
2014-01-08 01:43:58 -06:00
|
|
|
root["id"] = Id();
|
2013-12-06 00:40:26 -06:00
|
|
|
root["position"] = Position();
|
|
|
|
|
root["layer"] = Layer();
|
|
|
|
|
root["start"] = Start();
|
|
|
|
|
root["end"] = End();
|
2014-01-27 23:31:38 -06:00
|
|
|
root["duration"] = Duration();
|
2013-12-06 00:40:26 -06:00
|
|
|
|
|
|
|
|
// return JsonValue
|
|
|
|
|
return root;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load Json::JsonValue into this object
|
2013-12-07 21:09:55 -06:00
|
|
|
void ClipBase::SetJsonValue(Json::Value root) {
|
2013-12-06 00:40:26 -06:00
|
|
|
|
|
|
|
|
// Set data from Json (if key is found)
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["id"].isNull())
|
|
|
|
|
Id(root["id"].asString());
|
|
|
|
|
if (!root["position"].isNull())
|
2013-12-06 00:40:26 -06:00
|
|
|
Position(root["position"].asDouble());
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["layer"].isNull())
|
2013-12-06 00:40:26 -06:00
|
|
|
Layer(root["layer"].asInt());
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["start"].isNull())
|
2013-12-06 00:40:26 -06:00
|
|
|
Start(root["start"].asDouble());
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["end"].isNull())
|
2013-12-06 00:40:26 -06:00
|
|
|
End(root["end"].asDouble());
|
|
|
|
|
}
|
2015-02-26 00:02:06 -06:00
|
|
|
|
|
|
|
|
// Generate JSON for a property
|
2016-10-19 02:19:07 -05:00
|
|
|
Json::Value ClipBase::add_property_json(string name, float value, string type, string memo, Keyframe* keyframe, float min_value, float max_value, bool readonly, long int requested_frame) {
|
|
|
|
|
|
|
|
|
|
// Requested Point
|
|
|
|
|
Point requested_point(requested_frame, requested_frame);
|
2015-02-26 00:02:06 -06:00
|
|
|
|
|
|
|
|
// Create JSON Object
|
|
|
|
|
Json::Value prop = Json::Value(Json::objectValue);
|
|
|
|
|
prop["name"] = name;
|
|
|
|
|
prop["value"] = value;
|
|
|
|
|
prop["memo"] = memo;
|
|
|
|
|
prop["type"] = type;
|
|
|
|
|
prop["min"] = min_value;
|
|
|
|
|
prop["max"] = max_value;
|
2016-10-19 02:19:07 -05:00
|
|
|
if (keyframe) {
|
|
|
|
|
prop["keyframe"] = keyframe->Contains(requested_point);
|
|
|
|
|
prop["points"] = int(keyframe->GetCount());
|
|
|
|
|
Point closest_point = keyframe->GetClosestPoint(requested_point);
|
|
|
|
|
prop["interpolation"] = closest_point.interpolation;
|
|
|
|
|
prop["closest_point_x"] = closest_point.co.X;
|
|
|
|
|
prop["previous_point_x"] = keyframe->GetPreviousPoint(closest_point).co.X;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
prop["keyframe"] = false;
|
|
|
|
|
prop["points"] = 0;
|
|
|
|
|
prop["interpolation"] = CONSTANT;
|
|
|
|
|
prop["closest_point_x"] = -1;
|
|
|
|
|
prop["previous_point_x"] = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-16 19:19:14 -05:00
|
|
|
prop["readonly"] = readonly;
|
2015-10-02 18:22:10 -05:00
|
|
|
prop["choices"] = Json::Value(Json::arrayValue);
|
2015-02-26 00:02:06 -06:00
|
|
|
|
|
|
|
|
// return JsonValue
|
|
|
|
|
return prop;
|
|
|
|
|
}
|
2015-10-02 18:22:10 -05:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|