定制不同动画速度

This commit is contained in:
DreamMaoMao 2025-02-06 11:04:34 +08:00
parent 9b809f4011
commit a2df6eb124
2 changed files with 18 additions and 2 deletions

View file

@ -10,7 +10,10 @@ static const bool animations = true; // Enable animations
static const char *animation_type = "slide"; //slide or zoom static const char *animation_type = "slide"; //slide or zoom
static const char animation_fade_in = 0; // Enable animation fade in static const char animation_fade_in = 0; // Enable animation fade in
static const float zoom_initial_ratio = 0.5; // Initial window ratio for animations static const float zoom_initial_ratio = 0.5; // Initial window ratio for animations
static const uint32_t animation_duration = 300; // Animation speed static const uint32_t animation_duration_move = 300; // Animation move speed
static const uint32_t animation_duration_open = 300; // Animation open speed
static const uint32_t animation_duration_close = 200; // Animation close speed
static const uint32_t animation_duration_tag = 300; // Animation tag speed
// static const double animation_curve[4] = {0.05,0.9,0.1,1.05}; // Animation curve // static const double animation_curve[4] = {0.05,0.9,0.1,1.05}; // Animation curve
static const double animation_curve[4] = {0.46,1.0,0.29,0.99}; // Animation curve static const double animation_curve[4] = {0.46,1.0,0.29,0.99}; // Animation curve

15
main.c
View file

@ -132,6 +132,7 @@ struct dwl_animation {
bool begin_fade_in; bool begin_fade_in;
uint32_t total_frames; uint32_t total_frames;
uint32_t passed_frames; uint32_t passed_frames;
uint32_t duration;
struct wlr_box initial; struct wlr_box initial;
struct wlr_box current; struct wlr_box current;
}; };
@ -1702,7 +1703,7 @@ void client_commit(Client *c)
{ {
// 设置动画速度 // 设置动画速度
c->animation.passed_frames = 0; c->animation.passed_frames = 0;
c->animation.total_frames = animation_duration / output_frame_duration_ms(c); c->animation.total_frames = c->animation.duration / output_frame_duration_ms(c);
// 标记动画开始 // 标记动画开始
c->animation.running = true; c->animation.running = true;
@ -3803,6 +3804,18 @@ resize(Client *c, struct wlr_box geo, int interact)
client_set_opacity(c,1); client_set_opacity(c,1);
} }
if(c->iskilling) {
c->animation.duration = animation_duration_close;
} else if(c->animation.tagouting) {
c->animation.duration = animation_duration_tag;
} else if(c->animation.tagining) {
c->animation.duration = animation_duration_tag;
} else if(c->is_open_animation) {
c->animation.duration = animation_duration_open;
} else {
c->animation.duration = animation_duration_move;
}
// 动画起始位置大小设置 // 动画起始位置大小设置
if(c->animation.tagouting) { if(c->animation.tagouting) {
c->animainit_geom = c->geom; c->animainit_geom = c->geom;