Skip to content

Commit

Permalink
Merge pull request #628 from ferdnyc/bindings-tweaks
Browse files Browse the repository at this point in the history
Tweak the Python bindings for KeyFrame, Fraction
  • Loading branch information
ferdnyc committed Jan 29, 2021
2 parents 6852d15 + 3ac7eb8 commit 0d522e1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 30 deletions.
5 changes: 3 additions & 2 deletions bindings/python/openshot.i
Expand Up @@ -156,6 +156,7 @@
%{
#include <sstream>
#include <map>
#include <vector>

static std::vector<std::string> _keys{"num", "den"};
static int fracError = 0;
Expand All @@ -179,7 +180,7 @@
}
}
const std::string __getitem__(int index) {
if (index < _keys.size()) {
if (index < static_cast<int>(_keys.size())) {
return _keys[index];
}
/* Otherwise, raise an exception */
Expand All @@ -206,7 +207,7 @@
return map1;
}
/* Display methods */
const std::string __string__() {
const std::string __str__() {
std::ostringstream result;
result << $self->num << ":" << $self->den;
return result.str();
Expand Down
7 changes: 0 additions & 7 deletions src/KeyFrame.cpp
Expand Up @@ -128,13 +128,6 @@ Keyframe::Keyframe(double value) {
// Constructor which takes a vector of Points
Keyframe::Keyframe(const std::vector<openshot::Point>& points) : Points(points) {};

// Constructor which takes a vector of std::pair tuples (and adds them all)
Keyframe::Keyframe(const std::vector<openshot::Coordinate>& coordinates) {
for (const auto& co : coordinates) {
AddPoint(Point(co));
}
}

// Add a new point on the key-frame. Each point has a primary coordinate,
// a left handle, and a right handle.
void Keyframe::AddPoint(Point p) {
Expand Down
8 changes: 1 addition & 7 deletions src/KeyFrame.h
Expand Up @@ -62,20 +62,14 @@ namespace openshot {
std::vector<Point> Points; ///< Vector of all Points

public:
using CoordinateVec = std::vector<Coordinate>;
using PointsVec = std::vector<Point>;

/// Default constructor for the Keyframe class
Keyframe() = default;

/// Constructor which sets the default point & coordinate at X=1
Keyframe(double value);

/// Constructor which adds a supplied vector of Points
Keyframe(const PointsVec& points);

/// Constructor which takes a vector of std::pair tuples
Keyframe(const CoordinateVec& coordinates);
Keyframe(const std::vector<openshot::Point>& points);

/// Add a new point on the key-frame. Each point has a primary coordinate, a left handle, and a right handle.
void AddPoint(Point p);
Expand Down
14 changes: 0 additions & 14 deletions tests/KeyFrame_Tests.cpp
Expand Up @@ -510,18 +510,4 @@ TEST(Point_Vector_Constructor)
CHECK_CLOSE(30.0f, k1.GetValue(10), 0.0001);
}

TEST(Coordinate_Vector_Constructor)
{
std::vector<Coordinate> coordinates{
Coordinate(1, 100), Coordinate(10, 500), Coordinate(1000, 80000)
};
Keyframe k1(coordinates);

CHECK_EQUAL(1001, k1.GetLength());

auto p1 = k1.GetPoint(2);
CHECK_CLOSE(80000.0f, p1.co.Y, 0.00001);
}


}; // SUITE

0 comments on commit 0d522e1

Please sign in to comment.