Replace arbitrary spacesaver theme w/adjustable width
This commit is contained in:
+49
-41
@@ -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) {
|
static void s_recenter_icons(NeatBarLayer *neat_bar) {
|
||||||
if (neat_bar->up_layer) {
|
if (neat_bar->up_layer) {
|
||||||
layer_set_frame(bitmap_layer_get_layer(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);
|
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) {
|
void neat_bar_layer_set_theme_legacy_rect(NeatBarLayer *neat_bar) {
|
||||||
neat_bar_layer_set_floating(neat_bar, false);
|
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);
|
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);
|
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) {
|
void neat_bar_layer_set_background_color(NeatBarLayer *neat_bar, GColor background_color) {
|
||||||
if (gcolor_equal(background_color, neat_bar->background_color)) {
|
if (gcolor_equal(background_color, neat_bar->background_color)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
+2
-2
@@ -19,15 +19,15 @@ typedef struct {
|
|||||||
//uint8_t top_shrinkage;
|
//uint8_t top_shrinkage;
|
||||||
//uint8_t bottom_shrinkage;
|
//uint8_t bottom_shrinkage;
|
||||||
//int8_t spread; // positive integers push the icons further apart; negative integers pull them together
|
//int8_t spread; // positive integers push the icons further apart; negative integers pull them together
|
||||||
//uint8_t animation_type; // 0 = press, 1 = invert
|
//bool use_legacy_animations
|
||||||
void *context;
|
void *context;
|
||||||
} NeatBarLayer;
|
} NeatBarLayer;
|
||||||
|
|
||||||
NeatBarLayer *neat_bar_layer_create();
|
NeatBarLayer *neat_bar_layer_create();
|
||||||
void neat_bar_layer_set_icon(NeatBarLayer *layer, ButtonId button_id, GBitmap *icon);
|
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_default_rect(NeatBarLayer *neat_bar);
|
||||||
void neat_bar_layer_set_theme_spacesaver_rect(NeatBarLayer *neat_bar);
|
|
||||||
void neat_bar_layer_set_theme_legacy_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_floating(NeatBarLayer *neat_bar, bool floating);
|
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_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_background_color(NeatBarLayer *neat_bar, GColor background_color);
|
||||||
|
|||||||
Reference in New Issue
Block a user