Skip to content

Commit

Permalink
Coordinate: Add std::pair constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Dec 4, 2020
1 parent 2a9cf28 commit d6892dd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Coordinate.cpp
Expand Up @@ -33,16 +33,15 @@

using namespace openshot;

// Default constructor for a coordinate, which defaults the X and Y to zero (0,0)
Coordinate::Coordinate() :
X(0), Y(0) {
}
// Default constructor for a coordinate, delegating to the full signature
Coordinate::Coordinate() : Coordinate::Coordinate(0, 0) {};

// Constructor which also allows the user to set the X and Y
Coordinate::Coordinate(double x, double y) :
X(x), Y(y) {
}
Coordinate::Coordinate(double x, double y) : X(x), Y(y) {};

// Constructor which accepts a std::pair for (X, Y)
Coordinate::Coordinate(const std::pair<int, int>& co)
: X(co.first), Y(co.second) {};

// Generate JSON string of this object
std::string Coordinate::Json() const {
Expand Down
4 changes: 4 additions & 0 deletions src/Coordinate.h
Expand Up @@ -63,6 +63,10 @@ namespace openshot {
/// @param y The Y coordinate (usually representing the value of the property being animated)
Coordinate(double x, double y);

/// @brief Constructor which accepts a std::pair tuple for {X, Y}
/// @param co A std::pair<int, int> tuple containing (X, Y)
Coordinate(const std::pair<int, int>& co);

/// Get and Set JSON methods
std::string Json() const; ///< Generate JSON string of this object
Json::Value JsonValue() const; ///< Generate Json::Value for this object
Expand Down

0 comments on commit d6892dd

Please sign in to comment.