mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2025-10-29 05:40:21 -04:00
feat: layer zoom in type animation
This commit is contained in:
parent
79d82cfa12
commit
b9b82c1c96
1 changed files with 56 additions and 2 deletions
|
|
@ -197,6 +197,28 @@ void layer_draw_shadow(LayerSurface *l) {
|
|||
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) {
|
||||
if (!l)
|
||||
return;
|
||||
|
|
@ -271,8 +293,21 @@ void layer_animation_next_tick(LayerSurface *l) {
|
|||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||
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);
|
||||
|
||||
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){
|
||||
.x = x,
|
||||
.y = y,
|
||||
|
|
@ -368,12 +403,31 @@ void layer_set_pending_state(LayerSurface *l) {
|
|||
if (!l || !l->mapped)
|
||||
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;
|
||||
|
||||
if (l->animation.action == OPEN) {
|
||||
|
||||
if ((!l->animation_type_open &&
|
||||
strcmp(layer_animation_type_open, "slide") == 0) ||
|
||||
strcmp(layer_animation_type_open, "zoom") == 0) ||
|
||||
(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);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue