mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
Amend function and variable names; use Openbox default toggled icon; update documentation
This commit is contained in:
parent
308aa39d21
commit
97d97659fa
5 changed files with 34 additions and 25 deletions
|
|
@ -197,6 +197,16 @@ file within a particular theme. The following xbm buttons are supported:
|
||||||
- iconify.xbm
|
- iconify.xbm
|
||||||
- close.xbm
|
- close.xbm
|
||||||
- menu.xbm
|
- menu.xbm
|
||||||
|
- max_toggled.xbm
|
||||||
|
|
||||||
|
Additional icons can be defined to be shown when the mouse pointer is hovering
|
||||||
|
over the button in question:
|
||||||
|
|
||||||
|
- max_hover.xbm
|
||||||
|
- iconify_hover.xbm
|
||||||
|
- close_hover.xbm
|
||||||
|
- menu_hover.xbm
|
||||||
|
- max_hover_toggled.xbm
|
||||||
|
|
||||||
One advantage of xbm buttons over other formats is that they change color based
|
One advantage of xbm buttons over other formats is that they change color based
|
||||||
on the theme. Other formats use the suffices "-active" and "-inactive" to align
|
on the theme. Other formats use the suffices "-active" and "-inactive" to align
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,10 @@
|
||||||
struct ssd_button {
|
struct ssd_button {
|
||||||
struct view *view;
|
struct view *view;
|
||||||
enum ssd_part_type type;
|
enum ssd_part_type type;
|
||||||
struct wlr_scene_node *icon;
|
struct wlr_scene_node *normal;
|
||||||
struct wlr_scene_node *hover;
|
struct wlr_scene_node *hover;
|
||||||
struct wlr_scene_node *alticon;
|
struct wlr_scene_node *toggled;
|
||||||
struct wlr_scene_node *althover;
|
struct wlr_scene_node *toggled_hover;
|
||||||
struct wlr_scene_node *background;
|
struct wlr_scene_node *background;
|
||||||
|
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
|
|
@ -124,7 +124,7 @@ struct ssd_part *add_scene_button(
|
||||||
struct wlr_buffer *icon_buffer, struct wlr_buffer *hover_buffer,
|
struct wlr_buffer *icon_buffer, struct wlr_buffer *hover_buffer,
|
||||||
int x, struct view *view);
|
int x, struct view *view);
|
||||||
void
|
void
|
||||||
add_alt_icon(struct wl_list *part_list, enum ssd_part_type type,
|
add_toggled_icon(struct wl_list *part_list, enum ssd_part_type type,
|
||||||
struct wlr_buffer *icon_buffer, struct wlr_buffer *hover_buffer);
|
struct wlr_buffer *icon_buffer, struct wlr_buffer *hover_buffer);
|
||||||
struct ssd_part *add_scene_button_corner(
|
struct ssd_part *add_scene_button_corner(
|
||||||
struct wl_list *part_list, enum ssd_part_type type,
|
struct wl_list *part_list, enum ssd_part_type type,
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "common/scene-helpers.h"
|
|
||||||
#include "common/list.h"
|
#include "common/list.h"
|
||||||
#include "common/mem.h"
|
#include "common/mem.h"
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
|
|
@ -181,21 +180,21 @@ add_scene_button(struct wl_list *part_list, enum ssd_part_type type,
|
||||||
struct ssd_button *button = ssd_button_descriptor_create(button_root->node);
|
struct ssd_button *button = ssd_button_descriptor_create(button_root->node);
|
||||||
button->type = type;
|
button->type = type;
|
||||||
button->view = view;
|
button->view = view;
|
||||||
button->icon = icon_part->node;
|
button->normal = icon_part->node;
|
||||||
button->hover = hover_part->node;
|
button->hover = hover_part->node;
|
||||||
button->background = bg_rect->node;
|
button->background = bg_rect->node;
|
||||||
button->alticon = NULL;
|
button->toggled = NULL;
|
||||||
button->althover = NULL;
|
button->toggled_hover = NULL;
|
||||||
return button_root;
|
return button_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
add_alt_icon(struct wl_list *part_list, enum ssd_part_type type,
|
add_toggled_icon(struct wl_list *part_list, enum ssd_part_type type,
|
||||||
struct wlr_buffer *icon_buffer, struct wlr_buffer *hover_buffer)
|
struct wlr_buffer *icon_buffer, struct wlr_buffer *hover_buffer)
|
||||||
{
|
{
|
||||||
struct ssd_part *part = ssd_get_part(part_list, type);
|
struct ssd_part *part = ssd_get_part(part_list, type);
|
||||||
struct ssd_button *button = node_ssd_button_from_node(part->node);
|
struct ssd_button *button = node_ssd_button_from_node(part->node);
|
||||||
struct wlr_scene_tree *parent = lab_scene_tree_from_node(part->node);
|
struct wlr_scene_tree *parent = wlr_scene_tree_from_node(part->node);
|
||||||
|
|
||||||
/* Alternate icon */
|
/* Alternate icon */
|
||||||
struct wlr_box icon_geo = get_scale_box(icon_buffer,
|
struct wlr_box icon_geo = get_scale_box(icon_buffer,
|
||||||
|
|
@ -221,8 +220,8 @@ add_alt_icon(struct wl_list *part_list, enum ssd_part_type type,
|
||||||
|
|
||||||
wlr_scene_node_set_enabled(althover_part->node, false);
|
wlr_scene_node_set_enabled(althover_part->node, false);
|
||||||
|
|
||||||
button->alticon = alticon_part->node;
|
button->toggled = alticon_part->node;
|
||||||
button->althover = althover_part->node;
|
button->toggled_hover = althover_part->node;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ssd_part *
|
struct ssd_part *
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ ssd_titlebar_create(struct ssd *ssd)
|
||||||
add_scene_button(&subtree->parts, LAB_SSD_BUTTON_MAXIMIZE, parent,
|
add_scene_button(&subtree->parts, LAB_SSD_BUTTON_MAXIMIZE, parent,
|
||||||
color, maximize_button_unpressed, maximize_button_hover,
|
color, maximize_button_unpressed, maximize_button_hover,
|
||||||
width - SSD_BUTTON_WIDTH * 2, view);
|
width - SSD_BUTTON_WIDTH * 2, view);
|
||||||
add_alt_icon(&subtree->parts, LAB_SSD_BUTTON_MAXIMIZE,
|
add_toggled_icon(&subtree->parts, LAB_SSD_BUTTON_MAXIMIZE,
|
||||||
restore_button_unpressed, restore_button_hover);
|
restore_button_unpressed, restore_button_hover);
|
||||||
add_scene_button_corner(&subtree->parts,
|
add_scene_button_corner(&subtree->parts,
|
||||||
LAB_SSD_BUTTON_CLOSE, LAB_SSD_PART_CORNER_TOP_RIGHT, parent,
|
LAB_SSD_BUTTON_CLOSE, LAB_SSD_PART_CORNER_TOP_RIGHT, parent,
|
||||||
|
|
@ -186,14 +186,14 @@ ssd_titlebar_update(struct ssd *ssd)
|
||||||
width - SSD_BUTTON_WIDTH * 2, 0);
|
width - SSD_BUTTON_WIDTH * 2, 0);
|
||||||
struct ssd_button *button =
|
struct ssd_button *button =
|
||||||
node_ssd_button_from_node(part->node);
|
node_ssd_button_from_node(part->node);
|
||||||
if (button->alticon) {
|
if (button->toggled) {
|
||||||
wlr_scene_node_set_enabled(button->icon,
|
wlr_scene_node_set_enabled(button->normal,
|
||||||
!maximized);
|
!maximized);
|
||||||
wlr_scene_node_set_enabled(button->alticon,
|
wlr_scene_node_set_enabled(button->toggled,
|
||||||
maximized);
|
maximized);
|
||||||
wlr_scene_node_set_enabled(button->hover,
|
wlr_scene_node_set_enabled(button->hover,
|
||||||
false);
|
false);
|
||||||
wlr_scene_node_set_enabled(button->althover,
|
wlr_scene_node_set_enabled(button->toggled_hover,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -407,15 +407,15 @@ disable_old_hover:
|
||||||
}
|
}
|
||||||
if (button) {
|
if (button) {
|
||||||
bool maximized = button->view->maximized;
|
bool maximized = button->view->maximized;
|
||||||
if (maximized && !button->alticon) {
|
if (maximized && !button->toggled) {
|
||||||
maximized = false;
|
maximized = false;
|
||||||
}
|
}
|
||||||
wlr_scene_node_set_enabled(maximized ? button->althover : button->hover, true);
|
wlr_scene_node_set_enabled(maximized ? button->toggled_hover : button->hover, true);
|
||||||
hover_state->view = button->view;
|
hover_state->view = button->view;
|
||||||
hover_state->node = maximized ? button->althover : button->hover;
|
hover_state->node = maximized ? button->toggled_hover : button->hover;
|
||||||
hover_state->old_node = maximized ? button->alticon : button->icon;
|
hover_state->old_node = maximized ? button->toggled : button->normal;
|
||||||
hover_state->maximized = button->alticon ? (int)button->view->maximized : -1;
|
hover_state->maximized = button->toggled ? (int)button->view->maximized : -1;
|
||||||
wlr_scene_node_set_enabled(maximized ? button->alticon : button->icon, false);
|
wlr_scene_node_set_enabled(maximized ? button->toggled : button->normal, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ load_buttons(struct theme *theme)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"max_toggled",
|
"max_toggled",
|
||||||
{ 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f },
|
{ 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f },
|
||||||
{
|
{
|
||||||
&theme->button_restore_active_unpressed,
|
&theme->button_restore_active_unpressed,
|
||||||
theme->window_active_button_max_unpressed_image_color,
|
theme->window_active_button_max_unpressed_image_color,
|
||||||
|
|
@ -157,7 +157,7 @@ load_buttons(struct theme *theme)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"max_hover_toggled",
|
"max_hover_toggled",
|
||||||
{ 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f },
|
{ 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f },
|
||||||
{
|
{
|
||||||
&theme->button_restore_active_hover,
|
&theme->button_restore_active_hover,
|
||||||
theme->window_active_button_max_unpressed_image_color,
|
theme->window_active_button_max_unpressed_image_color,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue