Compare commits
3 Commits
main
...
c52965f888
| Author | SHA1 | Date | |
|---|---|---|---|
| c52965f888 | |||
| 1ed96b3b1d | |||
| 0e30d214b3 |
@@ -12,13 +12,12 @@ A more customizable replacement for the built-in Pebble action bar.
|
|||||||
- Custom height
|
- Custom height
|
||||||
- Custom x/y positions
|
- Custom x/y positions
|
||||||
- Legacy Pebble SDK 2.X-style preset
|
- Legacy Pebble SDK 2.X-style preset
|
||||||
|
- Includes corner radius, shortened height, and invert-style press animations
|
||||||
### Removed Features
|
### Removed Features
|
||||||
- Anything to do with back button overrides
|
- Anything to do with back button overrides
|
||||||
- Fully custom animations
|
- Fully custom animations
|
||||||
- Built-in animations can still be customized
|
- Built-in move animations can still be customized
|
||||||
- Duration, move distance/direction, and move axis are all configurable
|
- Duration, move distance/direction, and move axis are all configurable
|
||||||
- Round style
|
- Round style
|
||||||
- Using a rectangular bar on a round watch saves space and IMO looks way better
|
- Using a rectangular bar on a round watch saves space and IMO looks way better
|
||||||
- Use custom corner radius for a nice effect on round watches!
|
- Use custom corner radius for a nice effect on round watches!
|
||||||
### Pending Features
|
|
||||||
- Legacy (background invert) animations support
|
|
||||||
|
|||||||
+44
-4
@@ -90,6 +90,12 @@ static void s_animate_icon(NeatBarLayer *neat_bar, uint8_t button_index, bool is
|
|||||||
*pressed = false;
|
*pressed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// legacy animation: no icon movement, just invert the background third
|
||||||
|
if (neat_bar->animations_legacy_pressed_color) {
|
||||||
|
layer_mark_dirty(neat_bar->main_layer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Layer *layer = bitmap_layer_get_layer(bitmap_layer);
|
Layer *layer = bitmap_layer_get_layer(bitmap_layer);
|
||||||
GRect home = s_get_home_frame(neat_bar, button_index);
|
GRect home = s_get_home_frame(neat_bar, button_index);
|
||||||
|
|
||||||
@@ -139,9 +145,32 @@ static void s_select_up_handler(ClickRecognizerRef recognizer, void *context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void s_main_layer_update_proc(Layer *layer, GContext *ctx) {
|
static void s_main_layer_update_proc(Layer *layer, GContext *ctx) {
|
||||||
|
NeatBarLayer *neat_bar = s_current_neat_bar;
|
||||||
|
GRect bounds = layer_get_bounds(layer);
|
||||||
|
|
||||||
graphics_context_set_antialiased(ctx, false);
|
graphics_context_set_antialiased(ctx, false);
|
||||||
graphics_context_set_fill_color(ctx, s_current_neat_bar->background_color);
|
graphics_context_set_fill_color(ctx, neat_bar->background_color);
|
||||||
graphics_fill_rect(ctx, layer_get_bounds(layer), s_current_neat_bar->corner_radius, s_current_neat_bar->x_offset > 0 ? GCornersAll : GCornersLeft);
|
graphics_fill_rect(ctx, bounds, neat_bar->corner_radius, neat_bar->x_offset > 0 ? GCornersAll : GCornersLeft);
|
||||||
|
|
||||||
|
// legacy animation: invert the background third for any pressed button
|
||||||
|
if (neat_bar->animations_legacy_pressed_color) {
|
||||||
|
int16_t third_height = bounds.size.h / 3;
|
||||||
|
uint16_t radius = neat_bar->corner_radius;
|
||||||
|
uint16_t inner_radius = radius > 0 ? radius - 1 : 0;
|
||||||
|
graphics_context_set_fill_color(ctx, *(neat_bar->animations_legacy_pressed_color));
|
||||||
|
|
||||||
|
if (neat_bar->up_pressed) {
|
||||||
|
graphics_fill_rect(ctx, GRect(1, 1, bounds.size.w - 2, third_height - 2), inner_radius,
|
||||||
|
neat_bar->x_offset > 0 ? GCornersTop : GCornerTopLeft);
|
||||||
|
}
|
||||||
|
if (neat_bar->select_pressed) {
|
||||||
|
graphics_fill_rect(ctx, GRect(1, third_height + 1, bounds.size.w - 2, third_height - 2), 0, GCornerNone);
|
||||||
|
}
|
||||||
|
if (neat_bar->down_pressed) {
|
||||||
|
graphics_fill_rect(ctx, GRect(1, third_height * 2 + 1, bounds.size.w - 2, bounds.size.h - third_height * 2 - 2), inner_radius,
|
||||||
|
neat_bar->x_offset > 0 ? GCornersBottom : GCornerBottomLeft);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void s_base_click_config_provider(void *config_context) {
|
static void s_base_click_config_provider(void *config_context) {
|
||||||
@@ -191,11 +220,12 @@ void neat_bar_layer_set_theme_default_rect(NeatBarLayer *neat_bar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// match SDK 2.X aesthetic
|
// match SDK 2.X aesthetic
|
||||||
void neat_bar_layer_set_theme_legacy_rect(NeatBarLayer *neat_bar) {
|
void neat_bar_layer_set_theme_legacy_rect(NeatBarLayer *neat_bar, GColor8 *pressed_color) {
|
||||||
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);
|
||||||
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect);
|
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect);
|
||||||
neat_bar_layer_set_corner_radius(neat_bar, 3);
|
neat_bar_layer_set_corner_radius(neat_bar, 3);
|
||||||
|
neat_bar_layer_set_animations_type(neat_bar, pressed_color);
|
||||||
s_recenter_icons(neat_bar);
|
s_recenter_icons(neat_bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,6 +331,15 @@ void neat_bar_layer_set_background_color(NeatBarLayer *neat_bar, GColor backgrou
|
|||||||
layer_mark_dirty(neat_bar->main_layer);
|
layer_mark_dirty(neat_bar->main_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default: NULL (null disables legacy animations)
|
||||||
|
void neat_bar_layer_set_animations_type(NeatBarLayer *neat_bar, GColor8 *pressed_color) {
|
||||||
|
if (pressed_color->argb == neat_bar->animations_legacy_pressed_color->argb) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
neat_bar->animations_legacy_pressed_color = pressed_color;
|
||||||
|
layer_mark_dirty(neat_bar->main_layer);
|
||||||
|
}
|
||||||
|
|
||||||
// default: 0
|
// default: 0
|
||||||
void neat_bar_layer_set_spread(NeatBarLayer *neat_bar, int8_t spread) {
|
void neat_bar_layer_set_spread(NeatBarLayer *neat_bar, int8_t spread) {
|
||||||
if (spread == neat_bar->spread) {
|
if (spread == neat_bar->spread) {
|
||||||
@@ -366,9 +405,10 @@ NeatBarLayer *neat_bar_layer_create() {
|
|||||||
neat_bar->corner_radius = 0;
|
neat_bar->corner_radius = 0;
|
||||||
neat_bar->x_offset = 0;
|
neat_bar->x_offset = 0;
|
||||||
neat_bar->spread = 0;
|
neat_bar->spread = 0;
|
||||||
|
neat_bar->animations_duration = 144;
|
||||||
neat_bar->animations_move_on_y_axis = false;
|
neat_bar->animations_move_on_y_axis = false;
|
||||||
neat_bar->animations_move_distance = ANIM_DISTANCE;
|
neat_bar->animations_move_distance = ANIM_DISTANCE;
|
||||||
neat_bar->animations_duration = 144;
|
neat_bar->animations_legacy_pressed_color = NULL;
|
||||||
neat_bar->up_pressed = false;
|
neat_bar->up_pressed = false;
|
||||||
neat_bar->select_pressed = false;
|
neat_bar->select_pressed = false;
|
||||||
neat_bar->down_pressed = false;
|
neat_bar->down_pressed = false;
|
||||||
|
|||||||
+4
-3
@@ -17,10 +17,10 @@ typedef struct {
|
|||||||
uint16_t corner_radius;
|
uint16_t corner_radius;
|
||||||
uint16_t x_offset;
|
uint16_t x_offset;
|
||||||
int8_t spread;
|
int8_t spread;
|
||||||
|
uint8_t animations_duration;
|
||||||
bool animations_move_on_y_axis;
|
bool animations_move_on_y_axis;
|
||||||
int8_t animations_move_distance;
|
int8_t animations_move_distance;
|
||||||
uint8_t animations_duration;
|
GColor8 *animations_legacy_pressed_color;
|
||||||
//bool use_legacy_animations
|
|
||||||
bool up_pressed;
|
bool up_pressed;
|
||||||
bool select_pressed;
|
bool select_pressed;
|
||||||
bool down_pressed;
|
bool down_pressed;
|
||||||
@@ -28,12 +28,13 @@ typedef struct {
|
|||||||
} NeatBarLayer;
|
} NeatBarLayer;
|
||||||
|
|
||||||
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_legacy_rect(NeatBarLayer *neat_bar);
|
void neat_bar_layer_set_theme_legacy_rect(NeatBarLayer *neat_bar, GColor8 *pressed_color);
|
||||||
void neat_bar_layer_add_to_window(NeatBarLayer *neat_bar, Window *window);
|
void neat_bar_layer_add_to_window(NeatBarLayer *neat_bar, Window *window);
|
||||||
void neat_bar_layer_set_click_config_provider(NeatBarLayer *neat_bar, ClickConfigProvider click_config_provider);
|
void neat_bar_layer_set_click_config_provider(NeatBarLayer *neat_bar, ClickConfigProvider click_config_provider);
|
||||||
void neat_bar_layer_set_animations_move_distance(NeatBarLayer *neat_bar, int8_t distance);
|
void neat_bar_layer_set_animations_move_distance(NeatBarLayer *neat_bar, int8_t distance);
|
||||||
void neat_bar_layer_set_animations_move_axis(NeatBarLayer *neat_bar, bool use_y_axis);
|
void neat_bar_layer_set_animations_move_axis(NeatBarLayer *neat_bar, bool use_y_axis);
|
||||||
void neat_bar_layer_set_animations_duration(NeatBarLayer *neat_bar, uint8_t duration_ms);
|
void neat_bar_layer_set_animations_duration(NeatBarLayer *neat_bar, uint8_t duration_ms);
|
||||||
|
void neat_bar_layer_set_animations_type(NeatBarLayer *neat_bar, GColor8 *pressed_color);
|
||||||
void neat_bar_layer_set_floating(NeatBarLayer *neat_bar, uint16_t x_offset);
|
void neat_bar_layer_set_floating(NeatBarLayer *neat_bar, uint16_t x_offset);
|
||||||
void neat_bar_layer_set_width(NeatBarLayer *neat_bar, uint16_t width);
|
void neat_bar_layer_set_width(NeatBarLayer *neat_bar, uint16_t width);
|
||||||
void neat_bar_layer_set_height(NeatBarLayer *neat_bar, uint16_t height);
|
void neat_bar_layer_set_height(NeatBarLayer *neat_bar, uint16_t height);
|
||||||
|
|||||||
Reference in New Issue
Block a user