mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-05-13 16:37:27 +00:00
DRYer
This commit is contained in:
parent
43769bc3e0
commit
e15e882d10
3 changed files with 6 additions and 6 deletions
|
|
@ -15,6 +15,8 @@ typedef enum { EASING_STEP_START, EASING_STEP_END, EASING_STEP_NONE, EASING_STEP
|
|||
#ifndef ANIMATION_INTERNAL_API
|
||||
typedef struct {int x;} *Animation;
|
||||
#endif
|
||||
#define EASE_IN_OUT 0.42, 0, 0.58, 1
|
||||
#define ANIMATION_SAMPLE_WAIT (50 * MONOTONIC_T_1e6)
|
||||
Animation* alloc_animation(void);
|
||||
double apply_easing_curve(const Animation *a, double t /* must be between 0 and 1*/, monotonic_t duration);
|
||||
bool animation_is_valid(const Animation *a);
|
||||
|
|
|
|||
|
|
@ -680,7 +680,7 @@ collect_cursor_info(CursorRenderInfo *ans, Window *w, monotonic_t now, OSWindow
|
|||
monotonic_t time_into_cycle = time_since_start_blink % duration;
|
||||
double frac_into_cycle = (double)time_into_cycle / (double)duration;
|
||||
ans->opacity = (float)apply_easing_curve(OPT(animation.cursor), frac_into_cycle, duration);
|
||||
set_maximum_wait(ms_to_monotonic_t(50));
|
||||
set_maximum_wait(ANIMATION_SAMPLE_WAIT);
|
||||
} else {
|
||||
monotonic_t n = time_since_start_blink / OPT(cursor_blink_interval);
|
||||
ans->opacity = 1 - n % 2;
|
||||
|
|
@ -802,9 +802,7 @@ render_prepared_os_window(OSWindow *os_window, unsigned int active_window_id, co
|
|||
if (w->visible && WD.screen) {
|
||||
bool is_active_window = i == tab->active_window;
|
||||
draw_cells(WD.vao_idx, &WD, os_window, is_active_window, false, num_of_visible_windows == 1, w);
|
||||
if (WD.screen->start_visual_bell_at != 0) {
|
||||
set_maximum_wait(OPT(repaint_delay));
|
||||
}
|
||||
if (WD.screen->start_visual_bell_at != 0) set_maximum_wait(ANIMATION_SAMPLE_WAIT);
|
||||
w->cursor_opacity_at_last_render = WD.screen->cursor_render_info.opacity; w->last_cursor_shape = WD.screen->cursor_render_info.shape;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -982,8 +982,8 @@ get_visual_bell_intensity(Screen *screen) {
|
|||
if (!default_visual_bell_animation) {
|
||||
default_visual_bell_animation = alloc_animation();
|
||||
if (!default_visual_bell_animation) fatal("Out of memory");
|
||||
add_cubic_bezier_animation(default_visual_bell_animation, 0, 1, 0.42, 0, 0.58, 1);
|
||||
add_cubic_bezier_animation(default_visual_bell_animation, 1, 0, 0.42, 0, 0.58, 1);
|
||||
add_cubic_bezier_animation(default_visual_bell_animation, 0, 1, EASE_IN_OUT);
|
||||
add_cubic_bezier_animation(default_visual_bell_animation, 1, 0, EASE_IN_OUT);
|
||||
}
|
||||
const monotonic_t progress = monotonic() - screen->start_visual_bell_at;
|
||||
const monotonic_t duration = OPT(visual_bell_duration) / 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue