2026-06-18 10:18:16 +08:00
|
|
|
#ifndef jump_label_node_H
|
|
|
|
|
#define jump_label_node_H
|
2026-06-16 18:59:25 +08:00
|
|
|
|
2026-06-17 08:35:44 +08:00
|
|
|
#include <cairo.h>
|
2026-06-17 10:22:37 +08:00
|
|
|
#include <pango/pango.h>
|
2026-06-17 08:35:44 +08:00
|
|
|
#include <pango/pangocairo.h>
|
2026-06-17 10:22:37 +08:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdint.h>
|
2026-06-16 18:59:25 +08:00
|
|
|
#include <wlr/types/wlr_scene.h>
|
|
|
|
|
|
2026-06-17 10:22:37 +08:00
|
|
|
// 原有结构体,假设已存在
|
|
|
|
|
typedef struct {
|
|
|
|
|
float fg_color[4];
|
|
|
|
|
float bg_color[4];
|
|
|
|
|
float focus_fg_color[4];
|
|
|
|
|
float focus_bg_color[4];
|
|
|
|
|
float border_color[4];
|
|
|
|
|
int32_t border_width;
|
|
|
|
|
int32_t corner_radius;
|
|
|
|
|
int32_t padding_x;
|
|
|
|
|
int32_t padding_y;
|
|
|
|
|
const char *font_desc;
|
2026-06-18 10:18:16 +08:00
|
|
|
} DecorateDrawData;
|
2026-06-17 10:22:37 +08:00
|
|
|
|
2026-06-17 08:35:44 +08:00
|
|
|
struct mango_text_buffer {
|
|
|
|
|
struct wlr_buffer base;
|
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
|
};
|
2026-06-20 18:44:28 +08:00
|
|
|
typedef struct {
|
2026-06-16 18:59:25 +08:00
|
|
|
struct wlr_scene_buffer *scene_buffer;
|
2026-06-17 10:22:37 +08:00
|
|
|
struct mango_text_buffer *buffer;
|
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
|
int surface_pixel_w, surface_pixel_h;
|
2026-06-16 18:59:25 +08:00
|
|
|
|
2026-06-17 08:35:44 +08:00
|
|
|
float fg_color[4];
|
|
|
|
|
float bg_color[4];
|
2026-06-17 10:22:37 +08:00
|
|
|
float focus_fg_color[4];
|
|
|
|
|
float focus_bg_color[4];
|
2026-06-17 08:35:44 +08:00
|
|
|
float border_color[4];
|
|
|
|
|
int32_t border_width;
|
|
|
|
|
int32_t corner_radius;
|
2026-06-17 10:22:37 +08:00
|
|
|
int32_t padding_x;
|
|
|
|
|
int32_t padding_y;
|
2026-06-17 08:35:44 +08:00
|
|
|
char *font_desc;
|
|
|
|
|
|
2026-06-17 10:22:37 +08:00
|
|
|
// 缓存
|
2026-06-17 08:35:44 +08:00
|
|
|
char *cached_text;
|
2026-06-17 10:22:37 +08:00
|
|
|
char *cached_font_desc;
|
2026-06-17 08:35:44 +08:00
|
|
|
float cached_scale;
|
|
|
|
|
float cached_fg_color[4];
|
|
|
|
|
float cached_bg_color[4];
|
2026-06-17 10:22:37 +08:00
|
|
|
float cached_focus_fg_color[4];
|
|
|
|
|
float cached_focus_bg_color[4];
|
2026-06-17 08:35:44 +08:00
|
|
|
float cached_border_color[4];
|
2026-06-17 10:22:37 +08:00
|
|
|
int32_t cached_border_width;
|
|
|
|
|
int32_t cached_corner_radius;
|
|
|
|
|
int32_t cached_padding_x;
|
|
|
|
|
int32_t cached_padding_y;
|
|
|
|
|
bool cached_focused;
|
2026-06-17 08:35:44 +08:00
|
|
|
|
2026-06-17 10:22:37 +08:00
|
|
|
bool focused;
|
2026-06-17 08:35:44 +08:00
|
|
|
|
2026-06-17 10:22:37 +08:00
|
|
|
// 测量
|
2026-06-17 08:35:44 +08:00
|
|
|
cairo_surface_t *measure_surface;
|
|
|
|
|
cairo_t *measure_cr;
|
|
|
|
|
PangoContext *measure_context;
|
|
|
|
|
PangoLayout *measure_layout;
|
|
|
|
|
float measure_scale;
|
|
|
|
|
|
|
|
|
|
int32_t logical_width;
|
|
|
|
|
int32_t logical_height;
|
2026-06-20 18:44:28 +08:00
|
|
|
} MangoJumpLabel;
|
2026-06-16 18:59:25 +08:00
|
|
|
|
2026-06-20 18:44:28 +08:00
|
|
|
typedef struct {
|
|
|
|
|
uint32_t type; // must at first in struct
|
2026-06-17 10:22:37 +08:00
|
|
|
struct wlr_scene_buffer *scene_buffer;
|
|
|
|
|
struct mango_text_buffer *buffer;
|
|
|
|
|
cairo_surface_t *surface;
|
|
|
|
|
int surface_pixel_w, surface_pixel_h;
|
2026-06-20 18:44:28 +08:00
|
|
|
void *node_data; // 存储窗口指针
|
2026-06-17 10:22:37 +08:00
|
|
|
|
|
|
|
|
// 初始配置
|
2026-06-16 18:59:25 +08:00
|
|
|
float fg_color[4];
|
|
|
|
|
float bg_color[4];
|
2026-06-17 10:22:37 +08:00
|
|
|
float focus_fg_color[4];
|
|
|
|
|
float focus_bg_color[4];
|
2026-06-16 18:59:25 +08:00
|
|
|
float border_color[4];
|
|
|
|
|
int32_t border_width;
|
|
|
|
|
int32_t corner_radius;
|
|
|
|
|
int32_t padding_x;
|
|
|
|
|
int32_t padding_y;
|
2026-06-17 10:22:37 +08:00
|
|
|
char *font_desc;
|
2026-06-16 18:59:25 +08:00
|
|
|
|
2026-06-17 10:22:37 +08:00
|
|
|
// 尺寸
|
|
|
|
|
int32_t target_width;
|
|
|
|
|
int32_t target_height;
|
|
|
|
|
|
|
|
|
|
// 缓存
|
|
|
|
|
char *cached_text;
|
|
|
|
|
char *cached_font_desc;
|
|
|
|
|
float cached_scale;
|
|
|
|
|
float cached_fg_color[4];
|
|
|
|
|
float cached_bg_color[4];
|
|
|
|
|
float cached_focus_fg_color[4];
|
|
|
|
|
float cached_focus_bg_color[4];
|
|
|
|
|
float cached_border_color[4];
|
|
|
|
|
int32_t cached_border_width;
|
|
|
|
|
int32_t cached_corner_radius;
|
|
|
|
|
int32_t cached_padding_x;
|
|
|
|
|
int32_t cached_padding_y;
|
|
|
|
|
int32_t cached_target_width;
|
|
|
|
|
int32_t cached_target_height;
|
|
|
|
|
bool cached_focused;
|
|
|
|
|
|
|
|
|
|
bool focused;
|
|
|
|
|
|
|
|
|
|
// 上次绘制参数(用于尺寸变化重绘)
|
|
|
|
|
char *last_text;
|
|
|
|
|
float last_scale;
|
|
|
|
|
|
|
|
|
|
// 测量
|
|
|
|
|
cairo_surface_t *measure_surface;
|
|
|
|
|
cairo_t *measure_cr;
|
|
|
|
|
PangoContext *measure_context;
|
|
|
|
|
PangoLayout *measure_layout;
|
|
|
|
|
float measure_scale;
|
|
|
|
|
|
|
|
|
|
int32_t logical_width;
|
|
|
|
|
int32_t logical_height;
|
2026-06-20 18:44:28 +08:00
|
|
|
} MangoGroupBar;
|
2026-06-17 10:22:37 +08:00
|
|
|
|
|
|
|
|
void mango_text_global_finish(void);
|
2026-06-20 18:44:28 +08:00
|
|
|
MangoJumpLabel *mango_jump_label_node_create(struct wlr_scene_tree *parent,
|
|
|
|
|
DecorateDrawData data);
|
|
|
|
|
void mango_jump_label_node_destroy(MangoJumpLabel *node);
|
|
|
|
|
void mango_jump_label_node_set_background(MangoJumpLabel *node, float r,
|
|
|
|
|
float g, float b, float a);
|
|
|
|
|
void mango_jump_label_node_set_border(MangoJumpLabel *node, float r, float g,
|
|
|
|
|
float b, float a, int32_t width,
|
|
|
|
|
int32_t radius);
|
|
|
|
|
void mango_jump_label_node_set_padding(MangoJumpLabel *node, int32_t pad_x,
|
|
|
|
|
int32_t pad_y);
|
|
|
|
|
void mango_jump_label_node_update(MangoJumpLabel *node, const char *text,
|
|
|
|
|
float scale);
|
2026-06-16 18:59:25 +08:00
|
|
|
|
2026-06-20 18:44:28 +08:00
|
|
|
MangoGroupBar *mango_group_bar_create(void *cdata, uint32_t type,
|
|
|
|
|
struct wlr_scene_tree *parent,
|
|
|
|
|
DecorateDrawData data, int32_t width,
|
|
|
|
|
int32_t height);
|
|
|
|
|
void mango_group_bar_destroy(MangoGroupBar *node);
|
|
|
|
|
void mango_group_bar_set_size(MangoGroupBar *node, int32_t width,
|
|
|
|
|
int32_t height);
|
|
|
|
|
void mango_group_bar_update(MangoGroupBar *node, const char *text, float scale);
|
2026-06-16 18:59:25 +08:00
|
|
|
|
2026-06-20 18:44:28 +08:00
|
|
|
void mango_jump_label_node_set_focus(MangoJumpLabel *node, bool focused);
|
|
|
|
|
void mango_group_bar_set_focus(MangoGroupBar *node, bool focused);
|
2026-06-17 10:22:37 +08:00
|
|
|
|
2026-06-20 18:44:28 +08:00
|
|
|
void mango_group_bar_set_colors(MangoGroupBar *node, const float fg[4],
|
|
|
|
|
const float bg[4]);
|
|
|
|
|
void mango_jump_label_node_apply_config(MangoJumpLabel *node,
|
2026-06-18 11:52:16 +08:00
|
|
|
const DecorateDrawData *data);
|
2026-06-20 18:44:28 +08:00
|
|
|
void mango_group_bar_apply_config(MangoGroupBar *node,
|
|
|
|
|
const DecorateDrawData *data);
|
2026-06-18 10:18:16 +08:00
|
|
|
#endif // jump_label_node_H
|