feat: add fadein fadeout curve
This commit is contained in:
@@ -48,6 +48,8 @@ animation_curve_move=0.46,1.0,0.29,1
|
|||||||
animation_curve_tag=0.46,1.0,0.29,1
|
animation_curve_tag=0.46,1.0,0.29,1
|
||||||
animation_curve_close=0.08,0.92,0,1
|
animation_curve_close=0.08,0.92,0,1
|
||||||
animation_curve_focus=0.46,1.0,0.29,1
|
animation_curve_focus=0.46,1.0,0.29,1
|
||||||
|
animation_curve_opafadeout=0.5,0.5,0.5,0.5
|
||||||
|
animation_curve_opafadein=0.46,1.0,0.29,1
|
||||||
|
|
||||||
# Scroller Layout Setting
|
# Scroller Layout Setting
|
||||||
scroller_structs=20
|
scroller_structs=20
|
||||||
|
|||||||
@@ -630,6 +630,7 @@ void fadeout_client_animation_next_tick(Client *c) {
|
|||||||
|
|
||||||
int type = c->animation.action = c->animation.action;
|
int type = c->animation.action = c->animation.action;
|
||||||
double factor = find_animation_curve_at(animation_passed, type);
|
double factor = find_animation_curve_at(animation_passed, type);
|
||||||
|
|
||||||
uint32_t width = c->animation.initial.width +
|
uint32_t width = c->animation.initial.width +
|
||||||
(c->current.width - c->animation.initial.width) * factor;
|
(c->current.width - c->animation.initial.width) * factor;
|
||||||
uint32_t height =
|
uint32_t height =
|
||||||
@@ -650,7 +651,13 @@ void fadeout_client_animation_next_tick(Client *c) {
|
|||||||
.height = height,
|
.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)
|
if (animation_fade_out && !c->nofadeout)
|
||||||
wlr_scene_node_for_each_buffer(&c->scene->node,
|
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
|
? (double)passed_time / (double)c->animation.duration
|
||||||
: 1.0;
|
: 1.0;
|
||||||
|
|
||||||
|
double opacity_eased_progress =
|
||||||
|
find_animation_curve_at(linear_progress, OPAFADEIN);
|
||||||
|
|
||||||
float percent =
|
float percent =
|
||||||
animation_fade_in && !c->nofadein ? linear_progress : 1.0;
|
animation_fade_in && !c->nofadein ? opacity_eased_progress : 1.0;
|
||||||
float opacity =
|
float opacity =
|
||||||
c == selmon->sel ? c->focused_opacity : c->unfocused_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;
|
animation_curve = animation_curve_close;
|
||||||
} else if (type == FOCUS) {
|
} else if (type == FOCUS) {
|
||||||
animation_curve = animation_curve_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 {
|
} else {
|
||||||
animation_curve = animation_curve_move;
|
animation_curve = animation_curve_move;
|
||||||
}
|
}
|
||||||
@@ -32,6 +36,10 @@ void init_baked_points(void) {
|
|||||||
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_close));
|
calloc(BAKED_POINTS_COUNT, sizeof(*baked_points_close));
|
||||||
baked_points_focus =
|
baked_points_focus =
|
||||||
calloc(BAKED_POINTS_COUNT, sizeof(*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++) {
|
for (uint32_t i = 0; i < BAKED_POINTS_COUNT; i++) {
|
||||||
baked_points_move[i] = calculate_animation_curve_at(
|
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(
|
baked_points_focus[i] = calculate_animation_curve_at(
|
||||||
(double)i / (BAKED_POINTS_COUNT - 1), FOCUS);
|
(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) {
|
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;
|
baked_points = baked_points_close;
|
||||||
} else if (type == FOCUS) {
|
} else if (type == FOCUS) {
|
||||||
baked_points = baked_points_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 {
|
} else {
|
||||||
baked_points = baked_points_move;
|
baked_points = baked_points_move;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -276,7 +276,13 @@ void fadeout_layer_animation_next_tick(LayerSurface *l) {
|
|||||||
.height = height,
|
.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)
|
if (animation_fade_out)
|
||||||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
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 +
|
uint32_t y = l->animation.initial.y +
|
||||||
(l->current.y - l->animation.initial.y) * factor;
|
(l->current.y - l->animation.initial.y) * factor;
|
||||||
|
|
||||||
double opacity = MIN(fadein_begin_opacity +
|
double opacity_eased_progress =
|
||||||
animation_passed * (1.0 - fadein_begin_opacity),
|
find_animation_curve_at(animation_passed, OPAFADEIN);
|
||||||
1.0f);
|
|
||||||
|
double opacity =
|
||||||
|
MIN(fadein_begin_opacity +
|
||||||
|
opacity_eased_progress * (1.0 - fadein_begin_opacity),
|
||||||
|
1.0f);
|
||||||
|
|
||||||
if (animation_fade_in)
|
if (animation_fade_in)
|
||||||
wlr_scene_node_for_each_buffer(&l->scene->node,
|
wlr_scene_node_for_each_buffer(&l->scene->node,
|
||||||
|
|||||||
@@ -194,6 +194,8 @@ typedef struct {
|
|||||||
double animation_curve_tag[4];
|
double animation_curve_tag[4];
|
||||||
double animation_curve_close[4];
|
double animation_curve_close[4];
|
||||||
double animation_curve_focus[4];
|
double animation_curve_focus[4];
|
||||||
|
double animation_curve_opafadein[4];
|
||||||
|
double animation_curve_opafadeout[4];
|
||||||
|
|
||||||
int scroller_structs;
|
int scroller_structs;
|
||||||
float scroller_default_proportion;
|
float scroller_default_proportion;
|
||||||
@@ -1181,6 +1183,22 @@ void parse_option(Config *config, char *key, char *value) {
|
|||||||
"Error: Failed to parse animation_curve_focus: %s\n",
|
"Error: Failed to parse animation_curve_focus: %s\n",
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(key, "animation_curve_opafadein") == 0) {
|
||||||
|
int num =
|
||||||
|
parse_double_array(value, config->animation_curve_opafadein, 4);
|
||||||
|
if (num != 4) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Error: Failed to parse animation_curve_opafadein: %s\n",
|
||||||
|
value);
|
||||||
|
}
|
||||||
|
} else if (strcmp(key, "animation_curve_opafadeout") == 0) {
|
||||||
|
int num =
|
||||||
|
parse_double_array(value, config->animation_curve_opafadeout, 4);
|
||||||
|
if (num != 4) {
|
||||||
|
fprintf(stderr,
|
||||||
|
"Error: Failed to parse animation_curve_opafadeout: %s\n",
|
||||||
|
value);
|
||||||
|
}
|
||||||
} else if (strcmp(key, "scroller_structs") == 0) {
|
} else if (strcmp(key, "scroller_structs") == 0) {
|
||||||
config->scroller_structs = atoi(value);
|
config->scroller_structs = atoi(value);
|
||||||
} else if (strcmp(key, "scroller_default_proportion") == 0) {
|
} else if (strcmp(key, "scroller_default_proportion") == 0) {
|
||||||
@@ -2398,6 +2416,14 @@ void free_baked_points(void) {
|
|||||||
free(baked_points_focus);
|
free(baked_points_focus);
|
||||||
baked_points_focus = NULL;
|
baked_points_focus = NULL;
|
||||||
}
|
}
|
||||||
|
if (baked_points_opafadein) {
|
||||||
|
free(baked_points_opafadein);
|
||||||
|
baked_points_opafadein = NULL;
|
||||||
|
}
|
||||||
|
if (baked_points_opafadeout) {
|
||||||
|
free(baked_points_opafadeout);
|
||||||
|
baked_points_opafadeout = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_config(void) {
|
void free_config(void) {
|
||||||
@@ -2810,6 +2836,10 @@ void override_config(void) {
|
|||||||
sizeof(animation_curve_close));
|
sizeof(animation_curve_close));
|
||||||
memcpy(animation_curve_focus, config.animation_curve_focus,
|
memcpy(animation_curve_focus, config.animation_curve_focus,
|
||||||
sizeof(animation_curve_focus));
|
sizeof(animation_curve_focus));
|
||||||
|
memcpy(animation_curve_opafadein, config.animation_curve_opafadein,
|
||||||
|
sizeof(animation_curve_opafadein));
|
||||||
|
memcpy(animation_curve_opafadeout, config.animation_curve_opafadeout,
|
||||||
|
sizeof(animation_curve_opafadeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_value_default() {
|
void set_value_default() {
|
||||||
@@ -2958,6 +2988,10 @@ void set_value_default() {
|
|||||||
sizeof(animation_curve_close));
|
sizeof(animation_curve_close));
|
||||||
memcpy(config.animation_curve_focus, animation_curve_focus,
|
memcpy(config.animation_curve_focus, animation_curve_focus,
|
||||||
sizeof(animation_curve_focus));
|
sizeof(animation_curve_focus));
|
||||||
|
memcpy(config.animation_curve_opafadein, animation_curve_opafadein,
|
||||||
|
sizeof(animation_curve_opafadein));
|
||||||
|
memcpy(config.animation_curve_opafadeout, animation_curve_opafadeout,
|
||||||
|
sizeof(animation_curve_opafadeout));
|
||||||
|
|
||||||
memcpy(config.rootcolor, rootcolor, sizeof(rootcolor));
|
memcpy(config.rootcolor, rootcolor, sizeof(rootcolor));
|
||||||
memcpy(config.bordercolor, bordercolor, sizeof(bordercolor));
|
memcpy(config.bordercolor, bordercolor, sizeof(bordercolor));
|
||||||
|
|||||||
@@ -26,11 +26,13 @@ uint32_t animation_duration_open = 400; // Animation open speed
|
|||||||
uint32_t animation_duration_tag = 300; // Animation tag speed
|
uint32_t animation_duration_tag = 300; // Animation tag speed
|
||||||
uint32_t animation_duration_close = 300; // Animation close speed
|
uint32_t animation_duration_close = 300; // Animation close speed
|
||||||
uint32_t animation_duration_focus = 0; // Animation focus opacity speed
|
uint32_t animation_duration_focus = 0; // Animation focus opacity speed
|
||||||
double animation_curve_move[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
double animation_curve_move[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
double animation_curve_open[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
double animation_curve_open[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
double animation_curve_tag[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
double animation_curve_tag[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
double animation_curve_close[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
double animation_curve_close[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
double animation_curve_focus[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
double animation_curve_focus[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
|
double animation_curve_opafadein[4] = {0.46, 1.0, 0.29, 0.99}; // 动画曲线
|
||||||
|
double animation_curve_opafadeout[4] = {0.5, 0.5, 0.5, 0.5}; // 动画曲线
|
||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
uint32_t axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔
|
uint32_t axis_bind_apply_timeout = 100; // 滚轮绑定动作的触发的时间间隔
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ enum {
|
|||||||
}; /* EWMH atoms */
|
}; /* EWMH atoms */
|
||||||
#endif
|
#endif
|
||||||
enum { UP, DOWN, LEFT, RIGHT, UNDIR }; /* smartmovewin */
|
enum { UP, DOWN, LEFT, RIGHT, UNDIR }; /* smartmovewin */
|
||||||
enum { NONE, OPEN, MOVE, CLOSE, TAG, FOCUS };
|
enum { NONE, OPEN, MOVE, CLOSE, TAG, FOCUS, OPAFADEIN, OPAFADEOUT };
|
||||||
enum { UNFOLD, FOLD, INVALIDFOLD };
|
enum { UNFOLD, FOLD, INVALIDFOLD };
|
||||||
enum { PREV, NEXT };
|
enum { PREV, NEXT };
|
||||||
enum { STATE_UNSPECIFIED = 0, STATE_ENABLED, STATE_DISABLED };
|
enum { STATE_UNSPECIFIED = 0, STATE_ENABLED, STATE_DISABLED };
|
||||||
@@ -850,6 +850,8 @@ struct dvec2 *baked_points_open;
|
|||||||
struct dvec2 *baked_points_tag;
|
struct dvec2 *baked_points_tag;
|
||||||
struct dvec2 *baked_points_close;
|
struct dvec2 *baked_points_close;
|
||||||
struct dvec2 *baked_points_focus;
|
struct dvec2 *baked_points_focus;
|
||||||
|
struct dvec2 *baked_points_opafadein;
|
||||||
|
struct dvec2 *baked_points_opafadeout;
|
||||||
|
|
||||||
static struct wl_event_source *hide_source;
|
static struct wl_event_source *hide_source;
|
||||||
static bool cursor_hidden = false;
|
static bool cursor_hidden = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user