Пример #1
0
static void prv_init_custom_ui(uint16_t trip_id, uint8_t sequence) {
  s_time_count = trip_times_count(trip_id);
  s_trip_id = trip_id;
  trip_get(trip_id, &s_trip);
  s_index = prv_sequence_to_index(sequence);
  s_sequence = sequence;
  s_times = malloc(s_time_count * sizeof(TrainTime));
  trip_get_times(trip_id, s_time_count, s_times);
  
  snprintf(s_trip_name_buf, sizeof(s_trip_name_buf), "#%d", s_trip.trip_name);
  text_layer_set_text(s_train_number, s_trip_name_buf);

  static const char *trip_types[] = {
    "Baby Bullet",
    "Limited",
    "Local",
    "Shuttle",
  };
  text_layer_set_text(s_train_type, trip_types[s_trip.route]);
  
  
  // Set up the menu layer
  menu_layer_set_callbacks(s_stop_list, s_stop_list, (MenuLayerCallbacks) {
    .draw_row = prv_draw_menu_row,
    .get_num_rows = prv_get_menu_rows,
    .get_cell_height = prv_get_cell_height,
    .get_separator_height = menu_hack_borderless_cells,
  });
Пример #2
0
static void prv_draw_menu_row(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *callback_context) {
  char time_buf[6];
  char state_buf[13];
  char number_buf[4];
  TrainTrip trip;
  
  TrainTime *time = &s_times[cell_index->row];
  
  trip_get(time->trip, &trip);
  snprintf(number_buf, sizeof(number_buf), "%d", trip.trip_name);
  train_time_format_minutes(time->time, sizeof(time_buf), time_buf);
  train_time_format_state(time, sizeof(state_buf), state_buf);
  
  graphics_context_set_text_color(ctx, GColorBlack);
  graphics_draw_text(ctx, time_buf, fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS), GRect(0, -5, 114, 43), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
  graphics_draw_text(ctx, number_buf, fonts_get_system_font(FONT_KEY_GOTHIC_24), GRect(114, -4, 27, 20), GTextOverflowModeFill, GTextAlignmentRight, NULL);
}
Пример #3
0
static void prv_draw_menu_row(GContext *ctx, const Layer *cell_layer, MenuIndex *cell_index, void *menu) {
  char time_buf[6];
  char state_buf[13];
  char number_buf[4];
  TrainTrip trip;
  
  TrainTime *time = &s_times[cell_index->row];
  
  trip_get(time->trip, &trip);
  snprintf(number_buf, sizeof(number_buf), "%d", trip.trip_name);
  train_time_format_minutes(time->time, sizeof(time_buf), time_buf);
  train_time_format_state(time, sizeof(state_buf), state_buf);
  
  menu_hack_set_colours(ctx, menu, cell_index);
  
  graphics_fill_rect(ctx, layer_get_bounds(cell_layer), 0, GCornerNone);
  graphics_draw_text(ctx, time_buf, fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS), GRect(0, -5, 114, 43), GTextOverflowModeFill, GTextAlignmentLeft, NULL);
  graphics_draw_text(ctx, number_buf, fonts_get_system_font(FONT_KEY_GOTHIC_24), GRect(114, -6, 27, 20), GTextOverflowModeFill, GTextAlignmentRight, NULL);
  
  #ifdef PBL_COLOR
    graphics_context_set_fill_color(ctx, trip_get_colour(&trip));
    graphics_fill_circle(ctx, GPoint(135, 26), 5);
  #endif
}