Made gui2::point implicitly convertible to SDL_Point
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.
This commit is contained in:
parent
68ed124449
commit
04ffa265d1
2 changed files with 9 additions and 0 deletions
|
@ -20,6 +20,10 @@
|
|||
|
||||
namespace gui2
|
||||
{
|
||||
point::operator SDL_Point()
|
||||
{
|
||||
return {x, y};
|
||||
}
|
||||
|
||||
point& point::operator+=(const point& point)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <SDL_rect.h>
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
namespace gui2
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue