From 7155e2f4f04556115e91f3ca1b648b72f2310d45 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 20 Jul 2026 20:28:58 -0400 Subject: [PATCH] Allow disabling animations --- src/c/neat_bar.c | 30 +++++++++++++++++++++--------- src/c/neat_bar.h | 4 +++- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/c/neat_bar.c b/src/c/neat_bar.c index 15a8af5..65d8e5a 100644 --- a/src/c/neat_bar.c +++ b/src/c/neat_bar.c @@ -147,12 +147,14 @@ static void s_main_layer_update_proc(Layer *layer, GContext *ctx) { static void s_base_click_config_provider(void *config_context) { NeatBarLayer *neat_bar = config_context; void *context = neat_bar->context ? neat_bar->context : neat_bar; - window_raw_click_subscribe(BUTTON_ID_UP, s_up_down_handler, s_up_up_handler, neat_bar); - window_raw_click_subscribe(BUTTON_ID_DOWN, s_down_down_handler, s_down_up_handler, neat_bar); - window_raw_click_subscribe(BUTTON_ID_SELECT, s_select_down_handler, s_select_up_handler, neat_bar); - window_set_click_context(BUTTON_ID_UP, context); - window_set_click_context(BUTTON_ID_DOWN, context); - window_set_click_context(BUTTON_ID_SELECT, context); + if (neat_bar->animations_enabled) { + window_raw_click_subscribe(BUTTON_ID_UP, s_up_down_handler, s_up_up_handler, neat_bar); + window_raw_click_subscribe(BUTTON_ID_DOWN, s_down_down_handler, s_down_up_handler, neat_bar); + window_raw_click_subscribe(BUTTON_ID_SELECT, s_select_down_handler, s_select_up_handler, neat_bar); + window_set_click_context(BUTTON_ID_UP, context); + window_set_click_context(BUTTON_ID_DOWN, context); + window_set_click_context(BUTTON_ID_SELECT, context); + } if (neat_bar->click_config_provider) { neat_bar->click_config_provider(context); } @@ -192,11 +194,12 @@ void neat_bar_layer_set_click_config_provider(NeatBarLayer *neat_bar, ClickConfi s_update_click_config_provider(neat_bar); } -void neat_bar_layer_set_animations_move_distance(NeatBarLayer *neat_bar, int8_t distance) { - if (distance == neat_bar->animations_move_distance) { +// default: true +void neat_bar_layer_set_animations_enabled(NeatBarLayer *neat_bar, bool enabled) { + if (enabled == neat_bar->animations_enabled) { return; } - neat_bar->animations_move_distance = distance; + neat_bar->animations_enabled = enabled; } // default: false @@ -207,6 +210,14 @@ void neat_bar_layer_set_animations_move_axis(NeatBarLayer *neat_bar, bool use_y_ neat_bar->animations_move_on_y_axis = use_y_axis; } +// default: 5 (rect), 4 (round) +void neat_bar_layer_set_animations_move_distance(NeatBarLayer *neat_bar, int8_t distance) { + if (distance == neat_bar->animations_move_distance) { + return; + } + neat_bar->animations_move_distance = distance; +} + // default: 144 void neat_bar_layer_set_animations_duration(NeatBarLayer *neat_bar, uint8_t duration_ms) { if (duration_ms == neat_bar->animations_duration) { @@ -355,6 +366,7 @@ NeatBarLayer *neat_bar_layer_create() { neat_bar->bar_corner_radius = 0; neat_bar->bar_x_offset = 0; neat_bar->icons_spread = 0; + neat_bar->animations_enabled = true; neat_bar->animations_move_on_y_axis = false; neat_bar->animations_move_distance = ANIM_DISTANCE; neat_bar->animations_duration = 144; diff --git a/src/c/neat_bar.h b/src/c/neat_bar.h index 8d9b552..7bbf627 100644 --- a/src/c/neat_bar.h +++ b/src/c/neat_bar.h @@ -23,6 +23,7 @@ typedef struct { uint16_t bar_corner_radius; uint16_t bar_x_offset; int8_t icons_spread; + bool animations_enabled; bool animations_move_on_y_axis; int8_t animations_move_distance; uint8_t animations_duration; @@ -35,8 +36,9 @@ typedef struct { void neat_bar_layer_add_to_window(NeatBarLayer *neat_bar, Window *window); void neat_bar_layer_set_click_config_provider(NeatBarLayer *neat_bar, ClickConfigProvider click_config_provider); -void neat_bar_layer_set_animations_move_distance(NeatBarLayer *neat_bar, int8_t distance); +void neat_bar_layer_set_animations_enabled(NeatBarLayer *neat_bar, bool enabled); void neat_bar_layer_set_animations_move_axis(NeatBarLayer *neat_bar, bool use_y_axis); +void neat_bar_layer_set_animations_move_distance(NeatBarLayer *neat_bar, int8_t distance); void neat_bar_layer_set_animations_duration(NeatBarLayer *neat_bar, uint8_t duration_ms); void neat_bar_layer_set_floating(NeatBarLayer *neat_bar, uint16_t x_offset); void neat_bar_layer_set_width(NeatBarLayer *neat_bar, uint16_t width);