10#ifndef __UTILS_CAIRO_H__
11#define __UTILS_CAIRO_H__
35#define CAIRO_CACHES (ZRYTHM->cairo_caches)
40#define Z_CAIRO_FONT "Bold 9"
46#define Z_CAIRO_TEXT_PADDING 2
50z_cairo_draw_selection_with_color (
59z_cairo_draw_selection (
68z_cairo_draw_horizontal_line (
77z_cairo_draw_vertical_line (
89z_cairo_rounded_rectangle (
98 double radius = corner_radius / aspect;
99 double degrees = G_PI / 180.0;
101 cairo_new_sub_path (cr);
103 cr, x + width - radius, y + radius, radius, -90 * degrees,
106 cr, x + width - radius, y + height - radius, radius,
107 0 * degrees, 90 * degrees);
109 cr, x + radius, y + height - radius, radius, 90 * degrees,
112 cr, x + radius, y + radius, radius, 180 * degrees,
114 cairo_close_path (cr);
117#define z_cairo_get_text_extents_for_widget( \
118 _widget, _layout, _text, _width, _height) \
119 _z_cairo_get_text_extents_for_widget ( \
120 (GtkWidget *) _widget, _layout, _text, _width, _height)
135 PangoLayout * layout,
143#define z_cairo_draw_text(cr, widget, layout, text) \
144 z_cairo_draw_text_full ( \
145 cr, widget, layout, text, Z_CAIRO_TEXT_PADDING, \
146 Z_CAIRO_TEXT_PADDING)
156 PangoLayout * layout,
172 cairo_move_to (cr, x, height / 2);
173 cairo_line_to (cr, width / 2, y);
174 cairo_line_to (cr, width, height / 2);
175 cairo_line_to (cr, width / 2, height);
176 cairo_line_to (cr, x, height / 2);
177 cairo_close_path (cr);
185 const char * icon_name,
197 PangoEllipsizeMode ellipsize_mode,
198 int ellipsize_padding);
207 PangoFontDescription * descr,
208 PangoEllipsizeMode ellipsize_mode,
209 int ellipsize_padding);
231 cairo_surface_t ** surface_cache,
237z_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.