Compare commits
2 Commits
fd01b98223
...
8252e6ef34
| Author | SHA1 | Date | |
|---|---|---|---|
| 8252e6ef34 | |||
| 47c5134228 |
+24
-5
@@ -8,13 +8,17 @@
|
||||
const uint16_t UP_Y = 45;
|
||||
const uint16_t SELECT_Y = 105;
|
||||
const uint16_t DOWN_Y = 165;
|
||||
#elif PBL_PLATFORM_GABBRO // TODO Improve button positions (validate against official)
|
||||
const uint16_t UP_Y = 90;
|
||||
const uint16_t SELECT_Y = 121;
|
||||
const uint16_t DOWN_Y = 160;
|
||||
#else
|
||||
const uint16_t UP_Y = 50;
|
||||
const uint16_t SELECT_Y = 90;
|
||||
const uint16_t DOWN_Y = 120;
|
||||
#endif
|
||||
|
||||
static const GRect s_base_grect = GRect(PBL_DISPLAY_WIDTH - ACTION_BAR_WIDTH, 0, ACTION_BAR_WIDTH, PBL_DISPLAY_HEIGHT);
|
||||
static const GRect s_base_grect_rect = GRect(PBL_DISPLAY_WIDTH - ACTION_BAR_WIDTH, 0, ACTION_BAR_WIDTH, PBL_DISPLAY_HEIGHT);
|
||||
|
||||
static NeatBarLayer *s_current_neat_bar = NULL;
|
||||
|
||||
@@ -26,6 +30,7 @@ static void s_select_down_handler(ClickRecognizerRef recognizer, void *context)
|
||||
static void s_select_up_handler(ClickRecognizerRef recognizer, void *context) {}
|
||||
|
||||
static void s_main_layer_update_proc(Layer *layer, GContext *ctx) {
|
||||
graphics_context_set_antialiased(ctx, false);
|
||||
graphics_context_set_fill_color(ctx, s_current_neat_bar->background_color);
|
||||
graphics_fill_rect(ctx, layer_get_bounds(layer), s_current_neat_bar->corner_radius, s_current_neat_bar->floating ? GCornersAll : GCornersLeft);
|
||||
}
|
||||
@@ -65,12 +70,12 @@ void neat_bar_layer_set_floating(NeatBarLayer *neat_bar, bool floating) {
|
||||
if (floating == neat_bar->floating) {
|
||||
return;
|
||||
}
|
||||
uint16_t x = s_base_grect.origin.x;
|
||||
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(s_current_neat_bar->main_layer, s_current_neat_bar->main_grect);
|
||||
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect);
|
||||
neat_bar->floating = floating;
|
||||
layer_mark_dirty(neat_bar->main_layer);
|
||||
}
|
||||
@@ -83,6 +88,20 @@ void neat_bar_layer_set_corner_radius(NeatBarLayer *neat_bar, uint16_t corner_ra
|
||||
layer_mark_dirty(neat_bar->main_layer);
|
||||
}
|
||||
|
||||
void neat_bar_layer_set_theme_default_rect(NeatBarLayer *neat_bar) {
|
||||
neat_bar_layer_set_floating(neat_bar, false);
|
||||
neat_bar->main_grect = s_base_grect_rect;
|
||||
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect);
|
||||
neat_bar_layer_set_corner_radius(neat_bar, 0);
|
||||
}
|
||||
|
||||
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);
|
||||
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect);
|
||||
neat_bar_layer_set_corner_radius(neat_bar, 3);
|
||||
}
|
||||
|
||||
void neat_bar_layer_set_background_color(NeatBarLayer *neat_bar, GColor background_color) {
|
||||
if (gcolor_equal(background_color, neat_bar->background_color)) {
|
||||
return;
|
||||
@@ -131,8 +150,8 @@ void neat_bar_layer_set_icon(NeatBarLayer *neat_bar, ButtonId button_id, GBitmap
|
||||
|
||||
NeatBarLayer *neat_bar_layer_create() {
|
||||
NeatBarLayer *neat_bar = malloc(sizeof(NeatBarLayer));
|
||||
neat_bar->main_grect = s_base_grect;
|
||||
neat_bar->main_layer = layer_create(s_base_grect);
|
||||
neat_bar->main_grect = s_base_grect_rect;
|
||||
neat_bar->main_layer = layer_create(s_base_grect_rect);
|
||||
neat_bar->up_layer = NULL;
|
||||
neat_bar->down_layer = NULL;
|
||||
neat_bar->select_layer = NULL;
|
||||
|
||||
@@ -25,6 +25,8 @@ typedef struct {
|
||||
|
||||
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_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);
|
||||
|
||||
Reference in New Issue
Block a user