Replace arbitrary spacesaver theme w/adjustable width

This commit is contained in:
2026-07-19 11:24:59 -04:00
parent e2619526d5
commit 65db01d4c3
2 changed files with 51 additions and 43 deletions
+49 -41
View File
@@ -55,39 +55,6 @@ inline static void s_update_click_config_provider(NeatBarLayer *neat_bar) {
}
}
void neat_bar_layer_add_to_window(NeatBarLayer *neat_bar, Window *window) {
layer_add_child(window_get_root_layer(window), neat_bar->main_layer);
neat_bar->window = window;
s_update_click_config_provider(neat_bar);
}
void neat_bar_layer_set_click_config_provider(NeatBarLayer *neat_bar, ClickConfigProvider click_config_provider) {
neat_bar->click_config_provider = click_config_provider;
s_update_click_config_provider(neat_bar);
}
void neat_bar_layer_set_floating(NeatBarLayer *neat_bar, bool floating) {
if (floating == neat_bar->floating) {
return;
}
uint16_t x = s_base_grect_rect.origin.x;
if (floating) {
x = x - 2;
}
neat_bar->main_grect = GRect(x, neat_bar->main_grect.origin.y, neat_bar->main_grect.size.w, neat_bar->main_grect.size.h);
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect);
neat_bar->floating = floating;
layer_mark_dirty(neat_bar->main_layer);
}
void neat_bar_layer_set_corner_radius(NeatBarLayer *neat_bar, uint16_t corner_radius) {
if (corner_radius == neat_bar->corner_radius) {
return;
}
neat_bar->corner_radius = corner_radius;
layer_mark_dirty(neat_bar->main_layer);
}
static void s_recenter_icons(NeatBarLayer *neat_bar) {
if (neat_bar->up_layer) {
layer_set_frame(bitmap_layer_get_layer(neat_bar->up_layer),
@@ -111,14 +78,6 @@ void neat_bar_layer_set_theme_default_rect(NeatBarLayer *neat_bar) {
s_recenter_icons(neat_bar);
}
void neat_bar_layer_set_theme_spacesaver_rect(NeatBarLayer *neat_bar) {
neat_bar_layer_set_floating(neat_bar, false);
neat_bar->main_grect = GRect(s_base_grect_rect.origin.x + 12, 0, s_base_grect_rect.size.w - 12, s_base_grect_rect.size.h);
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect);
neat_bar_layer_set_corner_radius(neat_bar, 0);
s_recenter_icons(neat_bar);
}
void neat_bar_layer_set_theme_legacy_rect(NeatBarLayer *neat_bar) {
neat_bar_layer_set_floating(neat_bar, false);
neat_bar->main_grect = GRect(s_base_grect_rect.origin.x, 4, s_base_grect_rect.size.w, s_base_grect_rect.size.h - 8);
@@ -127,6 +86,55 @@ void neat_bar_layer_set_theme_legacy_rect(NeatBarLayer *neat_bar) {
s_recenter_icons(neat_bar);
}
void neat_bar_layer_add_to_window(NeatBarLayer *neat_bar, Window *window) {
layer_add_child(window_get_root_layer(window), neat_bar->main_layer);
neat_bar->window = window;
s_update_click_config_provider(neat_bar);
}
void neat_bar_layer_set_click_config_provider(NeatBarLayer *neat_bar, ClickConfigProvider click_config_provider) {
neat_bar->click_config_provider = click_config_provider;
s_update_click_config_provider(neat_bar);
}
void neat_bar_layer_set_floating(NeatBarLayer *neat_bar, bool floating) {
if (floating == neat_bar->floating) {
return;
}
uint16_t x = neat_bar->main_grect.origin.x;
if (floating) {
x = x - 2;
}
neat_bar->main_grect = GRect(x, neat_bar->main_grect.origin.y, neat_bar->main_grect.size.w, neat_bar->main_grect.size.h);
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect);
neat_bar->floating = floating;
layer_mark_dirty(neat_bar->main_layer);
}
void neat_bar_layer_set_width(NeatBarLayer *neat_bar, uint16_t width) {
if (width == neat_bar->main_grect.size.w) {
return;
}
neat_bar->main_grect.origin.x = PBL_DISPLAY_WIDTH - width;
neat_bar->main_grect.size.w = width;
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect);
if (neat_bar->floating) {
neat_bar->floating = false;
neat_bar_layer_set_floating(neat_bar, true);
} else {
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;
}
neat_bar->corner_radius = corner_radius;
layer_mark_dirty(neat_bar->main_layer);
}
void neat_bar_layer_set_background_color(NeatBarLayer *neat_bar, GColor background_color) {
if (gcolor_equal(background_color, neat_bar->background_color)) {
return;