src/toolbar_gui.cpp
changeset 9144 4c8d0193ebe0
parent 9142 858a058aa730
child 9161 fda175383e87
equal deleted inserted replaced
9143:029e126e3439 9144:4c8d0193ebe0
    73 	pos.x = w->widget[GB(parent_button, 0, 8)].left;
    73 	pos.x = w->widget[GB(parent_button, 0, 8)].left;
    74 	pos.x = w->left + Clamp(pos.x, 0, w->width - width);
    74 	pos.x = w->left + Clamp(pos.x, 0, w->width - width);
    75 	pos.y = w->height;
    75 	pos.y = w->height;
    76 
    76 
    77 	return pos;
    77 	return pos;
       
    78 }
       
    79 
       
    80 /**
       
    81  * In a window with menu_d custom extension, retrieve the menu item number from a position
       
    82  * @param w Window holding the menu items
       
    83  * @param x X coordinate of the position
       
    84  * @param y Y coordinate of the position
       
    85  * @return Index number of the menu item, or \c -1 if no valid selection under position
       
    86  */
       
    87 static int GetMenuItemIndex(const Window *w, int x, int y)
       
    88 {
       
    89 	if ((x -= w->left) >= 0 && x < w->width && (y -= w->top + 1) >= 0) {
       
    90 		y /= 10;
       
    91 
       
    92 		if (y < WP(w, const menu_d).item_count &&
       
    93 				!HasBit(WP(w, const menu_d).disabled_items, y)) {
       
    94 			return y;
       
    95 		}
       
    96 	}
       
    97 	return -1;
    78 }
    98 }
    79 
    99 
    80 /* --- Pausing --- */
   100 /* --- Pausing --- */
    81 
   101 
    82 static void ToolbarPauseClick(Window *w)
   102 static void ToolbarPauseClick(Window *w)