mirror of
https://github.com/labwc/labwc.git
synced 2026-04-12 08:21:13 -04:00
[wip] move more button related things into ssd_button.c
This commit is contained in:
parent
bfacfc107f
commit
2ff6d23e56
3 changed files with 59 additions and 60 deletions
|
|
@ -185,3 +185,61 @@ ssd_button_enable_rounded_corner(struct ssd_part *corner_tree, float *bg_color,
|
|||
/* Toggle rounded corner image itself */
|
||||
wlr_scene_node_set_enabled(rounded->node, enable);
|
||||
}
|
||||
|
||||
bool
|
||||
ssd_is_button(enum ssd_part_type type)
|
||||
{
|
||||
return type == LAB_SSD_BUTTON_CLOSE
|
||||
|| type == LAB_SSD_BUTTON_MAXIMIZE
|
||||
|| type == LAB_SSD_BUTTON_ICONIFY
|
||||
|| type == LAB_SSD_BUTTON_WINDOW_MENU;
|
||||
}
|
||||
|
||||
enum ssd_part_type
|
||||
ssd_button_get_type(const struct ssd_button *button)
|
||||
{
|
||||
return button ? button->type : LAB_SSD_NONE;
|
||||
}
|
||||
|
||||
struct view *
|
||||
ssd_button_get_view(const struct ssd_button *button)
|
||||
{
|
||||
return button ? button->view : NULL;
|
||||
}
|
||||
|
||||
struct ssd_hover_state *
|
||||
ssd_hover_state_new(void)
|
||||
{
|
||||
return znew(struct ssd_hover_state);
|
||||
}
|
||||
|
||||
void
|
||||
ssd_update_button_hover(struct wlr_scene_node *node,
|
||||
struct ssd_hover_state *hover_state)
|
||||
{
|
||||
struct ssd_button *button = NULL;
|
||||
if (!node || !node->data) {
|
||||
goto disable_old_hover;
|
||||
}
|
||||
|
||||
struct node_descriptor *desc = node->data;
|
||||
if (desc->type == LAB_NODE_DESC_SSD_BUTTON) {
|
||||
button = node_ssd_button_from_node(node);
|
||||
if (button->hover == hover_state->node) {
|
||||
/* Cursor is still on the same button */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
disable_old_hover:
|
||||
if (hover_state->node) {
|
||||
wlr_scene_node_set_enabled(hover_state->node, false);
|
||||
hover_state->view = NULL;
|
||||
hover_state->node = NULL;
|
||||
}
|
||||
if (button) {
|
||||
wlr_scene_node_set_enabled(button->hover, true);
|
||||
hover_state->view = button->view;
|
||||
hover_state->node = button->hover;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue