Fix icon positions on radial bar
This commit is contained in:
+7
-17
@@ -141,12 +141,11 @@ 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) {
|
||||||
GRect bounds = layer_get_bounds(layer);
|
|
||||||
graphics_context_set_fill_color(ctx, s_current_neat_bar->background_color);
|
graphics_context_set_fill_color(ctx, s_current_neat_bar->background_color);
|
||||||
switch (s_current_neat_bar->bar_style) {
|
switch (s_current_neat_bar->bar_style) {
|
||||||
case NEAT_BAR_STYLE_RADIAL: {
|
case NEAT_BAR_STYLE_RADIAL: {
|
||||||
GRect visual = s_current_neat_bar->main_grect_visual;
|
GRect visual = s_current_neat_bar->main_grect_visual;
|
||||||
graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(-(visual.size.w / 3))), GOvalScaleModeFitCircle,
|
graphics_fill_radial(ctx, grect_inset(layer_get_bounds(layer), GEdgeInsets(-1)), GOvalScaleModeFitCircle,
|
||||||
visual.size.w,
|
visual.size.w,
|
||||||
DEG_TO_TRIGANGLE(60), // ~2 o'clock
|
DEG_TO_TRIGANGLE(60), // ~2 o'clock
|
||||||
DEG_TO_TRIGANGLE(120) // ~4 o'clock
|
DEG_TO_TRIGANGLE(120) // ~4 o'clock
|
||||||
@@ -156,14 +155,14 @@ static void s_main_layer_update_proc(Layer *layer, GContext *ctx) {
|
|||||||
case NEAT_BAR_STYLE_ROUND: {
|
case NEAT_BAR_STYLE_ROUND: {
|
||||||
const uint32_t action_bar_circle_diameter = PBL_DISPLAY_HEIGHT * 19 / 9;
|
const uint32_t action_bar_circle_diameter = PBL_DISPLAY_HEIGHT * 19 / 9;
|
||||||
GRect neat_bar_circle_frame = (GRect){.size = GSize(action_bar_circle_diameter, action_bar_circle_diameter)};
|
GRect neat_bar_circle_frame = (GRect){.size = GSize(action_bar_circle_diameter, action_bar_circle_diameter)};
|
||||||
grect_align(&neat_bar_circle_frame, &bounds, GAlignLeft, false);
|
grect_align(&neat_bar_circle_frame, &s_current_neat_bar->main_grect_visual, GAlignLeft, false);
|
||||||
const int32_t inset_thickness = MAX(ABS(neat_bar_circle_frame.size.h), ABS(neat_bar_circle_frame.size.w));
|
const int32_t inset_thickness = MAX(ABS(neat_bar_circle_frame.size.h), ABS(neat_bar_circle_frame.size.w));
|
||||||
graphics_fill_radial(ctx, neat_bar_circle_frame, GOvalScaleModeFitCircle, inset_thickness, 0, TRIG_MAX_ANGLE);
|
graphics_fill_radial(ctx, neat_bar_circle_frame, GOvalScaleModeFitCircle, inset_thickness, 0, TRIG_MAX_ANGLE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
graphics_context_set_antialiased(ctx, false);
|
graphics_context_set_antialiased(ctx, false);
|
||||||
graphics_fill_rect(ctx, bounds, s_current_neat_bar->rect_bar_corner_radius, s_current_neat_bar->bar_x_offset > 0 ? GCornersAll : GCornersLeft);
|
graphics_fill_rect(ctx, s_current_neat_bar->main_grect_visual, s_current_neat_bar->rect_bar_corner_radius, s_current_neat_bar->bar_x_offset > 0 ? GCornersAll : GCornersLeft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,13 +253,6 @@ void neat_bar_layer_set_bar_style(NeatBarLayer *neat_bar, uint8_t bar_style) {
|
|||||||
if (bar_style == neat_bar->bar_style) {
|
if (bar_style == neat_bar->bar_style) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (bar_style) {
|
|
||||||
case NEAT_BAR_STYLE_RADIAL:
|
|
||||||
layer_set_frame(neat_bar->main_layer, GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect_visual);
|
|
||||||
}
|
|
||||||
neat_bar->bar_style = bar_style;
|
neat_bar->bar_style = bar_style;
|
||||||
layer_mark_dirty(neat_bar->main_layer);
|
layer_mark_dirty(neat_bar->main_layer);
|
||||||
}
|
}
|
||||||
@@ -272,7 +264,6 @@ void neat_bar_layer_set_rect_bar_floating(NeatBarLayer *neat_bar, uint16_t x_off
|
|||||||
}
|
}
|
||||||
neat_bar->bar_x_offset = x_offset;
|
neat_bar->bar_x_offset = x_offset;
|
||||||
neat_bar->main_grect_visual.origin.x = PBL_DISPLAY_WIDTH - neat_bar->main_grect_visual.size.w - x_offset;
|
neat_bar->main_grect_visual.origin.x = PBL_DISPLAY_WIDTH - neat_bar->main_grect_visual.size.w - x_offset;
|
||||||
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect_visual);
|
|
||||||
layer_mark_dirty(neat_bar->main_layer);
|
layer_mark_dirty(neat_bar->main_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +283,6 @@ void neat_bar_layer_set_bar_width(NeatBarLayer *neat_bar, uint16_t width) {
|
|||||||
}
|
}
|
||||||
neat_bar->main_grect_visual.origin.x = PBL_DISPLAY_WIDTH - width;
|
neat_bar->main_grect_visual.origin.x = PBL_DISPLAY_WIDTH - width;
|
||||||
neat_bar->main_grect_visual.size.w = width;
|
neat_bar->main_grect_visual.size.w = width;
|
||||||
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect_visual);
|
|
||||||
if (neat_bar->bar_x_offset > 0) {
|
if (neat_bar->bar_x_offset > 0) {
|
||||||
uint16_t x = neat_bar->bar_x_offset;
|
uint16_t x = neat_bar->bar_x_offset;
|
||||||
neat_bar->bar_x_offset = 0; // force update
|
neat_bar->bar_x_offset = 0; // force update
|
||||||
@@ -309,7 +299,6 @@ void neat_bar_layer_set_bar_height(NeatBarLayer *neat_bar, uint16_t height) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
neat_bar->main_grect_visual.size.h = height;
|
neat_bar->main_grect_visual.size.h = height;
|
||||||
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect_visual);
|
|
||||||
layer_mark_dirty(neat_bar->main_layer);
|
layer_mark_dirty(neat_bar->main_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,7 +308,6 @@ void neat_bar_layer_set_bar_y_offset(NeatBarLayer *neat_bar, uint16_t y_offset)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
neat_bar->main_grect_visual.origin.y = y_offset;
|
neat_bar->main_grect_visual.origin.y = y_offset;
|
||||||
layer_set_frame(neat_bar->main_layer, neat_bar->main_grect_visual);
|
|
||||||
layer_mark_dirty(neat_bar->main_layer);
|
layer_mark_dirty(neat_bar->main_layer);
|
||||||
s_recenter_icons(neat_bar);
|
s_recenter_icons(neat_bar);
|
||||||
}
|
}
|
||||||
@@ -381,7 +369,7 @@ void neat_bar_layer_set_icon(NeatBarLayer *neat_bar, ButtonId button_id, GBitmap
|
|||||||
: (button_id == BUTTON_ID_DOWN) ? SELECT_Y + neat_bar->icons_spread - total_y_offset
|
: (button_id == BUTTON_ID_DOWN) ? SELECT_Y + neat_bar->icons_spread - total_y_offset
|
||||||
: SELECT_Y - total_y_offset;
|
: SELECT_Y - total_y_offset;
|
||||||
current_bitmap_layer = bitmap_layer_create(GRect(neat_bar->icons_x_offset, adjusted_y, neat_bar->main_grect_visual.size.w, 25));
|
current_bitmap_layer = bitmap_layer_create(GRect(neat_bar->icons_x_offset, adjusted_y, neat_bar->main_grect_visual.size.w, 25));
|
||||||
layer_add_child(neat_bar->main_layer, bitmap_layer_get_layer(current_bitmap_layer));
|
layer_add_child(neat_bar->icon_parent_layer, bitmap_layer_get_layer(current_bitmap_layer));
|
||||||
switch (button_id) {
|
switch (button_id) {
|
||||||
case BUTTON_ID_UP:
|
case BUTTON_ID_UP:
|
||||||
neat_bar->up_layer = current_bitmap_layer;
|
neat_bar->up_layer = current_bitmap_layer;
|
||||||
@@ -406,7 +394,9 @@ NeatBarLayer *neat_bar_layer_create() {
|
|||||||
|
|
||||||
// layerage
|
// layerage
|
||||||
neat_bar->main_grect_visual = s_base_grect_rect;
|
neat_bar->main_grect_visual = s_base_grect_rect;
|
||||||
neat_bar->main_layer = layer_create(s_base_grect_rect);
|
neat_bar->main_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT)); // GRect covers entire screen - needed for radial support
|
||||||
|
neat_bar->icon_parent_layer = layer_create(neat_bar->main_grect_visual);
|
||||||
|
layer_add_child(neat_bar->main_layer, neat_bar->icon_parent_layer);
|
||||||
neat_bar->up_layer = NULL;
|
neat_bar->up_layer = NULL;
|
||||||
neat_bar->down_layer = NULL;
|
neat_bar->down_layer = NULL;
|
||||||
neat_bar->select_layer = NULL;
|
neat_bar->select_layer = NULL;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ typedef struct {
|
|||||||
struct Window *window;
|
struct Window *window;
|
||||||
GRect main_grect_visual;
|
GRect main_grect_visual;
|
||||||
Layer *main_layer;
|
Layer *main_layer;
|
||||||
|
Layer *icon_parent_layer;
|
||||||
BitmapLayer *up_layer;
|
BitmapLayer *up_layer;
|
||||||
BitmapLayer *down_layer;
|
BitmapLayer *down_layer;
|
||||||
BitmapLayer *select_layer;
|
BitmapLayer *select_layer;
|
||||||
|
|||||||
Reference in New Issue
Block a user