Blame src/util/dzl-cairo.h

Packit Service c6b782
/* dzl-cairo.h
Packit Service c6b782
 *
Packit Service c6b782
 * Copyright (C) 2014 Christian Hergert <christian@hergert.me>
Packit Service c6b782
 *
Packit Service c6b782
 * This file is free software; you can redistribute it and/or
Packit Service c6b782
 * modify it under the terms of the GNU Lesser General Public
Packit Service c6b782
 * License as published by the Free Software Foundation; either
Packit Service c6b782
 * version 2.1 of the License, or (at your option) any later version.
Packit Service c6b782
 *
Packit Service c6b782
 * This file is distributed in the hope that it will be useful,
Packit Service c6b782
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service c6b782
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service c6b782
 * Lesser General Public License for more details.
Packit Service c6b782
 *
Packit Service c6b782
 * You should have received a copy of the GNU General Public License
Packit Service c6b782
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service c6b782
 */
Packit Service c6b782
Packit Service c6b782
#ifndef DZL_CAIRO_H
Packit Service c6b782
#define DZL_CAIRO_H
Packit Service c6b782
Packit Service c6b782
#include <gtk/gtk.h>
Packit Service c6b782
Packit Service c6b782
#include "dzl-version-macros.h"
Packit Service c6b782
Packit Service c6b782
G_BEGIN_DECLS
Packit Service c6b782
Packit Service c6b782
DZL_AVAILABLE_IN_ALL
Packit Service c6b782
cairo_region_t *dzl_cairo_region_create_from_clip_extents (cairo_t            *cr);
Packit Service c6b782
DZL_AVAILABLE_IN_ALL
Packit Service c6b782
void            dzl_cairo_rounded_rectangle               (cairo_t            *cr,
Packit Service c6b782
                                                           const GdkRectangle *rect,
Packit Service c6b782
                                                           gint                x_radius,
Packit Service c6b782
                                                           gint                y_radius);
Packit Service c6b782
Packit Service c6b782
static inline gboolean
Packit Service c6b782
dzl_cairo_rectangle_x2 (const cairo_rectangle_int_t *rect)
Packit Service c6b782
{
Packit Service c6b782
  return rect->x + rect->width;
Packit Service c6b782
}
Packit Service c6b782
Packit Service c6b782
static inline gboolean
Packit Service c6b782
dzl_cairo_rectangle_y2 (const cairo_rectangle_int_t *rect)
Packit Service c6b782
{
Packit Service c6b782
  return rect->y + rect->height;
Packit Service c6b782
}
Packit Service c6b782
Packit Service c6b782
static inline gboolean
Packit Service c6b782
dzl_cairo_rectangle_center (const cairo_rectangle_int_t *rect)
Packit Service c6b782
{
Packit Service c6b782
  return rect->x + (rect->width/2);
Packit Service c6b782
}
Packit Service c6b782
Packit Service c6b782
static inline gboolean
Packit Service c6b782
dzl_cairo_rectangle_middle (const cairo_rectangle_int_t *rect)
Packit Service c6b782
{
Packit Service c6b782
  return rect->y + (rect->height/2);
Packit Service c6b782
}
Packit Service c6b782
Packit Service c6b782
static inline cairo_bool_t
Packit Service c6b782
dzl_cairo_rectangle_contains_rectangle (const cairo_rectangle_int_t *a,
Packit Service c6b782
                                        const cairo_rectangle_int_t *b)
Packit Service c6b782
{
Packit Service c6b782
    return (a->x <= b->x &&
Packit Service c6b782
            a->x + (int) a->width >= b->x + (int) b->width &&
Packit Service c6b782
            a->y <= b->y &&
Packit Service c6b782
            a->y + (int) a->height >= b->y + (int) b->height);
Packit Service c6b782
}
Packit Service c6b782
Packit Service c6b782
G_END_DECLS
Packit Service c6b782
Packit Service c6b782
#endif /* DZL_CAIRO_H */