Skip to content

Commit

Permalink
Made gui2::point implicitly convertible to SDL_Point
Browse files Browse the repository at this point in the history
I'm planning on moving this out of the GUI2 namespace and this will allow point objects
to be used with SDL functions that take SDL_Point arguments.
  • Loading branch information
Vultraz committed Nov 11, 2017
1 parent 68ed124 commit 04ffa26
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/gui/core/point.cpp
Expand Up @@ -20,6 +20,10 @@

namespace gui2
{
point::operator SDL_Point()
{
return {x, y};
}

point& point::operator+=(const point& point)
{
Expand Down
5 changes: 5 additions & 0 deletions src/gui/core/point.hpp
Expand Up @@ -14,6 +14,8 @@

#pragma once

#include <SDL_rect.h>

#include <iosfwd>

namespace gui2
Expand All @@ -36,6 +38,9 @@ struct point
/** y coordinate. */
int y;

/** Allow implicit conversion to SDL_Point. */
operator SDL_Point();

bool operator==(const point& point) const
{
return x == point.x && y == point.y;
Expand Down

0 comments on commit 04ffa26

Please sign in to comment.