示例#1
0
static void details_list_load(Window* window) {
  int len = kana_app_getCharCount(selectedIndex);
  for(int i=0; i < len; i++) {
    if(kana_app_act_learn_mode == HIRAGANA)
      icons[i] = gbitmap_create_with_resource(kana_app_getHiraganaColRow( selectedIndex, i));
    else
      icons[i] = gbitmap_create_with_resource(kana_app_getKatakanaColRow( selectedIndex, i));

    #ifdef PBL_COLOR
      gbitmap_set_palette(icons[i], kana_app_bitmap_pallete, false);
    #endif
  }

  details_ui.menu = kana_app_simple_menu_init(
    details_ui.window,
    kana_app_act_learn_mode == HIRAGANA ? "Hiragana" : "Katakana",
    kana_app_getCharCount(selectedIndex),
    kana_app_getRow(selectedIndex),
    NULL, 
    icons, 
    NULL
  );

  #ifdef PBL_COLOR
    kana_app_simple_menu_set_color(
      details_ui.menu,
      COLOR_BG, COLOR_TEXT,
      COLOR_HIGHLIGHT, COLOR_HIGHLIGHT_TEXT);
  #endif
}
示例#2
0
static void load_bitmap_answer(int position, bool useErrorPallete) {
  #ifndef PBL_COLOR
    if(useErrorPallete) return;
  #endif

  GRect answerBounds = GRect(144 - 34, 84 - 58 + position * 49, 30, 18);

  if(choosen_question_mode == QUESTION_MODE_KATAKANA) {        
    ui.bitmaps[position] = 
      gbitmap_create_with_resource(kana_app_getKatakana(currentQuestion.answer[position]));
  } else if(choosen_question_mode == QUESTION_MODE_HIRAGANA) {
    ui.bitmaps[position] = 
      gbitmap_create_with_resource(kana_app_getHiragana(currentQuestion.answer[position]));                  
  }

  #ifdef PBL_COLOR
    gbitmap_set_palette (
      ui.bitmaps[position], 
      useErrorPallete ?
         kana_app_bitmap_error_pallete : kana_app_bitmap_pallete, 
      false);
  #endif

  ui.bitmapLayers[position] = bitmap_layer_create(answerBounds);

  bitmap_layer_set_bitmap (
    ui.bitmapLayers[position], 
    ui.bitmaps[position] );

  layer_add_child (
    window_get_root_layer(ui.window), 
    bitmap_layer_get_layer(ui.bitmapLayers[position]) );    
}
示例#3
0
static void setup_image(SimplyImage *image) {
  image->is_palette_black_and_white = gbitmap_is_palette_black_and_white(image->bitmap);

  if (!image->is_palette_black_and_white) {
    return;
  }

  GColor8 *palette = gbitmap_get_palette(image->bitmap);
  GColor8 *palette_copy = malloc0(2 * sizeof(GColor8));
  memcpy(palette_copy, palette, 2 * sizeof(GColor8));
  gbitmap_set_palette(image->bitmap, palette_copy, false);
  image->palette = palette_copy;
}
示例#4
0
void handle_init() {
  time_t clock = time(NULL);
  now = localtime(&clock);
  window = window_create();
  window_stack_push(window, true /* Animated */);
  window_set_background_color(window, BG_COLOR);

  date_layer = layer_create(GRect(0, EXTENT, EXTENT, 24));
  layer_set_update_proc(date_layer, &date_layer_update_callback);
  layer_add_child(window_get_root_layer(window), date_layer);

  background_layer = layer_create(GRect(0, 0, EXTENT, EXTENT));
  layer_set_update_proc(background_layer, &background_layer_update_callback);
  layer_add_child(window_get_root_layer(window), background_layer);

  logo = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_LOGO);
  gbitmap_set_palette(logo, bw_palette, false);
  GRect frame = gbitmap_get_bounds(logo);
  grect_align(&frame, &GRect(0, 0, EXTENT, CENTER_Y), GAlignCenter, false);
  logo_layer = bitmap_layer_create(frame);
  bitmap_layer_set_bitmap	(logo_layer, logo);
  layer_add_child(background_layer, bitmap_layer_get_layer(logo_layer));

  hands_layer = layer_create(layer_get_frame(background_layer));
  layer_set_update_proc(hands_layer, &hands_layer_update_callback);
  layer_add_child(background_layer, hands_layer);

  battery_layer = layer_create(GRect(EXTENT-22-3, 3, 22, 10));
  layer_set_update_proc(battery_layer, &battery_layer_update_callback);
  layer_add_child(window_get_root_layer(window), battery_layer);

  for (int i = 0; i < 2; i++) {
    bluetooth_images[i] = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_BLUETOOTH_OFF + i);  
    gbitmap_set_palette(bluetooth_images[i], bw_palette, false);
  }
  bluetooth_layer = bitmap_layer_create(GRect(CENTER_X - 6, CENTER_Y - DOTS_RADIUS - 4, 13, 13));
  layer_add_child(background_layer, bitmap_layer_get_layer(bluetooth_layer));

#if DEBUG
  debug_layer = text_layer_create(GRect(0, 0, 32, 16));
  strcpy(debug_buffer, "");
  text_layer_set_text(debug_layer, debug_buffer);
  text_layer_set_text_color(debug_layer, FG_COLOR);
  text_layer_set_background_color(debug_layer, BG_COLOR);
  layer_add_child(window_get_root_layer(window), text_layer_get_layer(debug_layer));
#endif
  
  hour_path = gpath_create(&HOUR_POINTS);
  gpath_move_to(hour_path, GPoint(CENTER_X, CENTER_Y));
  min_path = gpath_create(&MIN_POINTS);
  gpath_move_to(min_path, GPoint(CENTER_X, CENTER_Y));
  sec_path = gpath_create(&SEC_POINTS);
  gpath_move_to(sec_path, GPoint(CENTER_X, CENTER_Y));
  battery_path = gpath_create(&BATTERY_POINTS);
  charge_path = gpath_create(&CHARGE_POINTS);

  startup_animation = animation_create();
  animation_set_curve(startup_animation, AnimationCurveEaseOut);
  animation_set_implementation(startup_animation, &startup_animation_implementation);
  startup_animation_init();
  app_focus_service_subscribe_handlers((AppFocusHandlers){
    .did_focus = handle_app_did_focus,
  });