Beispiel #1
0
void settings_changed_callback(int index, void *context)
{
    
    switch (index) {
        case MENU_ITEM_VIBRATE:
            _bpm_settings.vibrate = !_bpm_settings.vibrate;
            setting_items[MENU_ITEM_VIBRATE].subtitle = (_bpm_settings.vibrate ? "On" : "Off");
            break;
		case MENU_ITEM_ACCELEROMETER:
            _bpm_settings.accelerometer = !_bpm_settings.accelerometer;
            setting_items[MENU_ITEM_ACCELEROMETER].subtitle = (_bpm_settings.accelerometer ? "On" : "Off");
            break;
		case MENU_ITEM_DUALMODE:
            _bpm_settings.dual_mode = !_bpm_settings.dual_mode;
            setting_items[MENU_ITEM_DUALMODE].subtitle = (_bpm_settings.dual_mode ? "On" : "Off");
            break;
		case MENU_ITEM_LIGHT:
            _bpm_settings.light = !_bpm_settings.light;
            setting_items[MENU_ITEM_LIGHT].subtitle = (_bpm_settings.light ? "On" : "Off");
            break;
        default:
            break;
    }
	
	save_settings();
    menu_layer_reload_data(simple_menu_layer_get_menu_layer(menu_layer));
}
Beispiel #2
0
// Main window is a menu window.
static void main_window_load(Window *window) {
  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_frame(window_layer);
  main_menu_layer = simple_menu_layer_create(bounds, window, main_menu_sections, 1, NULL);

  // Load main menu.
  build_menu_from_struc(main_menu, sizeof(main_menu) / sizeof(struct menu_item), main_menu_sections, main_menu_items, main_menu_callback);

  // Add the prepared layer to the screen.
  layer_add_child(window_layer, (Layer *)main_menu_layer);

  // Note: It's beyond me at the moment why I need to do that, considering
  // I don't need to call menu_layer_reload_date for other menus and
  // I am drawing this menu only once, but it fixes the scrolling issue.
  menu_layer_reload_data(simple_menu_layer_get_menu_layer(main_menu_layer));
}
void show_menu_prompt() {
  if (active_controller == 0) {
    return;
  }
  
  Layer *window_layer = window_get_root_layer(active_controller->window);
  GRect bounding_frame = layer_get_frame(window_layer);
                                          
  sectionItems[0] = (SimpleMenuItem){.title="Run Home", .callback=(SimpleMenuLayerSelectCallback) &run_home_select, .icon=gbitmap_create_with_resource(RESOURCE_ID_RUN_HOME)};
  sectionItems[1] = (SimpleMenuItem){.title="End Run", .callback=(SimpleMenuLayerSelectCallback) &end_run, .icon=gbitmap_create_with_resource(RESOURCE_ID_CANCEL_ICON)};  
  sectionItems[2] = (SimpleMenuItem){.title="Back", .callback=(SimpleMenuLayerSelectCallback) &cancel_menu, .icon=gbitmap_create_with_resource(RESOURCE_ID_BACK)};
  
  sections[0] = (SimpleMenuSection) {.items=sectionItems, .num_items=3};
  
  active_controller->menu = simple_menu_layer_create(
    bounding_frame, 
    active_controller->window, sections, 1, on_menu_select);
  
  layer_add_child(window_layer, 
                  menu_layer_get_layer(simple_menu_layer_get_menu_layer(active_controller->menu)));
}
Beispiel #4
0
static void window_load(Window *window) {

  Layer *window_layer = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(window_layer);
  
  settings = (Settings)
    { .num_sets = 3
    , .num_points = 21
    , .max_points = 30
    , .first_server = PLAYER
    };

  load_settings(&settings);

  main_menu_sections[0] = (SimpleMenuSection) {
    .num_items = 1,
    .items = main_menu_items
  };

  main_menu_items[0] = (SimpleMenuItem) {
    .title = "Start Match",
    .callback = start_match
  };

  main_menu_sections[1] = (SimpleMenuSection) {
    .title = "Match Settings",
    .items = main_menu_item_options,
    .num_items = 2
  };

  main_menu_item_options[0] = (SimpleMenuItem) {
    .title = "Sets",
    .subtitle = setting_to_string(settings.num_sets),
    .callback = cycle_set_num
  };
  
  main_menu_item_options[1] = (SimpleMenuItem) {
    .title = "Points",
    .subtitle = setting_to_string(settings.num_points),
    .callback = cycle_points
  };
  
  main_menu_layer = simple_menu_layer_create(bounds, window, main_menu_sections, 2, NULL);
  layer_add_child(window_layer, simple_menu_layer_get_layer(main_menu_layer));

#ifdef PBL_COLOR
  menu_layer_set_highlight_colors(simple_menu_layer_get_menu_layer(main_menu_layer), GColorVividCerulean, GColorWhite);
#endif
}

static void window_unload(Window *window) {
  simple_menu_layer_destroy(main_menu_layer);
  window_destroy(window);
  s_main_window = NULL;
}

void menu_window_push() {
  if (!s_main_window) {
    s_main_window = window_create();
    window_set_window_handlers(s_main_window, (WindowHandlers) {
      .load = window_load,
      .unload = window_unload
    });
  }
  window_stack_push(s_main_window, true);
}
Beispiel #5
0
SimpleMenuLayer* simple_menu_layer_create__patch(GRect frame, Window * window, const SimpleMenuSection * sections, int32_t num_sections, void * callback_context) {
  SimpleMenuLayer* simple_menu_layer = simple_menu_layer_create(frame, window,  sections, num_sections, callback_context);
  discover_menu_layer_callbacks_offset(simple_menu_layer_get_menu_layer(simple_menu_layer));
  return simple_menu_layer;
}
Beispiel #6
0
void call_back_for_item(int index, void *ctx){
     menu_layer_reload_data(simple_menu_layer_get_menu_layer(simple_menu_layer));
 }