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


#include <glibmm.h>

#include <gskmm/pathmeasure.h>
#include <gskmm/private/pathmeasure_p.h>


/* Copyright (C) 2026 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 <gskmm/path.h>

namespace Gsk
{
std::optional<PathPoint> PathMeasure::get_point(float distance)
{
  PathPoint out_point;
  const bool result = gsk_path_measure_get_point(gobj(), distance, out_point.gobj());
  if (!result)
    return {};
  return out_point;
}
} // namespace Gsk

namespace
{
} // anonymous namespace


/* Why reinterpret_cast<PathMeasure*>(gobject) is needed:
 *
 * A PathMeasure instance is in fact always a GskPathMeasure instance.
 * Unfortunately, GskPathMeasure cannot be a member of PathMeasure,
 * because it is an opaque struct.  Also, the C interface does not provide
 * any hooks to install a destroy notification handler, thus we cannot
 * wrap it dynamically either.
 *
 * The cast works because PathMeasure does not have any member data, and
 * it is impossible to derive from it.  This is ensured by using final on the
 * class and by using = delete on the default constructor.
 */

namespace Glib
{

Glib::RefPtr<Gsk::PathMeasure> wrap(GskPathMeasure* object, bool take_copy)
{
  if(take_copy && object)
    gsk_path_measure_ref(object);

  // See the comment at the top of this file, if you want to know why the cast works.
  return Glib::make_refptr_for_instance<Gsk::PathMeasure>(reinterpret_cast<Gsk::PathMeasure*>(object));
}

} // namespace Glib


namespace Gsk
{

void PathMeasure::reference() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  gsk_path_measure_ref(reinterpret_cast<GskPathMeasure*>(const_cast<PathMeasure*>(this)));
}

void PathMeasure::unreference() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  gsk_path_measure_unref(reinterpret_cast<GskPathMeasure*>(const_cast<PathMeasure*>(this)));
}

GskPathMeasure* PathMeasure::gobj()
{
  // See the comment at the top of this file, if you want to know why the cast works.
  return reinterpret_cast<GskPathMeasure*>(this);
}

const GskPathMeasure* PathMeasure::gobj() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  return reinterpret_cast<const GskPathMeasure*>(this);
}

GskPathMeasure* PathMeasure::gobj_copy() const
{
  // See the comment at the top of this file, if you want to know why the cast works.
  const auto gobject = reinterpret_cast<GskPathMeasure*>(const_cast<PathMeasure*>(this));
  gsk_path_measure_ref(gobject);
  return gobject;
}


Glib::RefPtr<PathMeasure> PathMeasure::create(const Glib::RefPtr<const Path>& path)
{
  return Glib::wrap(gsk_path_measure_new(const_cast<GskPath*>(Glib::unwrap(path))));
}

Glib::RefPtr<PathMeasure> PathMeasure::create(const Glib::RefPtr<const Path>& path, float tolerance)
{
  return Glib::wrap(gsk_path_measure_new_with_tolerance(const_cast<GskPath*>(Glib::unwrap(path)), tolerance));
}

Glib::RefPtr<Path> PathMeasure::get_path() const
{
  auto retvalue = Glib::wrap(gsk_path_measure_get_path(const_cast<GskPathMeasure*>(gobj())));
  if(retvalue)
    retvalue->reference(); //The function does not do a ref for us.
  return retvalue;
}

float PathMeasure::get_tolerance() const
{
  return gsk_path_measure_get_tolerance(const_cast<GskPathMeasure*>(gobj()));
}

float PathMeasure::get_length() const
{
  return gsk_path_measure_get_length(const_cast<GskPathMeasure*>(gobj()));
}


} // namespace Gsk


