feat: layer zoom in type animation
This commit is contained in:
@@ -197,6 +197,28 @@ void layer_draw_shadow(LayerSurface *l) {
|
|||||||
wlr_scene_shadow_set_clipped_region(l->shadow, clipped_region);
|
wlr_scene_shadow_set_clipped_region(l->shadow, clipped_region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void layer_scene_buffer_apply_effect(struct wlr_scene_buffer *buffer, int sx,
|
||||||
|
int sy, void *data) {
|
||||||
|
animationScale *scale_data = (animationScale *)data;
|
||||||
|
|
||||||
|
struct wlr_scene_surface *scene_surface =
|
||||||
|
wlr_scene_surface_try_from_buffer(buffer);
|
||||||
|
|
||||||
|
if (scene_surface == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
struct wlr_surface *surface = scene_surface->surface;
|
||||||
|
|
||||||
|
unsigned int surface_width = surface->current.width;
|
||||||
|
unsigned int surface_height = surface->current.height;
|
||||||
|
surface_width = scale_data->width_scale * surface_width;
|
||||||
|
surface_height = scale_data->height_scale * surface_height;
|
||||||
|
|
||||||
|
if (surface_height > 0 && surface_width > 0) {
|
||||||
|
wlr_scene_buffer_set_dest_size(buffer, surface_width, surface_height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void fadeout_layer_animation_next_tick(LayerSurface *l) {
|
void fadeout_layer_animation_next_tick(LayerSurface *l) {
|
||||||
if (!l)
|
if (!l)
|
||||||
return;
|
return;
|
||||||
@@ -271,8 +293,21 @@ void layer_animation_next_tick(LayerSurface *l) {
|
|||||||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||||
scene_buffer_apply_opacity, &opacity);
|
scene_buffer_apply_opacity, &opacity);
|
||||||
|
|
||||||
|
animationScale scale_data;
|
||||||
|
scale_data.width_scale = (float)width / (float)l->current.width;
|
||||||
|
scale_data.height_scale = (float)height / (float)l->current.height;
|
||||||
|
|
||||||
wlr_scene_node_set_position(&l->scene->node, x, y);
|
wlr_scene_node_set_position(&l->scene->node, x, y);
|
||||||
|
|
||||||
|
if (((!l->animation_type_open &&
|
||||||
|
strcmp(layer_animation_type_open, "zoom") == 0) ||
|
||||||
|
(l->animation_type_open &&
|
||||||
|
strcmp(l->animation_type_open, "zoom") == 0)) &&
|
||||||
|
(scale_data.width_scale != 1.0 || scale_data.height_scale != 1.0)) {
|
||||||
|
wlr_scene_node_for_each_buffer(
|
||||||
|
&l->scene->node, layer_scene_buffer_apply_effect, &scale_data);
|
||||||
|
}
|
||||||
|
|
||||||
l->animation.current = (struct wlr_box){
|
l->animation.current = (struct wlr_box){
|
||||||
.x = x,
|
.x = x,
|
||||||
.y = y,
|
.y = y,
|
||||||
@@ -368,12 +403,31 @@ void layer_set_pending_state(LayerSurface *l) {
|
|||||||
if (!l || !l->mapped)
|
if (!l || !l->mapped)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const struct wlr_layer_surface_v1_state *state = &l->layer_surface->current;
|
||||||
|
struct wlr_box usable_area;
|
||||||
|
|
||||||
|
if (state->exclusive_zone > 0 || state->exclusive_zone == -1)
|
||||||
|
usable_area = l->mon->m;
|
||||||
|
else
|
||||||
|
usable_area = l->mon->w;
|
||||||
l->pending = l->geom;
|
l->pending = l->geom;
|
||||||
|
|
||||||
if (l->animation.action == OPEN) {
|
if (l->animation.action == OPEN) {
|
||||||
|
|
||||||
if ((!l->animation_type_open &&
|
if ((!l->animation_type_open &&
|
||||||
strcmp(layer_animation_type_open, "slide") == 0) ||
|
strcmp(layer_animation_type_open, "zoom") == 0) ||
|
||||||
(l->animation_type_open &&
|
(l->animation_type_open &&
|
||||||
strcmp(l->animation_type_open, "slide") == 0)) {
|
strcmp(l->animation_type_open, "zoom") == 0)) {
|
||||||
|
l->animainit_geom.width = l->geom.width * zoom_initial_ratio;
|
||||||
|
l->animainit_geom.height = l->geom.height * zoom_initial_ratio;
|
||||||
|
l->animainit_geom.x = usable_area.x + usable_area.width / 2 -
|
||||||
|
l->animainit_geom.width / 2;
|
||||||
|
l->animainit_geom.y = usable_area.y + usable_area.height / 2 -
|
||||||
|
l->animainit_geom.height / 2;
|
||||||
|
} else if ((!l->animation_type_open &&
|
||||||
|
strcmp(layer_animation_type_open, "slide") == 0) ||
|
||||||
|
(l->animation_type_open &&
|
||||||
|
strcmp(l->animation_type_open, "slide") == 0)) {
|
||||||
|
|
||||||
set_layer_dir_animaiton(l, &l->animainit_geom);
|
set_layer_dir_animaiton(l, &l->animainit_geom);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user