示例#1
0
// Initialization
static void init() {
  s_main_window = window_create();
  s_set_window = window_create();
  
// Remove the statusbar on SDK 2
#ifdef PBL_SDK_2
  window_set_fullscreen(s_main_window, true);
  window_set_fullscreen(s_set_window, true);
#endif
  
  // Read the persistent storage. Probably incorrectly
  valueRead = persist_read_data(SETTINGS_KEY, &settings, sizeof(settings));
  
  // Read the persistent storage better, meaning after that read fails, just go ahead and fix it
  if (settings.c_1 == 0) {
    settings.c_1 = 5;
    settings.c_2 = 5;
    settings.c_3 = 5;
    settings.c_4 = 5;
    settings.set = false;
  }
  
  window_set_background_color(s_main_window, GColorBlack);
  window_set_background_color(s_set_window, GColorBlack);
  window_set_window_handlers(s_main_window, (WindowHandlers) {
    .load = main_window_load,
    .unload = main_window_unload,
  });
static void init(void) {
	// Set initial value to track timer start/stop
	running = false;
	// Set variables to use for animated windows
	const bool animated = true;

	// Set up the base window
  window = window_create();
  Layer *window_layer = window_get_root_layer(window);
	window_set_background_color(window, GColorWhite);
  window_set_fullscreen(window, false);
	window_stack_push(window, animated);
	page = 1; // set to 1 for initial paging on menus

	// Bind input for base window
	window_set_click_config_provider(window, (ClickConfigProvider) click_config_provider);

	// Set up layers for base window
	timer_font = fonts_get_system_font(FONT_KEY_DROID_SERIF_28_BOLD);
	timer_layer = text_layer_create(GRect(0, 80, 144, 84));
	text_layer_set_background_color(timer_layer, GColorBlack);
  text_layer_set_font(timer_layer, timer_font);
	text_layer_set_text_color(timer_layer, GColorWhite);
	text_layer_set_text(timer_layer, "00h 00m");
	text_layer_set_text_alignment(timer_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(timer_layer));

	project_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
	project_layer = text_layer_create(GRect(0, 0, 144, 40));
	text_layer_set_background_color(project_layer, GColorWhite);
  text_layer_set_font(project_layer, project_font);
	text_layer_set_text_color(project_layer, GColorBlack);
	text_layer_set_text(project_layer, "No Project Selected");
	text_layer_set_text_alignment(project_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(project_layer));

	task_font = fonts_get_system_font(FONT_KEY_GOTHIC_18);
	task_layer = text_layer_create(GRect(0, 40, 144, 40));
	text_layer_set_background_color(task_layer, GColorWhite);
  text_layer_set_font(task_layer, task_font);
	text_layer_set_text_color(task_layer, GColorBlack);
	text_layer_set_text(task_layer, "No Task Selected");
	text_layer_set_text_alignment(task_layer, GTextAlignmentCenter);
  layer_add_child(window_layer, text_layer_get_layer(task_layer));


	// Set up menu window, but don't push to stack yet
	menu_window = window_create();
	window_set_background_color(menu_window, GColorWhite);
  window_set_fullscreen(menu_window, true);
	// Window Handlers
	window_set_window_handlers(menu_window, (WindowHandlers) {
		.load = menu_window_load,
		.unload = menu_window_unload,
	});
// Initialise UI
static void init(void)
{
	srand(time(NULL));
	inverter_timer 	= app_timer_register(INVERTER_TIMEOUT, inverter_timer_callback, 0);
	time_timer 			= app_timer_register(TIME_TIMEOUT, update_time, 0);
	
  window 					= window_create();
	
	window_set_fullscreen(window, true);
  window_stack_push(window, false);
	
	// Assign resources
  s_res_tv_image 				= gbitmap_create_with_resource(RESOURCE_ID_TV_IMAGE);
  s_res_static_1_image 	= gbitmap_create_with_resource(RESOURCE_ID_STATIC_2_IMAGE);
	s_res_bitham_42_bold 	= fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD);
	s_res_gothic_14 			= fonts_get_system_font(FONT_KEY_GOTHIC_14);
		
	// tv_bitmap
	tv_bitmap = bitmap_layer_create(GRect(0,0,144,168));
	bitmap_layer_set_bitmap(tv_bitmap, s_res_tv_image);
	bitmap_layer_set_background_color(tv_bitmap, GColorClear);
	bitmap_layer_set_compositing_mode(tv_bitmap, GCompOpAssign);
	layer_add_child(window_get_root_layer(window), (Layer *) tv_bitmap);
	
  // static_1_bitmap
  static_1_bitmap = bitmap_layer_create(GRect(14, 42, 115, 87));
  bitmap_layer_set_bitmap(static_1_bitmap, s_res_static_1_image);
	bitmap_layer_set_compositing_mode(static_1_bitmap, GCompOpOr);
  layer_add_child(window_get_root_layer(window), (Layer *)static_1_bitmap);
  
  // inverter_layer
  static_inverter_layer = inverter_layer_create(GRect(14, 42, 115, 0));
  layer_add_child(window_get_root_layer(window), (Layer *)static_inverter_layer);
	layer_set_hidden(inverter_layer_get_layer(static_inverter_layer), false);
	
	// Screen On layer
  screen_on_layer = text_layer_create(GRect(14, 42, 115, 87));
  text_layer_set_background_color(screen_on_layer, GColorWhite);
  layer_set_hidden(text_layer_get_layer(screen_on_layer), true);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(screen_on_layer));
	
	// ch_layer
	ch_layer = text_layer_create(GRect(102, 46, 24, 14));
	text_layer_set_background_color(ch_layer, GColorClear);
	text_layer_set_text(ch_layer, "Ch 3");
	text_layer_set_font(ch_layer, s_res_gothic_14);
	layer_add_child(window_get_root_layer(window), text_layer_get_layer(ch_layer));
	
  // time_layer
	clock_copy_time_string(buffer, 12);
  time_layer = text_layer_create(GRect(0, 56, 144, 42));
  text_layer_set_background_color(time_layer, GColorClear);
  text_layer_set_text(time_layer, buffer);
  text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);
  text_layer_set_font(time_layer, s_res_bitham_42_bold);
	layer_set_hidden(text_layer_get_layer(time_layer), true);
  layer_add_child(window_get_root_layer(window), (Layer *)time_layer);
	
	accel_tap_service_subscribe(tap_handler); // Subcribe to the tap event service
}
示例#4
0
static void init(void) {
  window = window_create();
  window_set_fullscreen(window, true);
  window_set_window_handlers(window, (WindowHandlers) {
      .load = window_load,
      .unload = window_unload,
      });
示例#5
0
int main(void)
{
    window = window_create();  /* Инициализируем окно */
    window_set_background_color(window, GColorBlack); /* устанавливаем фоновый цвет */
    window_set_fullscreen(window, true); /* включаем полноэкранность */
    window_stack_push(window, true);  /* открываем окно с анимацией */
    srand(time(NULL)); /* инициализируем генератор случайных чисел текущем временем */
    text_layer = text_layer_create(GRect(0 , 30, 144, 168)); /* создаем текстовый массив, указываем размер и координаты */
    text_layer_set_text_color(text_layer, GColorWhite);  /* устанавливаем цвет текста */
    text_layer_set_background_color(text_layer, GColorClear);  /* устанавливаем цвет фона */
    text_layer_set_font(text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28)); /* устанавливаем шрифт */
    text_layer_set_text_alignment(text_layer, GTextAlignmentCenter); /* устанавливаем выравнивание по центру */
    layer_add_child(window_get_root_layer(window), text_layer_get_layer(text_layer));  /* подключаем текстовый слой к основному в качестве дочернего */
#if (LANG == ENG)
    text_layer_set_text(text_layer, "Shake to roll \n the dice!");  /* показываем сообщение при запуске */
#endif
#if (LANG == RUS)
    text_layer_set_text(text_layer, "Встряхните часы для броска костей");  /* показываем сообщение при запуске */
#endif
    accel_tap_service_subscribe(accel_int);  /* подписываемся на прерывания от акселерометра */
    app_event_loop();  /* ждем событий */
    if (first_time == true) /* если выходим без запуска перебора... */
    { 
        text_layer_destroy(text_layer); /* ...то удаляем текстовый слой с сообщением */
    }
    else  /* если выходим уже после запуска... */
    {    
        bitmap_layer_destroy(image_layer); /* ...то уничтожаем текстовый слой... */
        gbitmap_destroy(image); /* ... и уничтожаем массив с графикой, текстовый слой уже удален в функции accel_int */
    }
    accel_tap_service_unsubscribe();  /* отписываемся от прерываний акселерометра */
    window_destroy(window);  /* уничтожаем главное окно, освобождаем ресурсы */
}
示例#6
0
/* Initialize the main app elements */
void carga_paradas(int n1, int fav, int buscar)
{
  i_buscar = 0;
  numero1= n1/100;
  numero2= (n1 % 100) /10;
  numero3=n1 % 10;
	window = window_create();
	WindowHandlers handlers = {
		.load = window_load,
		.unload = window_unload
	};
  #ifdef PBL_SDK_2
    window_set_fullscreen(window, true);
  #endif
	//app_message_register_inbox_received(in_received_handler);					 
	window_set_window_handlers(window, (WindowHandlers) handlers);
  if (fav==1)
    posicion=2;
  if (buscar==1)
    i_buscar = 1;
  valores_parada[0].tiempo1 = 0;
	window_stack_push(window, true);


}
示例#7
0
// Handle the start-up of the app
void tic_tock_toe_init(void) {

  // Create our app's base window
  window = window_create();
  window_set_fullscreen(window, true);
  window_stack_push(window, true);

  window_set_background_color(window, COLOR_BACKGROUND);

  // Init the layer that shows the board
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  boardLayer = layer_create(bounds); // Associate with layer object and set dimensions
  layer_set_update_proc(boardLayer, 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
  playersLayer = layer_create(bounds);
  layer_set_update_proc(playersLayer, playersLayer_update_callback);
  layer_add_child(window_layer, playersLayer);

  // Init the text layer used to show the time
  timeLayer = text_layer_create(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));
  layer_add_child(window_layer, text_layer_get_layer(timeLayer));

  tick_timer_service_subscribe(SECOND_UNIT, handle_second_tick);

  update_time_text();
}
示例#8
0
文件: bad.c 项目: mcr/grump
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorClear);
  #ifndef PBL_SDK_3
    window_set_fullscreen(s_window, true);
  #endif
    
  s_time_text = malloc(MAX_CHARS);
  s_time_text[0] = 'A';
  s_time_text[1] = 'B';
  s_time_text[2] = '\0';
  
  s_res_grumpy = gbitmap_create_with_resource(RESOURCE_ID_GRUMPY);
  s_font = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  // s_bitmaplayer_1
  s_bitmaplayer_1 = bitmap_layer_create(GRect(0, 0, 144, 144));
  bitmap_layer_set_bitmap(s_bitmaplayer_1, s_res_grumpy);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmaplayer_1);
  
  // s_textlayer_1
  s_textlayer_1 = text_layer_create(GRect(21, 146, 144, 34));
  text_layer_set_background_color(s_textlayer_1, GColorWhite);
  text_layer_set_text_color(s_textlayer_1, GColorBlack);
  text_layer_set_text(s_textlayer_1, s_time_text);
  text_layer_set_text_alignment(s_textlayer_1, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_1, s_font);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_1);
}
示例#9
0
static void init() {
  window = window_create();
  window_set_background_color(window, GColorBlack);
  window_set_fullscreen(window, true);

  icon_layer = bitmap_layer_create(GRect(32, 10, 80, 80));
  bitmap_layer_set_bitmap(icon_layer, icon_bitmap);
  layer_add_child(window_get_root_layer(window), bitmap_layer_get_layer(icon_layer));

  temperature_layer = text_layer_create(GRect(0, 100, 144, 68));
  text_layer_set_text_color(temperature_layer, GColorWhite);
  text_layer_set_background_color(temperature_layer, GColorClear);
  text_layer_set_font(temperature_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_text_alignment(temperature_layer, GTextAlignmentCenter);
  text_layer_set_text(temperature_layer, temperature);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(temperature_layer));

  Tuplet initial_values[] = {
    TupletInteger(WEATHER_ICON_KEY, (uint8_t) 1),
    TupletCString(WEATHER_TEMPERATURE_KEY, "1234\u00B0C"),
  };

  app_message_open(64, 64);
  send_cmd();

  app_sync_init(&sync, sync_buffer, sizeof(sync_buffer), initial_values, ARRAY_LENGTH(initial_values),
      sync_tuple_changed_callback, sync_error_callback, NULL);


  window_stack_push(window, true /* Animated */);
}
示例#10
0
void InitializeWindow(Window *window, const char *name, bool animated)
{
	window_init(window, name);
	window_stack_push(window, animated);
	window_set_fullscreen(window, true); // Do I want full screen?
	window_set_background_color(window, GColorBlack);		
}
示例#11
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  window_set_fullscreen(s_window, true);
  
  s_res_gothic_14 = fonts_get_system_font(FONT_KEY_GOTHIC_14);
  // text_address
  text_address = text_layer_create(GRect(0, 82, 144, 20));
  text_layer_set_background_color(text_address, GColorClear);
  text_layer_set_text_color(text_address, GColorWhite);
  text_layer_set_text(text_address, "-");
  text_layer_set_text_alignment(text_address, GTextAlignmentCenter);
  text_layer_set_font(text_address, s_res_gothic_14);
  layer_add_child(window_get_root_layer(s_window), (Layer *)text_address);
  
  // text_message
  text_message = text_layer_create(GRect(0, 99, 144, 34));
  text_layer_set_background_color(text_message, GColorClear);
  text_layer_set_text_color(text_message, GColorWhite);
  text_layer_set_text(text_message, "-");
  text_layer_set_text_alignment(text_message, GTextAlignmentCenter);
  text_layer_set_font(text_message, s_res_gothic_14);
  layer_add_child(window_get_root_layer(s_window), (Layer *)text_message);
  
  // s_textlayer_1
  s_textlayer_1 = text_layer_create(GRect(0, 57, 144, 20));
  text_layer_set_background_color(s_textlayer_1, GColorClear);
  text_layer_set_text_color(s_textlayer_1, GColorWhite);
  text_layer_set_text(s_textlayer_1, "Message Sent");
  text_layer_set_text_alignment(s_textlayer_1, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_1);
}
示例#12
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);
}
示例#13
0
void handle_init(AppContextRef ctx) {
  // Create the main window and push it in fullscreen mode
  window_init(&window, "Window Name");
  window_stack_push(&window, true /* Animated */);
  window_set_fullscreen(&window, true);

  // Initialize ressources and load the background image
  resource_init_current_app(&APP_RESOURCES);
  bmp_init_container(RESOURCE_ID_BACKGROUND_IMAGE, &background_image);
  layer_add_child(&window.layer, &background_image.layer.layer);

  // Create a text field to display the time until the next pass
  text_layer_init(&nextpass_text_layer, GRect(0, 126, 144, 34));
  text_layer_set_font(&nextpass_text_layer, fonts_get_system_font(FONT_KEY_BITHAM_34_MEDIUM_NUMBERS));
  text_layer_set_text_alignment(&nextpass_text_layer, GTextAlignmentCenter);
  text_layer_set_background_color(&nextpass_text_layer, GColorClear);
  layer_add_child(window_get_root_layer(&window), (Layer*)&time_text_layer);

  // Create a text field to display the current time
  text_layer_init(&time_text_layer, GRect(37, 0, 70, 24));
  text_layer_set_font(&time_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24));
  text_layer_set_text_alignment(&time_text_layer, GTextAlignmentCenter);
  text_layer_set_background_color(&time_text_layer, GColorClear);
  layer_add_child(window_get_root_layer(&window), (Layer*)&nextpass_text_layer);


  // Add background and both text fields to the window

  // Start an HTTP Request
  start_http_request();
}
示例#14
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  window_set_fullscreen(s_window, true);
  
  s_res_infinity_white = gbitmap_create_with_resource(RESOURCE_ID_infinity_white);
  s_res_gothic_28_bold = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
  // s_textlayer_title
  s_textlayer_title = text_layer_create(GRect(0, 140, 144, 14));
  text_layer_set_background_color(s_textlayer_title, GColorClear);
  text_layer_set_text_color(s_textlayer_title, GColorWhite);
  text_layer_set_text(s_textlayer_title, "Time is limitless.");
  text_layer_set_text_alignment(s_textlayer_title, GTextAlignmentCenter);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_title);
  
  // s_bitmaplayer_infinity
  s_bitmaplayer_infinity = bitmap_layer_create(GRect(47, 74, 50, 20));
  bitmap_layer_set_bitmap(s_bitmaplayer_infinity, s_res_infinity_white);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmaplayer_infinity);
  
  // s_textlayer_message
  s_textlayer_message = text_layer_create(GRect(0, 14, 144, 28));
  text_layer_set_background_color(s_textlayer_message, GColorClear);
  text_layer_set_text_color(s_textlayer_message, GColorWhite);
  text_layer_set_text(s_textlayer_message, "00:00");
  text_layer_set_text_alignment(s_textlayer_message, GTextAlignmentCenter);
  text_layer_set_font(s_textlayer_message, s_res_gothic_28_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_textlayer_message);
}
示例#15
0
文件: view.c 项目: N8Fear/adwc
static void
key_handler(struct window *window, struct input *input, uint32_t time,
	    uint32_t key, uint32_t unicode, uint32_t state, void *data)
{
	struct view *view = data;

	if(!state)
	        return;

	switch (key) {
	case KEY_F11:
		view->fullscreen ^= 1;
		window_set_fullscreen(window, view->fullscreen);
		break;
	case KEY_SPACE:
	case KEY_PAGEDOWN:
	case KEY_RIGHT:
	case KEY_DOWN:
                view_page_down(view);
		break;
	case KEY_BACKSPACE:
	case KEY_PAGEUP:
	case KEY_LEFT:
	case KEY_UP:
                view_page_up(view);
		break;
	default:
		break;
	}
}
示例#16
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);
}
示例#17
0
void init() {
	window = window_create();
  window_set_background_color(window, GColorBlack);
	WindowHandlers handlers = {
		.load = window_load,
		.unload = window_unload
	};
	window_set_window_handlers(window, handlers);
  window_set_fullscreen(window, true);

	//Register AppMessage events
	app_message_register_inbox_received(in_received_handler);
	app_message_open(512, 512);		//Large input and output buffer sizes

	window_stack_push(window, true);

  // Init the text layer used to show the time
    time_layer = text_layer_create(GRect(0, 0, 144 /* width */, 50 /* height */));
    text_layer_set_text_color(time_layer, GColorBlack);
    text_layer_set_background_color(time_layer, GColorWhite);
    text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
    text_layer_set_text_alignment(time_layer, GTextAlignmentCenter);

    // 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.)
    time_t now = time(NULL);
    struct tm *current_time = localtime(&now);
    handle_battery(battery_state_service_peek());
    handle_second_tick(current_time, SECOND_UNIT);
    tick_timer_service_subscribe(SECOND_UNIT, &handle_second_tick);
    battery_state_service_subscribe(&handle_battery);

    layer_add_child(window_get_root_layer(window), text_layer_get_layer(time_layer));
}
示例#18
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, false);
  
  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_inverterlayer_1
  s_inverterlayer_1 = inverter_layer_create(GRect(0, 0, 144, 35));
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_inverterlayer_1);
  
  // s_stop_name_layer
  s_stop_name_layer = text_layer_create(GRect(0, -7, 144, 29));
  text_layer_set_background_color(s_stop_name_layer, GColorClear);
  text_layer_set_text_color(s_stop_name_layer, GColorWhite);
  text_layer_set_text(s_stop_name_layer, "Mountain View");
  text_layer_set_text_alignment(s_stop_name_layer, GTextAlignmentCenter);
  text_layer_set_font(s_stop_name_layer, s_res_gothic_24_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_stop_name_layer);
  
  // s_direction_layer
  s_direction_layer = text_layer_create(GRect(0, 14, 144, 19));
  text_layer_set_background_color(s_direction_layer, GColorClear);
  text_layer_set_text_color(s_direction_layer, GColorWhite);
  text_layer_set_text(s_direction_layer, "Southbound");
  text_layer_set_text_alignment(s_direction_layer, GTextAlignmentCenter);
  text_layer_set_font(s_direction_layer, s_res_gothic_18);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_direction_layer);
  
  // s_train_menu
  s_train_menu = menu_layer_create(GRect(0, 35, 144, 117));
  menu_layer_set_click_config_onto_window(s_train_menu, s_window);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_train_menu);
}
示例#19
0
文件: window.c 项目: a2/pandozer
static void initialise_ui(void) {
  s_window = window_create();
  window_set_background_color(s_window, GColorBlack);
  window_set_fullscreen(s_window, 1);
  
  s_res_image_cloud = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_CLOUD);
  s_res_gothic_28_bold = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
  s_res_image_panda = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PANDA);
  s_res_image_panda_eye = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PANDA_EYE);
  // s_bitmap_cloud
  s_bitmap_cloud = bitmap_layer_create(GRect(5, 7, 134, 82));
  bitmap_layer_set_bitmap(s_bitmap_cloud, s_res_image_cloud);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmap_cloud);
  
  // s_text_time
  s_text_time = text_layer_create(GRect(20, 37, 104, 30));
  text_layer_set_background_color(s_text_time, GColorClear);
  text_layer_set_text_color(s_text_time, GColorWhite);
  text_layer_set_text(s_text_time, " ");
  text_layer_set_text_alignment(s_text_time, GTextAlignmentCenter);
  text_layer_set_font(s_text_time, s_res_gothic_28_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_text_time);
  
  // s_bitmap_panda
  s_bitmap_panda = bitmap_layer_create(GRect(32, 92, 102, 66));
  bitmap_layer_set_bitmap(s_bitmap_panda, s_res_image_panda);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmap_panda);
  
  // s_bitmap_panda_eye
  s_bitmap_panda_eye = bitmap_layer_create(GRect(43, 125, 17, 19));
  bitmap_layer_set_bitmap(s_bitmap_panda_eye, s_res_image_panda_eye);
  layer_add_child(window_get_root_layer(s_window), (Layer *)s_bitmap_panda_eye);
}
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 */);
}
示例#21
0
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, true);
  
  s_res_gothic_18_bold = fonts_get_system_font(FONT_KEY_GOTHIC_18_BOLD);
  s_res_gothic_28_bold = fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD);
  s_res_gothic_24_bold = fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD);
  // treshold_tl
  treshold_tl = text_layer_create(GRect(0, 0, 142, 19));
  text_layer_set_text(treshold_tl, "THRESHOLD");
  text_layer_set_text_alignment(treshold_tl, GTextAlignmentCenter);
  text_layer_set_font(treshold_tl, s_res_gothic_18_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)treshold_tl);
  
  // value_tl
  value_tl = text_layer_create(GRect(0, 69, 144, 36));
  text_layer_set_background_color(value_tl, GColorBlack);
  text_layer_set_text_color(value_tl, GColorWhite);
  text_layer_set_text(value_tl, "50");
  text_layer_set_text_alignment(value_tl, GTextAlignmentCenter);
  text_layer_set_font(value_tl, s_res_gothic_28_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)value_tl);
  
  // ok_tl
  ok_tl = text_layer_create(GRect(3, 23, 37, 28));
  text_layer_set_text(ok_tl, "< Ok");
  text_layer_set_font(ok_tl, s_res_gothic_24_bold);
  layer_add_child(window_get_root_layer(s_window), (Layer *)ok_tl);
}
示例#22
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);
}
示例#23
0
void create_window() {
  window = window_create();
  window_set_fullscreen(window, true);
  window_set_window_handlers(window, (WindowHandlers) {
     .load = window_load,
     .unload = window_unload    
  });
// Initialize all UI components
static void initialise_ui(void) {
  s_window = window_create();
  window_set_fullscreen(s_window, true);
  
  visitors = 0;
  max_visitors = 0;
  
  s_data_text_layer = text_layer_create(GRect(0, 54, 144, 35));
  text_layer_set_text_alignment(s_data_text_layer, GTextAlignmentCenter);
  text_layer_set_overflow_mode(s_data_text_layer, GTextOverflowModeWordWrap);
  text_layer_set_font(s_data_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
  text_layer_set_text(s_data_text_layer, "Loading...");
  layer_add_child(window_get_root_layer(s_window), text_layer_get_layer(s_data_text_layer));
  
  s_label_text_layer = text_layer_create(GRect(0, 136, 144, 35));
  text_layer_set_text_alignment(s_label_text_layer, GTextAlignmentCenter);
  text_layer_set_overflow_mode(s_label_text_layer, GTextOverflowModeWordWrap);
  text_layer_set_background_color(s_label_text_layer, GColorBlack);
  text_layer_set_text_color(s_label_text_layer, GColorWhite);
  text_layer_set_font(s_label_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
  text_layer_set_text(s_label_text_layer, "Concurrent Visits");
  layer_add_child(window_get_root_layer(s_window), text_layer_get_layer(s_label_text_layer));
  
  s_graph_layer = layer_create(GRect(10, 10, 124, 121));
  layer_set_update_proc(s_graph_layer, graph_layer_update_proc);
  layer_add_child(window_get_root_layer(s_window), s_graph_layer);
  
  get_data();
  s_timer = app_timer_register(REFRESH_TIME, timer_callback, NULL);
}
示例#25
0
文件: view.c 项目: anderco/weston
static struct view *
view_create(struct display *display,
	    uint32_t key, const char *filename, int fullscreen, int *view_counter)
{
	struct view *view;
	gchar *basename;
	gchar *title;
	GFile *file = NULL;
	GError *error = NULL;

	view = malloc(sizeof *view);
	if (view == NULL)
		return view;
	memset(view, 0, sizeof *view);

	file = g_file_new_for_commandline_arg(filename);
	basename = g_file_get_basename(file);
	if(!basename) {
		title = g_strdup("Wayland View");
	} else {
	        title = g_strdup_printf("Wayland View - %s", basename);
	        g_free(basename);
	}

        view->document = poppler_document_new_from_file(g_file_get_uri(file),
                                                        NULL, &error);

        if(error) {
		title = g_strdup("File not found");
        }

	view->window = window_create(display);
	view->widget = frame_create(view->window, view);
	window_set_title(view->window, title);
	g_free(title);
	view->display = display;

	window_set_user_data(view->window, view);
	window_set_key_handler(view->window, key_handler);
	window_set_keyboard_focus_handler(view->window,
					  keyboard_focus_handler);
	window_set_fullscreen_handler(view->window, fullscreen_handler);
	window_set_close_handler(view->window, close_handler);

	widget_set_button_handler(view->widget, button_handler);
	widget_set_resize_handler(view->widget, resize_handler);
	widget_set_redraw_handler(view->widget, redraw_handler);

	view->page = 0;

	view->fullscreen = fullscreen;
	window_set_fullscreen(view->window, view->fullscreen);

	window_schedule_resize(view->window, 500, 400);
	view->view_counter = view_counter;
	*view_counter += 1;

	return view;
}
void handle_init() {

  // Configure window
  window = window_create();
  window_stack_push(window, true /* Animated */);
  window_set_background_color(window, BKGD_COLOR);
  window_set_fullscreen(window, true);
  Layer *window_layer = window_get_root_layer(window);

  // Dynamic allocation of assets
  minuteFrame = GRect(53, 16, 40, 40);
  minuteLayer = text_layer_create(minuteFrame);
  hourLayer = bitmap_layer_create(GRect(0, 0, 144, 148));
  batteryLogoLayer = bitmap_layer_create(GRect(65, 151, 10, 15));
  batteryPercentLayer = text_layer_create(GRect(78, 150, 30, 167-150));
  dateLayer = text_layer_create(GRect(3, 150, 38, 167-150));
  dayLayer = text_layer_create(GRect(141-30, 150, 30, 167-150));
  text_layer_set_text_alignment(dayLayer, GTextAlignmentRight);
  bottomBarLayer = layer_create(GRect(1, 149, 142, 18));

  // Setup minute layer
  text_layer_set_text_color(minuteLayer, TEXT_COLOR);
  text_layer_set_background_color(minuteLayer, GColorClear);
  text_layer_set_font(minuteLayer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_MINUTE_38)));

  // Setup date & day layer
  text_layer_set_text_color(dateLayer, TEXT_COLOR);
  text_layer_set_background_color(dateLayer, GColorClear);
  text_layer_set_text_color(dayLayer, TEXT_COLOR);
  text_layer_set_background_color(dayLayer, GColorClear);

  // Setup battery layers
  text_layer_set_text_color(batteryPercentLayer, TEXT_COLOR);
  text_layer_set_background_color(batteryPercentLayer, GColorClear);

  // Setup line layer
  layer_set_update_proc(bottomBarLayer, bottom_bar_layer_update_callback);

  // Add layers into hierachy
  layer_add_child(bitmap_layer_get_layer(hourLayer), text_layer_get_layer(minuteLayer));
  layer_add_child(window_layer, bitmap_layer_get_layer(hourLayer));
  layer_add_child(window_layer, bottomBarLayer);
  layer_add_child(window_layer, bitmap_layer_get_layer(batteryLogoLayer));
  layer_add_child(window_layer, text_layer_get_layer(batteryPercentLayer));
  layer_add_child(window_layer, text_layer_get_layer(dateLayer));
  layer_add_child(window_layer, text_layer_get_layer(dayLayer));

  // Avoids a blank screen on watch start.
  time_t tick_time = time(NULL);
  display_time(localtime(&tick_time));
  handle_battery(battery_state_service_peek());
  handle_bluetooth(bluetooth_connection_service_peek());

  tick_timer_service_subscribe(MINUTE_UNIT, &handle_minute_tick);
  battery_state_service_subscribe(&handle_battery);
  bluetooth_connection_service_subscribe(&handle_bluetooth);

  initialized = true;
}
示例#27
0
static void
fullscreen_handler(struct window *window, void *data)
{
	struct gears *gears = data;

	gears->fullscreen ^= 1;
	window_set_fullscreen(window, gears->fullscreen);
}
示例#28
0
static void
fullscreen_handler(struct window *window, void *data)
{
	struct cliptest *cliptest = data;

	cliptest->fullscreen ^= 1;
	window_set_fullscreen(window, cliptest->fullscreen);
}
示例#29
0
static void
fullscreen_handler(struct window *window, void *data)
{
	struct image *image = data;

	image->fullscreen ^= 1;
	window_set_fullscreen(window, image->fullscreen);
}
示例#30
0
static void init(void) {
	window = window_create();
	window_set_background_color(window, GColorWhite);
	window_set_fullscreen(window, true);
	window_set_window_handlers(window, (WindowHandlers) {
		.load = window_load,
		.unload = window_unload
	});