// Generated by gmmproc 2.80.0 -- DO NOT MODIFY!


#include <glibmm.h>

#include <gdkmm/graphene_rect.h>
#include <gdkmm/private/graphene_rect_p.h>


/* Copyright 2023 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

#include <graphene.h>

namespace
{
graphene_rect_t* gdkmm_graphene_rect_copy(const graphene_rect_t* other)
{
  return graphene_rect_init_from_rect(graphene_rect_alloc(), other);
}

using get_functype = void (*)(const graphene_rect_t* r, graphene_point_t* p);
using Point = Gdk::Graphene::Point;

Point get_point(const graphene_rect_t* r, get_functype get_func)
{
  graphene_point_t* p = graphene_point_alloc();
  get_func(r, p);
  return Point(p, false);
}
} // anonymous namespace

namespace Gdk
{
namespace Graphene
{

Rect::Rect(float x, float y, float width, float height)
{
  gobject_ = graphene_rect_init(graphene_rect_alloc(), x, y, width, height);
}

Rect::operator bool() const
{
  return gobj();
}

Point Rect::get_center() const
{
  return get_point(gobj(), graphene_rect_get_center);
}

Point Rect::get_top_left() const
{
  return get_point(gobj(), graphene_rect_get_top_left);
}

Point Rect::get_top_right() const
{
  return get_point(gobj(), graphene_rect_get_top_right);
}

Point Rect::get_bottom_right() const
{
  return get_point(gobj(), graphene_rect_get_bottom_right);
}

Point Rect::get_bottom_left() const
{
  return get_point(gobj(), graphene_rect_get_bottom_left);
}

} //namespace Graphene
} //namespace Gdk

namespace
{
} // anonymous namespace


namespace Glib
{

Gdk::Graphene::Rect wrap(graphene_rect_t* object, bool take_copy /* = false */)
{
  return Gdk::Graphene::Rect(object, take_copy);
}

} // namespace Glib


namespace Gdk
{

namespace Graphene
{


Rect::Rect()
:
  gobject_ (nullptr) // Allows creation of invalid wrapper, e.g. for output arguments to methods.
{}

Rect::Rect(const Rect& src)
:
  gobject_ ((src.gobject_) ? gdkmm_graphene_rect_copy(src.gobject_) : nullptr)
{}

Rect::Rect(graphene_rect_t* castitem, bool make_a_copy /* = false */)
{
  if(!make_a_copy)
  {
    // It was given to us by a function which has already made a copy for us to keep.
    gobject_ = castitem;
  }
  else
  {
    // We are probably getting it via direct access to a struct,
    // so we can not just take it - we have to take a copy of it.
    if(castitem)
      gobject_ = gdkmm_graphene_rect_copy(castitem);
    else
      gobject_ = nullptr;
  }
}


Rect& Rect::operator=(const Rect& src)
{
  const auto new_gobject = (src.gobject_) ? gdkmm_graphene_rect_copy(src.gobject_) : nullptr;

  if(gobject_)
    graphene_rect_free(gobject_);

  gobject_ = new_gobject;

  return *this;
}

Rect::Rect(Rect&& other) noexcept
:
  gobject_(other.gobject_)
{
  other.gobject_ = nullptr;
}

Rect& Rect::operator=(Rect&& other) noexcept
{
  Rect temp (std::move(other));
  swap(temp);
  return *this;
}

Rect::~Rect() noexcept
{
  if(gobject_)
    graphene_rect_free(gobject_);
}

void Rect::swap(Rect& other) noexcept
{
  std::swap(gobject_, other.gobject_);
}

graphene_rect_t* Rect::gobj_copy() const
{
  return gdkmm_graphene_rect_copy(gobject_);
}


Point Rect::get_origin() const
{
  return Point(const_cast<graphene_point_t*>(&(gobj()->origin)), true);
}

void Rect::set_origin(const Point& value)
{
  gobj()->origin = *(value).gobj();
}

Size Rect::get_size() const
{
  return Size(const_cast<graphene_size_t*>(&(gobj()->size)), true);
}

void Rect::set_size(const Size& value)
{
  gobj()->size = *(value).gobj();
}

bool Rect::equal(const Rect& b) const
{
  return graphene_rect_equal(const_cast<graphene_rect_t*>(gobj()), (b).gobj());
}

void Rect::normalize()
{
  graphene_rect_normalize(gobj());
}

float Rect::get_x() const
{
  return graphene_rect_get_x(const_cast<graphene_rect_t*>(gobj()));
}

float Rect::get_y() const
{
  return graphene_rect_get_y(const_cast<graphene_rect_t*>(gobj()));
}

float Rect::get_width() const
{
  return graphene_rect_get_width(const_cast<graphene_rect_t*>(gobj()));
}

float Rect::get_height() const
{
  return graphene_rect_get_height(const_cast<graphene_rect_t*>(gobj()));
}

float Rect::get_area() const
{
  return graphene_rect_get_area(const_cast<graphene_rect_t*>(gobj()));
}

bool Rect::contains_point(const Point& p) const
{
  return graphene_rect_contains_point(const_cast<graphene_rect_t*>(gobj()), (p).gobj());
}

bool Rect::contains_rect(const Rect& b) const
{
  return graphene_rect_contains_rect(const_cast<graphene_rect_t*>(gobj()), (b).gobj());
}


} // namespace Graphene

} // namespace Gdk


