예제 #1
0
/*
 * Select button moves to next field - highlight and move
 */
static void select_single_click_handler(ClickRecognizerRef recognizer, void *context) {
  highlight_field(current_field, false);
  current_field++;
  if (current_field > F_DONE)
    current_field = F_SMART_ALARM;
  highlight_field(current_field, true);
}
예제 #2
0
/*
 * Select button moves to next field - highlight and move
 */
static void select_single_click_handler(ClickRecognizerRef recognizer, void *context) {
  highlight_field(current_field, false);
  current_field++;
  if (is24hr && (current_field == F_FROM_AMPM || current_field == F_TO_AMPM)) {
    current_field++;
  }
  if (current_field > F_TO_AMPM) {
    hide_set_alarm();
    return;
  }
  highlight_field(current_field, true);
}
예제 #3
0
/*
 * Build the settings window
 */
static void create_settings_window(void) {
  setting_window = window_create();
  Layer *window_layer = window_get_root_layer(setting_window);
  GRect bounds = layer_get_bounds(window_layer);
  int16_t centre = bounds.size.w / 2;
  int16_t width = bounds.size.w;

  window_set_background_color(setting_window, SETTING_BACKGROUND_COLOR);
  
  is24hr = clock_is_24h_style();

  // Get the resources we need
  large_font = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
  small_font = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
 
  // Set click provider
  window_set_click_config_provider(setting_window, (ClickConfigProvider) setting_click_config_provider);

  // from_layer
  from_layer = macro_text_layer_create(GRect(SA_ROW_1_X, SA_ROW_1_Y, SA_ROW_1_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, SETTING_BACKGROUND_COLOR, small_font, GTextAlignmentCenter);
  text_layer_set_text(from_layer, EARLIEST);

  // fields[FROM_HOUR]
  fields[F_FROM_HOUR] = macro_text_layer_create(GRect(is24hr ? SA_HOUR_LEFT_24 : SA_HOUR_LEFT_12, SA_ROW_2_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[FROM_MINUTE]
  fields[F_FROM_MINUTE] = macro_text_layer_create(GRect(is24hr ? SA_MIN_LEFT_24 : SA_MIN_LEFT_12, SA_ROW_2_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[FROM_AMPM]
  if (!is24hr) {
    fields[F_FROM_AMPM] = macro_text_layer_create(GRect(SA_AMPM_LEFT, SA_ROW_2_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);
  }
  
  // to_layer
  to_layer = macro_text_layer_create(GRect(SA_ROW_3_X, SA_ROW_3_Y, SA_ROW_3_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, SETTING_BACKGROUND_COLOR, small_font, GTextAlignmentCenter);
  text_layer_set_text(to_layer, LATEST);

  // fields[TO_HOUR]
  fields[F_TO_HOUR] = macro_text_layer_create(GRect(is24hr ? SA_HOUR_LEFT_24 : SA_HOUR_LEFT_12, SA_ROW_4_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[TO_MINUTE]
  fields[F_TO_MINUTE] = macro_text_layer_create(GRect(is24hr ? SA_MIN_LEFT_24 : SA_MIN_LEFT_12, SA_ROW_4_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);

  // fields[TO_AMPM]
  if (!is24hr) {
    fields[F_TO_AMPM] = macro_text_layer_create(GRect(SA_AMPM_LEFT, SA_ROW_4_Y, SA_WIDTH, SA_HEIGHT), window_layer, NON_HIGHLIGHT_FG_COLOR, NON_HIGHLIGHT_BG_COLOR, large_font, GTextAlignmentCenter);
  }
    
  current_field = F_FROM_HOUR;

  set_values();
  write_values_to_fields();
  highlight_field(current_field, true);
}
예제 #4
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);
}