Esempio n. 1
0
void menu_layer_set_click_config_onto_window__patch(MenuLayer * menu_layer, Window * window) {
  if (!menu_layer_ccp) {
    menu_layer_set_click_config_onto_window(menu_layer, window);
    menu_layer_ccp = window_get_click_config_provider(window);
  }
  window_set_click_config_provider_with_context(window, (ClickConfigProvider) menu_layer_click_config_provider, menu_layer);
}
Esempio n. 2
0
void spinner_init( spinner* spin,
                   Window* win,
                   ClickHandler up_handler,
                   ClickHandler down_handler,
                   ClickConfigProvider additional_click_config,
                   AppContextRef ctx )
{
   spin->up_handler = up_handler;
   spin->down_handler = down_handler;
   spin->ctx = ctx;

   spin->start_repeat_delay = SPINNER_DEFAULT_REPEAT_DELAY;
   spin->start_fast_repeat_count = SPINNER_DEFAULT_FAST_REPEAT_COUNT;
   spin->repeat_interval = SPINNER_DEFAULT_REPEAT_INTERVAL;
   spin->fast_repeat_interval = SPINNER_DEFAULT_FAST_REPEAT_INTERVAL;

   spin->fast_up_timer = 0;
   spin->fast_down_timer = 0;
   spin->num_fast_changes = 0;
   spin->additional_click_config = additional_click_config;
   
   window_set_click_config_provider_with_context(
      win,
      (ClickConfigProvider) &spinner_config_click_provider,
      (void*) spin );
}
Esempio n. 3
0
void scroll_layer_set_click_config_onto_window__patch(ScrollLayer * scroll_layer, Window * window) {
  if (!scroll_layer_ccp) {
    scroll_layer_set_click_config_onto_window(scroll_layer, window);
    scroll_layer_ccp = window_get_click_config_provider(window);
  }
  window_set_click_config_provider_with_context(window, (ClickConfigProvider) scroll_layer_click_config_provider, scroll_layer);
}
Esempio n. 4
0
void action_bar_layer_add_to_window(ActionBarLayer *action_bar, struct Window *window) {
    GRect p=window->layer.frame;
    layer_insert_below_sibling((Layer*)action_bar,&window->layer);
    layer_set_frame ((Layer*)action_bar,GRect(p.size.w-ACTION_BAR_WIDTH,ACTION_BAR_SPACING,ACTION_BAR_WIDTH,p.size.h-2*ACTION_BAR_SPACING));
    window_set_click_config_provider_with_context  (window,action_bar_click_config_provider,action_bar);
    action_bar->window=window;
}
Esempio n. 5
0
//! Create window data and layers in here, as well as any variable prepping
//! @param window A pointer to the window the load was called by
static void prv_window_load_handler(Window *window) {
  // window properties
  Layer *root = window_get_root_layer(window);
  GRect bounds = layer_get_bounds(root);
  WindowData *data = (WindowData*)malloc(sizeof(WindowData));
  // check return
  if (data) {
    // set window properties
    window_set_user_data(window, data);
    window_set_click_config_provider_with_context(window, prv_click_config_provider, data);
    // create drawing layer and store pointer to window data in it
    data->draw_layer = layer_create_with_data(bounds, sizeof(StickFigure*));
    WindowData **layer_data = (WindowData**)layer_get_data(data->draw_layer);
    (*layer_data) = data;
    layer_set_update_proc(data->draw_layer, prv_layer_update_proc_handler);
    layer_add_child(root, data->draw_layer);

    // create the stick figure
    data->stick_figure = stick_figure_create();
    stick_figure_snap_pose(data->stick_figure, PoseWaitingForStart, prv_get_epoch_ms());

    // create the button
    data->button = drawing_button_create();

    // set some window data properties
    data->start_epoch = 0;

    // load image resources
    data->config_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_CONFIG);
    data->grid_1_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_GRID_1);
    data->grid_2_bmp = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_GRID_2);

    // open app message communication with the phone
    app_message_set_context(data);
    app_message_register_inbox_received(prv_inbox_recived);
    app_message_open(APP_MESSAGE_INBOX_SIZE_MINIMUM, APP_MESSAGE_OUTBOX_SIZE_MINIMUM);

    // start first refresh
    data->app_timer = app_timer_register(REFRESH_RATE_MS_PER_FRAME, prv_app_timer_callback, data);
    return;
  }

  // error handling
  window_stack_remove(window, false);
  APP_LOG(APP_LOG_LEVEL_ERROR, "Error: Failed to allocate memory for WindowData.");
}
Esempio n. 6
0
DatePickerWindow initDatePicker() {
   DatePickerWindow w;

   w.selected = 0;
   w.date = Today();

   w.window = window_create();
   w.day.layer = text_layer_create(GRect(9, 66, 28, 35));
   w.month.layer = text_layer_create(GRect(43, 66, 28, 35));
   w.year.layer = text_layer_create(GRect(76, 66, 58, 35));

   char* day = Day(&w.date);
   text_layer_set_text(w.day.layer, day);
   text_layer_set_font(w.day.layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
   text_layer_set_text_alignment(w.day.layer, GTextAlignmentCenter);
   text_layer_set_background_color(w.day.layer, C_BACKGROUND);
   text_layer_set_text_color(w.day.layer, C_FOREGROUND);
   layer_add_child(window_get_root_layer(w.window), text_layer_get_layer(w.day.layer));

   char* month = Month(&w.date);
   text_layer_set_text(w.month.layer, month);
   text_layer_set_font(w.month.layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
   text_layer_set_text_alignment(w.month.layer, GTextAlignmentCenter);
   text_layer_set_background_color(w.month.layer, C_BACKGROUND);
   text_layer_set_text_color(w.month.layer, C_FOREGROUND);
   layer_add_child(window_get_root_layer(w.window), text_layer_get_layer(w.month.layer));

   char* year = Year(&w.date);
   text_layer_set_text(w.year.layer, year);
   text_layer_set_font(w.year.layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
   text_layer_set_text_alignment(w.year.layer, GTextAlignmentCenter);
   text_layer_set_background_color(w.year.layer, C_BACKGROUND);
   text_layer_set_text_color(w.year.layer, C_FOREGROUND);
   layer_add_child(window_get_root_layer(w.window), text_layer_get_layer(w.year.layer));

   updateWhichSelected(w);

   window_set_click_config_provider_with_context(w.window, (ClickConfigProvider)config_provider, (void*)&w);

   return w;
}
Esempio n. 7
0
static void force_back_button(Window *window, MenuLayer *menu_layer) {
  previous_click_config_provider = window_get_click_config_provider(window);
  window_set_click_config_provider_with_context(window, new_click_config_provider, menu_layer);
}
void selection_layer_set_click_config_onto_window(Layer *layer, struct Window *window) {
  if (layer && window) {
    window_set_click_config_provider_with_context(window, (ClickConfigProvider)prv_click_config_provider, layer);
  }
}
Esempio n. 9
0
void scroll_layer_set_click_config_onto_window(ScrollLayer *l, struct Window *window) {
    window_set_click_config_provider_with_context(window,scroll_layer_click_config_provider,l);
}