Beispiel #1
0
void handle_init(AppContextRef ctx)
{
   my_ctx = ctx;

   // Metronome window.

  window_init(&window, "Metronome Win");
  window.window_handlers.appear = (WindowHandler) &metronome_win_appear;
  window.window_handlers.disappear = (WindowHandler) &metronome_win_disappear;

  spinner_init( &tempo_spin,
                &window,
                (ClickHandler) tempo_up,
                (ClickHandler) tempo_down,
                (ClickConfigProvider) &config_click_provider,
                my_ctx );

  metronome_win_lay_out();

  window_stack_push(&window, true /* Animated */);

  // Menu configuration.

  window_init(&menu_win, "Menu Win");
  
  simple_menu_layer_init( &menu_lay,
                          GRect( 0, 0, 144, 141 ),
                          &menu_win,
                          menu_sect,
                          ARRAY_LENGTH(menu_sect),
                          NULL );
  menu_win.window_handlers.appear = (WindowHandler) &update_menu;
  layer_add_child( &menu_win.layer, (Layer*) &menu_lay );

  vibe_dur_win_init();

  stop_after_win_init();

  find_tempo_win_init();

  timer_stack_init_once();

  spinner_init_once();
}
/**
 * 初期化
 */
void config_window_handle_init(AppContextRef ctx) {
    (void) ctx;

    // 画面の初期化
    window_init(&configWindow, "SmartTraining");
    window_set_fullscreen(&configWindow, true);
    //    window_set_background_color(&selTrainTypeWindow, GColorBlack);

    // メニューレイヤー初期化[0]
    char *buffer = "00.00";
    setVersion(VERSION_MAJOR, VERSION_MINOR, buffer);
    config_window_data.menuItems[0] = (SimpleMenuItem)
    {
        .title = "Version",
        .subtitle = buffer,
        .icon = NULL,
        .callback = NULL 
    };

    config_window_data.menuSections[0] = (SimpleMenuSection)
    {
        .title = NULL,
        .items = config_window_data.menuItems,
        .num_items = ARRAY_LENGTH(config_window_data.menuItems)
    };
    simple_menu_layer_init(&config_window_data.menuLayer,
            configWindow.layer.frame, &configWindow,
            config_window_data.menuSections,
            ARRAY_LENGTH(config_window_data.menuSections), NULL);
    layer_add_child(&configWindow.layer,
            simple_menu_layer_get_layer(&config_window_data.menuLayer));
}

/**
 * 後始末
 */
void config_window_handle_deinit(AppContextRef ctx) {
}
Beispiel #3
0
void handle_init(AppContextRef ctx) {
  (void)ctx;

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

  items[0] = (SimpleMenuItem) {
      .title = "One",
      .subtitle = "subtitle",
      .icon = NULL,
      .callback = &menu_select_callback
  };
  items[1] = (SimpleMenuItem) {
      .title = "Two",
      .subtitle = "subtitle",
      .icon = NULL,
      .callback = &menu_select_callback
  };

  sections[0] = (SimpleMenuSection) {
      .title = "Section One",
      .items = items,
      .num_items = ARRAY_LENGTH(items)
  };


  simple_menu_layer_init(&menu, window.layer.frame, &window, sections, 1, NULL);
  layer_add_child(&window.layer, simple_menu_layer_get_layer(&menu));


  // make a text layer for logging output:
  text_layer_init(&debugLayer, GRect(0,168-42, 144,42));
  text_layer_set_text(&debugLayer, "log");
  text_layer_set_text_alignment(&debugLayer, GTextAlignmentCenter);
  layer_add_child(&window.layer, &debugLayer.layer);

}


void pbl_main(void *params) {
  PebbleAppHandlers handlers = {
    .init_handler = &handle_init
  };
  app_event_loop(params, &handlers);
}




// helper function:
char *itoa(int num)
{
	static char buff[20] = {};
	int i = 0, temp_num = num, length = 0;
	char *string = buff;
	
	if(num >= 0) {
		// count how many characters in the number
		while(temp_num) {
			temp_num /= 10;
			length++;
		}
		
		// assign the number to the buffer starting at the end of the 
		// number and going to the begining since we are doing the
		// integer to character conversion on the last number in the
		// sequence
		for(i = 0; i < length; i++) {
		 	buff[(length-1)-i] = '0' + (num % 10);
			num /= 10;
		}
		buff[i] = '\0'; // can't forget the null byte to properly end our string
	}
	else
		return "Unsupported Number";
	
	return string;
}
// --------------------------------------------------------
//			menu_timer_init()
//
//     called by TempusFugit.c to initialize menu data
// --------------------------------------------------------
void menu_timer_init() {

// -------------------------------
// init window handlers
// -------------------------------
	window_init(&menu_timer_window, "Timer Menu");
	window_set_background_color(&menu_timer_window, GColorWhite);
//	window_set_window_handlers(&menu_timer_window, (WindowHandlers) {
//        .appear = (WindowHandler)handle_appear,
//        .disappear = (WindowHandler)handle_disappear,
// 		.load = handle_load,
//		.unload = handle_unload,
//    }
//);

// -------------------------------
// Initialize first menu section
// -------------------------------
int menu_count = 0;

	menu_timer_data.first_menu_items[menu_count++] = (SimpleMenuItem) {
		.title = "START/STOP",
		.callback = menu_timer_start_callback,
	};

	menu_timer_data.first_menu_items[menu_count++] = (SimpleMenuItem) {
		.title = "RESET",
		.callback = menu_timer_reset_callback,
	};	

	menu_timer_data.first_menu_items[menu_count++] = (SimpleMenuItem) {
		.title = "CLEAR",
		.callback = menu_timer_clear_callback,
	};

	menu_timer_data.first_menu_items[menu_count++] = (SimpleMenuItem) {
		.title = "Button Mode ->",
		.callback = menu_timer_buttons_callback,
	};

	menu_timer_data.first_menu_items[menu_count++] = (SimpleMenuItem) {
		.title = "Help ->",
		.callback = menu_timer_help_callback,
	};

	menu_timer_data.first_menu_items[menu_count++] = (SimpleMenuItem) {
		.title = "About ->",
		.callback = menu_timer_about_callback,
	};

	// -------------------------------
	// Initialize third menu section
	// -------------------------------
//	menu_count = 0;
//	menu_timer_data.third_menu_items[menu_count++] = (SimpleMenuItem) {
//		.title = "Help ->",
//		.callback = menu_timer_help_callback,
//	};

//	menu_timer_data.third_menu_items[menu_count++] = (SimpleMenuItem) {
//		.title = "About ->",
//		.callback = menu_timer_about_callback,
//	};

	// -------------------------------
	//  Bind menu items to
	//  corresponding menu sections
	// -------------------------------
	menu_timer_data.menu_sections[0] = (SimpleMenuSection) {
		.num_items = NUM_MENU_TIMER_FIRST_ITEMS,
		.items = menu_timer_data.first_menu_items,
	};

//	menu_timer_data.menu_sections[1] = (SimpleMenuSection) {
//		.title = "(More...)",
//		.num_items = NUM_MENU_TIMER_SECOND_ITEMS,
//		.items = menu_timer_data.second_menu_items,
//	};
//	menu_timer_data.menu_sections[2] = (SimpleMenuSection) {
//		.num_items = NUM_MENU_TIMER_THIRD_ITEMS,
//		.items = menu_timer_data.third_menu_items,
//	};

// -------------------------------
//  initialize menu window
// -------------------------------
	simple_menu_layer_init(&menu_timer_data.menu_layer, menu_timer_window.layer.frame, &menu_timer_window, menu_timer_data.menu_sections, NUM_MENU_TIMER_SECTIONS, NULL);
	layer_add_child(&menu_timer_window.layer, &menu_timer_data.menu_layer.menu.scroll_layer.layer);

}  // menu__timer_init()

// --------------------------------------------------------
//			menu_timer_deinit()
// --------------------------------------------------------
void menu_timer_deinit() {

} // menu_timer_deinit()