Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_region_menu_popup.c
| Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | static uiBut *ui_popup_menu_memory__internal(uiBlock *block, uiBut *but) | ||||
| if (but) { | if (but) { | ||||
| /* set */ | /* set */ | ||||
| mem[hash_mod] = ui_popup_string_hash(but->str, but->flag & UI_BUT_HAS_SEP_CHAR); | mem[hash_mod] = ui_popup_string_hash(but->str, but->flag & UI_BUT_HAS_SEP_CHAR); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /* get */ | /* get */ | ||||
| for (but = block->buttons.first; but; but = but->next) { | LISTBASE_FOREACH (uiBut *, but_iter, &block->buttons) { | ||||
| if (mem[hash_mod] == ui_popup_string_hash(but->str, but->flag & UI_BUT_HAS_SEP_CHAR)) { | if (mem[hash_mod] == | ||||
| return but; | ui_popup_string_hash(but_iter->str, but_iter->flag & UI_BUT_HAS_SEP_CHAR)) { | ||||
| return but_iter; | |||||
| } | } | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| uiBut *ui_popup_menu_memory_get(uiBlock *block) | uiBut *ui_popup_menu_memory_get(uiBlock *block) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, void *arg_pup) | ||||
| block->direction = direction; | block->direction = direction; | ||||
| UI_block_layout_resolve(block, &width, &height); | UI_block_layout_resolve(block, &width, &height); | ||||
| UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); | UI_block_flag_enable(block, UI_BLOCK_MOVEMOUSE_QUIT); | ||||
| if (pup->popup) { | if (pup->popup) { | ||||
| uiBut *bt; | |||||
| int offset[2]; | int offset[2]; | ||||
| uiBut *but_activate = NULL; | uiBut *but_activate = NULL; | ||||
| UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NUMSELECT); | UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_NUMSELECT); | ||||
| UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); | UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); | ||||
| UI_block_direction_set(block, direction); | UI_block_direction_set(block, direction); | ||||
| /* offset the mouse position, possibly based on earlier selection */ | /* offset the mouse position, possibly based on earlier selection */ | ||||
| uiBut *bt; | |||||
| if ((block->flag & UI_BLOCK_POPUP_MEMORY) && (bt = ui_popup_menu_memory_get(block))) { | if ((block->flag & UI_BLOCK_POPUP_MEMORY) && (bt = ui_popup_menu_memory_get(block))) { | ||||
| /* position mouse on last clicked item, at 0.8*width of the | /* position mouse on last clicked item, at 0.8*width of the | ||||
| * button, so it doesn't overlap the text too much, also note | * button, so it doesn't overlap the text too much, also note | ||||
| * the offset is negative because we are inverse moving the | * the offset is negative because we are inverse moving the | ||||
| * block to be under the mouse */ | * block to be under the mouse */ | ||||
| offset[0] = -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect)); | offset[0] = -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect)); | ||||
| offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y); | offset[1] = -(bt->rect.ymin + 0.5f * UI_UNIT_Y); | ||||
| if (ui_but_is_editable(bt)) { | if (ui_but_is_editable(bt)) { | ||||
| but_activate = bt; | but_activate = bt; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* position mouse at 0.8*width of the button and below the tile | /* position mouse at 0.8*width of the button and below the tile | ||||
| * on the first item */ | * on the first item */ | ||||
| offset[0] = 0; | offset[0] = 0; | ||||
| for (bt = block->buttons.first; bt; bt = bt->next) { | LISTBASE_FOREACH (uiBut *, but_iter, &block->buttons) { | ||||
| offset[0] = min_ii(offset[0], -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect))); | offset[0] = min_ii(offset[0], | ||||
| -(but_iter->rect.xmin + 0.8f * BLI_rctf_size_x(&but_iter->rect))); | |||||
| } | } | ||||
| offset[1] = 2.1 * UI_UNIT_Y; | offset[1] = 2.1 * UI_UNIT_Y; | ||||
| for (bt = block->buttons.first; bt; bt = bt->next) { | LISTBASE_FOREACH (uiBut *, but_iter, &block->buttons) { | ||||
| if (ui_but_is_editable(bt)) { | if (ui_but_is_editable(but_iter)) { | ||||
| but_activate = bt; | but_activate = but_iter; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* in rare cases this is needed since moving the popup | /* in rare cases this is needed since moving the popup | ||||
| * to be within the window bounds may move it away from the mouse, | * to be within the window bounds may move it away from the mouse, | ||||
| * This ensures we set an item to be active. */ | * This ensures we set an item to be active. */ | ||||
| ▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Standard Popup Menus | /** \name Standard Popup Menus | ||||
| * \{ */ | * \{ */ | ||||
| void UI_popup_menu_reports(bContext *C, ReportList *reports) | void UI_popup_menu_reports(bContext *C, ReportList *reports) | ||||
| { | { | ||||
| Report *report; | |||||
| uiPopupMenu *pup = NULL; | uiPopupMenu *pup = NULL; | ||||
| uiLayout *layout; | uiLayout *layout; | ||||
| if (!CTX_wm_window(C)) { | if (!CTX_wm_window(C)) { | ||||
| return; | return; | ||||
| } | } | ||||
| for (report = reports->list.first; report; report = report->next) { | LISTBASE_FOREACH (Report *, report, &reports->list) { | ||||
| int icon; | int icon; | ||||
| const char *msg, *msg_next; | const char *msg, *msg_next; | ||||
| if (report->type < reports->printlevel) { | if (report->type < reports->printlevel) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (pup == NULL) { | if (pup == NULL) { | ||||
| ▲ Show 20 Lines • Show All 168 Lines • Show Last 20 Lines | |||||