mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-02-20 01:40:18 -05:00
feat: add fadein fadeout curve
This commit is contained in:
parent
ddc2448d1c
commit
91f4604199
7 changed files with 92 additions and 12 deletions
|
|
@ -630,6 +630,7 @@ void fadeout_client_animation_next_tick(Client *c) {
|
|||
|
||||
int type = c->animation.action = c->animation.action;
|
||||
double factor = find_animation_curve_at(animation_passed, type);
|
||||
|
||||
uint32_t width = c->animation.initial.width +
|
||||
(c->current.width - c->animation.initial.width) * factor;
|
||||
uint32_t height =
|
||||
|
|
@ -650,7 +651,13 @@ void fadeout_client_animation_next_tick(Client *c) {
|
|||
.height = height,
|
||||
};
|
||||
|
||||
double opacity = MAX(fadeout_begin_opacity - animation_passed, 0);
|
||||
double opacity_eased_progress =
|
||||
find_animation_curve_at(animation_passed, OPAFADEOUT);
|
||||
|
||||
double percent = fadeout_begin_opacity -
|
||||
(opacity_eased_progress * fadeout_begin_opacity);
|
||||
|
||||
double opacity = MAX(percent, 0);
|
||||
|
||||
if (animation_fade_out && !c->nofadeout)
|
||||
wlr_scene_node_for_each_buffer(&c->scene->node,
|
||||
|
|
@ -1109,8 +1116,11 @@ bool client_apply_focus_opacity(Client *c) {
|
|||
? (double)passed_time / (double)c->animation.duration
|
||||
: 1.0;
|
||||
|
||||
double opacity_eased_progress =
|
||||
find_animation_curve_at(linear_progress, OPAFADEIN);
|
||||
|
||||
float percent =
|
||||
animation_fade_in && !c->nofadein ? linear_progress : 1.0;
|
||||
animation_fade_in && !c->nofadein ? opacity_eased_progress : 1.0;
|
||||
float opacity =
|
||||
c == selmon->sel ? c->focused_opacity : c->unfocused_opacity;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ struct dvec2 calculate_animation_curve_at(double t, int type) {
|
|||
animation_curve = animation_curve_close;
|
||||
} else if (type == FOCUS) {
|
||||
animation_curve = animation_curve_focus;
|
||||
} else if (type == OPAFADEIN) {
|
||||
animation_curve = animation_curve_opafadein;
|
||||
} else if (type == OPAFADEOUT) {
|
||||
animation_curve = animation_curve_opafadeout;
|
||||
} else {
|
||||
animation_curve = animation_curve_move;
|
||||
}
|
||||
|
|
@ -32,6 +36,10 @@ void init_baked_points(void) {
|
|||
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_close));
|
||||
baked_points_focus =
|
||||
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_focus));
|
||||
baked_points_opafadein =
|
||||
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_opafadein));
|
||||
baked_points_opafadeout =
|
||||
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_opafadeout));
|
||||
|
||||
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
|
||||
baked_points_move[i] = calculate_animation_curve_at(
|
||||
|
|
@ -53,6 +61,14 @@ void init_baked_points(void) {
|
|||
baked_points_focus[i] = calculate_animation_curve_at(
|
||||
(double)i / (BAKED_POINTS_COUNT - 1), FOCUS);
|
||||
}
|
||||
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
|
||||
baked_points_opafadein[i] = calculate_animation_curve_at(
|
||||
(double)i / (BAKED_POINTS_COUNT - 1), OPAFADEIN);
|
||||
}
|
||||
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
|
||||
baked_points_opafadeout[i] = calculate_animation_curve_at(
|
||||
(double)i / (BAKED_POINTS_COUNT - 1), OPAFADEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
double find_animation_curve_at(double t, int type) {
|
||||
|
|
@ -71,6 +87,10 @@ double find_animation_curve_at(double t, int type) {
|
|||
baked_points = baked_points_close;
|
||||
} else if (type == FOCUS) {
|
||||
baked_points = baked_points_focus;
|
||||
} else if (type == OPAFADEIN) {
|
||||
baked_points = baked_points_opafadein;
|
||||
} else if (type == OPAFADEOUT) {
|
||||
baked_points = baked_points_opafadeout;
|
||||
} else {
|
||||
baked_points = baked_points_move;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -276,7 +276,13 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
|
|||
.height = height,
|
||||
};
|
||||
|
||||
double opacity = MAX(fadeout_begin_opacity - animation_passed, 0.0f);
|
||||
double opacity_eased_progress =
|
||||
find_animation_curve_at(animation_passed, OPAFADEOUT);
|
||||
|
||||
double percent = fadeout_begin_opacity -
|
||||
(opacity_eased_progress * fadeout_begin_opacity);
|
||||
|
||||
double opacity = MAX(percent, 0.0f);
|
||||
|
||||
if (animation_fade_out)
|
||||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||
|
|
@ -318,9 +324,13 @@ void layer_animation_next_tick(LayerSurface *l) {
|
|||
uint32_t y = l->animation.initial.y +
|
||||
(l->current.y - l->animation.initial.y) * factor;
|
||||
|
||||
double opacity = MIN(fadein_begin_opacity +
|
||||
animation_passed * (1.0 - fadein_begin_opacity),
|
||||
1.0f);
|
||||
double opacity_eased_progress =
|
||||
find_animation_curve_at(animation_passed, OPAFADEIN);
|
||||
|
||||
double opacity =
|
||||
MIN(fadein_begin_opacity +
|
||||
opacity_eased_progress * (1.0 - fadein_begin_opacity),
|
||||
1.0f);
|
||||
|
||||
if (animation_fade_in)
|
||||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue