void handle_init(AppContextRef ctx) {
	(void)ctx;

	window_init(&window, "Window Name");
	window_stack_push(&window, true /* Animated */);
	window_set_background_color(&window, GColorBlack);
	
	Minutes_Open = 0;
	
	//Texts
		//Year
		text_layer_init(&year_layer, GRect(8, 7, 144-16, 7+12));
		text_layer_set_text_color(&year_layer, GColorWhite);
		text_layer_set_background_color(&year_layer, GColorClear);
		text_layer_set_font(&year_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
		text_layer_set_text(&year_layer, "Year");
		layer_add_child(&window.layer, &year_layer.layer);

		//Month
		text_layer_init(&month_layer, GRect(8, 38, 144-16, 38+12));
		text_layer_set_text_color(&month_layer, GColorWhite);
		text_layer_set_background_color(&month_layer, GColorClear);
		text_layer_set_font(&month_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
		text_layer_set_text(&month_layer, "Month");
		layer_add_child(&window.layer, &month_layer.layer);

		//Week
		text_layer_init(&week_layer, GRect(8, 69, 144-16, 69+12));
		text_layer_set_text_color(&week_layer, GColorWhite);
		text_layer_set_background_color(&week_layer, GColorClear);
		text_layer_set_font(&week_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
		text_layer_set_text(&week_layer, "Week");
		layer_add_child(&window.layer, &week_layer.layer);

		//Day
		text_layer_init(&day_layer, GRect(8, 100, 144-16, 100+12));
		text_layer_set_text_color(&day_layer, GColorWhite);
		text_layer_set_background_color(&day_layer, GColorClear);
		text_layer_set_font(&day_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
		text_layer_set_text(&day_layer, "Day");
		layer_add_child(&window.layer, &day_layer.layer);

	//Clock text
	text_layer_init(&text_time_layer, GRect(0, 127, 144, 127+26));
	text_layer_set_text_color(&text_time_layer, GColorWhite);
	text_layer_set_background_color(&text_time_layer, GColorClear);
	text_layer_set_font(&text_time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
	text_layer_set_text_alignment(&text_time_layer, GTextAlignmentCenter);
	text_layer_set_text(&text_time_layer, "00:00");
	layer_add_child(&window.layer, &text_time_layer.layer);


	layer_init(&bars_layer, window.layer.frame);
	bars_layer.update_proc = &bars_update_callback;
	layer_add_child(&window.layer, &bars_layer);

	layer_init(&main_layer, window.layer.frame);
	main_layer.update_proc = &progress_update_callback;
	layer_add_child(&window.layer, &main_layer);
}
Beispiel #2
0
// Handle the start-up of the app
void handle_init_app(AppContextRef app_ctx) {

  // Create our app's base window
  window_init(&window, "Tic Tock Toe watch");
  window_stack_push(&window, true);

  window_set_background_color(&window, COLOR_BACKGROUND);

  // Init the layer that shows the board
  layer_init(&boardLayer, window.layer.frame); // Associate with layer object and set dimensions
  boardLayer.update_proc = &boardLayer_update_callback; // Set the drawing callback function for the layer.
  layer_add_child(&window.layer, &boardLayer); // Add the child to the app's base window

  // Init the layer that shows the player marks
  // TODO: Wrap this boilerplate in a function?
  layer_init(&playersLayer, window.layer.frame);
  playersLayer.update_proc = &playersLayer_update_callback;
  layer_add_child(&window.layer, &playersLayer);

  // Init the text layer used to show the time
  // TODO: Determine best practice for text. e.g. TextLayer with standard update proc vs Layer with custom update proc
  // TODO: Wrap this boilerplate in a function?
  text_layer_init(&timeLayer, GRect(0, 168-42, 144 /* width */, 42 /* height */));
  text_layer_set_text_alignment(&timeLayer, GTextAlignmentCenter);
  text_layer_set_text_color(&timeLayer, COLOR_FOREGROUND);
  text_layer_set_background_color(&timeLayer, GColorClear);
  text_layer_set_font(&timeLayer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));

  update_time_display();

  layer_add_child(&window.layer, &timeLayer.layer);
}
Beispiel #3
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Plain Watch");
  window_stack_push(&window, true /* Animated */);
  window_set_background_color(&window, GColorBlack);

  resource_init_current_app(&APP_RESOURCES);

  layer_init(&hour_display_layer, window.layer.frame);
  hour_display_layer.update_proc = &hour_display_layer_update_callback;
  layer_add_child(&window.layer, &hour_display_layer);

  gpath_init(&hour_hand_outline_path, &HOUR_HAND_OUTLINE_PATH_POINTS);
  gpath_move_to(&hour_hand_outline_path, grect_center_point(&hour_display_layer.frame));
  gpath_init(&hour_hand_path, &HOUR_HAND_PATH_POINTS);
  gpath_move_to(&hour_hand_path, grect_center_point(&hour_display_layer.frame));

  layer_init(&minute_display_layer, window.layer.frame);
  minute_display_layer.update_proc = &minute_display_layer_update_callback;
  layer_add_child(&window.layer, &minute_display_layer);

  gpath_init(&minute_hand_outline_path, &MINUTE_HAND_OUTLINE_PATH_POINTS);
  gpath_move_to(&minute_hand_outline_path, grect_center_point(&minute_display_layer.frame));
  gpath_init(&minute_hand_path, &MINUTE_HAND_PATH_POINTS);
  gpath_move_to(&minute_hand_path, grect_center_point(&minute_display_layer.frame));
}
Beispiel #4
0
void handle_init(AppContextRef ctx) {
	(void)ctx;
	
	app_ctx = ctx;

	window_init(&window, "Vibe");
	window_stack_push(&window, true /* Animated */);
    
	power = 3;
	on = false;
	
	resource_init_current_app(&APP_RESOURCES);
	
	layer_init(&controls_layer, GRect(124, 3, 20, 146));
	controls_layer.update_proc = &controls_update_callback;
	layer_add_child(&window.layer, &controls_layer);
	
	layer_init(&bars_layer, GRect(22, 22, 85, 115));
	bars_layer.update_proc = &bars_update_callback;
	layer_add_child(&window.layer, &bars_layer);
	
	bmp_init_container(RESOURCE_ID_IMAGE_CONTROLS, &controls);
	bmp_init_container(RESOURCE_ID_IMAGE_BAR_ON,   &bar_on);
	bmp_init_container(RESOURCE_ID_IMAGE_BAR_OFF,  &bar_off);
	
	window_set_click_config_provider(&window, (ClickConfigProvider) click_config_provider);
}
Beispiel #5
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Bar Graph");
  window_stack_push(&window, true /* Animated */);

  resource_init_current_app(&APP_RESOURCES);

  bmp_init_container(RESOURCE_ID_IMAGE_FACE, &faceImage);
  layer_add_child(&window.layer, &faceImage.layer.layer);

  layer_init(&hourLayer, window.layer.frame);
  hourLayer.update_proc = &update_hour;
  layer_add_child(&window.layer, &hourLayer);

  layer_init(&minLayer, window.layer.frame);
  minLayer.update_proc = &update_minute;
  layer_add_child(&window.layer, &minLayer);

  text_layer_init(&dateText, GRect(0,138,144,30));
  text_layer_set_text_color(&dateText, GColorWhite);
  text_layer_set_background_color(&dateText, GColorClear);
  text_layer_set_text_alignment(&dateText, GTextAlignmentCenter);
  text_layer_set_font(&dateText, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ARIAL_22)));
  layer_add_child(&window.layer, &dateText.layer);

  update_date();
}
Beispiel #6
0
void handle_init(AppContextRef ctx) {

  window_init(&window, "Simplicity");
  window_stack_push(&window, true /* Animated */);
  window_set_background_color(&window, GColorBlack);

  resource_init_current_app(&APP_RESOURCES);

  layer_init(&time_layer, GRect(0, 12, 144, 168-68));
  layer_add_child(&window.layer, &time_layer);

  text_layer_init(&text_date_layer, window.layer.frame);
  text_layer_set_text_color(&text_date_layer, GColorWhite);
  text_layer_set_background_color(&text_date_layer, GColorClear);
  layer_set_frame(&text_date_layer.layer, GRect(8, 0, 144-8, 168-68));
  text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21)));
  layer_add_child(&time_layer, &text_date_layer.layer);


  text_layer_init(&text_time_layer, window.layer.frame);
  text_layer_set_text_color(&text_time_layer, GColorWhite);
  text_layer_set_background_color(&text_time_layer, GColorClear);
  layer_set_frame(&text_time_layer.layer, GRect(7, 24, 144-7, 168-92));
  text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49)));
  layer_add_child(&time_layer, &text_time_layer.layer);


  layer_init(&line_layer, window.layer.frame);
  line_layer.update_proc = &line_layer_update_callback;
  layer_add_child(&time_layer, &line_layer);

  layer_init(&car_layer, GRect(0, 90, 144, 168-90));
  layer_add_child(&window.layer, &car_layer);

  text_layer_init(&text_rated_layer, window.layer.frame);
  text_layer_set_text_color(&text_rated_layer, GColorWhite);
  text_layer_set_background_color(&text_rated_layer, GColorClear);
  layer_set_frame(&text_rated_layer.layer, GRect(8, 0, 144-8, 168-68));
  text_layer_set_font(&text_rated_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21)));
  layer_add_child(&car_layer, &text_rated_layer.layer);
	
  text_layer_init(&text_state_layer, window.layer.frame);
  text_layer_set_text_color(&text_state_layer, GColorWhite);
  text_layer_set_background_color(&text_state_layer, GColorClear);
  layer_set_frame(&text_state_layer.layer, GRect(8, 20, 144-8, 168-68));
  text_layer_set_font(&text_state_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_CONDENSED_21)));
  layer_add_child(&car_layer, &text_state_layer.layer);
	
  layer_init(&battery_layer, GRect(72, 10, 144-70, 10));
  battery_layer.update_proc = &battery_layer_update_callback;
  layer_add_child(&car_layer, &battery_layer);

  Tuplet initial_values[] = {
    TupletInteger(TESLA_RATED_REMAIN_KEY, (uint16_t) 148),
    TupletCString(TESLA_STATE_STRING_KEY, "Charging"),
	TupletInteger(TESLA_BATTERY_PERCENT_KEY, (uint8_t) 72),
  };
  app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values),
                sync_tuple_changed_callback, sync_error_callback, NULL);
}
Beispiel #7
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Modern Watch");
  window_stack_push(&window, true /* Animated */);
  resource_init_current_app(&APP_RESOURCES);

#if DISPLAY_DATE_ANALOG
  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_DATEBOX, &background_image_container);
#elif INVERTED
  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_INVERTED, &background_image_container);
#else
  bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
#endif
  layer_add_child(&window.layer, &background_image_container.layer.layer);

#if DISPLAY_DATE_ANALOG
  date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ORBITRON_MEDIUM_12));
  text_layer_init(&date_layer, GRect(116, 77, 20, 20));
#else
  date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_DIGITALDREAM_NARROW_12));
  text_layer_init(&date_layer, GRect(27, 110, 90, 30));
#endif
#if DISPLAY_DATE_ANALOG
  text_layer_set_text_color(&date_layer, GColorBlack);
#elif INVERTED
  text_layer_set_text_color(&date_layer, GColorBlack);
#else
  text_layer_set_text_color(&date_layer, GColorWhite);
#endif
  text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter);
  text_layer_set_background_color(&date_layer, GColorClear);
  text_layer_set_font(&date_layer, date_font);
  layer_add_child(&window.layer, &date_layer.layer);

  draw_date();

  layer_init(&hour_display_layer, window.layer.frame);
  hour_display_layer.update_proc = &hour_display_layer_update_callback;
  layer_add_child(&window.layer, &hour_display_layer);

  gpath_init(&hour_hand_path, &HOUR_HAND_PATH_POINTS);
  gpath_move_to(&hour_hand_path, grect_center_point(&hour_display_layer.frame));

  layer_init(&minute_display_layer, window.layer.frame);
  minute_display_layer.update_proc = &minute_display_layer_update_callback;
  layer_add_child(&window.layer, &minute_display_layer);

  gpath_init(&minute_hand_path, &MINUTE_HAND_PATH_POINTS);
  gpath_move_to(&minute_hand_path, grect_center_point(&minute_display_layer.frame));

  layer_init(&center_display_layer, window.layer.frame);
  center_display_layer.update_proc = &center_display_layer_update_callback;
  layer_add_child(&window.layer, &center_display_layer);
#if DISPLAY_SECONDS
  layer_init(&second_display_layer, window.layer.frame);
  second_display_layer.update_proc = &second_display_layer_update_callback;
  layer_add_child(&window.layer, &second_display_layer);
#endif
}
static void handle_init(AppContextRef app_ctx) {
  window_init(&s_data.window, "Simple Analog Watch");

  s_data.day_buffer[0] = '\0';
  s_data.num_buffer[0] = '\0';

  // init hand paths
  gpath_init(&s_data.minute_arrow, &MINUTE_HAND_POINTS);
  gpath_init(&s_data.hour_arrow, &HOUR_HAND_POINTS);

  const GPoint center = grect_center_point(&s_data.window.layer.bounds);
  gpath_move_to(&s_data.minute_arrow, center);
  gpath_move_to(&s_data.hour_arrow, center);

  // init clock face paths
  for (int i = 0; i < NUM_CLOCK_TICKS; ++i) {
    gpath_init(&s_data.tick_paths[i], &ANALOG_BG_POINTS[i]);
  }

  // init layers
  layer_init(&s_data.simple_bg_layer, s_data.window.layer.frame);
  s_data.simple_bg_layer.update_proc = &bg_update_proc;
  layer_add_child(&s_data.window.layer, &s_data.simple_bg_layer);

  // init date layer -> a plain parent layer to create a date update proc
  layer_init(&s_data.date_layer, s_data.window.layer.frame);
  s_data.date_layer.update_proc = &date_update_proc;
  layer_add_child(&s_data.window.layer, &s_data.date_layer);

  // init day
  text_layer_init(&s_data.day_label, GRect(46, 114, 27, 20));
  text_layer_set_text(&s_data.day_label, s_data.day_buffer);
  text_layer_set_background_color(&s_data.day_label, GColorBlack);
  text_layer_set_text_color(&s_data.day_label, GColorWhite);
  GFont norm18 = fonts_get_system_font(FONT_KEY_GOTHIC_18);
  text_layer_set_font(&s_data.day_label, norm18);

  layer_add_child(&s_data.date_layer, &s_data.day_label.layer);

  // init num
  text_layer_init(&s_data.num_label, GRect(73, 114, 18, 20));

  text_layer_set_text(&s_data.num_label, s_data.num_buffer);
  text_layer_set_background_color(&s_data.num_label, GColorBlack);
  text_layer_set_text_color(&s_data.num_label, GColorWhite);
  GFont bold18 = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  text_layer_set_font(&s_data.num_label, bold18);

  layer_add_child(&s_data.date_layer, &s_data.num_label.layer);

  // init hands
  layer_init(&s_data.hands_layer, s_data.simple_bg_layer.frame);
  s_data.hands_layer.update_proc = &hands_update_proc;
  layer_add_child(&s_data.window.layer, &s_data.hands_layer);

  // Push the window onto the stack
  const bool animated = true;
  window_stack_push(&s_data.window, animated);
}
Beispiel #9
0
void handle_init(AppContextRef ctx) {
    (void)ctx;

    window_init(&window, "Brown Watch");
    window_stack_push(&window, true /* Animated */);

    resource_init_current_app(&APP_RESOURCES);
#if DISPLAY_DATE_SHORT
    bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND_BOX, &background_image_container);
#else
    bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image_container);
#endif
    layer_add_child(&window.layer, &background_image_container.layer.layer);


#if DISPLAY_DATE_SHORT || DISPLAY_DATE_LONG
    date_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_OPENSANS_REGULAR_14));
    text_layer_init(&date_layer, GRect(27, 110, 90, 30));
    text_layer_set_text_alignment(&date_layer, GTextAlignmentCenter);
    text_layer_set_text_color(&date_layer, GColorWhite);
    text_layer_set_background_color(&date_layer, GColorClear);
    text_layer_set_font(&date_layer, date_font);
    layer_add_child(&window.layer, &date_layer.layer);
    draw_date();
#endif

    layer_init(&hour_display_layer, window.layer.frame);
    hour_display_layer.update_proc = &hour_display_layer_update_callback;
    layer_add_child(&window.layer, &hour_display_layer);

    gpath_init(&hour_hand_outline_path, &HOUR_HAND_OUTLINE_PATH_POINTS);
    gpath_move_to(&hour_hand_outline_path, grect_center_point(&hour_display_layer.frame));
    gpath_init(&hour_hand_path, &HOUR_HAND_PATH_POINTS);
    gpath_move_to(&hour_hand_path, grect_center_point(&hour_display_layer.frame));

    layer_init(&minute_display_layer, window.layer.frame);
    minute_display_layer.update_proc = &minute_display_layer_update_callback;
    layer_add_child(&window.layer, &minute_display_layer);

    gpath_init(&minute_hand_outline_path, &MINUTE_HAND_OUTLINE_PATH_POINTS);
    gpath_move_to(&minute_hand_outline_path, grect_center_point(&minute_display_layer.frame));
    gpath_init(&minute_hand_path, &MINUTE_HAND_PATH_POINTS);
    gpath_move_to(&minute_hand_path, grect_center_point(&minute_display_layer.frame));

    layer_init(&center_display_layer, window.layer.frame);
    center_display_layer.update_proc = &center_display_layer_update_callback;
    layer_add_child(&window.layer, &center_display_layer);

#if DISPLAY_SECONDS
    layer_init(&second_display_layer, window.layer.frame);
    second_display_layer.update_proc = &second_display_layer_update_callback;
    layer_add_child(&window.layer, &second_display_layer);
#endif
}
void scroll_layer_init(ScrollLayer *scroll_layer, GRect frame) {
    layer_init (&scroll_layer->layer,frame);
    layer_init (&scroll_layer->content_sublayer,(GRect){{0,0},frame.size});
    layer_init (&scroll_layer->shadow_sublayer,(GRect){{0,0},frame.size});
    layer_set_update_proc(&scroll_layer->shadow_sublayer,&scroll_layer_shadow_layer_update_func);
    layer_add_child (&scroll_layer->layer,&scroll_layer->content_sublayer);
    layer_add_child (&scroll_layer->layer,&scroll_layer->shadow_sublayer);
    scroll_layer->callbacks.click_config_provider=0;
    scroll_layer->callbacks.content_offset_changed_handler=0;
    scroll_layer->context=0;
    //no initalization for the animation
}
Beispiel #11
0
void message_layer_init(Window * window) {
	messageLayer.unreadGmails = 0;
	messageLayer.unreadSms = 0;
	messageLayer.missedCalls = 0;
	messageLayer.hangouts = 0;
	//Load font
	messageLayer.messageFont = get_font_15();
	// initialize base layer
	layer_init(&messageLayer.baseLayer, baseLayerBounds);
	layer_add_child(&window->layer, &messageLayer.baseLayer);
	// initalize sms layers
	layer_init(&messageLayer.smsImageLayer, smsImageBounds);
	messageLayer.smsImageLayer.update_proc = load_sms_image;
	layer_add_child(&messageLayer.baseLayer, &messageLayer.smsImageLayer);	
	text_layer_init(&messageLayer.smsTextLayer, smsTextBounds);
	text_layer_set_font(&messageLayer.smsTextLayer, *messageLayer.messageFont);
	text_layer_set_text_alignment(&messageLayer.smsTextLayer, GTextAlignmentCenter);
	text_layer_set_background_color(&messageLayer.smsTextLayer, GColorBlack);
	text_layer_set_text_color(&messageLayer.smsTextLayer, GColorWhite);
	layer_add_child(&messageLayer.baseLayer, &messageLayer.smsTextLayer.layer);
	// initalize gmail layers
	layer_init(&messageLayer.gmailImageLayer, gmailImageBounds);
	messageLayer.gmailImageLayer.update_proc = load_gmail_image;
	layer_add_child(&messageLayer.baseLayer, &messageLayer.gmailImageLayer);	
	text_layer_init(&messageLayer.gmailTextLayer, gmailTextBounds);
	text_layer_set_font(&messageLayer.gmailTextLayer, *messageLayer.messageFont);
	text_layer_set_text_alignment(&messageLayer.gmailTextLayer, GTextAlignmentCenter);
	text_layer_set_background_color(&messageLayer.gmailTextLayer, GColorBlack);
	text_layer_set_text_color(&messageLayer.gmailTextLayer, GColorWhite);
	layer_add_child(&messageLayer.baseLayer, &messageLayer.gmailTextLayer.layer);
	// initalize missed calls layers
	layer_init(&messageLayer.missedCallImageLayer, missedCallImageBounds);
	messageLayer.missedCallImageLayer.update_proc = load_phone_image;
	layer_add_child(&messageLayer.baseLayer, &messageLayer.missedCallImageLayer);	
	text_layer_init(&messageLayer.missedCallTextLayer, missedCallTextBounds);
	text_layer_set_font(&messageLayer.missedCallTextLayer, *messageLayer.messageFont);
	text_layer_set_text_alignment(&messageLayer.missedCallTextLayer, GTextAlignmentCenter);
	text_layer_set_background_color(&messageLayer.missedCallTextLayer, GColorBlack);
	text_layer_set_text_color(&messageLayer.missedCallTextLayer, GColorWhite);
	layer_add_child(&messageLayer.baseLayer, &messageLayer.missedCallTextLayer.layer);
	// initalize hangout layers
	layer_init(&messageLayer.hangoutImageLayer, hangoutImageBounds);
	messageLayer.hangoutImageLayer.update_proc = load_hangout_image;
	layer_add_child(&messageLayer.baseLayer, &messageLayer.hangoutImageLayer);	
	text_layer_init(&messageLayer.hangoutTextLayer, hangoutTextBounds);
	text_layer_set_font(&messageLayer.hangoutTextLayer, *messageLayer.messageFont);
	text_layer_set_text_alignment(&messageLayer.hangoutTextLayer, GTextAlignmentCenter);
	text_layer_set_background_color(&messageLayer.hangoutTextLayer, GColorBlack);
	text_layer_set_text_color(&messageLayer.hangoutTextLayer, GColorWhite);
	layer_add_child(&messageLayer.baseLayer, &messageLayer.hangoutTextLayer.layer);

}
Beispiel #12
0
void handle_init(AppContextRef ctx) {
  srand(time(NULL));//seed randmoness!
  window_init(&window, "Window Name");
  window_stack_push(&window, true /* Animated */);
  text_layer_init(&dateLayer, GRect(0, 0, 144, 50));
  text_layer_set_text_alignment(&dateLayer, GTextAlignmentCenter);
  text_layer_set_font(&dateLayer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
  text_layer_set_background_color(&dateLayer, GColorBlack);
  text_layer_set_text_color(&dateLayer, GColorWhite);
  text_layer_set_overflow_mode(&dateLayer, GTextOverflowModeWordWrap);
  layer_add_child(&window.layer, &dateLayer.layer);

  text_layer_init(&busLayer, GRect(0, 93, 144, 75));
  text_layer_set_text_alignment(&busLayer, GTextAlignmentCenter);
  text_layer_set_font(&busLayer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
  text_layer_set_background_color(&busLayer, GColorBlack);
  text_layer_set_text_color(&busLayer, GColorWhite);
  text_layer_set_overflow_mode(&busLayer, GTextOverflowModeWordWrap);
  layer_add_child(&window.layer, &busLayer.layer);

// Init the layer for the display
  layer_init(&display_layer, window.layer.frame);
  display_layer.update_proc = &display_layer_update_callback;
  layer_add_child(&window.layer, &display_layer);

  adjX = ((int) ( (144-((bitRect.size.w+BIT_SPACING)*ROW_WIDTH))/2)) -2;//change the -2 if needed
  adjY = ((int) ( ((168-YSTART)-((bitRect.size.h+BIT_SPACING)*COL_HEIGHT)  )/2)) - YSHORT/2;

  handle_minute_tick(ctx, NULL);
}
Beispiel #13
0
void handle_init(AppContextRef ctx) {
	Layer *rootLayer;
	int i;
	
	window_init(&window, "Minimalist");
	window_stack_push(&window, true /* Animated */);
	window_set_background_color(&window, GColorBlack);
	
	clock12 = !clock_is_24h_style();
	
	resource_init_current_app(&APP_RESOURCES);
	
	for (i=0; i<NUM_IMAGES; i++) {
		heap_bitmap_init(&digitBmp[i], digitId[i]);
#if WHITE_BACKGROUND
		bmpNegative(&digitBmp[i].bmp);
#endif
	}
	
	rootLayer = window_get_root_layer(&window);
	layer_init(&layer, GRect(0,0,SCREENW,SCREENH));
	layer_set_update_proc(&layer, &update_display);
	layer_add_child(rootLayer, &layer);
	
	handle_tick(ctx, NULL);
	//layer_mark_dirty(&layer);
}
Beispiel #14
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  	window_init(&s_window, "barwatch");
	window_stack_push(&s_window, true /* Animated */);
	
	layer_init(&bar_layer, GRect(0,0, s_window.layer.frame.size.w, s_window.layer.frame.size.h));
 	bar_layer.update_proc = draw_bar_layer;
	layer_add_child(&s_window.layer, &bar_layer);
	
	/* Initialize inverter layer 
	 * add one to x and y and subtract bar height by 2 so that the
	 * inverter layer fits inside the rectangle and doesn't invert the rectangle */
	inverter_layer_init(&days_in_year_inverter_layer, GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 0), 0, BAR_HEIGHT - 2));
	inverter_layer_init(&days_in_month_inverter_layer,GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 0), 0, BAR_HEIGHT - 2));
	inverter_layer_init(&days_in_week_inverter_layer, GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 1), 0, BAR_HEIGHT - 2));
	inverter_layer_init(&hours_inverter_layer,        GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 1), 0, BAR_HEIGHT - 2));
	inverter_layer_init(&minutes_inverter_layer,      GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 2), 0, BAR_HEIGHT - 2));
	inverter_layer_init(&seconds_inverter_layer,      GRect(BAR_OFFSET + 1, FIRST_BAR_Y + 1 + ((BAR_HEIGHT + BAR_MARGIN) * 2), 0, BAR_HEIGHT - 2));
	
	layer_add_child(&s_window.layer, &days_in_year_inverter_layer.layer);
	layer_add_child(&s_window.layer, &days_in_month_inverter_layer.layer);
  	layer_add_child(&s_window.layer, &days_in_week_inverter_layer.layer);
	layer_add_child(&s_window.layer, &hours_inverter_layer.layer);
	layer_add_child(&s_window.layer, &minutes_inverter_layer.layer);
	layer_add_child(&s_window.layer, &seconds_inverter_layer.layer);
	
	draw_once = true;
}
void displayHelp() {
    static Window window;
    static Layer chromeLayer;
    static TextLayer helpTextLayer;


    window_init(&window, "Help");
    window_set_fullscreen(&window, true);

    window.layer.frame.origin.x = 5;
    window.layer.frame.origin.y = 5;

    // TODO: Should have get/set bounds functions public?
    window.layer.bounds.size.w -= 10;
    window.layer.bounds.size.h -= 10;

    window_set_background_color(&window, GColorClear);

    // TODO: Set proper/better frame/bounds values here?
    layer_init(&chromeLayer, window.layer.frame);
    chromeLayer.update_proc = &help_window_update_callback;
    layer_add_child(&window.layer, &chromeLayer);


    text_layer_init(&helpTextLayer, GRect(16, 16, 144-24-8 /* width */, 168-24-8 /* height */));
    text_layer_set_text_color(&helpTextLayer, GColorWhite);
    text_layer_set_background_color(&helpTextLayer, GColorBlack);
    text_layer_set_font(&helpTextLayer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
    text_layer_set_text(&helpTextLayer, ">Select (long press)<\nChange edit mode.\n\n>Up/Down<\nIncrease/decrease axis value\n\n(Press back to close)");

    layer_add_child(&window.layer, &helpTextLayer.layer);

    window_stack_push(&window, false /* Not animated */);
}
Beispiel #16
0
void handle_init(AppContextRef ctx) {
    memset(&background_image, 0, sizeof(background_image));
    memset(&day_name_image, 0, sizeof(day_name_image));
    memset(&date_digits_images, 0, sizeof(date_digits_images));
    memset(&time_digits_images, 0, sizeof(time_digits_images));
    memset(&digits, 0, sizeof(digits));
    memset(&display_layer, 0, sizeof(display_layer));
    
    
    window_init(&window, "LCAR");
    window_stack_push(&window, true /* Animated */);
    
    resource_init_current_app(&APP_RESOURCES);
    
    bmp_init_container(RESOURCE_ID_IMAGE_BACKGROUND, &background_image);
    layer_init(&display_layer, GRect(43, 110, 82, 35));
    display_layer.update_proc = &display_layer_update_callback;
    
    layer_add_child(&window.layer, &background_image.layer.layer);
    
    
    layer_add_child(&window.layer, &background_image.layer.layer);
    layer_add_child(&window.layer,&display_layer);
    
 
    
    
    // Avoids a blank screen on watch start.
    PblTm tick_time;
    
    get_time(&tick_time);
    update_display(&tick_time);
    
}
void initLayerPathAndCenter(Layer *layer, GPath *path, const GPathInfo *pathInfo, const void *updateProc) {
	layer_init(layer, GRect(0, 0, 70, 70));
	layer->update_proc = updateProc;
	layer_add_child(&window.layer, layer);
	gpath_init(path, pathInfo);
	gpath_move_to(path, grect_center_point(&layer->frame));
}
Beispiel #18
0
void handle_init(AppContextRef ctx) {

  window_init(&window, "Simplicity");
  window_stack_push(&window, true /* Animated */);
  window_set_background_color(&window, GColorBlack);

  resource_init_current_app(&APP_RESOURCES);


  text_layer_init(&text_date_layer, window.layer.frame);
  text_layer_set_text_color(&text_date_layer, GColorWhite);
  text_layer_set_background_color(&text_date_layer, GColorClear);
  layer_set_frame(&text_date_layer.layer, GRect(8, 28, 144-8, 40));
  text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TEST_21)));
  layer_add_child(&window.layer, &text_date_layer.layer);


  text_layer_init(&text_time_layer, window.layer.frame);
  text_layer_set_text_color(&text_time_layer, GColorWhite);
  text_layer_set_background_color(&text_time_layer, GColorClear);
  layer_set_frame(&text_time_layer.layer, GRect(1, 62, 144-2, 168-62));
  text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_TEST_48)));
  layer_add_child(&window.layer, &text_time_layer.layer);


  layer_init(&line_layer, window.layer.frame);
  line_layer.update_proc = &line_layer_update_callback;
  layer_add_child(&window.layer, &line_layer);


  // TODO: Update display here to avoid blank display on launch?
}
void handle_init_app(AppContextRef app_ctx) {
  window_init(&window, "Less Simple");
  window_stack_push(&window, true);
  window_set_background_color(&window, GColorBlack);

  text_layer_init(&date_layer, GRect(PADDING*1.5, PADDING + DATE_TOP_PADDING, SCREEN_WIDTH-PADDING, LINE_HEIGHT));
  text_layer_set_text_color(&date_layer, GColorWhite);
  text_layer_set_background_color(&date_layer, GColorClear);
  text_layer_set_font(&date_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28));
  layer_add_child(&window.layer, &date_layer.layer);

  text_layer_init(&time_layer, GRect(0, PADDING + LINE_HEIGHT*1, SCREEN_WIDTH, LINE_HEIGHT));
  text_layer_set_text_color(&time_layer, GColorWhite);
  text_layer_set_text_alignment(&time_layer, GTextAlignmentCenter);
  text_layer_set_background_color(&time_layer, GColorClear);
  text_layer_set_font(&time_layer, fonts_get_system_font(FONT_KEY_GOTHAM_42_MEDIUM_NUMBERS));
  layer_add_child(&window.layer, &time_layer.layer);

  text_layer_init(&second_layer, GRect(0, LINE_HEIGHT*2, SCREEN_WIDTH, LINE_HEIGHT));
  text_layer_set_text_color(&second_layer, GColorWhite);
  text_layer_set_text_alignment(&second_layer, GTextAlignmentCenter);
  text_layer_set_background_color(&second_layer, GColorClear);
  text_layer_set_font(&second_layer, fonts_get_system_font(FONT_KEY_GOTHAM_42_LIGHT));
  layer_add_child(&window.layer, &second_layer.layer);

  // Ensures time is displayed immediately (will break if NULL tick event accessed).
  // (This is why it's a good idea to have a separate routine to do the update itself.)
  handle_second_tick(app_ctx, NULL);

  layer_init(&lineLayer, window.layer.frame);
  lineLayer.update_proc = &line_layer_update_callback;
  layer_add_child(&window.layer, &lineLayer);
}
Beispiel #20
0
void digitslot_layer_init(DigitSlot* slot, GRect rect, int divider, int startDigit) {
    slot->normTime = ANIMATION_NORMALIZED_MAX;
    slot->prevDigit = 0;
    slot->curDigit = startDigit;
    slot->divider = divider;
    layer_init(&slot->layer, rect);
    slot->layer.update_proc = (LayerUpdateProc)digitslot_layer_update;
}
Beispiel #21
0
void handle_init(AppContextRef ctx) {

  window_init(&window, "Window Name");
  window_stack_push(&window, true /* Animated */);

  resource_init_current_app(&APP_RESOURCES);
  bmp_init_container(RESOURCE_ID_CLOCKFACE, &clockface);

  layer_init(&clockface_layer, window.layer.frame);
  layer_init(&hands_layer, window.layer.frame);

  clockface_layer.update_proc = &clockface_layer_update_proc;
  hands_layer.update_proc = &hands_layer_update_proc;

  layer_add_child(&window.layer, &clockface_layer);
  layer_add_child(&window.layer, &hands_layer);
}
Beispiel #22
0
void bitmap_layer_init(BitmapLayer *image, GRect frame) {
    layer_init ((Layer*)image,frame);
    layer_set_update_proc((Layer*)image,bitmap_layer_update_func);
    image->bitmap=0;
    image->background_color=GColorClear;
    image->alignment=GAlignCenter;
    image->compositing_mode=GCompOpAssign;
}
Beispiel #23
0
void rotbmp_pair_layer_init (RotBmpPairLayer* layer,GRect frame) {
    layer_init((Layer*)layer,frame);
    rotbmp_layer_init (&layer->white_layer,frame); //the white and black layers are not added as childs
    rotbmp_layer_init (&layer->black_layer,frame);
    layer->white_layer.compositing_mode=GCompOpOr;
    layer->black_layer.compositing_mode=GCompOpClear;
    layer_set_update_proc ((Layer*)layer,rotbmp_pair_layer_update_func);
}
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "VerySimple");
  window_stack_push(&window, true /* Animated */);
  window_set_background_color(&window, GColorBlack);

  resource_init_current_app(&APP_RESOURCES);


  text_layer_init(&text_date_layer, window.layer.frame);
  text_layer_set_text_color(&text_date_layer, GColorWhite);
  text_layer_set_background_color(&text_date_layer, GColorClear);
  layer_set_frame(&text_date_layer.layer, GRect(8, 68, 144-8, 168-68));

  text_layer_set_font(&text_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROB_CONDENSED_21)));
  layer_add_child(&window.layer, &text_date_layer.layer);


  text_layer_init(&text_time_layer, window.layer.frame);
  text_layer_set_text_color(&text_time_layer, GColorWhite);
  text_layer_set_background_color(&text_time_layer, GColorClear);
  layer_set_frame(&text_time_layer.layer, GRect(7, 92, 144-7, 168-92));
  text_layer_set_font(&text_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_BOLD_SUBSET_49)));
  layer_add_child(&window.layer, &text_time_layer.layer);

	
  layer_init(&line_layer, window.layer.frame);
  line_layer.update_proc = &line_layer_update_callback;
  layer_add_child(&window.layer, &line_layer);
	
    initLayerPathAndCenter(&hour_display_layer, &hour_hand_path, &HOUR_HAND_POINTS, &hour_display_layer_update_callback);
	initLayerPathAndCenter(&minute_display_layer, &minute_hand_path, &MINUTE_HAND_POINTS, &minute_display_layer_update_callback);
	
   dow_layer.update_proc = &dow_update_proc;
   layer_add_child(&window.layer, &dow_layer);

	hour_display_layer.frame.origin.x = (144/2) - (hour_display_layer.frame.size.w/2) ;
	minute_display_layer.frame.origin.x = (144/2) - (minute_display_layer.frame.size.w/2) ;
  layer_init(&center_display_layer, GRect(0, 0, 144, 70));

//		 center_display_layer.frame.origin.x = (144/2) - (center_display_layer.frame.size.w/2) ;
  center_display_layer.update_proc = &center_display_layer_update_callback;
  layer_add_child(&window.layer, &center_display_layer);
}
Beispiel #25
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

  window_init(&window, "Chess");
  window_stack_push(&window, true /* Animated */);
  window_set_background_color(&window, GColorWhite);

  resource_init_current_app(&APP_RESOURCES);

  bmp_init_container(RESOURCE_ID_IMAGE_BOARD, &img_board_container);
  bmp_init_container(RESOURCE_ID_IMAGE_SELECT, &img_select);
  bmp_init_container(RESOURCE_ID_IMAGE_B_PAWN, &img_b_pawn);
  bmp_init_container(RESOURCE_ID_IMAGE_B_BISHOP, &img_b_bishop);
  bmp_init_container(RESOURCE_ID_IMAGE_B_KNIGHT, &img_b_knight);
  bmp_init_container(RESOURCE_ID_IMAGE_B_QUEEN, &img_b_queen);
  bmp_init_container(RESOURCE_ID_IMAGE_B_KING, &img_b_king);
  bmp_init_container(RESOURCE_ID_IMAGE_B_ROOK, &img_b_rook);
  bmp_init_container(RESOURCE_ID_IMAGE_W_PAWN, &img_w_pawn);
  bmp_init_container(RESOURCE_ID_IMAGE_W_BISHOP, &img_w_bishop);
  bmp_init_container(RESOURCE_ID_IMAGE_W_KNIGHT, &img_w_knight);
  bmp_init_container(RESOURCE_ID_IMAGE_W_QUEEN, &img_w_queen);
  bmp_init_container(RESOURCE_ID_IMAGE_W_KING, &img_w_king);
  bmp_init_container(RESOURCE_ID_IMAGE_W_ROOK, &img_w_rook);
  
  layer_add_child(&window.layer, &img_board_container.layer.layer);

  layer_init(&input_layer, GRect(0,0, 144, 168));
  input_layer.update_proc = input_layer_update_callback;
  layer_add_child(&img_board_container.layer.layer, &input_layer);

  layer_init(&board_layer, GRect(0,0, 144, 168));
  board_layer.update_proc = board_layer_update_callback;
  layer_add_child(&input_layer, &board_layer);

  text_layer_init(&strBoardLayer, GRect(0, 0, 144/* width */, 11/* height */));
  text_layer_set_text_color(&strBoardLayer, GColorWhite);
  text_layer_set_background_color(&strBoardLayer, GColorBlack);
  //text_layer_set_font(&strBoardLayer, fonts_get_system_font(FONT_KEY_GOTHIC_14_BOLD));
  layer_add_child(&img_board_container.layer.layer, &strBoardLayer.layer);
  // Attach our desired button functionality
  window_set_click_config_provider(&window, (ClickConfigProvider) click_config_provider);

  board = chess_init();
  print_board();
}
void handle_init(AppContextRef ctx) {
    (void)ctx;

    window_init(&window, "Watchface");
    window_stack_push(&window, true /* Animated */);
    window_set_background_color(&window, GColorBlack);
        
    PblTm t;
    get_time(&t);
    setPhase(daysSinceNewMoon(t.tm_year+1900,t.tm_yday,t.tm_hour));
    
    curHour=t.tm_hour;
    curMin=t.tm_min;
    curSec=t.tm_sec;
    
    if(showDetailedMoonGraphic){
        
        resource_init_current_app(&LUNARCLOCK_IMAGE_RESOURCES);
        bmp_init_container(RESOURCE_ID_IMAGE_MOON, &moonimage_container);
        layer_add_child(&window.layer, &moonimage_container.layer.layer);
    }else{
        layer_init(&moon_layer, window.layer.frame);
        moon_layer.update_proc = &moon_layer_update_callback;
        layer_add_child(&window.layer, &moon_layer);
    }
    layer_init(&shadow_layer, window.layer.frame);
    shadow_layer.update_proc = &shadow_layer_update_callback;
    layer_add_child(&window.layer, &shadow_layer);
    
    layer_init(&phase_layer, window.layer.frame);
    phase_layer.update_proc = &phase_layer_update_callback;
    layer_add_child(&window.layer, &phase_layer);
    
    if(showHours){
        layer_init(&hour_layer, window.layer.frame);
        hour_layer.update_proc = &hour_layer_update_callback;
        layer_add_child(&window.layer, &hour_layer);
        
        gpath_init(&hour_hand, &hour_hand_info);
        gpath_move_to(&hour_hand, GPoint(centerx, centery));
        
    }
    if(showMinutes){
        layer_init(&minute_layer, window.layer.frame);
        minute_layer.update_proc = &minute_layer_update_callback;
        layer_add_child(&window.layer, &minute_layer);
        
        gpath_init(&minute_hand, &minute_hand_info);
        gpath_move_to(&minute_hand, GPoint(centerx, centery));
    }
    if(showSeconds){
        layer_init(&second_layer, window.layer.frame);
        second_layer.update_proc = &second_layer_update_callback;
        layer_add_child(&window.layer, &second_layer);
    }
    layer_init(&top_layer, window.layer.frame);
    top_layer.update_proc = &top_layer_update_callback;
    layer_add_child(&window.layer, &top_layer);
}
Beispiel #27
0
void weather_layer_init(WeatherLayer* weather_layer, GPoint pos) {
	layer_init(&weather_layer->layer, GRect(pos.x, pos.y, 144, 68));
	// Add temperature layer
	text_layer_init(&weather_layer->temp_layer, GRect(70, 9, 64, 68));
	text_layer_set_text_alignment(&weather_layer->temp_layer, GTextAlignmentRight);
	text_layer_set_font(&weather_layer->temp_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FUTURA_40)));
	layer_add_child(&weather_layer->layer, &weather_layer->temp_layer.layer);
	// Note absence of icon layer
	weather_layer->has_weather_icon = false;
}
Beispiel #28
0
void rotbmp_layer_init (RotBitmapLayer* layer,GRect frame) {
    layer_init ((Layer*)layer,frame);
    layer->bitmap=0;
    layer->corner_clip_color=GColorClear; //What is this?!
    layer->rotation=0;
    layer->src_ic=GPoint(0,0);
    layer->dest_ic=GPoint(0,0);
    layer->compositing_mode=GCompOpAssign;
    layer_set_update_proc((Layer*)layer,rotbmp_layer_update_func);
}
Beispiel #29
0
static void handle_init( AppContextRef ctx )
{
    ( void ) ctx;
    
    GPATH_INIT( &hour_path, hour_points );
    gpath_move_to( &hour_path, GPoint( W / 2, H / 2 ) );
    
    GPATH_INIT( &minute_path, minute_points );
    gpath_move_to( &minute_path, GPoint( W / 2, H / 2 ) );
    
    GPATH_INIT( &second_path, second_points );
    gpath_move_to( &second_path, GPoint( W / 2, H / 2 ) );
    
    GPATH_INIT( &major_tick_path, major_tick_points );
    gpath_move_to( &major_tick_path, GPoint( W / 2, H / 2 ) );
    
    GPATH_INIT( &hour_tick_path, hour_tick_points );
    gpath_move_to( &hour_tick_path, GPoint( W / 2, H / 2 ) );
    
    GPATH_INIT( &minor_tick_path, minor_tick_points );
    gpath_move_to( &minor_tick_path, GPoint( W / 2, H / 2 ) );
    
    get_time( &now );
    
    window_init( &window, "Main" );
    window_stack_push( &window, true );
    window_set_background_color( &window, GColorBlack );
    
    resource_init_current_app( &RESOURCES );
    
    font_time = fonts_load_custom_font(resource_get_handle( RESOURCE_ID_FONT_GILLSANS_40 ) );
    font_date = fonts_load_custom_font(resource_get_handle( RESOURCE_ID_FONT_GILLSANS_20 ) );

    layer_init( &bg_layer, GRect( 0, 0, W, H ) );
    layer_add_child( &window.layer, &bg_layer );
    bg_layer.update_proc = bg_layer_update;
    layer_mark_dirty( &bg_layer );
    
    layer_init( &hand_layer, GRect( 0, 0, W, H ) );
    layer_add_child( &window.layer, &hand_layer );
    hand_layer.update_proc = hand_layer_update;
    layer_mark_dirty( &hand_layer );
}
Beispiel #30
0
/* initialize blue and opengl stuff */
void blue_gl_init(INITFUNC_ARGS){
    /* Blue type initialization */
    window_type = window_init(lib, Module);
    view_type   = view_init(lib, Module);
    layer_type  = layer_init(lib, Module);
    shape_type  = shape_init(lib, Module);
    image_type  = image_init(lib, Module);
    light_type  = light_init(lib, Module);
    text_type  = text_init(lib, Module);
}