labwc/include/common/graphic-helpers.h

73 lines
1.9 KiB
C
Raw Normal View History

2022-08-20 00:01:06 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
#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>
#include <wayland-server-core.h>
2022-08-20 00:01:06 +02:00
struct wlr_scene_tree;
struct wlr_scene_rect;
struct wlr_fbox;
2022-08-20 00:01:06 +02:00
2024-10-16 11:34:19 +09:00
struct border_rect {
2022-08-20 00:01:06 +02:00
struct wlr_scene_tree *tree;
2024-10-16 11:34:19 +09:00
int border_width; /* read-only */
2022-08-20 00:01:06 +02:00
/* Private */
2024-10-16 11:34:19 +09:00
struct wlr_scene_rect *top;
struct wlr_scene_rect *bottom;
struct wlr_scene_rect *left;
struct wlr_scene_rect *right;
struct wlr_scene_rect *bg;
struct wl_listener destroy;
};
struct multi_rect {
struct wlr_scene_tree *tree;
/* Private */
struct border_rect *border_rects[3];
2022-08-20 00:01:06 +02:00
struct wl_listener destroy;
};
2024-10-16 11:34:19 +09:00
/**
* Create a new rectangular with a single border (border_rect).
*
* bg_color can take NULL, in which case no background is rendered.
*
* A border_rect can be positioned by positioning border_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 border_rect *border_rect_create(struct wlr_scene_tree *parent,
float border_color[4], float bg_color[4], int border_width);
void border_rect_set_size(struct border_rect *rect, int width, int height);
2022-08-20 00:01:06 +02:00
/**
* Create a new multi_rect.
*
2024-10-16 11:34:19 +09:00
* A multi_rect consists of 3 nested border_rects without a background.
* Each of the border_rect is using the same @line_width but its own color
* based on the @colors argument.
2022-08-20 00:01:06 +02:00
*/
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);
/**
* Sets the cairo color.
* Splits a float[4] single color array into its own arguments
*/
void set_cairo_color(cairo_t *cairo, const float *color);
/* Draws a border with a specified line width */
void draw_cairo_border(cairo_t *cairo, struct wlr_fbox fbox, double line_width);
struct lab_data_buffer;
#endif /* LABWC_GRAPHIC_HELPERS_H */