diff --git a/src/EffectBase.cpp b/src/EffectBase.cpp index dd57e8bb..d833b8cb 100644 --- a/src/EffectBase.cpp +++ b/src/EffectBase.cpp @@ -185,12 +185,15 @@ Json::Value EffectBase::BasePropertiesJSON(int64_t requested_frame) const { 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"] = add_property_json("Apply Before Clip Keyframes", info.apply_before_clip, "int", "", NULL, 0, 1, false, requested_frame); 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)); + // Set the parent effect which properties this effect will inherit + root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); + return root; } diff --git a/src/effects/Bars.cpp b/src/effects/Bars.cpp index b7704f95..da5b7036 100644 --- a/src/effects/Bars.cpp +++ b/src/effects/Bars.cpp @@ -172,9 +172,6 @@ std::string Bars::PropertiesJSON(int64_t requested_frame) const { root["right"] = add_property_json("Right Size", right.GetValue(requested_frame), "float", "", &right, 0.0, 0.5, false, requested_frame); root["bottom"] = add_property_json("Bottom Size", bottom.GetValue(requested_frame), "float", "", &bottom, 0.0, 0.5, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Blur.cpp b/src/effects/Blur.cpp index c6f0b8db..d1ffe053 100644 --- a/src/effects/Blur.cpp +++ b/src/effects/Blur.cpp @@ -219,9 +219,6 @@ std::string Blur::PropertiesJSON(int64_t requested_frame) const { root["sigma"] = add_property_json("Sigma", sigma.GetValue(requested_frame), "float", "", &sigma, 0, 100, false, requested_frame); root["iterations"] = add_property_json("Iterations", iterations.GetValue(requested_frame), "float", "", &iterations, 0, 100, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Brightness.cpp b/src/effects/Brightness.cpp index fe599c2f..5fdf7f84 100644 --- a/src/effects/Brightness.cpp +++ b/src/effects/Brightness.cpp @@ -152,9 +152,6 @@ std::string Brightness::PropertiesJSON(int64_t requested_frame) const { root["brightness"] = add_property_json("Brightness", brightness.GetValue(requested_frame), "float", "", &brightness, -1.0, 1.0, false, requested_frame); root["contrast"] = add_property_json("Contrast", contrast.GetValue(requested_frame), "float", "", &contrast, -128, 128.0, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Caption.cpp b/src/effects/Caption.cpp index 8f6e3e57..8e36dbc5 100644 --- a/src/effects/Caption.cpp +++ b/src/effects/Caption.cpp @@ -484,9 +484,6 @@ std::string Caption::PropertiesJSON(int64_t requested_frame) const { root["caption_text"] = add_property_json("Captions", 0.0, "caption", caption_text, NULL, -1, -1, false, requested_frame); root["caption_font"] = add_property_json("Font", 0.0, "font", font_name, NULL, -1, -1, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/ChromaKey.cpp b/src/effects/ChromaKey.cpp index 731e4fc1..41421eac 100644 --- a/src/effects/ChromaKey.cpp +++ b/src/effects/ChromaKey.cpp @@ -595,9 +595,6 @@ std::string ChromaKey::PropertiesJSON(int64_t requested_frame) const { root["keymethod"]["choices"].append(add_property_choice_json("CIE Distance", 9, method)); root["keymethod"]["choices"].append(add_property_choice_json("Cb,Cr vector", 10, method)); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/ColorShift.cpp b/src/effects/ColorShift.cpp index a1f6cad2..a0f056c0 100644 --- a/src/effects/ColorShift.cpp +++ b/src/effects/ColorShift.cpp @@ -258,9 +258,6 @@ std::string ColorShift::PropertiesJSON(int64_t requested_frame) const { root["alpha_x"] = add_property_json("Alpha X Shift", alpha_x.GetValue(requested_frame), "float", "", &alpha_x, -1, 1, false, requested_frame); root["alpha_y"] = add_property_json("Alpha Y Shift", alpha_y.GetValue(requested_frame), "float", "", &alpha_y, -1, 1, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Crop.cpp b/src/effects/Crop.cpp index 7967d556..aada4968 100644 --- a/src/effects/Crop.cpp +++ b/src/effects/Crop.cpp @@ -29,7 +29,7 @@ Crop::Crop( Keyframe left, Keyframe top, Keyframe right, Keyframe bottom, Keyframe x, Keyframe y) : - left(left), top(top), right(right), bottom(bottom), x(x), y(y) + left(left), top(top), right(right), bottom(bottom), x(x), y(y), resize(false) { // Init effect properties init_effect_details(); @@ -99,14 +99,17 @@ std::shared_ptr Crop::GetFrame(std::shared_ptr QImage cropped(sz, QImage::Format_RGBA8888_Premultiplied); cropped.fill(Qt::transparent); - const QImage src(*frame_image); - QPainter p(&cropped); - p.drawImage(paint_r, src, copy_r); + p.drawImage(paint_r, *frame_image, copy_r); p.end(); - // Set frame image - frame->AddImage(std::make_shared(cropped.copy())); + if (resize) { + // Resize image to match cropped QRect (reduce frame size) + frame->AddImage(std::make_shared(cropped.copy(paint_r.toRect()))); + } else { + // Copy cropped image into transparent frame image (maintain frame size) + frame->AddImage(std::make_shared(cropped.copy())); + } // return the modified frame return frame; @@ -131,6 +134,7 @@ Json::Value Crop::JsonValue() const { root["bottom"] = bottom.JsonValue(); root["x"] = x.JsonValue(); root["y"] = y.JsonValue(); + root["resize"] = resize; // return JsonValue return root; @@ -172,6 +176,8 @@ void Crop::SetJsonValue(const Json::Value root) { x.SetJsonValue(root["x"]); if (!root["y"].isNull()) y.SetJsonValue(root["y"]); + if (!root["resize"].isNull()) + resize = root["resize"].asBool(); } // Get all properties for a specific frame @@ -188,8 +194,10 @@ std::string Crop::PropertiesJSON(int64_t requested_frame) const { root["x"] = add_property_json("X Offset", x.GetValue(requested_frame), "float", "", &x, -1.0, 1.0, false, requested_frame); root["y"] = add_property_json("Y Offset", y.GetValue(requested_frame), "float", "", &y, -1.0, 1.0, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); + // Add replace_image choices (dropdown style) + root["resize"] = add_property_json("Resize Image", resize, "int", "", NULL, 0, 1, false, requested_frame); + root["resize"]["choices"].append(add_property_choice_json("Yes", true, resize)); + root["resize"]["choices"].append(add_property_choice_json("No", false, resize)); // Return formatted string return root.toStyledString(); diff --git a/src/effects/Crop.h b/src/effects/Crop.h index a21391ab..9d03a8dc 100644 --- a/src/effects/Crop.h +++ b/src/effects/Crop.h @@ -46,8 +46,9 @@ namespace openshot Keyframe top; ///< Size of top bar Keyframe right; ///< Size of right bar Keyframe bottom; ///< Size of bottom bar - Keyframe x; ///< X-offset - Keyframe y; ///< Y-offset + Keyframe x; ///< X-offset + Keyframe y; ///< Y-offset + bool resize; ///< Auto-resize image after crop operation /// Blank constructor, useful when using Json to load the effect properties Crop(); @@ -58,10 +59,10 @@ namespace openshot /// @param top The curve to adjust the top bar size (between 0 and 1) /// @param right The curve to adjust the right bar size (between 0 and 1) /// @param bottom The curve to adjust the bottom bar size (between 0 and 1) - /// @param x x-offset of original image in output frame (-1.0 - 1.0) - /// @param y y-offset of original image in output frame (-1.0 - 1.0) + /// @param x x-offset of original image in output frame (-1.0 - 1.0) + /// @param y y-offset of original image in output frame (-1.0 - 1.0) Crop(Keyframe left, Keyframe top, Keyframe right, Keyframe bottom, - Keyframe x=0.0, Keyframe y=0.0); + Keyframe x=0.0, Keyframe y=0.0); /// @brief This method is required for all derived classes of ClipBase, and returns a /// new openshot::Frame object. All Clip keyframes and effects are resolved into @@ -70,9 +71,9 @@ namespace openshot /// @returns A new openshot::Frame object /// @param frame_number The frame number (starting at 1) of the clip or effect on the timeline. std::shared_ptr - GetFrame(int64_t frame_number) override { - return GetFrame(std::make_shared(), frame_number); - } + GetFrame(int64_t frame_number) override { + return GetFrame(std::make_shared(), frame_number); + } /// @brief This method is required for all derived classes of ClipBase, and returns a /// modified openshot::Frame object @@ -84,7 +85,7 @@ namespace openshot /// @param frame The frame object that needs the clip or effect applied to it /// @param frame_number The frame number (starting at 1) of the clip or effect on the timeline. std::shared_ptr - GetFrame(std::shared_ptr frame, int64_t frame_number) override; + GetFrame(std::shared_ptr frame, int64_t frame_number) override; // Get and Set JSON methods std::string Json() const override; ///< Generate JSON string of this object diff --git a/src/effects/Deinterlace.cpp b/src/effects/Deinterlace.cpp index 13a3293f..9a1a67e3 100644 --- a/src/effects/Deinterlace.cpp +++ b/src/effects/Deinterlace.cpp @@ -138,9 +138,6 @@ std::string Deinterlace::PropertiesJSON(int64_t requested_frame) const { root["isOdd"]["choices"].append(add_property_choice_json("Yes", true, isOdd)); root["isOdd"]["choices"].append(add_property_choice_json("No", false, isOdd)); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Hue.cpp b/src/effects/Hue.cpp index 22b16fcf..12a64a39 100644 --- a/src/effects/Hue.cpp +++ b/src/effects/Hue.cpp @@ -149,9 +149,6 @@ std::string Hue::PropertiesJSON(int64_t requested_frame) const { // Keyframes root["hue"] = add_property_json("Hue", hue.GetValue(requested_frame), "float", "", &hue, 0.0, 1.0, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Mask.cpp b/src/effects/Mask.cpp index 28e998d8..3f111803 100644 --- a/src/effects/Mask.cpp +++ b/src/effects/Mask.cpp @@ -275,9 +275,6 @@ std::string Mask::PropertiesJSON(int64_t requested_frame) const { else root["reader"] = add_property_json("Source", 0.0, "reader", "{}", NULL, 0, 1, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Negate.cpp b/src/effects/Negate.cpp index 95f64eee..c51ee1e5 100644 --- a/src/effects/Negate.cpp +++ b/src/effects/Negate.cpp @@ -89,9 +89,6 @@ std::string Negate::PropertiesJSON(int64_t requested_frame) const { // Generate JSON properties list Json::Value root = BasePropertiesJSON(requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Pixelate.cpp b/src/effects/Pixelate.cpp index ad0f79a7..76cc3c39 100644 --- a/src/effects/Pixelate.cpp +++ b/src/effects/Pixelate.cpp @@ -161,9 +161,6 @@ std::string Pixelate::PropertiesJSON(int64_t requested_frame) const { root["right"] = add_property_json("Right Margin", right.GetValue(requested_frame), "float", "", &right, 0.0, 1.0, false, requested_frame); root["bottom"] = add_property_json("Bottom Margin", bottom.GetValue(requested_frame), "float", "", &bottom, 0.0, 1.0, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Saturation.cpp b/src/effects/Saturation.cpp index 88aeaf03..2e06db9e 100644 --- a/src/effects/Saturation.cpp +++ b/src/effects/Saturation.cpp @@ -215,9 +215,6 @@ std::string Saturation::PropertiesJSON(int64_t requested_frame) const { root["saturation_G"] = add_property_json("Saturation (Green)", saturation_G.GetValue(requested_frame), "float", "", &saturation_G, 0.0, 4.0, false, requested_frame); root["saturation_B"] = add_property_json("Saturation (Blue)", saturation_B.GetValue(requested_frame), "float", "", &saturation_B, 0.0, 4.0, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Shift.cpp b/src/effects/Shift.cpp index c4d5d28f..e99570a2 100644 --- a/src/effects/Shift.cpp +++ b/src/effects/Shift.cpp @@ -175,9 +175,6 @@ std::string Shift::PropertiesJSON(int64_t requested_frame) const { root["x"] = add_property_json("X Shift", x.GetValue(requested_frame), "float", "", &x, -1, 1, false, requested_frame); root["y"] = add_property_json("Y Shift", y.GetValue(requested_frame), "float", "", &y, -1, 1, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Stabilizer.cpp b/src/effects/Stabilizer.cpp index 6944a5d7..998730fb 100644 --- a/src/effects/Stabilizer.cpp +++ b/src/effects/Stabilizer.cpp @@ -217,9 +217,6 @@ std::string Stabilizer::PropertiesJSON(int64_t requested_frame) const { root["zoom"] = add_property_json("Zoom", zoom.GetValue(requested_frame), "float", "", &zoom, 0.0, 2.0, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); } diff --git a/src/effects/Wave.cpp b/src/effects/Wave.cpp index 0f77c8cd..286cb632 100644 --- a/src/effects/Wave.cpp +++ b/src/effects/Wave.cpp @@ -163,9 +163,6 @@ std::string Wave::PropertiesJSON(int64_t requested_frame) const { root["shift_x"] = add_property_json("X Shift", shift_x.GetValue(requested_frame), "float", "", &shift_x, 0.0, 1000.0, false, requested_frame); root["speed_y"] = add_property_json("Vertical speed", speed_y.GetValue(requested_frame), "float", "", &speed_y, 0.0, 300.0, false, requested_frame); - // Set the parent effect which properties this effect will inherit - root["parent_effect_id"] = add_property_json("Parent", 0.0, "string", info.parent_effect_id, NULL, -1, -1, false, requested_frame); - // Return formatted string return root.toStyledString(); }