mirror of
https://github.com/Threnklyn/pebble-directions.git
synced 2026-05-18 21:03:27 +02:00
added a status bar
This commit is contained in:
@@ -88,15 +88,15 @@ void directions_draw_summary(GContext *ctx, GRect bounds, GColor color, int dist
|
||||
// * Square UI *
|
||||
// *************
|
||||
// Header bg
|
||||
GRect header_box = GRect(0, 0, bounds.size.w, 67);
|
||||
GRect header_box = GRect(0, 0, bounds.size.w, 60 + STATUS_BAR_LAYER_HEIGHT);
|
||||
graphics_context_set_fill_color(ctx, color);
|
||||
graphics_fill_rect(ctx, header_box, 0, GCornerNone);
|
||||
// Time
|
||||
GRect time_box = GRect(7, 7, bounds.size.w - 14, 28);
|
||||
GRect time_box = GRect(7, STATUS_BAR_LAYER_HEIGHT, bounds.size.w - 14, 28);
|
||||
graphics_context_set_text_color(ctx, GColorWhite);
|
||||
graphics_draw_text(ctx, string_time, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD), time_box, GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
|
||||
// Distance
|
||||
GRect distance_box = GRect(7, 7 + time_box.size.h, bounds.size.w - 14, 18);
|
||||
GRect distance_box = GRect(7, STATUS_BAR_LAYER_HEIGHT + time_box.size.h, bounds.size.w - 14, 18);
|
||||
graphics_context_set_text_color(ctx, color_distance);
|
||||
graphics_draw_text(ctx, string_distance, fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD), distance_box, GTextOverflowModeWordWrap, GTextAlignmentLeft, NULL);
|
||||
// Address
|
||||
@@ -133,7 +133,7 @@ void directions_draw_step(GContext *ctx, GRect bounds, GColor color, char *text,
|
||||
graphics_fill_circle(ctx, GPoint(bounds.size.w / 2, -80), 140);
|
||||
// Draw icon
|
||||
graphics_context_set_compositing_mode(ctx, GCompOpSet);
|
||||
graphics_draw_bitmap_in_rect(ctx, step_icon, GRect((bounds.size.w - 24) / 2, 24, 24, 24));
|
||||
graphics_draw_bitmap_in_rect(ctx, step_icon, GRect((bounds.size.w - 24) / 2, 28, 24, 24));
|
||||
// Draw text
|
||||
GRect text_box = GRect(0, 67, bounds.size.w, bounds.size.h - 74);
|
||||
GTextAttributes *text_attributes = graphics_text_attributes_create();
|
||||
@@ -151,7 +151,7 @@ void directions_draw_step(GContext *ctx, GRect bounds, GColor color, char *text,
|
||||
graphics_fill_rect(ctx, header_box, 0, GCornerNone);
|
||||
// Draw icon
|
||||
graphics_context_set_compositing_mode(ctx, GCompOpSet);
|
||||
graphics_draw_bitmap_in_rect(ctx, step_icon, GRect((bounds.size.w - 24) / 2, 14, 24, 24));
|
||||
graphics_draw_bitmap_in_rect(ctx, step_icon, GRect((bounds.size.w - 24) / 2, 18, 24, 24));
|
||||
// Draw text
|
||||
GRect text_box = GRect(7, 7 + header_box.size.h, bounds.size.w - 14, bounds.size.h - header_box.size.h - 14);
|
||||
graphics_context_set_text_color(ctx, color_text);
|
||||
|
||||
+38
-22
@@ -30,6 +30,8 @@ static int window_height;
|
||||
static MenuLayer *directions_list;
|
||||
static GColor selected_type_color;
|
||||
|
||||
static StatusBarLayer *status_bar;
|
||||
|
||||
// Step icons
|
||||
static GBitmap *icon_step_type;
|
||||
static GBitmap *icon_step_forward;
|
||||
@@ -315,6 +317,10 @@ static void window_unload() {
|
||||
menu_layer_destroy(directions_list);
|
||||
directions_list = NULL;
|
||||
|
||||
// Destroy the status bar layer
|
||||
status_bar_layer_destroy(status_bar);
|
||||
status_bar = NULL;
|
||||
|
||||
// Destroy the progress layer
|
||||
progress_layer_destroy(progress_layer);
|
||||
progress_layer = NULL;
|
||||
@@ -341,7 +347,7 @@ static void window_unload() {
|
||||
}
|
||||
|
||||
static void window_disappear() {
|
||||
// Remove the progress layer
|
||||
// Remove the progress layer (to kill all timers that are still running)
|
||||
progress_layer_remove(progress_layer);
|
||||
}
|
||||
|
||||
@@ -352,27 +358,26 @@ static void window_load() {
|
||||
window_height = bounds.size.h;
|
||||
|
||||
// Work out the correct type color
|
||||
switch (selected_type_enum) {
|
||||
case 0:
|
||||
selected_type_color = COLOR_CAR;
|
||||
break;
|
||||
case 1:
|
||||
selected_type_color = COLOR_BIKE;
|
||||
break;
|
||||
case 2:
|
||||
selected_type_color = COLOR_TRAIN;
|
||||
break;
|
||||
case 3:
|
||||
selected_type_color = COLOR_WALK;
|
||||
break;
|
||||
default:
|
||||
selected_type_color = GColorBlack;
|
||||
}
|
||||
|
||||
// Set up the dictation session
|
||||
dictation_session = dictation_session_create(0, dictation_session_callback, NULL);
|
||||
dictation_session_enable_confirmation(dictation_session, true);
|
||||
dictation_session_enable_error_dialogs(dictation_session, true);
|
||||
#ifdef PBL_COLOR
|
||||
switch (selected_type_enum) {
|
||||
case 0:
|
||||
selected_type_color = COLOR_CAR;
|
||||
break;
|
||||
case 1:
|
||||
selected_type_color = COLOR_BIKE;
|
||||
break;
|
||||
case 2:
|
||||
selected_type_color = COLOR_TRAIN;
|
||||
break;
|
||||
case 3:
|
||||
selected_type_color = COLOR_WALK;
|
||||
break;
|
||||
default:
|
||||
selected_type_color = GColorBlack;
|
||||
}
|
||||
#else
|
||||
selected_type_color = GColorBlack;
|
||||
#endif
|
||||
|
||||
// Create the menu layer
|
||||
directions_list = menu_layer_create(bounds);
|
||||
@@ -390,9 +395,20 @@ static void window_load() {
|
||||
// Add the menu layer to the window
|
||||
layer_add_child(window_layer, menu_layer_get_layer(directions_list));
|
||||
|
||||
// Create and set up the status bar layer
|
||||
status_bar = status_bar_layer_create();
|
||||
status_bar_layer_set_colors(status_bar, selected_type_color, GColorWhite);
|
||||
status_bar_layer_set_separator_mode(status_bar, StatusBarLayerSeparatorModeNone);
|
||||
layer_add_child(window_layer, status_bar_layer_get_layer(status_bar));
|
||||
|
||||
// Create the progress layer
|
||||
progress_layer = progress_layer_create(bounds);
|
||||
|
||||
// Set up the dictation session
|
||||
dictation_session = dictation_session_create(0, dictation_session_callback, NULL);
|
||||
dictation_session_enable_confirmation(dictation_session, true);
|
||||
dictation_session_enable_error_dialogs(dictation_session, true);
|
||||
|
||||
// Create the step icon resources
|
||||
switch (selected_type_enum) {
|
||||
case 0:
|
||||
|
||||
Reference in New Issue
Block a user