mirror of
https://github.com/labwc/labwc.git
synced 2025-11-05 13:29:58 -05:00
menu: Dynamically adjust menu width based on widest item
Adds two new theme vars: - menu.width.min (menu will never be smaller than this) - menu.width.max (menu will never be wider than this + padding) A fixed menu width can be achieved by setting menu.width.min == menu.width.max.
This commit is contained in:
parent
f0666ba5c9
commit
d00327bc32
7 changed files with 115 additions and 14 deletions
|
|
@ -25,7 +25,7 @@ struct scaled_font_buffer {
|
|||
/**
|
||||
* Create an auto scaling font buffer, providing a wlr_scene_buffer node for
|
||||
* display. It gets destroyed automatically when the backing scaled_scene_buffer
|
||||
* is being destoyed which in turn happens automatically when the backing
|
||||
* is being destroyed which in turn happens automatically when the backing
|
||||
* wlr_scene_buffer (or one of its parents) is being destroyed.
|
||||
*
|
||||
* To actually show some text, scaled_font_buffer_update() has to be called.
|
||||
|
|
@ -48,4 +48,12 @@ struct scaled_font_buffer *scaled_font_buffer_create(struct wlr_scene_tree *pare
|
|||
void scaled_font_buffer_update(struct scaled_font_buffer *self, const char *text,
|
||||
int max_width, struct font *font, float *color, const char *arrow);
|
||||
|
||||
/**
|
||||
* Update the max width of an existing auto scaling font buffer
|
||||
* and force a new render.
|
||||
*
|
||||
* No steps are taken to detect if its actually required to render a new buffer.
|
||||
*/
|
||||
void scaled_font_buffer_set_max_width(struct scaled_font_buffer *self, int max_width);
|
||||
|
||||
#endif /* __LAB_COMMON_SCALED_FONT_BUFFER_H */
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ struct menuitem {
|
|||
struct menu *submenu;
|
||||
bool selectable;
|
||||
int height;
|
||||
int native_width;
|
||||
struct wlr_scene_tree *tree;
|
||||
struct menu_scene normal;
|
||||
struct menu_scene selected;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,9 @@ struct theme {
|
|||
float menu_items_active_bg_color[4];
|
||||
float menu_items_active_text_color[4];
|
||||
|
||||
int menu_min_width;
|
||||
int menu_max_width;
|
||||
|
||||
int menu_separator_line_thickness;
|
||||
int menu_separator_padding_width;
|
||||
int menu_separator_padding_height;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue