Make bar height adjustable
This commit is contained in:
+15
-3
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user