diff --git a/README.md b/README.md index fd6534b..8995916 100644 --- a/README.md +++ b/README.md @@ -18,10 +18,8 @@ A customizable replacement for the built-in Pebble action bar. - Round style - Using a rectangular bar on a round watch saves space and IMO looks way better ### Pending Features -- Custom icon x offsets - Match move animation distance to stock per-platform - Match move animation duration to stock - Allow customizing move animations - Built-in haptics - Legacy (background invert) animations support -- Teardown/destroy/deinit helper diff --git a/src/c/neat_bar.c b/src/c/neat_bar.c index 31a68ff..c96a0d1 100644 --- a/src/c/neat_bar.c +++ b/src/c/neat_bar.c @@ -295,3 +295,17 @@ NeatBarLayer *neat_bar_layer_create() { s_current_neat_bar = neat_bar; return neat_bar; } + +void neat_bar_layer_destroy(NeatBarLayer *neat_bar) { + if (neat_bar == NULL) { + return; + } + bitmap_layer_destroy(neat_bar->down_layer); + bitmap_layer_destroy(neat_bar->select_layer); + bitmap_layer_destroy(neat_bar->up_layer); + layer_destroy(neat_bar->main_layer); + if (s_current_neat_bar == neat_bar) { + s_current_neat_bar = NULL; + } + free(neat_bar); +} diff --git a/src/c/neat_bar.h b/src/c/neat_bar.h index 4c012bc..caa52fb 100644 --- a/src/c/neat_bar.h +++ b/src/c/neat_bar.h @@ -21,16 +21,17 @@ typedef struct { void *context; } NeatBarLayer; -NeatBarLayer *neat_bar_layer_create(); -void neat_bar_layer_set_icon(NeatBarLayer *layer, ButtonId button_id, GBitmap *icon); void neat_bar_layer_set_theme_default_rect(NeatBarLayer *neat_bar); void neat_bar_layer_set_theme_legacy_rect(NeatBarLayer *neat_bar); +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_floating(NeatBarLayer *neat_bar, uint16_t x_offset); void neat_bar_layer_set_width(NeatBarLayer *neat_bar, uint16_t width); void neat_bar_layer_set_height(NeatBarLayer *neat_bar, uint16_t height); void neat_bar_layer_set_y_offset(NeatBarLayer *neat_bar, uint16_t y_offset); -void neat_bar_layer_set_floating(NeatBarLayer *neat_bar, uint16_t x_offset); void neat_bar_layer_set_corner_radius(NeatBarLayer *neat_bar, uint16_t corner_radius); void neat_bar_layer_set_background_color(NeatBarLayer *neat_bar, GColor background_color); void neat_bar_layer_set_spread(NeatBarLayer *neat_bar, int8_t spread); -void neat_bar_layer_set_click_config_provider(NeatBarLayer *neat_bar, ClickConfigProvider click_config_provider); -void neat_bar_layer_add_to_window(NeatBarLayer *neat_bar, Window *window); +void neat_bar_layer_set_icon(NeatBarLayer *layer, ButtonId button_id, GBitmap *icon); +NeatBarLayer *neat_bar_layer_create(); +void neat_bar_layer_destroy(NeatBarLayer *neat_bar);