Пример #1
0
static void handle_init() {
  SlidingTextData *data = (SlidingTextData*)malloc(sizeof(SlidingTextData));
  s_data = data;

  data->render_state.next_hours = 0;
  data->render_state.next_minutes = 0;
  data->render_state.demo_time.secs = 0;
  data->render_state.demo_time.mins = 0;
  data->render_state.demo_time.hour = 0;

  data->window = window_create();

  int bgcolor = persist_read_int(KEY_BACKGROUND_COLOR);
  GColor back_color = GColorFromHEX(bgcolor);
  window_set_background_color(data->window, back_color);

  data->bitham42_bold = fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD);
  data->bitham42_light = fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT);

  Layer *window_layer = window_get_root_layer(data->window);
  GRect layer_frame = layer_get_frame(window_layer);
  const int16_t width = layer_frame.size.w;
  init_sliding_row(data, &data->rows[0], GRect(0, 20, width, 60), data->bitham42_bold, 6);
  layer_add_child(window_layer, text_layer_get_layer(data->rows[0].label));

  init_sliding_row(data, &data->rows[1], GRect(0, 56, width, 96), data->bitham42_light, 3);
  layer_add_child(window_layer, text_layer_get_layer(data->rows[1].label));

  init_sliding_row(data, &data->rows[2], GRect(0, 92, width, 132), data->bitham42_light, 0);
  layer_add_child(window_layer, text_layer_get_layer(data->rows[2].label));

  GFont norm14 = fonts_get_system_font(FONT_KEY_GOTHIC_14);

  data->demo_label = text_layer_create(GRect(0, -3, 100, 20));
  text_layer_set_background_color(data->demo_label, GColorClear);

  int color = persist_read_int(KEY_TEXT_COLOR);
  GColor text_color = GColorFromHEX(color);

  text_layer_set_text_color(data->demo_label, text_color);
  text_layer_set_font(data->demo_label, norm14);
  text_layer_set_text(data->demo_label, "demo mode");
  layer_add_child(window_layer, text_layer_get_layer(data->demo_label));

  layer_set_hidden(text_layer_get_layer(data->demo_label), true);
  layer_mark_dirty(window_layer);

  make_animation();

  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);

  const bool animated = true;
  window_stack_push(data->window, animated);

  app_message_register_inbox_received(inbox_received_handler);
  app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
}
Пример #2
0
static void handle_init() {
  SlidingTextData *data = (SlidingTextData*)malloc(sizeof(SlidingTextData));
  s_data = data;

  data->render_state.next_hours = 0;
  data->render_state.next_minutes = 0;
  data->render_state.demo_time.secs = 0;
  data->render_state.demo_time.mins = 0;
  data->render_state.demo_time.hour = 0;

  data->window = window_create();

  window_set_background_color(data->window, GColorBlack);

  data->bitham42_bold = fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD);
  data->bitham42_light = fonts_get_system_font(FONT_KEY_BITHAM_42_LIGHT);

  Layer *window_layer = window_get_root_layer(data->window);
  GRect layer_frame = layer_get_frame(window_layer);

  const int16_t width = layer_frame.size.w;
  const int16_t height = layer_frame.size.h;
  const int16_t row_height = 36;
  const int16_t initial_row_y = PBL_IF_ROUND_ELSE(26, 20);

  int16_t current_row_y = initial_row_y;
  int16_t current_row_h = initial_row_y + 40;

  init_sliding_row(data, &data->rows[0], GRect(0, current_row_y, width, current_row_h), data->bitham42_bold, 6);
  layer_add_child(window_layer, text_layer_get_layer(data->rows[0].label));
  current_row_y += row_height;
  current_row_h += row_height;

  init_sliding_row(data, &data->rows[1], GRect(0, current_row_y, width, current_row_h), data->bitham42_light, 3);
  layer_add_child(window_layer, text_layer_get_layer(data->rows[1].label));
  current_row_y += row_height;
  current_row_h += row_height;

  init_sliding_row(data, &data->rows[2], GRect(0, current_row_y, width, current_row_h), data->bitham42_light, 0);
  layer_add_child(window_layer, text_layer_get_layer(data->rows[2].label));
  current_row_y += row_height;
  current_row_h += row_height;

  GFont norm14 = fonts_get_system_font(FONT_KEY_GOTHIC_14);

  data->demo_label = text_layer_create(GRect(0, -3, 100, 20));
  text_layer_set_background_color(data->demo_label, GColorClear);
  text_layer_set_text_color(data->demo_label, GColorWhite);
  text_layer_set_font(data->demo_label, norm14);
  text_layer_set_text(data->demo_label, "demo mode");
  layer_add_child(window_layer, text_layer_get_layer(data->demo_label));

  layer_set_hidden(text_layer_get_layer(data->demo_label), true);
  layer_mark_dirty(window_layer);

  make_animation();

  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);

  const bool animated = true;
  window_stack_push(data->window, animated);
}
Пример #3
0
static void handle_init() {
  SlidingTextData *data = (SlidingTextData*)malloc(sizeof(SlidingTextData));
  s_data = data;

  data->render_state.next_hours = 0;
  data->render_state.next_minutes = 0;
  data->render_state.demo_time.secs = 0;
  data->render_state.demo_time.mins = 0;
  data->render_state.demo_time.hour = 0;

  data->s_main_window = window_create();

  window_set_background_color(data->s_main_window, GColorWhite);

  data->helvetica30_bold = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HELVETICA_BOLD_30));
  data->helvetica20_light = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_HELVETICA_LIGHT_20));

  Layer *s_window_layer = window_get_root_layer(data->s_main_window);
  GRect layer_frame = layer_get_frame(s_window_layer);
  const int16_t width = layer_frame.size.w;

  ////////
  
  if (persist_read_int(KEY_SKIN_SELECT)) {
	  skin_select = persist_read_int(KEY_SKIN_SELECT);
	  	  
		  if (skin_select == 100)
		  	activeSkin = RESOURCE_ID_CHARLIEBROWN_COLOR_IMAGE;
			
		  if (skin_select == 101)
		  	activeSkin = RESOURCE_ID_FLASHY_COLOR_IMAGE;
	
		  if (skin_select == 102)
		  	activeSkin = RESOURCE_ID_SQUIGGLE_COLOR_IMAGE;
		  
		  if (skin_select == 103)
		  	activeSkin = RESOURCE_ID_ZEBRA_COLOR_IMAGE;
		  
		  if (skin_select == 104)
		  	activeSkin = RESOURCE_ID_SUPERBOX_COLOR_IMAGE;
		  
		  if (skin_select == 105)
		  	activeSkin = RESOURCE_ID_LEOPARD_COLOR_IMAGE;
	  } 
 
  
  s_squiggle_bitmap = gbitmap_create_with_resource(activeSkin);
  s_bitmap_layer = bitmap_layer_create(layer_frame);
  bitmap_layer_set_bitmap(s_bitmap_layer, s_squiggle_bitmap);
  layer_add_child(s_window_layer, bitmap_layer_get_layer(s_bitmap_layer));
  
  s_path1 = gpath_create(&PATH_INFO1);

  s_path1_layer = layer_create(layer_frame);
  layer_set_update_proc(s_path1_layer, layer1_update_proc);
  layer_add_child(s_window_layer, s_path1_layer);
  
  s_path2 = gpath_create(&PATH_INFO2);

  s_path2_layer = layer_create(layer_frame);
  layer_set_update_proc(s_path2_layer, layer2_update_proc);
  layer_add_child(s_window_layer, s_path2_layer);
    
  ////////
  
  init_sliding_row(data, &data->rows[1], GRect(8, 135, width, 30), data->helvetica20_light, 3);
  layer_add_child(s_window_layer, text_layer_get_layer(data->rows[1].label));
  
  init_sliding_row(data, &data->rows[0], GRect(8, 100, width, 40), data->helvetica30_bold, 6);
  layer_add_child(s_window_layer, text_layer_get_layer(data->rows[0].label));

  init_sliding_row(data, &data->rows[2], GRect(8, 170, width, 0), data->helvetica20_light, 0);
  layer_add_child(s_window_layer, text_layer_get_layer(data->rows[2].label));

  GFont norm14 = fonts_get_system_font(FONT_KEY_GOTHIC_14);

  data->demo_label = text_layer_create(GRect(0, -3, 100, 20));
  text_layer_set_background_color(data->demo_label, GColorWhite);
  text_layer_set_text_color(data->demo_label, GColorBlack);
  text_layer_set_font(data->demo_label, norm14);
  text_layer_set_text(data->demo_label, "demo mode");
  layer_add_child(s_window_layer, text_layer_get_layer(data->demo_label));

  layer_set_hidden(text_layer_get_layer(data->demo_label), true);
  layer_mark_dirty(s_window_layer);

  make_animation();

  tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);

  const bool animated = true;
  window_stack_push(data->s_main_window, animated); 

  ////////
  
  app_message_register_inbox_received(inbox_received_handler);
  app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());

}