Esempio n. 1
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, false);
  
  s_res_image_action_increment = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_INCREMENT);
  s_res_image_action_decrement = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_DECREMENT);
  s_res_font_dd_50 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DD_50));
  s_res_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
  // action_bar_layer
  action_bar_layer = action_bar_layer_create();
  action_bar_layer_add_to_window(action_bar_layer, s_window);
  action_bar_layer_set_background_color(action_bar_layer, GColorWhite);
  action_bar_layer_set_icon(action_bar_layer, BUTTON_ID_UP, s_res_image_action_increment);
  action_bar_layer_set_icon(action_bar_layer, BUTTON_ID_DOWN, s_res_image_action_decrement);
  layer_add_child(window_get_root_layer(s_window), (Layer *)action_bar_layer);
  
  // number_text_layer
  number_text_layer = text_layer_create(GRect(6, 39, 116, 50));
  text_layer_set_text(number_text_layer, "0");
  text_layer_set_text_alignment(number_text_layer, GTextAlignmentCenter);
  text_layer_set_font(number_text_layer, s_res_font_dd_50);
  layer_add_child(window_get_root_layer(s_window), (Layer *)number_text_layer);
  
  // title_text_layer
  title_text_layer = text_layer_create(GRect(2, 93, 123, 20));
  text_layer_set_text(title_text_layer, "Text layer");
  text_layer_set_text_alignment(title_text_layer, GTextAlignmentCenter);
  text_layer_set_font(title_text_layer, s_res_gothic_18);
  layer_add_child(window_get_root_layer(s_window), (Layer *)title_text_layer);
}
Esempio n. 2
0
static void initialise_ui(void) {
    s_window = window_create();
    window_set_background_color(s_window, GColorBlack);
    IF_2(window_set_fullscreen(s_window, true));

    s_res_img_upaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_UPACTION);
    s_res_img_nextaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_NEXTACTION);
    s_res_img_downaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_DOWNACTION);
    s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
    s_res_bitham_30_black = fonts_get_system_font(FONT_KEY_BITHAM_30_BLACK);
    // action_layer
    action_layer = action_bar_layer_create();
    action_bar_layer_add_to_window(action_layer, s_window);
    action_bar_layer_set_background_color(action_layer, GColorWhite);
    action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_upaction);
    action_bar_layer_set_icon(action_layer, BUTTON_ID_SELECT, s_res_img_nextaction);
    action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_downaction);
    layer_set_frame(action_bar_layer_get_layer(action_layer), GRect(124, 0, 20, 168));
    IF_3(layer_set_bounds(action_bar_layer_get_layer(action_layer), GRect(-5, 0, 30, 168)));
    layer_add_child(window_get_root_layer(s_window), (Layer *)action_layer);

    time_layer = layer_create(GRect(0, 0, 124, 168));
    layer_set_update_proc(time_layer, draw_time);
    layer_add_child(window_get_root_layer(s_window), time_layer);
}
Esempio n. 3
0
void action_bar_nav_v_kodi(Window *window){
  // Initialize the action bar:
  action_bar = action_bar_layer_create();
  action_bar_layer_set_background_color(action_bar, GColorGreen);
  // Associate the action bar with the window:
  action_bar_layer_add_to_window(action_bar, window);
  // Set the click config provider:
  action_bar_layer_set_click_config_provider(action_bar, click_config_provider_kodi_nav_v);

  // Set the icons:
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_DOTV);
  // The loading of the icons is omitted for brevity... See gbitmap_create_with_resource()
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_SELECT, s_background_bitmap, true);
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_UP);
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_UP, s_background_bitmap, true);
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_DOWN);
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_DOWN, s_background_bitmap, true);

  // Use tap service? If not, use data service
  if (TAP_NOT_DATA) {
    // Subscribe to the accelerometer tap service
    accel_tap_service_subscribe(tap_handler_kodi_nav_v);
  } else {
    // Subscribe to the accelerometer data service
    int num_samples = 3;
    accel_data_service_subscribe(num_samples, data_handler);

    // Choose update rate
    accel_service_set_sampling_rate(ACCEL_SAMPLING_10HZ);
  }
}
Esempio n. 4
0
static void initialise_ui(void) {
    s_window = window_create();
    window_set_fullscreen(s_window, true);

    s_res_yes = gbitmap_create_with_resource(RESOURCE_ID_YES);
    s_res_no = gbitmap_create_with_resource(RESOURCE_ID_NO);
    s_res_gothic_24 = fonts_get_system_font(FONT_KEY_GOTHIC_24);
    s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
    // s_actionbarlayer_1
    s_actionbarlayer_1 = action_bar_layer_create();
    action_bar_layer_add_to_window(s_actionbarlayer_1, s_window);
    action_bar_layer_set_background_color(s_actionbarlayer_1, GColorBlack);
    action_bar_layer_set_icon(s_actionbarlayer_1, BUTTON_ID_UP, s_res_yes);
    action_bar_layer_set_icon(s_actionbarlayer_1, BUTTON_ID_DOWN, s_res_no);
    layer_add_child(window_get_root_layer(s_window), (Layer *)s_actionbarlayer_1);

    // s_textlayer_1
    s_textlayer_1 = text_layer_create(GRect(6, 14, 114, 99));
    text_layer_set_text(s_textlayer_1, "You're close to a weighing machine!");
    text_layer_set_text_alignment(s_textlayer_1, GTextAlignmentCenter);
    text_layer_set_font(s_textlayer_1, s_res_gothic_24);
    layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_1);

    // s_textlayer_2
    s_textlayer_2 = text_layer_create(GRect(12, 99, 100, 57));
    text_layer_set_text(s_textlayer_2, "Input your weight?");
    text_layer_set_text_alignment(s_textlayer_2, GTextAlignmentCenter);
    text_layer_set_font(s_textlayer_2, s_res_gothic_24_bold);
    layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_2);
}
Esempio n. 5
0
static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  APP_LOG(APP_LOG_LEVEL_DEBUG, "window height = %d", layer_get_frame(window_layer).size.h);

  s_action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(s_action_bar, window);
  action_bar_layer_set_click_config_provider(s_action_bar, 
                                             click_config_provider);

  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_UP, s_icon_plus);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_DOWN, s_icon_minus);
  action_bar_layer_set_icon(s_action_bar, BUTTON_ID_SELECT, s_icon_done);
  
  
  int width = layer_get_frame(window_layer).size.w - ACTION_BAR_WIDTH - 3;

  // Header Text Layer
  s_header_layer = text_layer_create(GRect(4, 0, width, 60));
  text_layer_set_font(s_header_layer, 
                      fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_background_color(s_header_layer, GColorClear);
  text_layer_set_text(s_header_layer, "Mood Tracker");
  layer_add_child(window_layer, text_layer_get_layer(s_header_layer));

  // Body Text Layer
  s_body_layer = text_layer_create(GRect(4, 44, width, 60));
  text_layer_set_font(s_body_layer, 
                      fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_background_color(s_body_layer, GColorClear);
  layer_add_child(window_layer, text_layer_get_layer(s_body_layer));

  // Label Text Layer
  s_label_layer = text_layer_create(GRect(4, 44 + 28, width, 60));
  text_layer_set_font(s_label_layer, 
                      fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(s_label_layer, GColorClear);
  
  text_layer_set_text(s_label_layer, "of mood today");
  layer_add_child(window_layer, text_layer_get_layer(s_label_layer));
  
#ifdef PBL_COLOR
  // Set the Window background color to a color that is similar to hospital 
  // walls
  window_set_background_color(window, GColorCadetBlue);
  // Set the actionbar background color to a color that is similar to medical 
  // staff uniforms
  action_bar_layer_set_background_color(s_action_bar, GColorCobaltBlue);
  
  text_layer_set_text_color(s_header_layer, GColorBlack);
  text_layer_set_text_color(s_body_layer, GColorBlack);
  text_layer_set_text_color(s_label_layer, GColorBlack);
#endif

  update_text();
}
Esempio n. 6
0
static void windows_squeezebox_load(Window *window){
  // layer_mark_dirty(simple_menu_layer_get_layer(s_simple_menu_layer));

  // Initialize the action bar:
  action_bar = action_bar_layer_create();
  action_bar_layer_set_background_color(action_bar, GColorRed);
  // Associate the action bar with the window:
  action_bar_layer_add_to_window(action_bar, window);
  // Set the click config provider:
  action_bar_layer_set_click_config_provider(action_bar, click_config_provider2);

  // Set the icons:
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_PLAY);
  // The loading of the icons is omitted for brevity... See gbitmap_create_with_resource()
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_SELECT, s_background_bitmap, true);
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_PREVIOUS);
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_UP, s_background_bitmap, true);
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_NEXT);
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_DOWN, s_background_bitmap, true);

  // Create title TextLayer
  s_title_info_layer = text_layer_create(GRect(0, 30, 144, 25));
  text_layer_set_background_color(s_title_info_layer, GColorClear);
  text_layer_set_text_color(s_title_info_layer, GColorRed);
  text_layer_set_text(s_title_info_layer, "title");
  // s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_20));
  // text_layer_set_font(s_title_info_layer, s_weather_font);
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_title_info_layer));

  // Create album TextLayer
  s_album_info_layer = text_layer_create(GRect(0, 60, 144, 25));
  text_layer_set_background_color(s_album_info_layer, GColorClear);
  text_layer_set_text_color(s_album_info_layer, GColorRed);
  text_layer_set_text(s_album_info_layer, "album");
  // s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_20));
  // text_layer_set_font(s_album_info_layer, s_weather_font);
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_album_info_layer));

  // Create artist TextLayer
  s_artist_info_layer = text_layer_create(GRect(0, 90, 144, 25));
  text_layer_set_background_color(s_artist_info_layer, GColorClear);
  text_layer_set_text_color(s_artist_info_layer, GColorRed);
  text_layer_set_text(s_artist_info_layer, "artist");
  // s_weather_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_PERFECT_DOS_20));
  // text_layer_set_font(s_artist_info_layer, s_weather_font);
  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(s_artist_info_layer));

  //Request track info
  send_int("sb", "track_info");
}
Esempio n. 7
0
static void main_window_load(Window *window) {
// Create time TextLayer
//   s_time_layer = text_layer_create(GRect(0, 55, 144, 50));
//   text_layer_set_background_color(s_time_layer, GColorClear);
//   text_layer_set_text_color(s_time_layer, GColorBlack);
  
  s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  s_res_logo = gbitmap_create_with_resource(RESOURCE_ID_BILL);
  // s_actionbar
  s_actionbar = action_bar_layer_create();
  action_bar_layer_add_to_window(s_actionbar, s_window);
  action_bar_layer_set_background_color(s_actionbar, GColorClear);
  action_bar_layer_set_icon(s_actionbar, BUTTON_ID_SELECT, s_res_logo);
  action_bar_layer_set_click_config_provider(s_actionbar, click_config_provider);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_actionbar);
  rbl = rot_bitmap_layer_create(arrow);
  GRect gr = layer_get_frame((Layer *)rbl);
  gr.origin.x = 35;
  gr.origin.y = 25;
  layer_set_frame((Layer *)rbl, gr);
  s_time = text_layer_create(GRect(0, 110, 144, 30));
  text_layer_set_text(s_time, "20 m away");
  text_layer_set_text_alignment(s_time, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(window), (Layer *)s_time);
  s_name = text_layer_create(GRect(0, 130, 144, 30));
  text_layer_set_background_color(s_name, GColorBlack);
  text_layer_set_text_color(s_name, GColorWhite);
  text_layer_set_text(s_name, "Md. Nafees");
  text_layer_set_text_alignment(s_name, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(window), (Layer *)s_name);
//   int h = 1337;
//   snprintf(buf, 100, "%d", h);
//   text_layer_set_text(s_time_layer, buf);
  
  
  // s_orderid
  s_orderid = text_layer_create(GRect(0, 0, 144, 24));
  text_layer_set_background_color(s_orderid, GColorBlack);
  text_layer_set_text_color(s_orderid, GColorWhite);
  text_layer_set_text(s_orderid, "Order #1337");
  text_layer_set_text_alignment(s_orderid, GTextAlignmentCenter);
  text_layer_set_font(s_orderid, s_res_gothic_18_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_orderid);
  
  //rot_bitmap_layer_create()

  // Improve the layout to be more like a watchface
//   text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
//   text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);

  // Add it as a child layer to the Window's root layer
  layer_add_child(window_get_root_layer(window), (Layer *)(rbl));
}
Esempio n. 8
0
static void initialise_ui(void) {
  
  s_window = window_create();
  Layer *root_layer = window_get_root_layer(s_window);
  GRect bounds = layer_get_bounds(root_layer); 
  window_set_background_color(s_window, COLOR_FALLBACK(GColorBulgarianRose, GColorBlack)); 
  IF_2(window_set_fullscreen(s_window, false));
  
#ifdef PBL_ROUND
  int dev_layer_left = (bounds.size.w - DEV_LAYER_WIDTH)/2;
  int dev_layer_top = (bounds.size.h - DEV_LAYER_HEIGHT)/2;
#else
  int dev_layer_left = ((bounds.size.w - DEV_LAYER_WIDTH - ACTION_BAR_WIDTH)/2) + 4;
  int dev_layer_top = ((bounds.size.h - DEV_LAYER_HEIGHT - 14)/2) + IF_32(14, 0);
#endif
  
  s_rect_above = GRect(dev_layer_left, -(DEV_LAYER_HEIGHT+2), DEV_LAYER_WIDTH, DEV_LAYER_HEIGHT);
  s_rect_onscreen = GRect(dev_layer_left, dev_layer_top, DEV_LAYER_WIDTH, DEV_LAYER_HEIGHT);
  s_rect_below = GRect(dev_layer_left, bounds.size.h+2, DEV_LAYER_WIDTH, DEV_LAYER_HEIGHT);
  
  // s_devicecard_layer
  s_devicecard_layer = devicecard_layer_create(s_rect_onscreen);
  layer_add_child(root_layer, s_devicecard_layer->layer);
  
  // s_layer_spots
  s_layer_spots = layer_create(PBL_IF_RECT_ELSE(GRect((dev_layer_left/2)-SPOT_RADIUS, dev_layer_top, 
                                                (SPOT_RADIUS*2)+1 , DEV_LAYER_HEIGHT), bounds));
  layer_add_child(root_layer, (Layer *)s_layer_spots);
  
#ifndef PBL_SDK_2
  s_status_bar = status_bar_layer_create();
  status_bar_layer_set_colors(s_status_bar, COLOR_FALLBACK(GColorBulgarianRose, GColorBlack), GColorWhite);
  layer_add_child(root_layer, status_bar_layer_get_layer(s_status_bar));
#endif
  
  s_res_image_action_up = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_UP);
  s_res_image_action_set = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_SET);
  s_res_image_action_down = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_ACTION_DOWN);
  
  // s_actionbar_main
  s_actionbar_main = action_bar_layer_create();
  action_bar_layer_add_to_window(s_actionbar_main, s_window);
  action_bar_layer_set_background_color(s_actionbar_main, GColorWhite);
  action_bar_layer_set_icon(s_actionbar_main, BUTTON_ID_UP, s_res_image_action_up);
  action_bar_layer_set_icon(s_actionbar_main, BUTTON_ID_SELECT, s_res_image_action_set);
  action_bar_layer_set_icon(s_actionbar_main, BUTTON_ID_DOWN, s_res_image_action_down);
#ifdef PBL_RECT
  layer_set_frame(action_bar_layer_get_layer(s_actionbar_main), GRect(bounds.size.w-20, 0, 20, bounds.size.h));
  IF_3(layer_set_bounds(action_bar_layer_get_layer(s_actionbar_main), GRect(-5, 0, 30, bounds.size.h)));
#endif
  layer_add_child(root_layer, (Layer *)s_actionbar_main);
}
Esempio n. 9
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  IF_2(window_set_fullscreen(s_window, true));
  
  s_res_img_upaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_UPACTION);
  s_res_img_okaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_OKACTION);
  s_res_img_downaction = gbitmap_create_with_resource(RESOURCE_ID_IMG_DOWNACTION);
  s_res_gothic_24 = fonts_get_system_font(FONT_KEY_GOTHIC_24);
  s_res_gothic_28 = fonts_get_system_font(FONT_KEY_GOTHIC_28);
  // s_actionbarlayer
  s_actionbarlayer = action_bar_layer_create();
  action_bar_layer_add_to_window(s_actionbarlayer, s_window);
  action_bar_layer_set_background_color(s_actionbarlayer, GColorWhite);
  action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_UP, s_res_img_upaction);
  action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_SELECT, s_res_img_okaction);
  action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_DOWN, s_res_img_downaction);
  layer_set_frame(action_bar_layer_get_layer(s_actionbarlayer), GRect(124, 0, 20, 168));
  IF_3(layer_set_bounds(action_bar_layer_get_layer(s_actionbarlayer), GRect(-5, 0, 30, 168)));
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_actionbarlayer);
  
  // s_textlayer_info
  s_textlayer_info = text_layer_create(GRect(7, 25, 117, 32));
  text_layer_set_background_color(s_textlayer_info, GColorClear);
  text_layer_set_text_color(s_textlayer_info, GColorWhite);
  text_layer_set_text(s_textlayer_info, "Skip Until:");
  text_layer_set_text_alignment(s_textlayer_info, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_info, s_res_gothic_24);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_info);
  
  // s_textlayer_date
  s_textlayer_date = text_layer_create(GRect(2, 64, 122, 32));
  text_layer_set_background_color(s_textlayer_date, GColorClear);
  text_layer_set_text_color(s_textlayer_date, GColorWhite);
  text_layer_set_text(s_textlayer_date, "Thu, Feb 22");
  text_layer_set_text_alignment(s_textlayer_date, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_date, s_res_gothic_28);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_date);
  
  // s_textlayer_status
  s_textlayer_status = text_layer_create(GRect(7, 100, 117, 32));
  text_layer_set_background_color(s_textlayer_status, GColorClear);
  text_layer_set_text_color(s_textlayer_status, GColorWhite);
  text_layer_set_text(s_textlayer_status, "(No skipping)");
  text_layer_set_text_alignment(s_textlayer_status, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_status, s_res_gothic_24);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_status);
}
Esempio n. 10
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  IF_A(window_set_fullscreen(s_window, true));
  
  s_res_img_standby = gbitmap_create_with_resource(RESOURCE_ID_IMG_STANDBY);
  s_res_img_settings = gbitmap_create_with_resource(RESOURCE_ID_IMG_SETTINGS);
  s_res_roboto_bold_subset_49 = fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49);
  s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  // action_layer
  action_layer = action_bar_layer_create();
  action_bar_layer_add_to_window(action_layer, s_window);
  action_bar_layer_set_background_color(action_layer, GColorWhite);
  action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_standby);
  action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_settings);
  layer_set_frame(action_bar_layer_get_layer(action_layer), GRect(124, 0, 20, 168));
  IF_B(layer_set_bounds(action_bar_layer_get_layer(action_layer), GRect(-5, 0, 30, 168)));
  layer_add_child(window_get_root_layer(s_window), (Layer *)action_layer);
  
  // clockbg_layer
  clockbg_layer = text_layer_create(GRect(0, 60, 144, 50));
  text_layer_set_background_color(clockbg_layer, GColorBlack);
  text_layer_set_text_color(clockbg_layer, GColorClear);
  text_layer_set_text(clockbg_layer, "    ");
  layer_add_child(window_get_root_layer(s_window), (Layer *)clockbg_layer);
  
  // clock_layer
  clock_layer = text_layer_create(GRect(0, 52, 144, 65));
  text_layer_set_background_color(clock_layer, GColorClear);
  text_layer_set_text_color(clock_layer, GColorWhite);
  text_layer_set_text(clock_layer, "23:55");
  text_layer_set_text_alignment(clock_layer, GTextAlignmentCenter);
  text_layer_set_font(clock_layer, s_res_roboto_bold_subset_49);
  layer_add_child(window_get_root_layer(s_window), (Layer *)clock_layer);
  
  // onoff_layer
  onoff_layer = text_layer_create(GRect(2, 2, 119, 56));
  layer_set_update_proc(text_layer_get_layer(onoff_layer), draw_onoff); 
  layer_add_child(window_get_root_layer(s_window), (Layer *)onoff_layer);
  
  // info_layer
  info_layer = text_layer_create(GRect(2, 110, 119, 56));
  layer_set_update_proc(text_layer_get_layer(info_layer), draw_info); 
  layer_add_child(window_get_root_layer(s_window), (Layer *)info_layer);
}
Esempio n. 11
0
static void action_bar_movie_kodi(Window *window){
  // Initialize the action bar:
  action_bar = action_bar_layer_create();
  action_bar_layer_set_background_color(action_bar, GColorRed);
  // Associate the action bar with the window:
  action_bar_layer_add_to_window(action_bar, window);
  // Set the click config provider:
  action_bar_layer_set_click_config_provider(action_bar, click_config_provider_kodi_movie);

  // Set the icons:
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_PLAY);
  // The loading of the icons is omitted for brevity... See gbitmap_create_with_resource()
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_SELECT, s_background_bitmap, true);
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_PREVIOUS);
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_UP, s_background_bitmap, true);
  s_background_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_NEXT);
  action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_DOWN, s_background_bitmap, true);
}
Esempio n. 12
0
static void initialise_ui(void) {
  s_window = window_create();
  #ifndef PBL_SDK_3
    window_set_fullscreen(s_window, false);
  #endif
  
  s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  s_res_gothic_18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
  s_res_gothic_14 = fonts_get_system_font(FONT_KEY_GOTHIC_14);
  // s_actionbarlayer
  s_actionbarlayer = action_bar_layer_create();
  action_bar_layer_add_to_window(s_actionbarlayer, s_window);
  action_bar_layer_set_background_color(s_actionbarlayer, GColorBlack);
  action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_UP, bitmap_add);
  action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_SELECT, bitmap_play);
  action_bar_layer_set_icon(s_actionbarlayer, BUTTON_ID_DOWN, bitmap_minus);
  action_bar_layer_set_click_config_provider(s_actionbarlayer, action_bar_click_config_provider);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_actionbarlayer);
  
  // s_textlayer_name
  s_textlayer_name = text_layer_create(GRect(5, 7, 100, 24));
  text_layer_set_font(s_textlayer_name, s_res_gothic_24_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_name);
  
  // s_textlayer_days
  layers[0] = text_layer_create(GRect(16-6, 60, 30+6, 24));
  text_layer_set_text_alignment(layers[0], GTextAlignmentRight);
  text_layer_set_font(layers[0], s_res_gothic_18);
  layer_add_child(window_get_root_layer(s_window), (Layer *)layers[0]);
  
  for (uint8_t l=1; l<N_LAYERS; l++) {
    layers[l] = text_layer_create(GRect(30+20*l, 60, 20, 24));
    text_layer_set_text_alignment(layers[l], GTextAlignmentCenter);
    text_layer_set_font(layers[l], s_res_gothic_18);
    layer_add_child(window_get_root_layer(s_window), (Layer *)layers[l]);
  }
  
  // s_textlayer_help
  s_textlayer_help = text_layer_create(GRect(5, 118, 109, 34));
  text_layer_set_text(s_textlayer_help, "SHORT press: 1 unit\nLONG press: 5 units");
  text_layer_set_font(s_textlayer_help, s_res_gothic_14);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_help);
}
Esempio n. 13
0
static void settings_load(Window *settings) {
	Layer *settings_layer = window_get_root_layer(settings);
	
	//Set up Settings Action Bar
	up_arrow_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_UP_ARROW);
	down_arrow_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_DOWN_ARROW);
	ok_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_OK);
	settings_action_bar = action_bar_layer_create();
	action_bar_layer_add_to_window(settings_action_bar, settings);
	action_bar_layer_set_background_color(settings_action_bar, GColorWhite);
	action_bar_layer_set_click_config_provider(settings_action_bar, settings_click_config_provider);
	action_bar_layer_set_icon(settings_action_bar, BUTTON_ID_UP, up_arrow_icon);
	action_bar_layer_set_icon(settings_action_bar, BUTTON_ID_DOWN, down_arrow_icon);
	action_bar_layer_set_icon(settings_action_bar, BUTTON_ID_SELECT, ok_icon);
	
	// Settings US Text Layer
	settings_US_text_layer = text_layer_create(GRect(20, 32, 80, 30));
	text_layer_set_text_color(settings_US_text_layer, GColorWhite);
	text_layer_set_background_color(settings_US_text_layer, GColorClear);
	if (units == 0) {
		text_layer_set_font(settings_US_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
	}
	else {
		text_layer_set_font(settings_US_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
	}
	text_layer_set_text_alignment(settings_US_text_layer, GTextAlignmentCenter);
	text_layer_set_text(settings_US_text_layer, "US");
	layer_add_child(settings_layer, text_layer_get_layer(settings_US_text_layer));
	
	// Settings Metric Text Layer
	settings_METRIC_text_layer = text_layer_create(GRect(20, 82, 80, 30));
	text_layer_set_text_color(settings_METRIC_text_layer, GColorWhite);
	text_layer_set_background_color(settings_METRIC_text_layer, GColorClear);
	if (units == 0) {
		text_layer_set_font(settings_METRIC_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
	}
	else {
		text_layer_set_font(settings_METRIC_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
	}
	text_layer_set_text_alignment(settings_METRIC_text_layer, GTextAlignmentCenter);
	text_layer_set_text(settings_METRIC_text_layer, "METRIC");
	layer_add_child(settings_layer, text_layer_get_layer(settings_METRIC_text_layer));
}
Esempio n. 14
0
static void initialise_ui(void) {
  
  Layer *root_layer = NULL;
  GRect bounds; 
  s_window = window_create_fullscreen(&root_layer, &bounds);
  
  s_res_img_standby = gbitmap_create_with_resource(RESOURCE_ID_IMG_STANDBY);
  s_res_img_settings = gbitmap_create_with_resource(RESOURCE_ID_IMG_SETTINGS);
  s_res_roboto_bold_subset_49 = fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49);
  s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  // action_layer
  action_layer = action_bar_layer_create();
  action_bar_layer_add_to_window(action_layer, s_window);
  action_bar_layer_set_background_color(action_layer, GColorWhite);
  action_bar_layer_set_icon(action_layer, BUTTON_ID_UP, s_res_img_standby);
  action_bar_layer_set_icon(action_layer, BUTTON_ID_DOWN, s_res_img_settings);
#ifdef PBL_RECT
  layer_set_frame(action_bar_layer_get_layer(action_layer), GRect(bounds.size.w-20, 0, 20, bounds.size.h));
  IF_3(layer_set_bounds(action_bar_layer_get_layer(action_layer), GRect(-6, 0, 31, bounds.size.h)));
  // Put Action Bar underneath other layers on rectangular Pebbles
  layer_add_child(root_layer, action_bar_layer_get_layer(action_layer));
#endif
  
  // clock_layer
  clock_layer = layer_create_with_proc(root_layer, draw_clock,
                                       GRect(0 - PBL_IF_RECT_ELSE(0, ACTION_BAR_WIDTH/2), (bounds.size.h/2)-32-PBL_IF_ROUND_ELSE(2, 0), bounds.size.w, 65));
  
  // onoff_layer
  onoff_layer = layer_create_with_proc(root_layer, draw_onoff,
                                      PBL_IF_RECT_ELSE(GRect(2, (bounds.size.h/2)-82, 119, 56),
                                                   GRect(-10, (bounds.size.h/2)-82, bounds.size.w+11, 56)));
  
  // info_layer
  info_layer = layer_create_with_proc(root_layer, draw_info,
                                     PBL_IF_RECT_ELSE(GRect(2, (bounds.size.h/2)+26, 119, 56),
                                                 GRect(-10, (bounds.size.h/2)+24, bounds.size.w+11, 56)));
  
#ifdef PBL_ROUND
  // Put Action Bar on top for Pebble Round
  layer_add_child(root_layer, (Layer *)action_layer);
#endif
}
Esempio n. 15
0
void help_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  int16_t width = bounds.size.w - ACTION_BAR_WIDTH;
  
  s_check_bitmap = gbitmap_create_with_resource(RESOURCE_ID_CHECK);
  
  s_help_action_bar = action_bar_layer_create();
  action_bar_layer_set_icon_animated(s_help_action_bar, BUTTON_ID_SELECT, s_check_bitmap, true);
  action_bar_layer_set_background_color(s_help_action_bar, GColorElectricUltramarine);
  action_bar_layer_set_click_config_provider(s_help_action_bar, help_click_config_provider);
  
  s_help_layer = text_layer_create(GRect(bounds.origin.x, bounds.origin.y + PBL_IF_ROUND_ELSE(60, 50), width - 5, bounds.size.h));
  text_layer_set_text(s_help_layer, PBL_IF_ROUND_ELSE("Example Reminder:\n\n\"Remind me to pick up milk at 5pm\" ", "Example Reminder:\n\n\"Remind me to pick up milk at 5pm\" "));
  text_layer_set_font(s_help_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
  text_layer_set_text_alignment(s_help_layer, GTextAlignmentCenter);
  
  layer_add_child(window_layer, text_layer_get_layer(s_help_layer));
  action_bar_layer_add_to_window(s_help_action_bar, window);
}
Esempio n. 16
0
static void resort_load(Window *resort) {
	Layer *resort_layer = window_get_root_layer(resort);
	
	//Set up Settings Action Bar
	up_arrow_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_UP_ARROW);
	down_arrow_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_DOWN_ARROW);
	right_arrow_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_RIGHT_ARROW);
	resort_action_bar = action_bar_layer_create();
	action_bar_layer_add_to_window(resort_action_bar, resort);
	action_bar_layer_set_background_color(resort_action_bar, GColorWhite);
	action_bar_layer_set_click_config_provider(resort_action_bar, resort_click_config_provider);
	action_bar_layer_set_icon(resort_action_bar, BUTTON_ID_UP, up_arrow_icon);
	action_bar_layer_set_icon(resort_action_bar, BUTTON_ID_DOWN, down_arrow_icon);
	action_bar_layer_set_icon(resort_action_bar, BUTTON_ID_SELECT, right_arrow_icon);
	
	// Resort Top Text Layer
	resort_top_text_layer = text_layer_create(GRect(20, 32, 80, 30));
	text_layer_set_text_color(resort_top_text_layer, GColorWhite);
	text_layer_set_background_color(resort_top_text_layer, GColorClear);
	text_layer_set_font(resort_top_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
	text_layer_set_text_alignment(resort_top_text_layer, GTextAlignmentCenter);
	text_layer_set_text(resort_top_text_layer, "*         *");
	layer_add_child(resort_layer, text_layer_get_layer(resort_top_text_layer));
	
	// Resort Center Text Layer
	resort_center_text_layer = text_layer_create(GRect(20, 82, 80, 30));
	text_layer_set_text_color(resort_center_text_layer, GColorWhite);
	text_layer_set_background_color(resort_center_text_layer, GColorClear);
	text_layer_set_font(resort_center_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
	text_layer_set_text_alignment(resort_center_text_layer, GTextAlignmentCenter);
	text_layer_set_text(resort_center_text_layer, "Loading...");
	layer_add_child(resort_layer, text_layer_get_layer(resort_center_text_layer));
	
	// Resort Bottom Text Layer
	resort_bottom_text_layer = text_layer_create(GRect(20, 32, 80, 30));
	text_layer_set_text_color(resort_bottom_text_layer, GColorWhite);
	text_layer_set_background_color(resort_bottom_text_layer, GColorClear);
	text_layer_set_font(resort_bottom_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
	text_layer_set_text_alignment(resort_bottom_text_layer, GTextAlignmentCenter);
	text_layer_set_text(resort_bottom_text_layer, "*         *");
	layer_add_child(resort_layer, text_layer_get_layer(resort_bottom_text_layer));}
Esempio n. 17
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  #ifndef PBL_SDK_3
    window_set_fullscreen(s_window, true);
  #endif
  
  s_res_icon_up = gbitmap_create_with_resource(RESOURCE_ID_ICON_UP);
  s_res_icon_etc = gbitmap_create_with_resource(RESOURCE_ID_ICON_ETC);
  s_res_icon_down = gbitmap_create_with_resource(RESOURCE_ID_ICON_DOWN);
  s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  // layer_actionbar
  layer_actionbar = action_bar_layer_create();
  action_bar_layer_add_to_window(layer_actionbar, s_window);
  action_bar_layer_set_background_color(layer_actionbar, GColorBlack);
  action_bar_layer_set_icon(layer_actionbar, BUTTON_ID_UP, s_res_icon_up);
  action_bar_layer_set_icon(layer_actionbar, BUTTON_ID_SELECT, s_res_icon_etc);
  action_bar_layer_set_icon(layer_actionbar, BUTTON_ID_DOWN, s_res_icon_down);
  layer_add_child(window_get_root_layer(s_window), (Layer *)layer_actionbar);
  
  // layer_location
  layer_location = text_layer_create(GRect(0, 0, 122, 22));
  text_layer_set_background_color(layer_location, GColorBlack);
  text_layer_set_text_color(layer_location, GColorWhite);
  text_layer_set_text(layer_location, "Text layer");
  text_layer_set_font(layer_location, s_res_gothic_18_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)layer_location);
  
  // layer_details
  layer_details = text_layer_create(GRect(0, 22, 124, 146));
  text_layer_set_text(layer_details, "Text layer");
  text_layer_set_font(layer_details, s_res_gothic_18_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)layer_details);
  
  // layer_logo
  layer_logo = bitmap_layer_create(GRect(0, 48, 144, 120));
  layer_add_child(window_get_root_layer(s_window), (Layer *)layer_logo);
}
Esempio n. 18
0
static void initialise_ui(void) {
  s_window = window_create();
  #ifndef PBL_SDK_3
    window_set_fullscreen(s_window, false);
  #endif
  
  s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  s_res_gothic_14 = fonts_get_system_font(FONT_KEY_GOTHIC_14);
  s_res_gothic_28_bold = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
  s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  s_res_bus_nodata = gbitmap_create_with_resource(RESOURCE_ID_BUS_NODATA);
  s_res_actionicon_previous_white = gbitmap_create_with_resource(RESOURCE_ID_ACTIONICON_PREVIOUS_WHITE);
  s_res_actionicon_refresh_white = gbitmap_create_with_resource(RESOURCE_ID_ACTIONICON_REFRESH_WHITE);
  s_res_actionicon_next_white = gbitmap_create_with_resource(RESOURCE_ID_ACTIONICON_NEXT_WHITE);
  // textlayer_bus_no
  textlayer_bus_no = text_layer_create(GRect(3, 1, 51, 26));
  text_layer_set_background_color(textlayer_bus_no, GColorClear);
  text_layer_set_text(textlayer_bus_no, "...");
  text_layer_set_text_alignment(textlayer_bus_no, GTextAlignmentCenter);
  text_layer_set_font(textlayer_bus_no, s_res_gothic_24_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)textlayer_bus_no);
  
  // textlayer_busstop_name
  textlayer_busstop_name = text_layer_create(GRect(4, 25, 119, 20));
  text_layer_set_background_color(textlayer_busstop_name, GColorClear);
  text_layer_set_text(textlayer_busstop_name, "...");
  layer_add_child(window_get_root_layer(s_window), (Layer *)textlayer_busstop_name);
  
  // textlayer_busstop_code
  textlayer_busstop_code = text_layer_create(GRect(60, 2, 59, 20));
  text_layer_set_background_color(textlayer_busstop_code, GColorClear);
  text_layer_set_text(textlayer_busstop_code, "...");
  text_layer_set_text_alignment(textlayer_busstop_code, GTextAlignmentRight);
  text_layer_set_font(textlayer_busstop_code, s_res_gothic_14);
  layer_add_child(window_get_root_layer(s_window), (Layer *)textlayer_busstop_code);
  
  // textlayer_arrive_now
  textlayer_arrive_now = text_layer_create(GRect(23, 49, 79, 31));
  text_layer_set_background_color(textlayer_arrive_now, GColorClear);
  text_layer_set_text(textlayer_arrive_now, "...");
  text_layer_set_text_alignment(textlayer_arrive_now, GTextAlignmentCenter);
  text_layer_set_font(textlayer_arrive_now, s_res_gothic_28_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)textlayer_arrive_now);
  
  // textlayer_arrive_next
  textlayer_arrive_next = text_layer_create(GRect(28, 104, 68, 24));
  text_layer_set_background_color(textlayer_arrive_next, GColorClear);
  text_layer_set_text(textlayer_arrive_next, "...");
  text_layer_set_text_alignment(textlayer_arrive_next, GTextAlignmentCenter);
  text_layer_set_font(textlayer_arrive_next, s_res_gothic_18_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)textlayer_arrive_next);
  
  // textlayer_nextbus_label
  textlayer_nextbus_label = text_layer_create(GRect(4, 93, 100, 20));
  text_layer_set_background_color(textlayer_nextbus_label, GColorClear);
  text_layer_set_text(textlayer_nextbus_label, "Next Bus:");
  layer_add_child(window_get_root_layer(s_window), (Layer *)textlayer_nextbus_label);
  
  // bitmaplayer_current
  bitmaplayer_current = bitmap_layer_create(GRect(45, 77, 35, 10));
  bitmap_layer_set_bitmap(bitmaplayer_current, s_res_bus_nodata);
  layer_add_child(window_get_root_layer(s_window), (Layer *)bitmaplayer_current);
  
  // bitmaplayer_next
  bitmaplayer_next = bitmap_layer_create(GRect(45, 123, 35, 10));
  bitmap_layer_set_bitmap(bitmaplayer_next, s_res_bus_nodata);
  layer_add_child(window_get_root_layer(s_window), (Layer *)bitmaplayer_next);
  
  // textlayer_debug
  textlayer_debug = text_layer_create(GRect(4, 38, 114, 20));
  text_layer_set_background_color(textlayer_debug, GColorClear);
  text_layer_set_text(textlayer_debug, "Debug/Notices");
  text_layer_set_font(textlayer_debug, s_res_gothic_14);
  layer_add_child(window_get_root_layer(s_window), (Layer *)textlayer_debug);
  
  // actionbar_layer
  actionbar_layer = action_bar_layer_create();
  action_bar_layer_add_to_window(actionbar_layer, s_window);
  action_bar_layer_set_background_color(actionbar_layer, GColorBlack);
  action_bar_layer_set_icon(actionbar_layer, BUTTON_ID_UP, s_res_actionicon_previous_white);
  action_bar_layer_set_icon(actionbar_layer, BUTTON_ID_SELECT, s_res_actionicon_refresh_white);
  action_bar_layer_set_icon(actionbar_layer, BUTTON_ID_DOWN, s_res_actionicon_next_white);
  layer_add_child(window_get_root_layer(s_window), (Layer *)actionbar_layer);
  
  // textlayer_pages
  textlayer_pages = text_layer_create(GRect(3, 132, 116, 20));
  text_layer_set_background_color(textlayer_pages, GColorClear);
  text_layer_set_text(textlayer_pages, "?/?");
  text_layer_set_text_alignment(textlayer_pages, GTextAlignmentRight);
  text_layer_set_font(textlayer_pages, s_res_gothic_14);
  layer_add_child(window_get_root_layer(s_window), (Layer *)textlayer_pages);
  
  // bitmap_wab_now
  bitmap_wab_now = bitmap_layer_create(GRect(94, 56, 29, 29));
  layer_add_child(window_get_root_layer(s_window), (Layer *)bitmap_wab_now);
  
  // bitmap_wab_next
  bitmap_wab_next = bitmap_layer_create(GRect(94, 105, 25, 27));
  layer_add_child(window_get_root_layer(s_window), (Layer *)bitmap_wab_next);
}
Esempio n. 19
0
static void result_window_load(Window *window) {
	Layer *window_layer = window_get_root_layer(window);
	GRect bounds = layer_get_bounds(window_layer);
	RestaurantInformation *ptr;
	uint8_t status;
	bool valid_result = false; // create action bar and bind key pressing only when valid result is displayed
#ifdef PBL_ROUND
	// no need for the following variables
#else
	GSize max_size, sub_max_size;
	int title_height;
	TextLayer *temp;
#endif
	
	APP_LOG(APP_LOG_LEVEL_DEBUG, "Result window load");
	status = search_result.query_status;
	switch(status){
		case QUERY_STATUS_SUCCESS:
			valid_result = true;
			// Randomly pick up the restaurant
			search_result.random_result = rand()%search_result.num_of_restaurant;
			// Collect required fields
			ptr = &(search_result.restaurant_info[search_result.random_result]);
			strncpy(title_text, ptr->name, sizeof(title_text));
			if(user_setting.unit == 0){
				snprintf(sub_text, sizeof(sub_text), "%s %u %s", direction_name[ptr->direction], 
					(unsigned int)(ptr->distance), setting_unit_option_text[user_setting.unit]);
			}
			else{
				snprintf(sub_text, sizeof(sub_text), "%s %u.%u %s", direction_name[ptr->direction], 
					(unsigned int)(ptr->distance/100), (unsigned int)(ptr->distance%100), setting_unit_option_text[user_setting.unit]);
			}
			break;
		case QUERY_STATUS_NO_RESULT:
		case QUERY_STATUS_GPS_TIMEOUT:
			// Set corresponding error messages to title and subtitle
			strncpy(title_text, query_status_error_message[status], sizeof(title_text));
			strncpy(sub_text, query_status_error_sub_message[status], sizeof(sub_text));
			break;
		case QUERY_STATUS_GOOGLE_API_ERROR:
			// Collect error message from returned information
			strncpy(title_text, query_status_error_message[status], sizeof(title_text));
			strncpy(sub_text, search_result.api_error_message, sizeof(sub_text));
			break;
		default:
			// Other query status = unknown error
			strncpy(title_text, unknown_error_message, sizeof(title_text));
			snprintf(sub_text, sizeof(sub_text), "%s %s%d", unknown_error_sub_message, "Incorrect query status:",status);
			break;
	}

#ifdef PBL_ROUND
	// action bar part
	if(valid_result == true){
		icon_agenda_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_AGENDA);
		text_layer_width = bounds.size.w - ACTION_BAR_WIDTH;
		s_result_action_bar_layer = action_bar_layer_create();
#ifdef PBL_COLOR
		action_bar_layer_set_background_color(s_result_action_bar_layer, highlight_alt_bg_color);
#endif
	}
	else{
		text_layer_width = bounds.size.w;
	}

	// title part
	s_result_title_layer = layer_create(bounds);
	layer_set_update_proc(s_result_title_layer, result_title_layer_update_proc);

	// subtitle part
	s_result_sub_layer = layer_create(GRect(bounds.origin.x, bounds.origin.y+120, bounds.size.w, bounds.size.h-100));
	layer_set_update_proc(s_result_sub_layer, result_sub_layer_update_proc);

	layer_add_child(window_layer, s_result_title_layer);
	layer_add_child(window_layer, s_result_sub_layer);
	action_bar_layer_add_to_window(s_result_action_bar_layer, window);
	action_bar_layer_set_icon(s_result_action_bar_layer, BUTTON_ID_SELECT, icon_agenda_bitmap);
	action_bar_layer_set_click_config_provider(s_result_action_bar_layer, result_click_config_provider);

#else // #ifdef PBL_ROUND	
	// action bar part
	if(valid_result == true){
		icon_agenda_bitmap = gbitmap_create_with_resource(RESOURCE_ID_ICON_AGENDA);
		text_layer_width = bounds.size.w - ACTION_BAR_WIDTH;
		s_result_action_bar_layer = action_bar_layer_create();
#ifdef PBL_COLOR
		action_bar_layer_set_background_color(s_result_action_bar_layer, highlight_alt_bg_color);
#endif
		action_bar_layer_add_to_window(s_result_action_bar_layer, window);
		action_bar_layer_set_icon(s_result_action_bar_layer, BUTTON_ID_SELECT, icon_agenda_bitmap);
	}
	else{
		text_layer_width = bounds.size.w;
	}
	// compute require height for sub-title
	temp = text_layer_create(GRect(bounds.origin.x, bounds.origin.y, text_layer_width, bounds.size.h));
	text_layer_set_font(temp, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
	text_layer_set_text(temp, sub_text);
	sub_max_size = text_layer_get_content_size(temp);
	text_layer_destroy(temp);

	// title part
	s_result_title_text_layer = text_layer_create(GRect(bounds.origin.x, bounds.origin.y, text_layer_width, 2000));
	text_layer_set_font(s_result_title_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
	text_layer_set_text_alignment(s_result_title_text_layer, GTextAlignmentLeft);
	text_layer_set_overflow_mode(s_result_title_text_layer, GTextOverflowModeWordWrap);
	text_layer_set_background_color(s_result_title_text_layer, bg_color);
	text_layer_set_text_color(s_result_title_text_layer, text_color);
	text_layer_set_text(s_result_title_text_layer, title_text);
	max_size = text_layer_get_content_size(s_result_title_text_layer);

	// adjust title height. Always have 10px padding for certain characters to display
	if(max_size.h > (bounds.size.h - sub_max_size.h + 10))
		title_height = (bounds.size.h - sub_max_size.h + 10);  // title is very long: leave some space for sub-title.
	else if(max_size.h < (bounds.size.h/2 + 10))
		title_height = (bounds.size.h/2 + 10);  // title is short: make it half part
	else
		title_height = max_size.h + 10;  // title is long, but not very long: use current size

	// create scroll layer
	s_result_scroll_layer = scroll_layer_create(GRect(bounds.origin.x, bounds.origin.y, text_layer_width, title_height));
	if(valid_result == true){
		scroll_layer_set_click_config_onto_window(s_result_scroll_layer, window);
		scroll_layer_set_callbacks(s_result_scroll_layer, (ScrollLayerCallbacks){.click_config_provider=result_click_config_provider});
Esempio n. 20
0
static void gui_main_window_load(Window *window) {
  /* root layer */
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);

  /* create action bar */
  s_action_bar = action_bar_layer_create();
  action_bar_layer_add_to_window(s_action_bar, window);
  action_bar_layer_set_background_color(s_action_bar, PBL_IF_COLOR_ELSE(GColorTiffanyBlue, GColorWhite));
  action_bar_layer_set_click_config_provider(s_action_bar, gui_ab_click_provider);
  gui_ab_update_icons();

  bounds.size.w -= ACTION_BAR_WIDTH;

  /* background layer */
  s_layer_bg = layer_create(bounds);
  layer_set_update_proc(s_layer_bg, gui_layer_bg_update);
  layer_add_child(window_layer, s_layer_bg);

  /* create content layer on the left */
  s_layer_content = layer_create(bounds);
  layer_set_update_proc(s_layer_content, gui_layer_content_update);
  layer_add_child(window_layer, s_layer_content);

  int kern = 2;
  /* text layer center */
  int ch = 22;
  s_text_center_descr = text_layer_create(GRect(PADDING_X, bounds.size.h/2-(ch+kern)/2, bounds.size.w-2*PADDING_X, ch));
  text_layer_set_font(s_text_center_descr, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(s_text_center_descr, GColorClear);
  text_layer_set_text_alignment(s_text_center_descr, GTextAlignmentCenter);
  text_layer_set_text(s_text_center_descr, "");
  layer_add_child(s_layer_content, text_layer_get_layer(s_text_center_descr));

  /* text layers upper */
  /*   description */
  int dh = 22;
  int ds = 3;
  s_text_upper_descr = text_layer_create(GRect(PADDING_X, bounds.size.h/2-dh-ch/2, bounds.size.w-2*PADDING_X, dh));
  text_layer_set_font(s_text_upper_descr, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(s_text_upper_descr, GColorClear);
  text_layer_set_text_alignment(s_text_upper_descr, PBL_IF_ROUND_ELSE(GTextAlignmentRight, GTextAlignmentCenter));
  text_layer_set_text(s_text_upper_descr, "");
  layer_add_child(s_layer_content, text_layer_get_layer(s_text_upper_descr));
  /*   time 1 */
  int t1h = 32;
  int t1s = 5;
  s_text_upper_time1 = text_layer_create(GRect(PADDING_X*2, bounds.size.h/2-dh-ch/2+ds-t1h, bounds.size.w-2*PADDING_X*2, t1h));
  text_layer_set_font(s_text_upper_time1, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_background_color(s_text_upper_time1, GColorClear);
  text_layer_set_text_alignment(s_text_upper_time1, PBL_IF_ROUND_ELSE(GTextAlignmentRight, GTextAlignmentCenter));
  text_layer_set_text(s_text_upper_time1, "");
  layer_add_child(s_layer_content, text_layer_get_layer(s_text_upper_time1));
  /*  time 2 */
  int t2h = 20;
  s_text_upper_time2 = text_layer_create(GRect(PADDING_X, bounds.size.h/2-kern-dh-ch/2+ds-t1h+t1s-t2h, bounds.size.w-2*PADDING_X, t2h));
  text_layer_set_font(s_text_upper_time2, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(s_text_upper_time2, GColorClear);
  text_layer_set_text_alignment(s_text_upper_time2, PBL_IF_ROUND_ELSE(GTextAlignmentRight, GTextAlignmentCenter));
  text_layer_set_text(s_text_upper_time2, "");
  layer_add_child(s_layer_content, text_layer_get_layer(s_text_upper_time2));

  /* text layer lower */
  /*   description */
  s_text_lower_descr = text_layer_create(GRect(PADDING_X, bounds.size.h/2-kern+ch/2, bounds.size.w-2*PADDING_X, dh));
  text_layer_set_font(s_text_lower_descr, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(s_text_lower_descr, GColorClear);
  text_layer_set_text_alignment(s_text_lower_descr, PBL_IF_ROUND_ELSE(GTextAlignmentRight, GTextAlignmentCenter));
  text_layer_set_text(s_text_lower_descr, "");
  layer_add_child(s_layer_content, text_layer_get_layer(s_text_lower_descr));
  /*   time 1 */
  s_text_lower_time1 = text_layer_create(GRect(PADDING_X*2, bounds.size.h/2-kern+ch/2+dh-ds, bounds.size.w-2*PADDING_X*2, t1h));
  text_layer_set_font(s_text_lower_time1, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_background_color(s_text_lower_time1, GColorClear);
  text_layer_set_text_alignment(s_text_lower_time1, PBL_IF_ROUND_ELSE(GTextAlignmentRight, GTextAlignmentCenter));
  text_layer_set_text(s_text_lower_time1, "");
  layer_add_child(s_layer_content, text_layer_get_layer(s_text_lower_time1));
  /*  time 2 */
  s_text_lower_time2 = text_layer_create(GRect(PADDING_X, bounds.size.h/2-kern+ch/2+dh-ds+t1h-t1s, bounds.size.w-2*PADDING_X, t2h));
  text_layer_set_font(s_text_lower_time2, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(s_text_lower_time2, GColorClear);
  text_layer_set_text_alignment(s_text_lower_time2, PBL_IF_ROUND_ELSE(GTextAlignmentRight, GTextAlignmentCenter));
  text_layer_set_text(s_text_lower_time2, "");
  layer_add_child(s_layer_content, text_layer_get_layer(s_text_lower_time2));
}
Esempio n. 21
0
File: main.c Progetto: imclab/rest
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  window_set_fullscreen(s_window, false);

  s_res_image_go = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_GO);
  s_res_bitham_34_medium_numbers = fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS);
  s_res_roboto_bold_subset_49 = fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49);
  s_res_roboto_condensed_21 = fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21);
  // s_actionbarlayer_main
  s_actionbarlayer_main = action_bar_layer_create();
  action_bar_layer_add_to_window(s_actionbarlayer_main, s_window);
  action_bar_layer_set_background_color(s_actionbarlayer_main, GColorWhite);
  action_bar_layer_set_icon(s_actionbarlayer_main, BUTTON_ID_UP, s_res_image_go);
  action_bar_layer_set_icon(s_actionbarlayer_main, BUTTON_ID_SELECT, s_res_image_go);
  action_bar_layer_set_icon(s_actionbarlayer_main, BUTTON_ID_DOWN, s_res_image_go);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_actionbarlayer_main);

  // s_textlayer_120
  s_textlayer_120 = text_layer_create(GRect(15, 4, 100, 42));
  text_layer_set_background_color(s_textlayer_120, GColorBlack);
  text_layer_set_text_color(s_textlayer_120, GColorWhite);
  text_layer_set_text(s_textlayer_120, "120");
  text_layer_set_text_alignment(s_textlayer_120, GTextAlignmentRight);
  text_layer_set_font(s_textlayer_120, s_res_bitham_34_medium_numbers);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_120);

  // s_textlayer_60
  s_textlayer_60 = text_layer_create(GRect(15, 102, 100, 42));
  text_layer_set_background_color(s_textlayer_60, GColorBlack);
  text_layer_set_text_color(s_textlayer_60, GColorWhite);
  text_layer_set_text(s_textlayer_60, "60");
  text_layer_set_text_alignment(s_textlayer_60, GTextAlignmentRight);
  text_layer_set_font(s_textlayer_60, s_res_bitham_34_medium_numbers);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_60);

  // s_textlayer_90
  s_textlayer_90 = text_layer_create(GRect(15, 54, 100, 34));
  text_layer_set_background_color(s_textlayer_90, GColorBlack);
  text_layer_set_text_color(s_textlayer_90, GColorWhite);
  text_layer_set_text(s_textlayer_90, "90");
  text_layer_set_text_alignment(s_textlayer_90, GTextAlignmentRight);
  text_layer_set_font(s_textlayer_90, s_res_bitham_34_medium_numbers);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_90);

  // s_textlayer_count
  s_textlayer_count = text_layer_create(GRect(20, 36, 104, 60));
  text_layer_set_background_color(s_textlayer_count, GColorBlack);
  text_layer_set_text_color(s_textlayer_count, GColorWhite);
  text_layer_set_text(s_textlayer_count, "0");
  text_layer_set_text_alignment(s_textlayer_count, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_count, s_res_roboto_bold_subset_49);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_count);

  // s_textlayer_over
  s_textlayer_over = text_layer_create(GRect(61, 91, 80, 28));
  text_layer_set_background_color(s_textlayer_over, GColorBlack);
  text_layer_set_text_color(s_textlayer_over, GColorWhite);
  text_layer_set_text(s_textlayer_over, "0:00");
  text_layer_set_font(s_textlayer_over, s_res_roboto_condensed_21);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_over);

  // s_inverterlayer_theme
  s_inverterlayer_theme = inverter_layer_create(GRect(0, 0, 144, 152));
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_inverterlayer_theme);
}
Esempio n. 22
0
/*
 * Build the settings window
 */
static void create_settings_window(void) {
  setting_window = window_create();
  Layer *window_layer = window_get_root_layer(setting_window);

  window_set_background_color(setting_window, SETTING_BACKGROUND_COLOR);

  // Get the resources we need
  up_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_UP);
  next_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_NEXT);
  down_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_DOWN);
  tick_button_res = gbitmap_create_with_resource(RESOURCE_ID_PICK_TICK);
  small_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  large_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);

  // button_layer
  button_layer = action_bar_layer_create();
  action_bar_layer_add_to_window(button_layer, setting_window);
  action_bar_layer_set_background_color(button_layer, ACTION_BAR_BACKGROUND_COLOR);
  action_bar_layer_set_icon(button_layer, BUTTON_ID_UP, up_button_res);
  action_bar_layer_set_icon(button_layer, BUTTON_ID_SELECT, next_button_res);
  action_bar_layer_set_icon(button_layer, BUTTON_ID_DOWN, down_button_res);
#ifdef PBL_PLATFORM_BASALT 
  action_bar_layer_set_icon_press_animation(button_layer, BUTTON_ID_UP, ActionBarLayerIconPressAnimationMoveUp);
  action_bar_layer_set_icon_press_animation(button_layer, BUTTON_ID_SELECT, ActionBarLayerIconPressAnimationMoveRight);
  action_bar_layer_set_icon_press_animation(button_layer, BUTTON_ID_DOWN, ActionBarLayerIconPressAnimationMoveDown);
#endif
  layer_add_child(window_layer, (Layer *) button_layer);
  action_bar_layer_set_click_config_provider(button_layer, setting_click_config_provider);

  // title_layer
  title_layer = macro_text_layer_create(GRect(SETTING_TITLE_LEFT, 6, 90, SETTING_SMALL_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, small_font, GTextAlignmentLeft);
  text_layer_set_text(title_layer, SMART_ALARM);

  // from_layer
  from_layer = macro_text_layer_create(GRect(SETTING_TITLE_LEFT, 30, 55, SETTING_SMALL_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, small_font, GTextAlignmentLeft);
  text_layer_set_text(from_layer, EARLIEST);

  // fields[FROM_HOUR]
  fields[F_FROM_HOUR] = macro_text_layer_create(GRect(20, SETTING_FROM_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // from_colon_layer
  from_colon_layer = macro_text_layer_create(GRect(43, SETTING_FROM_TOP, 13, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);
  text_layer_set_text(from_colon_layer, COLON);

  // fields[FROM_MINUTE]
  fields[F_FROM_MINUTE] = macro_text_layer_create(GRect(52, SETTING_FROM_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // to_layer
  to_layer = macro_text_layer_create(GRect(SETTING_TITLE_LEFT, 81, 48, SETTING_SMALL_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, small_font, GTextAlignmentLeft);
  text_layer_set_text(to_layer, LATEST);

  // fields[TO_HOUR]
  fields[F_TO_HOUR] = macro_text_layer_create(GRect(20, SETTING_TO_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // to_color_layer
  to_color_layer = macro_text_layer_create(GRect(43, SETTING_TO_TOP, 13, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);
  text_layer_set_text(to_color_layer, COLON);

  // fields[TO_MINUTE]
  fields[F_TO_MINUTE] = macro_text_layer_create(GRect(52, SETTING_TO_TOP, SETTING_TIME_WIDTH, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[SMART_ALARM]
  fields[F_SMART_ALARM] = macro_text_layer_create(GRect(SA_LEFT, SA_TOP, 25, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[DONE]
  fields[F_DONE] = macro_text_layer_create(GRect(DONE_LEFT, DONE_TOP, 45, SETTING_BIG_FONT_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  current_field = F_SMART_ALARM;

  set_values();
  write_values_to_fields();
  highlight_field(current_field, true);
}
Esempio n. 23
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  #ifndef PBL_SDK_3
    window_set_fullscreen(s_window, 0);
  #endif
  
  s_res_content_regular_12 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_content_regular_12));
  s_res_content_regular_24 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_content_regular_24));
  s_res_left_led = gbitmap_create_with_resource(RESOURCE_ID_Left_LED);
  s_res_send_button = gbitmap_create_with_resource(RESOURCE_ID_Send_Button);
  s_res_right_led = gbitmap_create_with_resource(RESOURCE_ID_Right_LED);
  s_res_content_regular_16 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_content_regular_16));
  // s_time_layer
  s_time_layer = text_layer_create(GRect(0, 0, 144, 18));
  text_layer_set_background_color(s_time_layer, GColorClear);
  text_layer_set_text_color(s_time_layer, GColorWhite);
  text_layer_set_text(s_time_layer, "00:00");
  text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
  text_layer_set_font(s_time_layer, s_res_content_regular_12);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_time_layer);
  
  // s_xy_values_layer
  s_xy_values_layer = text_layer_create(GRect(13, 66, 99, 36));
  text_layer_set_background_color(s_xy_values_layer, GColorClear);
  text_layer_set_text_color(s_xy_values_layer, GColorWhite);
  text_layer_set_text(s_xy_values_layer, "000 000");
  text_layer_set_text_alignment(s_xy_values_layer, GTextAlignmentCenter);
  text_layer_set_font(s_xy_values_layer, s_res_content_regular_24);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_xy_values_layer);
  
  // s_actionbarlayer_1
  s_actionbarlayer_1 = action_bar_layer_create();
  action_bar_layer_add_to_window(s_actionbarlayer_1, s_window);
  action_bar_layer_set_background_color(s_actionbarlayer_1, GColorBlack);
  action_bar_layer_set_icon(s_actionbarlayer_1, BUTTON_ID_UP, s_res_left_led);
  action_bar_layer_set_icon(s_actionbarlayer_1, BUTTON_ID_SELECT, s_res_send_button);
  action_bar_layer_set_icon(s_actionbarlayer_1, BUTTON_ID_DOWN, s_res_right_led);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_actionbarlayer_1);
  
  // s_left_stop
  s_left_stop = bitmap_layer_create(GRect(40, 53, 15, 15));
  bitmap_layer_set_bitmap(s_left_stop, s_res_left_led);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_left_stop);
  
  // s_right_stop
  s_right_stop = bitmap_layer_create(GRect(70, 53, 15, 15));
  bitmap_layer_set_bitmap(s_right_stop, s_res_right_led);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_right_stop);
  
  // s_transmitting
  s_transmitting = bitmap_layer_create(GRect(55, 105, 15, 15));
  bitmap_layer_set_bitmap(s_transmitting, s_res_send_button);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_transmitting);
  
  // s_delay_text
  s_delay_text = text_layer_create(GRect(73, 98, 30, 30));
  text_layer_set_background_color(s_delay_text, GColorClear);
  text_layer_set_text_color(s_delay_text, GColorWhite);
  text_layer_set_text(s_delay_text, "0");
  text_layer_set_font(s_delay_text, s_res_content_regular_16);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_delay_text);
}
Esempio n. 24
0
static void window_load(Window *window) {
	Layer *window_layer = window_get_root_layer(window);
	static int row_height = 22;
	int it = 2;
	const int button_bar_width = 20;
	const int text_layer_width = 144 - button_bar_width;
	
	//Set up Window Action Bar
	up_arrow_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_UP_ARROW);
	down_arrow_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_DOWN_ARROW);
	settings_icon = gbitmap_create_with_resource(RESOURCE_ID_ICON_SETTINGS);
	window_action_bar = action_bar_layer_create();
	action_bar_layer_add_to_window(window_action_bar, window);
	action_bar_layer_set_background_color(window_action_bar, GColorBlack);
	action_bar_layer_set_click_config_provider(window_action_bar, click_config_provider);
	action_bar_layer_set_icon(window_action_bar, BUTTON_ID_UP, up_arrow_icon);
	action_bar_layer_set_icon(window_action_bar, BUTTON_ID_DOWN, down_arrow_icon);
	action_bar_layer_set_icon(window_action_bar, BUTTON_ID_SELECT, settings_icon);

	// Area Name Layer	
	area_name_layer = text_layer_create(GRect(0, -2, text_layer_width, 48));
	text_layer_set_text_color(area_name_layer, GColorWhite);
	text_layer_set_background_color(area_name_layer, GColorClear);
	text_layer_set_font(area_name_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
	text_layer_set_text_alignment(area_name_layer, GTextAlignmentCenter);
	text_layer_set_overflow_mode(area_name_layer, GTextOverflowModeWordWrap);
	layer_add_child(window_layer, text_layer_get_layer(area_name_layer));
	
	// Weather Description Layer
	weather_layer = text_layer_create(GRect(0, it++ * row_height, text_layer_width, row_height));
	text_layer_set_text_color(weather_layer, GColorWhite);
	text_layer_set_background_color(weather_layer, GColorClear);
	text_layer_set_font(weather_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
	text_layer_set_text_alignment(weather_layer, GTextAlignmentCenter);
	layer_add_child(window_layer, text_layer_get_layer(weather_layer));
	
	// Snowfall Layer	
	snowfall_layer = text_layer_create(GRect(0, it++ * row_height, text_layer_width, row_height));
	text_layer_set_text_color(snowfall_layer, GColorWhite);
	text_layer_set_background_color(snowfall_layer, GColorClear);
	text_layer_set_font(snowfall_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
	text_layer_set_text_alignment(snowfall_layer, GTextAlignmentCenter);
	layer_add_child(window_layer, text_layer_get_layer(snowfall_layer));
	
	// Temperature Layer
	temps_layer = text_layer_create(GRect(0, it++ * row_height, text_layer_width, row_height));
	text_layer_set_text_color(temps_layer, GColorWhite);
	text_layer_set_background_color(temps_layer, GColorClear);
	text_layer_set_font(temps_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
	text_layer_set_text_alignment(temps_layer, GTextAlignmentCenter);
	layer_add_child(window_layer, text_layer_get_layer(temps_layer));
	
	// Wind Layer	
	wind_layer = text_layer_create(GRect(0, it++ * row_height, text_layer_width, row_height));
	text_layer_set_text_color(wind_layer, GColorWhite);
	text_layer_set_background_color(wind_layer, GColorClear);
	text_layer_set_font(wind_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
	text_layer_set_text_alignment(wind_layer, GTextAlignmentCenter);
	layer_add_child(window_layer, text_layer_get_layer(wind_layer));
	
	// Update Time Layer
	update_layer = text_layer_create(GRect(0, it++ * row_height + 4, text_layer_width, row_height));
	text_layer_set_text_color(update_layer, GColorWhite);
	text_layer_set_background_color(update_layer, GColorClear);
	text_layer_set_font(update_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
	text_layer_set_text_alignment(update_layer, GTextAlignmentCenter);
	layer_add_child(window_layer, text_layer_get_layer(update_layer));
	
	Tuplet initial_values[] = {
		TupletInteger(INDEX_KEY, (uint8_t) 0),
		TupletCString(AREA_NAME_KEY, "Loading..."),
		TupletCString(WEATHER_DESC_KEY, "Loading..."),
		TupletCString(WIND_KEY, "Wind: --- @ -- ---"),
		TupletCString(AREA_TEMPS_KEY, "Temp(--): -- to --"),
		TupletCString(AREA_SNOWFALL_KEY, "Snow(24h): --   "),
		TupletCString(UPDATE_TIME_KEY, "Updated @ --:--"),
		TupletInteger(UNITS_KEY, (uint8_t) 0),
	};
	
	app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values),
				  sync_tuple_changed_callback, sync_error_callback, NULL);
	
	send_cmd();
}