mirror of
https://github.com/labwc/labwc.git
synced 2026-02-07 04:07:42 -05:00
theme: refine the management of corner buttons
- The builtin hover effect is now unrounded when the window is tiled. - All the corner button icons including ones provided by the user are now rounded when the window is not tiled. - Fixed the bug that the window menu button as a fallback of the window icon is not correctly rounded.
This commit is contained in:
parent
c413e65a20
commit
c2a3a354db
6 changed files with 417 additions and 637 deletions
|
|
@ -18,12 +18,16 @@
|
|||
struct ssd_button {
|
||||
struct view *view;
|
||||
enum ssd_part_type type;
|
||||
struct wlr_scene_node *normal;
|
||||
struct wlr_scene_node *hover;
|
||||
struct wlr_scene_node *toggled;
|
||||
struct wlr_scene_node *toggled_hover;
|
||||
struct wlr_scene_tree *icon_tree;
|
||||
struct wlr_scene_tree *hover_tree;
|
||||
/*
|
||||
* Bitmap of lab_button_state that represents a combination of
|
||||
* hover/toggled/rounded states.
|
||||
*/
|
||||
uint8_t state_set;
|
||||
/*
|
||||
* Button nodes for each combination of hover/toggled/rounded states.
|
||||
* nodes[state_set] should be displayed.
|
||||
*/
|
||||
struct wlr_scene_node *nodes[LAB_BS_ALL + 1];
|
||||
|
||||
struct wl_listener destroy;
|
||||
};
|
||||
|
|
@ -140,13 +144,10 @@ struct ssd_part *add_scene_rect(
|
|||
struct ssd_part *add_scene_buffer(
|
||||
struct wl_list *list, enum ssd_part_type type,
|
||||
struct wlr_scene_tree *parent, struct wlr_buffer *buffer, int x, int y);
|
||||
struct ssd_part *add_scene_button(
|
||||
struct wl_list *part_list, enum ssd_part_type type,
|
||||
struct wlr_scene_tree *parent, struct wlr_buffer *icon_buffer,
|
||||
struct wlr_buffer *hover_buffer, int x, struct view *view);
|
||||
void add_toggled_icon(struct ssd_button *button, struct wl_list *part_list,
|
||||
enum ssd_part_type type, struct wlr_buffer *icon_buffer,
|
||||
struct wlr_buffer *hover_buffer);
|
||||
struct ssd_part *add_scene_button(struct wl_list *part_list,
|
||||
enum ssd_part_type type, struct wlr_scene_tree *parent,
|
||||
struct lab_data_buffer *buffers[LAB_BS_ALL + 1], int x,
|
||||
struct view *view);
|
||||
void update_window_icon_buffer(struct wlr_scene_node *button_node,
|
||||
struct wlr_buffer *buffer);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,14 +21,19 @@
|
|||
*/
|
||||
enum ssd_part_type {
|
||||
LAB_SSD_NONE = 0,
|
||||
LAB_SSD_BUTTON_CLOSE,
|
||||
|
||||
LAB_SSD_BUTTON_CLOSE = 1,
|
||||
LAB_SSD_BUTTON_MAXIMIZE,
|
||||
LAB_SSD_BUTTON_ICONIFY,
|
||||
LAB_SSD_BUTTON_WINDOW_ICON,
|
||||
LAB_SSD_BUTTON_WINDOW_MENU,
|
||||
LAB_SSD_BUTTON_SHADE,
|
||||
LAB_SSD_BUTTON_OMNIPRESENT,
|
||||
LAB_SSD_BUTTON, /* only for internal use */
|
||||
/* only for internal use */
|
||||
LAB_SSD_BUTTON_FIRST = LAB_SSD_BUTTON_CLOSE,
|
||||
LAB_SSD_BUTTON_LAST = LAB_SSD_BUTTON_OMNIPRESENT,
|
||||
LAB_SSD_BUTTON,
|
||||
|
||||
LAB_SSD_PART_TITLEBAR,
|
||||
LAB_SSD_PART_TITLEBAR_CORNER_RIGHT,
|
||||
LAB_SSD_PART_TITLEBAR_CORNER_LEFT,
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include "ssd.h"
|
||||
|
||||
enum lab_justification {
|
||||
LAB_JUSTIFY_LEFT,
|
||||
|
|
@ -30,6 +31,14 @@ struct theme_snapping_overlay {
|
|||
float border_color[3][4];
|
||||
};
|
||||
|
||||
enum lab_button_state {
|
||||
LAB_BS_HOVERD = 1 << 0,
|
||||
LAB_BS_TOGGLED = 1 << 1,
|
||||
LAB_BS_ROUNDED = 1 << 2,
|
||||
|
||||
LAB_BS_ALL = LAB_BS_HOVERD | LAB_BS_TOGGLED | LAB_BS_ROUNDED,
|
||||
};
|
||||
|
||||
struct theme {
|
||||
int border_width;
|
||||
|
||||
|
|
@ -65,21 +74,6 @@ struct theme {
|
|||
/* the shape of the hover effect */
|
||||
enum lab_shape window_button_hover_bg_shape;
|
||||
|
||||
/* button colors */
|
||||
float window_active_button_menu_unpressed_image_color[4];
|
||||
float window_active_button_iconify_unpressed_image_color[4];
|
||||
float window_active_button_max_unpressed_image_color[4];
|
||||
float window_active_button_close_unpressed_image_color[4];
|
||||
float window_active_button_shade_unpressed_image_color[4];
|
||||
float window_active_button_omnipresent_unpressed_image_color[4];
|
||||
float window_inactive_button_menu_unpressed_image_color[4];
|
||||
float window_inactive_button_iconify_unpressed_image_color[4];
|
||||
float window_inactive_button_max_unpressed_image_color[4];
|
||||
float window_inactive_button_close_unpressed_image_color[4];
|
||||
float window_inactive_button_shade_unpressed_image_color[4];
|
||||
float window_inactive_button_omnipresent_unpressed_image_color[4];
|
||||
/* TODO: add pressed and hover colors for buttons */
|
||||
|
||||
int menu_item_padding_x;
|
||||
int menu_item_padding_y;
|
||||
int menu_item_height;
|
||||
|
|
@ -128,47 +122,26 @@ struct theme {
|
|||
float window_active_shadow_color[4];
|
||||
float window_inactive_shadow_color[4];
|
||||
|
||||
struct {
|
||||
/*
|
||||
* The texture of a window buttons for each hover/toggled/rounded
|
||||
* state. This can be accessed like:
|
||||
*
|
||||
* buttons[LAB_SSD_BUTTON_ICONIFY][LAB_BS_HOVERD | LAB_BS_TOGGLED]
|
||||
*
|
||||
* Elements in buttons[0] are all NULL since LAB_SSD_BUTTON_FIRST is 1.
|
||||
*/
|
||||
struct lab_data_buffer *buttons
|
||||
[LAB_SSD_BUTTON_LAST + 1][LAB_BS_ALL + 1];
|
||||
|
||||
/* TODO: add toggled/hover/pressed/disabled colors for buttons */
|
||||
float button_colors[LAB_SSD_BUTTON_LAST + 1][4];
|
||||
|
||||
/* TODO: move other window.(in)active.* entries to here */
|
||||
|
||||
} window[2]; /* indexed by THEME_INACTIVE and THEME_ACTIVE */
|
||||
|
||||
/* textures */
|
||||
struct lab_data_buffer *button_close_active_unpressed;
|
||||
struct lab_data_buffer *button_maximize_active_unpressed;
|
||||
struct lab_data_buffer *button_restore_active_unpressed;
|
||||
struct lab_data_buffer *button_iconify_active_unpressed;
|
||||
struct lab_data_buffer *button_menu_active_unpressed;
|
||||
struct lab_data_buffer *button_shade_active_unpressed;
|
||||
struct lab_data_buffer *button_unshade_active_unpressed;
|
||||
struct lab_data_buffer *button_omnipresent_active_unpressed;
|
||||
struct lab_data_buffer *button_exclusive_active_unpressed;
|
||||
|
||||
struct lab_data_buffer *button_close_inactive_unpressed;
|
||||
struct lab_data_buffer *button_maximize_inactive_unpressed;
|
||||
struct lab_data_buffer *button_restore_inactive_unpressed;
|
||||
struct lab_data_buffer *button_iconify_inactive_unpressed;
|
||||
struct lab_data_buffer *button_menu_inactive_unpressed;
|
||||
struct lab_data_buffer *button_shade_inactive_unpressed;
|
||||
struct lab_data_buffer *button_unshade_inactive_unpressed;
|
||||
struct lab_data_buffer *button_omnipresent_inactive_unpressed;
|
||||
struct lab_data_buffer *button_exclusive_inactive_unpressed;
|
||||
|
||||
/* hover variants are optional and may be NULL */
|
||||
struct lab_data_buffer *button_close_active_hover;
|
||||
struct lab_data_buffer *button_maximize_active_hover;
|
||||
struct lab_data_buffer *button_restore_active_hover;
|
||||
struct lab_data_buffer *button_iconify_active_hover;
|
||||
struct lab_data_buffer *button_menu_active_hover;
|
||||
struct lab_data_buffer *button_shade_active_hover;
|
||||
struct lab_data_buffer *button_unshade_active_hover;
|
||||
struct lab_data_buffer *button_omnipresent_active_hover;
|
||||
struct lab_data_buffer *button_exclusive_active_hover;
|
||||
|
||||
struct lab_data_buffer *button_close_inactive_hover;
|
||||
struct lab_data_buffer *button_maximize_inactive_hover;
|
||||
struct lab_data_buffer *button_restore_inactive_hover;
|
||||
struct lab_data_buffer *button_iconify_inactive_hover;
|
||||
struct lab_data_buffer *button_menu_inactive_hover;
|
||||
struct lab_data_buffer *button_shade_inactive_hover;
|
||||
struct lab_data_buffer *button_unshade_inactive_hover;
|
||||
struct lab_data_buffer *button_omnipresent_inactive_hover;
|
||||
struct lab_data_buffer *button_exclusive_inactive_hover;
|
||||
|
||||
struct lab_data_buffer *corner_top_left_active_normal;
|
||||
struct lab_data_buffer *corner_top_right_active_normal;
|
||||
|
|
@ -190,6 +163,9 @@ struct theme {
|
|||
int mag_border_width;
|
||||
};
|
||||
|
||||
#define THEME_INACTIVE 0
|
||||
#define THEME_ACTIVE 1
|
||||
|
||||
struct server;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue