From 92780d18b1cc2f823ab0e27d76ef4d944fa88465 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Sun, 19 Jul 2026 11:56:27 -0400 Subject: [PATCH] Make bar height adjustable --- src/c/neat_bar.c | 18 +++++++++++++++--- src/c/neat_bar.h | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/c/neat_bar.c b/src/c/neat_bar.c index b09c79a..c1ef1c7 100644 --- a/src/c/neat_bar.c +++ b/src/c/neat_bar.c @@ -56,17 +56,18 @@ inline static void s_update_click_config_provider(NeatBarLayer *neat_bar) { } static void s_recenter_icons(NeatBarLayer *neat_bar) { + int16_t y_offset = neat_bar->main_grect.origin.y; if (neat_bar->up_layer) { layer_set_frame(bitmap_layer_get_layer(neat_bar->up_layer), - GRect(1, UP_Y, neat_bar->main_grect.size.w, 18)); + GRect(1, UP_Y - y_offset, neat_bar->main_grect.size.w, 18)); } if (neat_bar->select_layer) { layer_set_frame(bitmap_layer_get_layer(neat_bar->select_layer), - GRect(1, SELECT_Y, neat_bar->main_grect.size.w, 18)); + GRect(1, SELECT_Y - y_offset, neat_bar->main_grect.size.w, 18)); } if (neat_bar->down_layer) { layer_set_frame(bitmap_layer_get_layer(neat_bar->down_layer), - GRect(1, DOWN_Y, neat_bar->main_grect.size.w, 18)); + GRect(1, DOWN_Y - y_offset, neat_bar->main_grect.size.w, 18)); } } @@ -127,6 +128,17 @@ void neat_bar_layer_set_width(NeatBarLayer *neat_bar, uint16_t width) { s_recenter_icons(neat_bar); } +void neat_bar_layer_set_height(NeatBarLayer *neat_bar, uint16_t height) { + if (height == neat_bar->main_grect.size.h) { + return; + } + neat_bar->main_grect.origin.y = (PBL_DISPLAY_HEIGHT - height) / 2; + neat_bar->main_grect.size.h = height; + layer_set_frame(neat_bar->main_layer, neat_bar->main_grect); + layer_mark_dirty(neat_bar->main_layer); + s_recenter_icons(neat_bar); +} + void neat_bar_layer_set_corner_radius(NeatBarLayer *neat_bar, uint16_t corner_radius) { if (corner_radius == neat_bar->corner_radius) { return; diff --git a/src/c/neat_bar.h b/src/c/neat_bar.h index 9c7c0e6..e44d1ee 100644 --- a/src/c/neat_bar.h +++ b/src/c/neat_bar.h @@ -28,6 +28,7 @@ void neat_bar_layer_set_icon(NeatBarLayer *layer, ButtonId button_id, GBitmap *i 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_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_floating(NeatBarLayer *neat_bar, bool floating); 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);