mirror of
https://github.com/labwc/labwc.git
synced 2025-11-02 09:01:47 -05:00
common/font: add scaled_font_buffer_create_for_titlebar()
Co-authored-by: tokyo4j <hrak1529@gmail.com>
This commit is contained in:
parent
3ca7adace0
commit
54b236e027
4 changed files with 76 additions and 18 deletions
|
|
@ -20,6 +20,16 @@ struct scaled_font_buffer {
|
|||
float bg_color[4];
|
||||
struct font font;
|
||||
struct scaled_scene_buffer *scaled_buffer;
|
||||
|
||||
/*
|
||||
* The following fields are used only for the titlebar, where
|
||||
* the font buffer can be rendered with a pattern background to
|
||||
* support gradients. In this case, the font buffer is also
|
||||
* padded to a fixed height (with the text centered vertically)
|
||||
* in order to align the pattern with the rest of the titlebar.
|
||||
*/
|
||||
int fixed_height;
|
||||
cairo_pattern_t *bg_pattern; /* overrides bg_color if set */
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -33,6 +43,17 @@ struct scaled_font_buffer {
|
|||
*/
|
||||
struct scaled_font_buffer *scaled_font_buffer_create(struct wlr_scene_tree *parent);
|
||||
|
||||
/**
|
||||
* Create an auto scaling font buffer for titlebar text.
|
||||
* The font buffer takes a new reference to bg_pattern.
|
||||
*
|
||||
* @param fixed_height Fixed height for the buffer (logical pixels)
|
||||
* @param bg_pattern Background pattern (solid color or gradient)
|
||||
*/
|
||||
struct scaled_font_buffer *
|
||||
scaled_font_buffer_create_for_titlebar(struct wlr_scene_tree *parent,
|
||||
int fixed_height, cairo_pattern_t *bg_pattern);
|
||||
|
||||
/**
|
||||
* Update an existing auto scaling font buffer.
|
||||
*
|
||||
|
|
@ -44,6 +65,9 @@ struct scaled_font_buffer *scaled_font_buffer_create(struct wlr_scene_tree *pare
|
|||
* - truncated = buffer->width == max_width
|
||||
* - text_changed = strcmp(old_text, new_text)
|
||||
* - font and color the same
|
||||
*
|
||||
* bg_color is ignored for font buffers created with
|
||||
* scaled_font_buffer_create_for_titlebar().
|
||||
*/
|
||||
void scaled_font_buffer_update(struct scaled_font_buffer *self, const char *text,
|
||||
int max_width, struct font *font, const float *color,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue