Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_region_menu_popup.c
| Show First 20 Lines • Show All 378 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Popup Menu API with begin & end | /** \name Popup Menu API with begin & end | ||||
| * \{ */ | * \{ */ | ||||
| /** | |||||
| * Only return handler, and set optional title. | |||||
| * \param block_name: Assigned to uiBlock.name (useful info for debugging). | |||||
| */ | |||||
| uiPopupMenu *UI_popup_menu_begin_ex(bContext *C, | uiPopupMenu *UI_popup_menu_begin_ex(bContext *C, | ||||
| const char *title, | const char *title, | ||||
| const char *block_name, | const char *block_name, | ||||
| int icon) | int icon) | ||||
| { | { | ||||
| const uiStyle *style = UI_style_get_dpi(); | const uiStyle *style = UI_style_get_dpi(); | ||||
| uiPopupMenu *pup = MEM_callocN(sizeof(uiPopupMenu), "popup menu"); | uiPopupMenu *pup = MEM_callocN(sizeof(uiPopupMenu), "popup menu"); | ||||
| uiBut *but; | uiBut *but; | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | uiPopupMenu *UI_popup_menu_begin_ex(bContext *C, | ||||
| return pup; | return pup; | ||||
| } | } | ||||
| uiPopupMenu *UI_popup_menu_begin(bContext *C, const char *title, int icon) | uiPopupMenu *UI_popup_menu_begin(bContext *C, const char *title, int icon) | ||||
| { | { | ||||
| return UI_popup_menu_begin_ex(C, title, __func__, icon); | return UI_popup_menu_begin_ex(C, title, __func__, icon); | ||||
| } | } | ||||
| /** | |||||
| * Setting the button makes the popup open from the button instead of the cursor. | |||||
| */ | |||||
| void UI_popup_menu_but_set(uiPopupMenu *pup, struct ARegion *butregion, uiBut *but) | void UI_popup_menu_but_set(uiPopupMenu *pup, struct ARegion *butregion, uiBut *but) | ||||
| { | { | ||||
| pup->but = but; | pup->but = but; | ||||
| pup->butregion = butregion; | pup->butregion = butregion; | ||||
| } | } | ||||
| /* set the whole structure to work */ | |||||
| void UI_popup_menu_end(bContext *C, uiPopupMenu *pup) | void UI_popup_menu_end(bContext *C, uiPopupMenu *pup) | ||||
| { | { | ||||
| wmWindow *window = CTX_wm_window(C); | wmWindow *window = CTX_wm_window(C); | ||||
| uiPopupBlockHandle *menu; | uiPopupBlockHandle *menu; | ||||
| uiBut *but = NULL; | uiBut *but = NULL; | ||||
| ARegion *butregion = NULL; | ARegion *butregion = NULL; | ||||
| pup->popup = true; | pup->popup = true; | ||||
| ▲ Show 20 Lines • Show All 224 Lines • Show Last 20 Lines | |||||