2022-08-20 00:01:06 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2023-05-13 16:10:33 +03:00
|
|
|
#ifndef LABWC_GRAPHIC_HELPERS_H
|
|
|
|
|
#define LABWC_GRAPHIC_HELPERS_H
|
2022-08-20 00:01:06 +02:00
|
|
|
|
2022-07-06 17:37:22 +02:00
|
|
|
#include <cairo.h>
|
2022-10-05 08:43:56 +02:00
|
|
|
#include <wayland-server-core.h>
|
|
|
|
|
|
2022-08-20 00:01:06 +02:00
|
|
|
struct wlr_scene_tree;
|
|
|
|
|
struct wlr_scene_rect;
|
2023-06-29 17:45:33 +01:00
|
|
|
struct wlr_fbox;
|
2022-08-20 00:01:06 +02:00
|
|
|
|
|
|
|
|
struct multi_rect {
|
|
|
|
|
struct wlr_scene_tree *tree;
|
|
|
|
|
int line_width; /* read-only */
|
|
|
|
|
|
|
|
|
|
/* Private */
|
|
|
|
|
struct wlr_scene_rect *top[3];
|
|
|
|
|
struct wlr_scene_rect *bottom[3];
|
|
|
|
|
struct wlr_scene_rect *left[3];
|
|
|
|
|
struct wlr_scene_rect *right[3];
|
|
|
|
|
struct wl_listener destroy;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new multi_rect.
|
|
|
|
|
* A multi_rect consists of 3 nested rectangular outlines.
|
|
|
|
|
* Each of the rectangular outlines is using the same @line_width
|
|
|
|
|
* but its own color based on the @colors argument.
|
|
|
|
|
*
|
|
|
|
|
* The multi-rect can be positioned by positioning multi_rect->tree->node.
|
|
|
|
|
*
|
|
|
|
|
* It can be destroyed by destroying its tree node (or one of its
|
|
|
|
|
* parent nodes). Once the tree node has been destroyed the struct
|
|
|
|
|
* will be free'd automatically.
|
|
|
|
|
*/
|
|
|
|
|
struct multi_rect *multi_rect_create(struct wlr_scene_tree *parent,
|
|
|
|
|
float *colors[3], int line_width);
|
|
|
|
|
|
|
|
|
|
void multi_rect_set_size(struct multi_rect *rect, int width, int height);
|
2022-08-20 20:11:58 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the cairo color.
|
|
|
|
|
* Splits a float[4] single color array into its own arguments
|
|
|
|
|
*/
|
|
|
|
|
void set_cairo_color(cairo_t *cairo, float *color);
|
|
|
|
|
|
|
|
|
|
/* Draws a border with a specified line width */
|
2023-06-29 17:45:33 +01:00
|
|
|
void draw_cairo_border(cairo_t *cairo, struct wlr_fbox fbox, double line_width);
|
2023-05-13 16:10:33 +03:00
|
|
|
|
2023-12-17 02:16:49 +01:00
|
|
|
struct lab_data_buffer;
|
|
|
|
|
|
|
|
|
|
struct surface_context {
|
|
|
|
|
bool is_duplicate;
|
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct surface_context get_cairo_surface_from_lab_data_buffer(
|
|
|
|
|
struct lab_data_buffer *buffer);
|
|
|
|
|
|
2023-05-13 16:10:33 +03:00
|
|
|
#endif /* LABWC_GRAPHIC_HELPERS_H */
|