12#ifndef __UTILS_CAIRO_H__
13#define __UTILS_CAIRO_H__
15#include "gtk_wrapper.h"
37#define CAIRO_CACHES (gZrythm->cairo_caches)
42#define Z_CAIRO_FONT "Bold 9"
48#define Z_CAIRO_TEXT_PADDING 2
52z_cairo_draw_selection_with_color (
61z_cairo_draw_selection (
70z_cairo_draw_horizontal_line (
79z_cairo_draw_vertical_line (
91z_cairo_rounded_rectangle (
100 double radius = corner_radius / aspect;
101 double degrees = G_PI / 180.0;
103 cairo_new_sub_path (cr);
105 cr, x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
107 cr, x + width - radius, y + height - radius, radius, 0 * degrees,
110 cr, x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);
111 cairo_arc (cr, x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
112 cairo_close_path (cr);
115#define z_cairo_get_text_extents_for_widget( \
116 _widget, _layout, _text, _width, _height) \
117 _z_cairo_get_text_extents_for_widget ( \
118 (GtkWidget *) _widget, _layout, _text, _width, _height)
133 PangoLayout * layout,
141#define z_cairo_draw_text(cr, widget, layout, text) \
142 z_cairo_draw_text_full ( \
143 cr, widget, layout, text, Z_CAIRO_TEXT_PADDING, Z_CAIRO_TEXT_PADDING)
153 PangoLayout * layout,
162z_cairo_diamond (cairo_t * cr,
double x,
double y,
double width,
double height)
164 cairo_move_to (cr, x, height / 2);
165 cairo_line_to (cr, width / 2, y);
166 cairo_line_to (cr, width, height / 2);
167 cairo_line_to (cr, width / 2, height);
168 cairo_line_to (cr, x, height / 2);
169 cairo_close_path (cr);
186 PangoEllipsizeMode ellipsize_mode,
187 int ellipsize_padding);
196 PangoFontDescription * descr,
197 PangoEllipsizeMode ellipsize_mode,
198 int ellipsize_padding);
220 cairo_surface_t ** surface_cache,
226z_cairo_caches_new (
void);
void z_cairo_reset_caches(cairo_t **cr_cache, cairo_surface_t **surface_cache, int width, int height, cairo_t *new_cr)
Resets a surface and cairo_t with a new surface and cairo_t based on the given rectangle and cairo_t.
cairo_surface_t * z_cairo_get_surface_from_icon_name(const char *icon_name, int size, int scale)
Returns a surface for the icon name.
void z_cairo_draw_text_full(cairo_t *cr, GtkWidget *widget, PangoLayout *layout, const char *text, int start_x, int start_y)
Draws the given text using the given font starting at the given position.
void _z_cairo_get_text_extents_for_widget(GtkWidget *widget, PangoLayout *layout, const char *text, int *width, int *height)
Gets the width of the given text in pixels for the given widget.
PangoLayout * z_cairo_create_pango_layout_from_string(GtkWidget *widget, const char *font, PangoEllipsizeMode ellipsize_mode, int ellipsize_padding)
Creates a PangoLayout to be cached in widgets based on the given settings.
PangoLayout * z_cairo_create_pango_layout_from_description(GtkWidget *widget, PangoFontDescription *descr, PangoEllipsizeMode ellipsize_mode, int ellipsize_padding)
Creates a PangoLayout to be cached in widgets based on the given settings.
PangoLayout * z_cairo_create_default_pango_layout(GtkWidget *widget)
Creates a PangoLayout with default settings.
Dictionary * icon_surface_dict
Icon surface dictionary: icon name: cairo_surface_t.