Make icons y offset configurable
This commit is contained in:
@@ -9,8 +9,7 @@
|
|||||||
- Increased max icon size (unlimited width; 25px height)!
|
- Increased max icon size (unlimited width; 25px height)!
|
||||||
- Custom bar corner radius!
|
- Custom bar corner radius!
|
||||||
- Custom bar width/height!
|
- Custom bar width/height!
|
||||||
- Custom bar x/y positions!
|
- Custom bar/icon x/y offsets!
|
||||||
- Custom icon x positions!
|
|
||||||
### Missing Features (unplanned)
|
### Missing Features (unplanned)
|
||||||
- Anything to do with back button overrides
|
- Anything to do with back button overrides
|
||||||
- Fully custom animations
|
- Fully custom animations
|
||||||
|
|||||||
+18
-10
@@ -39,17 +39,16 @@ static const GRect s_base_grect_rect = GRect(PBL_DISPLAY_WIDTH - ACTION_BAR_WIDT
|
|||||||
static NeatBarLayer *s_current_neat_bar = NULL;
|
static NeatBarLayer *s_current_neat_bar = NULL;
|
||||||
|
|
||||||
static GRect s_get_home_frame(NeatBarLayer *neat_bar, uint8_t button_index) {
|
static GRect s_get_home_frame(NeatBarLayer *neat_bar, uint8_t button_index) {
|
||||||
int16_t y_offset = neat_bar->main_grect.origin.y;
|
|
||||||
int8_t spread = neat_bar->icons_spread;
|
int8_t spread = neat_bar->icons_spread;
|
||||||
uint16_t width = neat_bar->main_grect.size.w;
|
uint16_t width = neat_bar->main_grect.size.w;
|
||||||
|
|
||||||
switch (button_index) {
|
switch (button_index) {
|
||||||
case BUTTON_ID_UP:
|
case BUTTON_ID_UP:
|
||||||
return GRect(neat_bar->icons_x_offset, SELECT_Y - spread - y_offset, width, 25);
|
return GRect(neat_bar->icons_x_offset, SELECT_Y - spread - neat_bar->icons_y_offset, width, 25);
|
||||||
case BUTTON_ID_SELECT:
|
case BUTTON_ID_SELECT:
|
||||||
return GRect(neat_bar->icons_x_offset, SELECT_Y - y_offset, width, 25);
|
return GRect(neat_bar->icons_x_offset, SELECT_Y - neat_bar->icons_y_offset, width, 25);
|
||||||
case BUTTON_ID_DOWN:
|
case BUTTON_ID_DOWN:
|
||||||
return GRect(neat_bar->icons_x_offset, SELECT_Y + spread - y_offset, width, 25);
|
return GRect(neat_bar->icons_x_offset, SELECT_Y + spread - neat_bar->icons_y_offset, width, 25);
|
||||||
default:
|
default:
|
||||||
return GRectZero;
|
return GRectZero;
|
||||||
}
|
}
|
||||||
@@ -179,19 +178,18 @@ inline static void s_update_click_config_provider(NeatBarLayer *neat_bar) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void s_recenter_icons(NeatBarLayer *neat_bar) {
|
static void s_recenter_icons(NeatBarLayer *neat_bar) {
|
||||||
int16_t y_offset = neat_bar->main_grect.origin.y;
|
|
||||||
int8_t spread = neat_bar->icons_spread;
|
int8_t spread = neat_bar->icons_spread;
|
||||||
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),
|
||||||
GRect(neat_bar->icons_x_offset, SELECT_Y - spread - y_offset, neat_bar->main_grect.size.w, 25));
|
GRect(neat_bar->icons_x_offset, SELECT_Y - spread - neat_bar->icons_y_offset, neat_bar->main_grect.size.w, 25));
|
||||||
}
|
}
|
||||||
if (neat_bar->select_layer) {
|
if (neat_bar->select_layer) {
|
||||||
layer_set_frame(bitmap_layer_get_layer(neat_bar->select_layer),
|
layer_set_frame(bitmap_layer_get_layer(neat_bar->select_layer),
|
||||||
GRect(neat_bar->icons_x_offset, SELECT_Y - y_offset, neat_bar->main_grect.size.w, 25));
|
GRect(neat_bar->icons_x_offset, SELECT_Y - neat_bar->icons_y_offset, neat_bar->main_grect.size.w, 25));
|
||||||
}
|
}
|
||||||
if (neat_bar->down_layer) {
|
if (neat_bar->down_layer) {
|
||||||
layer_set_frame(bitmap_layer_get_layer(neat_bar->down_layer),
|
layer_set_frame(bitmap_layer_get_layer(neat_bar->down_layer),
|
||||||
GRect(neat_bar->icons_x_offset, SELECT_Y + spread - y_offset, neat_bar->main_grect.size.w, 25));
|
GRect(neat_bar->icons_x_offset, SELECT_Y + spread - neat_bar->icons_y_offset, neat_bar->main_grect.size.w, 25));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +322,7 @@ void neat_bar_layer_set_icons_spread(NeatBarLayer *neat_bar, int8_t spread) {
|
|||||||
s_recenter_icons(neat_bar);
|
s_recenter_icons(neat_bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
// default: 0 (rect), -1 (round)
|
// default: 1 (rect), -1 (round)
|
||||||
void neat_bar_layer_set_icons_x_offset(NeatBarLayer *neat_bar, int8_t x_offset) {
|
void neat_bar_layer_set_icons_x_offset(NeatBarLayer *neat_bar, int8_t x_offset) {
|
||||||
if (x_offset == neat_bar->icons_x_offset) {
|
if (x_offset == neat_bar->icons_x_offset) {
|
||||||
return;
|
return;
|
||||||
@@ -333,6 +331,15 @@ void neat_bar_layer_set_icons_x_offset(NeatBarLayer *neat_bar, int8_t x_offset)
|
|||||||
s_recenter_icons(neat_bar);
|
s_recenter_icons(neat_bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default: 0
|
||||||
|
void neat_bar_layer_set_icons_y_offset(NeatBarLayer *neat_bar, int8_t y_offset) {
|
||||||
|
if (y_offset == neat_bar->icons_y_offset) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
neat_bar->icons_y_offset = y_offset;
|
||||||
|
s_recenter_icons(neat_bar);
|
||||||
|
}
|
||||||
|
|
||||||
// constraints: must be <=25px in height (width is only constrained to the width of the bar)
|
// constraints: must be <=25px in height (width is only constrained to the width of the bar)
|
||||||
void neat_bar_layer_set_icon(NeatBarLayer *neat_bar, ButtonId button_id, GBitmap *icon) {
|
void neat_bar_layer_set_icon(NeatBarLayer *neat_bar, ButtonId button_id, GBitmap *icon) {
|
||||||
BitmapLayer *current_bitmap_layer;
|
BitmapLayer *current_bitmap_layer;
|
||||||
@@ -352,7 +359,7 @@ void neat_bar_layer_set_icon(NeatBarLayer *neat_bar, ButtonId button_id, GBitmap
|
|||||||
int16_t adjusted_y = (button_id == BUTTON_ID_UP) ? SELECT_Y - neat_bar->icons_spread
|
int16_t adjusted_y = (button_id == BUTTON_ID_UP) ? SELECT_Y - neat_bar->icons_spread
|
||||||
: (button_id == BUTTON_ID_DOWN) ? SELECT_Y + neat_bar->icons_spread
|
: (button_id == BUTTON_ID_DOWN) ? SELECT_Y + neat_bar->icons_spread
|
||||||
: SELECT_Y;
|
: SELECT_Y;
|
||||||
current_bitmap_layer = bitmap_layer_create(GRect(neat_bar->icons_x_offset, adjusted_y, neat_bar->main_grect.size.w, 25));
|
current_bitmap_layer = bitmap_layer_create(GRect(neat_bar->icons_x_offset, adjusted_y - neat_bar->icons_y_offset, neat_bar->main_grect.size.w, 25));
|
||||||
layer_add_child(neat_bar->main_layer, bitmap_layer_get_layer(current_bitmap_layer));
|
layer_add_child(neat_bar->main_layer, bitmap_layer_get_layer(current_bitmap_layer));
|
||||||
switch (button_id) {
|
switch (button_id) {
|
||||||
case BUTTON_ID_UP:
|
case BUTTON_ID_UP:
|
||||||
@@ -394,6 +401,7 @@ NeatBarLayer *neat_bar_layer_create() {
|
|||||||
neat_bar->bar_x_offset = 0;
|
neat_bar->bar_x_offset = 0;
|
||||||
neat_bar->icons_spread = DEFAULT_SPREAD;
|
neat_bar->icons_spread = DEFAULT_SPREAD;
|
||||||
neat_bar->icons_x_offset = DEFAULT_ICONS_X_OFFSET;
|
neat_bar->icons_x_offset = DEFAULT_ICONS_X_OFFSET;
|
||||||
|
neat_bar->icons_y_offset = 0;
|
||||||
neat_bar->animations_enabled = true;
|
neat_bar->animations_enabled = true;
|
||||||
neat_bar->animations_move_on_y_axis = false;
|
neat_bar->animations_move_on_y_axis = false;
|
||||||
neat_bar->animations_move_distance = DEFAULT_ANIM_DISTANCE;
|
neat_bar->animations_move_distance = DEFAULT_ANIM_DISTANCE;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ typedef struct {
|
|||||||
uint16_t bar_x_offset;
|
uint16_t bar_x_offset;
|
||||||
int8_t icons_spread;
|
int8_t icons_spread;
|
||||||
int8_t icons_x_offset;
|
int8_t icons_x_offset;
|
||||||
|
int8_t icons_y_offset;
|
||||||
bool animations_enabled;
|
bool animations_enabled;
|
||||||
bool animations_move_on_y_axis;
|
bool animations_move_on_y_axis;
|
||||||
int8_t animations_move_distance;
|
int8_t animations_move_distance;
|
||||||
@@ -51,6 +52,7 @@ void neat_bar_layer_set_bar_y_offset(NeatBarLayer *neat_bar, uint16_t y_offset);
|
|||||||
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);
|
||||||
void neat_bar_layer_set_icons_spread(NeatBarLayer *neat_bar, int8_t spread);
|
void neat_bar_layer_set_icons_spread(NeatBarLayer *neat_bar, int8_t spread);
|
||||||
void neat_bar_layer_set_icons_x_offset(NeatBarLayer *neat_bar, int8_t x_offset);
|
void neat_bar_layer_set_icons_x_offset(NeatBarLayer *neat_bar, int8_t x_offset);
|
||||||
|
void neat_bar_layer_set_icons_y_offset(NeatBarLayer *neat_bar, int8_t y_offset);
|
||||||
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);
|
||||||
NeatBarLayer *neat_bar_layer_create();
|
NeatBarLayer *neat_bar_layer_create();
|
||||||
void neat_bar_layer_destroy(NeatBarLayer *neat_bar);
|
void neat_bar_layer_destroy(NeatBarLayer *neat_bar);
|
||||||
|
|||||||
Reference in New Issue
Block a user