static void cb_draw_row(GContext *g_ctx, const Layer *l_cell, MenuIndex *i_cell, void *ctx) {
  ActionMenu *menu = ctx;
  GRect bounds = layer_get_bounds(l_cell);

  if(menu_layer_get_selected_index(menu->menulayer).row == i_cell->row) {
    graphics_context_set_fill_color(g_ctx, GColorWhite);
    graphics_fill_rect(g_ctx, bounds, 0, GCornerNone);
  }

  bounds.origin.x += 4;
  bounds.size.w -= 2*4;

  graphics_context_set_fill_color(g_ctx, GColorBlack);
  graphics_fill_rect(g_ctx, bounds, 4, GCornersAll);

  bounds.size.w -= 2*4;
  bounds.origin.x += 4;

  bounds.origin.y += 4;
  bounds.size.h -= 2*4;

  graphics_draw_text(g_ctx,
    menu->current_level->items[i_cell->row]->label,
    fonts_get_system_font(ACTION_MENU_FONT),
    bounds,
    GTextOverflowModeWordWrap,
    GTextAlignmentLeft,
    0);

  if(menu->current_level->items[i_cell->row]->child && menu_layer_get_selected_index(menu->menulayer).row == i_cell->row) {
    if(menu->arrow_image == NULL){
      menu->arrow_image = gbitmap_create_with_data(ARROW_IMAGE_DATA);
    }
    graphics_draw_bitmap_in_rect(g_ctx, menu->arrow_image, (GRect){.origin={116, bounds.origin.y + (bounds.size.h - 4) / 2},.size={7,5}});
示例#2
0
文件: plugboard.c 项目: ExiaSR/Enigma
static void connect_letter(char selectLetter){
  // If we see that space sign it means we clear that letter 
  // Get the current index

  if(selectLetter == ' ' ){
    // If plugused is 0 or less then set it to 0 so we don't go over the bound

    if(plugUsed <= 0){
      plugUsed = 0;
    }
    // decrement
    else{
      plugUsed--;
    }

  }
  else{
    // If the plug used is over ten then tell the user that 10 is the limit
    if(plugUsed +1> 10){
        // -----   Show message -------
      selectLetter = ' ';
    } 
    // If if the plug used is not ten then keep incrementing
    else{
      plugUsed++;

    }
  }
  int index = menu_layer_get_selected_index(plug_layer).row;
  plugConnectLetters[index][0] = selectLetter;
  menu_layer_reload_data(plug_layer);


}
示例#3
0
/*
 * This is the menu item draw callback where you specify what each item should look like
 */
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {

#ifdef PBL_COLOR
  graphics_context_set_compositing_mode(ctx, GCompOpSet);
#endif

  // Pick up names from the array except for the one instance where we fiddle with it
  int16_t index = cell_index->row + menu_slide;
  const char *subtitle = menu_def[index].subtitle;
  const char *title = menu_def[index].title;
  GBitmap *icon = menu_def[index].state == NULL ? NULL : menu_icons[*(menu_def[index].state)];

  if ((menu_def[index].feature & FEATURE_WAKEUP) == FEATURE_WAKEUP && auto_reset_state == 1 && original_auto_reset_state == 1) {
    snprintf(menu_text, sizeof(menu_text), MENU_AUTO_RESET_DES_ON, twenty_four_to_twelve(get_config_data()->autohr), get_config_data()->automin, am_pm_text(get_config_data()->autohr));
    subtitle = menu_text;
  } else if ((menu_def[index].feature & FEATURE_SMART_ALARM) == FEATURE_SMART_ALARM) {
    copy_alarm_time_range_into_field(menu_text, sizeof(menu_text));
    subtitle = menu_text;
  } 
  
  #ifndef PBL_ROUND
     menu_cell_basic_draw(ctx, cell_layer, title, subtitle, icon);
  #else
     menu_cell_basic_draw(ctx, cell_layer, title, subtitle, NULL);
     if (icon != NULL && menu_layer_get_selected_index(menu_layer).row == cell_index->row) {
        graphics_draw_bitmap_in_rect(ctx, icon, GRect(10, 7, 24, 28));
     }
  #endif

}
示例#4
0
文件: HTTP.c 项目: clach04/HTTP-Push
static void send_to_phone() {
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Preparing data to send to Phone");

  if (listSize == 0) return;
  DictionaryIterator *dict;
  app_message_outbox_begin(&dict);

  int indexToSend = (int) menu_layer_get_selected_index(s_menu_layer).row;
  APP_LOG(APP_LOG_LEVEL_DEBUG, "statusList[indexToSend] set to: %s", statusList[indexToSend]);
  
  if (strcmp(statusList[indexToSend],"Ready") != 0 &&
     strcmp(statusList[indexToSend],"Pending...") != 0) {
    free (statusList[indexToSend]);
    statusList[indexToSend] = NULL;
   APP_LOG(APP_LOG_LEVEL_DEBUG, "?Preparing data to send to Phone");
  }
  menu_layer_reload_data(s_menu_layer);
  statusList[indexToSend] = "Pending...";
  APP_LOG(APP_LOG_LEVEL_DEBUG, "statusList[%d] set to Waiting...", indexToSend);

  APP_LOG(APP_LOG_LEVEL_DEBUG, "Menu index to send: %d", indexToSend);
  dict_write_uint8(dict,KEY_INDEX,indexToSend);
  const uint32_t final_size = dict_write_end(dict);
  APP_LOG(APP_LOG_LEVEL_DEBUG, "Sent message to phone! (%d bytes)", (int) final_size);
  app_message_outbox_send();
}
void select_item() {
  uint64_t elapsed = stop_timer(&select_timeout_sec, &select_timeout_msec);
  if (elapsed > SELECT_TIME_THR) {
    MenuIndex idx = menu_layer_get_selected_index(menu_layer);
    menu_select_callback(menu_layer, &idx, NULL);
  }
}
示例#6
0
static void menu_select_long_click_handler(ClickRecognizerRef recognizer, MenuLayer* menu_layer) {
  MenuLayerCallbacks callbacks = MENULAYER_CALLBACKS(menu_layer);
  MenuIndex selected_index = menu_layer_get_selected_index(menu_layer);
  if (callbacks.select_long_click) {
    callbacks.select_long_click(menu_layer, &selected_index, MENULAYER_CALLBACK_CONTEXT(menu_layer));
  }
}
示例#7
0
static void items_select_long_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) {
    const int index = menu_layer_get_selected_index(&items_menu_layer).row;

    items_todo_list_delete(index);
    send_request(HTTP_CMD_DELETE, current_list, index);

    menu_layer_reload_data(&items_menu_layer);
}
static void select_next_font_handler(ClickRecognizerRef recognizer, void *context) {
  current_font++;
  if ((unsigned)current_font >= NUM_FONTS) {
    current_font = 0;
  }
  MenuIndex idx = menu_layer_get_selected_index(menu_layer);
  idx.row = current_font;
  menu_layer_set_selected_index(menu_layer, idx, MenuRowAlignCenter, false);
  show_selected_font_and_message();
}
static void select_previous_font_handler(ClickRecognizerRef recognizer, void *context) {
  current_font--;
  if (current_font < 0) {
    current_font = NUM_FONTS - 1;
  }
  MenuIndex idx = menu_layer_get_selected_index(menu_layer);
  idx.row = current_font;
  menu_layer_set_selected_index(menu_layer, idx, MenuRowAlignCenter, false);
  show_selected_font_and_message();
}
示例#10
0
void push_appropriate_window(void){
  MenuIndex home_row = menu_layer_get_selected_index(home_menu_layer);
  switch(home_row.row){
	case 0: window_stack_push(matchup_window, true); has_initial_matchup_data = true; break;
	case 1: window_stack_push(league_window, true); has_league_data = true; break;
	case 2: window_stack_push(team_window, true); has_team_data = true; break;
	case 3: window_stack_push(credits_window, true); break;
  }
  window_stack_remove(loading_window, false);
	
  current = HOME + 1 + home_row.row;
}
示例#11
0
int16_t menu_get_cell_height_callback( MenuLayer *menu_layer, MenuIndex *cell_index, void *callback_context) {
#ifdef PBL_ROUND
    MenuIndex sel = menu_layer_get_selected_index(menu_layer);
    if ((sel.section==cell_index->section) && (sel.row==cell_index->row)) {
        return 60;
    }else {
        return 40;
    }
#else
    return 40;
#endif
}
示例#12
0
文件: menu.c 项目: tfritzon/Slebble
void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
    Menu* menu = data;
    MenuIndex selected_item = menu_layer_get_selected_index(menu->layer);
    if(menu->id == 0 && cell_index->section == 0)
        menu_cell_basic_draw(ctx, cell_layer, "Nearby Stations", "", NULL);
    else {
        if(selected_item.row == cell_index->row && text_scroll >= 0)
            menu_cell_basic_draw(ctx, cell_layer, menu->row[cell_index->row]->title+((uint)text_scroll*sizeof(char)), menu->row[cell_index->row]->subtitle, NULL);
        else
            menu_cell_basic_draw(ctx, cell_layer, menu->row[cell_index->row]->title, menu->row[cell_index->row]->subtitle, NULL);
    }
}
示例#13
0
static void scroll_menu_callback(void) {
    nrbyStps_scrollTimer = NULL;
    nrbyStps_scrollOffset++;
    if (!nrbyStps_scrollingStillRequired) {
        nrbyStps_scrollOffset = -1;
        nrbyStps_scrollingStillRequired = true;
        nrbyStps_scrollTimer = app_timer_register(SCROLL_WAIT, (AppTimerCallback)scroll_menu_callback, NULL);
        return;
    }

    MenuIndex index = menu_layer_get_selected_index(s_menuLayer);
    if (index.row != 0) {
        nrbyStps_reloadingToScroll = true;
    }
    nrbyStps_scrollingStillRequired = false;
    menu_layer_reload_data(s_menuLayer);
    nrbyStps_scrollTimer = app_timer_register(SCROLL_WAIT, (AppTimerCallback)scroll_menu_callback, NULL);
}
示例#14
0
static void window_appear(Window *window) {
  // Session deletion from review UI could the selected row when returning to this window
  MenuIndex menu_index = menu_layer_get_selected_index(menu_layer_main_menu);
  uint16_t section = menu_index.section;
  uint16_t row = menu_index.row;
  uint16_t num_rows = num_rows_callback(menu_layer_main_menu, section, NULL);
  
  window_unload(window);
  window_load(window);
  
  if (row >= num_rows) {
    // Exception handling for review UI deleting a session
    menu_layer_set_selected_index(menu_layer_main_menu, MenuIndex(section,0), MenuRowAlignCenter, false);
  } else {
    menu_layer_set_selected_index(menu_layer_main_menu, MenuIndex(section,row), MenuRowAlignCenter, false);
  }
  
  layer_mark_dirty(menu_layer_get_layer(menu_layer_main_menu));
}
示例#15
0
void CallMenuSelectCallback(Menu *menu, ClickRecognizerRef recognizer, Window *window)
{
    if(!menu->menuLayerInitialized)
        return;

    MenuIndex index = menu_layer_get_selected_index(menu->menuLayer);

    if(index.row < GetMenuCellCount(menu, index.section))
    {
        if(menu->useCallbackFunctions)
        {
            menu->menuSelectCallback(&index);
        }
        else
        {
            menu->cellList[index.row].callback();
        }
    }
}
示例#16
0
文件: menu.c 项目: tfritzon/Slebble
/**
* CRASHES HERE
*/
void text_scroll_handler(void *data) {
    Menu* menu = *((Menu**)data);
    MenuIndex selected_item = menu_layer_get_selected_index(menu->layer);

    if(menu->size > 0) {
        char current_char = *(menu->row[selected_item.row]->title+((uint)text_scroll*sizeof(char)));
        //Fixes åäö edge case
        if(current_char == 195)
            text_scroll++;
    }

    if(!(menu->id == 0 && selected_item.section == 0))
        text_scroll++;

    if(menu->size > 0 && text_scroll > ((int)strlen(menu->row[selected_item.row]->title)) - 17)
        text_scroll = -2;

    menu_layer_reload_data(menu->layer);
    scroll_timer = app_timer_register(500, &text_scroll_handler, data);

}
示例#17
0
void home_select(MenuLayer *menu_layer, MenuIndex *index, void *data){
  MenuIndex home_row = menu_layer_get_selected_index(home_menu_layer);
  if(home_row.row == 3){
	push_appropriate_window();  
	return;
  }
  
  if(pre_draft) return;	
	
  if(home_row.row == 0){
	if(!has_initial_matchup_data){
	  send_request("MATCHUP");  
	  window_stack_push(loading_window, true);
	  loading_timer_cancel();
	  loading_timer_start();
	  current = LOADING;	
	}
	else push_appropriate_window();
  } 
  else if(home_row.row == 1){
	if(!has_league_data){
	  send_request("LEAGUE");
	  window_stack_push(loading_window, true);
	  loading_timer_cancel();
  	  loading_timer_start();
	  current = LOADING;
	}
    else push_appropriate_window();
  }
  else if(home_row.row == 2){
	if(!has_team_data){
	  send_request("TEAM");
	  window_stack_push(loading_window, true);
  	  loading_timer_cancel();
  	  loading_timer_start();
  	  current = LOADING;
	}
	else push_appropriate_window();
  }
}
示例#18
0
/**
* Called when select button is clicked
* Sends the action to the phone and removes the alert
*/
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
  // Get the selected item in the menu
  MenuIndex selected = menu_layer_get_selected_index(action_menu);
  
  // The menu only has section 0 at the moment, if it is not this then we have an erroneous state
  if (selected.section == 0) {
    // Build the message
    DictionaryIterator *iter;
    app_message_outbox_begin(&iter);
    
    // Write the message type and hazard ID fields in
    int type = DICT_TYPE_ACTION;
    dict_write_int(iter, DICT_TYPE_KEY, &type, sizeof(int), true);
    dict_write_int(iter, DICT_HAZARD_ID_KEY, &(current_alert->alert_id), sizeof(int), true);
    
    // Determine which action the user has selected
    int action;
    switch (selected.row) {
      case 0:
        action = DICT_ACTION_ACK;
        break;
      case 1:
        action = DICT_ACTION_DIS;
        break;
    }
    dict_write_int(iter, DICT_ACTION_KEY, &action, sizeof(int), true);
    
    // Send the message
    app_message_outbox_send();
    
    // Remove alert from the Pebble and show the notification
    remove_alert_node(current_alert);
    refresh_alert_window();
    show_action_sent_window();
  }
}
示例#19
0
static void lists_select_callback(MenuLayer *menu_layer, MenuIndex *cell_index, void *data) {

    if (info_on)
    {
        unlock_info();
        hide_info();
        //display_info("LOADING...");
    } else {
        const int index = cell_index->row;

        window_stack_push(&items_window, true);
        //Send first request (INFOS):
        current_list = index;
        //send_request(HTTP_CMD_REQUEST_ITEM, current_list, 0);

        //scroll to top:
        while (menu_layer_get_selected_index(&items_menu_layer).row > 0) {
            menu_layer_set_selected_next(&items_menu_layer, true, MenuRowAlignTop, true);
        }

        //refresh menu layer:
        menu_layer_reload_data(&items_menu_layer);
    }
}
示例#20
0
void emergency_conf_selectClickHandler(ClickRecognizerRef recognizer, void *context) {
  MenuIndex index = menu_layer_get_selected_index(menu_layer);
  emergency_conf_select_click_callback(menu_layer, &index, NULL);
}
示例#21
0
// This is the menu item draw callback where you specify what each item should look like
static void menu_draw_row_callback(GContext* ctx, const Layer *cell_layer, MenuIndex *cell_index, void *data) {
    
#ifdef PBL_BW
    graphics_context_set_text_color(ctx, GColorBlack);
#endif
    
    
    
    if (cell_index->section > NUM_SECTIONS) return;
    if (cell_index->row > channels[cell_index->section].num) return;
    
    chan_info* channel = &channels[cell_index->section].chans[cell_index->row];
    
    int left_pad=0;
    
    // Title and icon
#ifdef PBL_ROUND
    GTextAttributes *s_attributes
    = graphics_text_attributes_create();
    
    // Enable text flow with an inset of 5 pixels
    graphics_text_attributes_enable_screen_text_flow(s_attributes, 5);
    
    MenuIndex sel = menu_layer_get_selected_index(menu_layer);
    
    if ((sel.section==cell_index->section) && (sel.row==cell_index->row)) {
        
        graphics_draw_text(ctx, channel_icon_str(channel),
                           fonts_get_font(RESOURCE_ID_FONT_ICONS_16), GRect(4, 4, PEBBLE_WIDTH-4, 16),
                           GTextOverflowModeFill, GTextAlignmentCenter, s_attributes);
        
        graphics_draw_text(ctx, channel->name,
                           fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
                           GRect(4, 14, PEBBLE_WIDTH - 4, 24), GTextOverflowModeTrailingEllipsis,
                           GTextAlignmentCenter, s_attributes);

        graphics_draw_text(ctx, channel->unread_msg,
                           fonts_get_system_font(channel->unread == 0 ? FONT_KEY_GOTHIC_14 : FONT_KEY_GOTHIC_14_BOLD),
                           GRect(4, 36, PEBBLE_WIDTH - 4 - left_pad, 14),
                           GTextOverflowModeTrailingEllipsis,
                           GTextAlignmentCenter, s_attributes);
        
        
//        graphics_draw_text(ctx, channel_icon_str(channel),
//                           fonts_get_font(RESOURCE_ID_FONT_ICONS_16), GRect(4, 4, 16, 16),
//                           GTextOverflowModeFill, GTextAlignmentCenter, s_attributes);
//        
//        graphics_draw_text(ctx, channel->name,
//                           fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
//                           GRect(24, -6, PEBBLE_WIDTH - 24, 24), GTextOverflowModeTrailingEllipsis,
//                           GTextAlignmentLeft, s_attributes);
    } else {
        graphics_draw_text(ctx, channel->name,
                           fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
                           GRect(4, -6, PEBBLE_WIDTH - 4, 24), GTextOverflowModeTrailingEllipsis,
                           GTextAlignmentCenter, s_attributes);
        
        graphics_draw_text(ctx, channel->unread_msg,
                           fonts_get_system_font(channel->unread == 0 ? FONT_KEY_GOTHIC_14 : FONT_KEY_GOTHIC_14_BOLD),
                           GRect(4, 20, PEBBLE_WIDTH - 4 - left_pad, 14),
                           GTextOverflowModeTrailingEllipsis,
                           GTextAlignmentCenter, s_attributes);
    }

    
    graphics_text_attributes_destroy(s_attributes);
#else
    graphics_draw_text(ctx, channel_icon_str(channel),
                       fonts_get_font(RESOURCE_ID_FONT_ICONS_16), GRect(4+left_pad, 4, 16, 16),
                       GTextOverflowModeFill, GTextAlignmentCenter, NULL);
    
    graphics_draw_text(ctx, channel->name,
                       fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD),
                       GRect(22+left_pad, -6, PEBBLE_WIDTH - 24- left_pad, 24), GTextOverflowModeTrailingEllipsis,
                       GTextAlignmentLeft, NULL);
    
    graphics_draw_text(ctx, channel->unread_msg,
                       fonts_get_system_font(channel->unread == 0 ? FONT_KEY_GOTHIC_14 : FONT_KEY_GOTHIC_14_BOLD),
                       GRect(4+left_pad, 20, PEBBLE_WIDTH - 8 - left_pad, 14),
                       GTextOverflowModeTrailingEllipsis,
                       GTextAlignmentLeft, NULL);
#endif
    
    
}
示例#22
0
static void prv_handle_window_unload(Window* window) {
  persist_selected_stop(menu_layer_get_selected_index(s_menu).row);
  destroy_ui();
}