Enable custom corner radius
This commit is contained in:
+11
-2
@@ -25,7 +25,7 @@ static void s_select_up_handler(ClickRecognizerRef recognizer, void *context) {}
|
||||
|
||||
static void s_main_layer_update_proc(Layer *layer, GContext *ctx) {
|
||||
graphics_context_set_fill_color(ctx, s_current_neat_bar->background_color);
|
||||
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone); // TODO enable legacy corners
|
||||
graphics_fill_rect(ctx, layer_get_bounds(layer), s_current_neat_bar->corner_radius, GCornersLeft);
|
||||
}
|
||||
|
||||
static void s_base_click_config_provider(void *config_context) {
|
||||
@@ -59,6 +59,14 @@ void neat_bar_layer_set_click_config_provider(NeatBarLayer *neat_bar, ClickConfi
|
||||
s_update_click_config_provider(neat_bar);
|
||||
}
|
||||
|
||||
void neat_bar_layer_set_corner_radius(NeatBarLayer *neat_bar, uint16_t corner_radius) {
|
||||
if (corner_radius == 0) {
|
||||
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;
|
||||
@@ -107,12 +115,13 @@ 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_layer = layer_create(GRect(PBL_DISPLAY_WIDTH - ACTION_BAR_WIDTH, 0, ACTION_BAR_WIDTH, PBL_DISPLAY_HEIGHT));
|
||||
neat_bar->main_layer = layer_create(GRect(PBL_DISPLAY_WIDTH - ACTION_BAR_WIDTH, 0, ACTION_BAR_WIDTH, PBL_DISPLAY_HEIGHT)); // TODO allow custom GRect
|
||||
neat_bar->up_layer = NULL;
|
||||
neat_bar->down_layer = NULL;
|
||||
neat_bar->select_layer = NULL;
|
||||
neat_bar->click_config_provider = NULL;
|
||||
neat_bar->background_color = GColorBlack;
|
||||
neat_bar->corner_radius = 0;
|
||||
neat_bar->context = NULL;
|
||||
layer_set_update_proc(neat_bar->main_layer, s_main_layer_update_proc);
|
||||
s_current_neat_bar = neat_bar;
|
||||
|
||||
+3
-1
@@ -13,14 +13,16 @@ typedef struct {
|
||||
BitmapLayer *select_layer;
|
||||
ClickConfigProvider click_config_provider;
|
||||
GColor8 background_color;
|
||||
uint16_t corner_radius;
|
||||
//int8_t spread; // positive integers push the icons further apart; negative integers pull them together
|
||||
//uint8_t animation_type; // 0 = press, 1 = invert
|
||||
//uint8_t shape; // 0 = rect/round, 1 = rect/rect, 2 = rect/round (legacy), 3 = rect/rect (legacy)
|
||||
//bool force_rectangular;
|
||||
void *context;
|
||||
} NeatBarLayer;
|
||||
|
||||
NeatBarLayer *neat_bar_layer_create();
|
||||
void neat_bar_layer_set_icon(NeatBarLayer *layer, ButtonId button_id, GBitmap *icon);
|
||||
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_click_config_provider(NeatBarLayer *neat_bar, ClickConfigProvider click_config_provider);
|
||||
void neat_bar_layer_add_to_window(NeatBarLayer *neat_bar, Window *window);
|
||||
|
||||
Reference in New Issue
Block a user