Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_regions.c
| Context not available. | |||||
| { | { | ||||
| uiBlock *block; | uiBlock *block; | ||||
| if (ar->do_draw & RGN_DRAW_REFRESH_UI) { | |||||
| uiBlock *block_next; | |||||
| ar->do_draw &= ~RGN_DRAW_REFRESH_UI; | |||||
| for (block = ar->uiblocks.first; block; block = block_next) { | |||||
| block_next = block->next; | |||||
| ui_popup_block_refresh((bContext *)C, block->handle, NULL, NULL); | |||||
| } | |||||
| } | |||||
| for (block = ar->uiblocks.first; block; block = block->next) | for (block = ar->uiblocks.first; block; block = block->next) | ||||
| uiDrawBlock(C, block); | uiDrawBlock(C, block); | ||||
| } | } | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut *but, | static void ui_popup_block_remove(bContext *C, uiPopupBlockHandle *handle) | ||||
| uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, | |||||
| void *arg) | |||||
| { | { | ||||
| wmWindow *window = CTX_wm_window(C); | ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region); | ||||
| static ARegionType type; | |||||
| ARegion *ar; | |||||
| uiBlock *block; | |||||
| uiPopupBlockHandle *handle; | |||||
| uiSafetyRct *saferct; | |||||
| int width = UI_ThemeMenuShadowWidth(); | |||||
| /* create handle */ | if (handle->scrolltimer) | ||||
| handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle"); | WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), handle->scrolltimer); | ||||
| } | |||||
| /* store context for operator */ | /** | ||||
| handle->ctx_area = CTX_wm_area(C); | * Called for creatign new popups and refreshing existing ones. | ||||
| handle->ctx_region = CTX_wm_region(C); | */ | ||||
| uiBlock *ui_popup_block_refresh( | |||||
| /* create area region */ | bContext *C, uiPopupBlockHandle *handle, | ||||
| ar = ui_add_temporary_region(CTX_wm_screen(C)); | ARegion *butregion, uiBut *but) | ||||
| handle->region = ar; | { | ||||
| const int width = UI_ThemeMenuShadowWidth(); | |||||
| wmWindow *window = CTX_wm_window(C); | |||||
| ARegion *ar = handle->region; | |||||
| int event_xy[2]; | |||||
| memset(&type, 0, sizeof(ARegionType)); | uiBlockCreateFunc create_func = handle->popup_create_vars.create_func; | ||||
| type.draw = ui_block_region_draw; | uiBlockHandleCreateFunc handle_create_func = handle->popup_create_vars.handle_create_func; | ||||
| type.regionid = RGN_TYPE_TEMPORARY; | void *arg = handle->popup_create_vars.arg; | ||||
| ar->type = &type; | |||||
| UI_add_region_handlers(&ar->handlers); | uiBlock *block_old = ar->uiblocks.first; | ||||
| uiBlock *block; | |||||
| /* XXX, needed since refreshing existing popups shouldn't follow the mouse. | |||||
| * we could pass coords to uiEndBlock as an alternative */ | |||||
| copy_v2_v2_int(event_xy, &window->eventstate->x); | |||||
| copy_v2_v2_int(&window->eventstate->x, handle->popup_create_vars.event_xy); | |||||
| /* create ui block */ | /* create ui block */ | ||||
| if (create_func) | if (create_func) | ||||
| block = create_func(C, handle->region, arg); | block = create_func(C, ar, arg); | ||||
| else | else | ||||
| block = handle_create_func(C, handle, arg); | block = handle_create_func(C, handle, arg); | ||||
| /* callbacks _must_ leave this for us, otherwise we can't call uiBlockUpdateFromOld */ | |||||
| BLI_assert(!block->endblock); | |||||
| if (block->handle) { | if (block->handle) { | ||||
| memcpy(block->handle, handle, sizeof(uiPopupBlockHandle)); | memcpy(block->handle, handle, sizeof(uiPopupBlockHandle)); | ||||
| MEM_freeN(handle); | MEM_freeN(handle); | ||||
| Context not available. | |||||
| block->flag |= UI_BLOCK_LOOP; | block->flag |= UI_BLOCK_LOOP; | ||||
| /* defer this until blocks are translated (below) */ | |||||
| block->oldblock = NULL; | |||||
| if (!block->endblock) | if (!block->endblock) | ||||
| uiEndBlock(C, block); | uiEndBlock(C, block); | ||||
| Context not available. | |||||
| handle->direction = block->direction; | handle->direction = block->direction; | ||||
| } | } | ||||
| else { | else { | ||||
| uiSafetyRct *saferct; | |||||
| /* keep a list of these, needed for pulldown menus */ | /* keep a list of these, needed for pulldown menus */ | ||||
| saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct"); | saferct = MEM_callocN(sizeof(uiSafetyRct), "uiSafetyRct"); | ||||
| saferct->safety = block->safety; | saferct->safety = block->safety; | ||||
| Context not available. | |||||
| ui_block_translate(block, -ar->winrct.xmin, -ar->winrct.ymin); | ui_block_translate(block, -ar->winrct.xmin, -ar->winrct.ymin); | ||||
| /* adds subwindow */ | if (block_old) { | ||||
| ED_region_init(C, ar); | block->oldblock = block_old; | ||||
| uiBlockUpdateFromOld(C, block); | |||||
| uiFreeInactiveBlocks(C, &ar->uiblocks); | |||||
| } | |||||
| /* checks which buttons are visible, sets flags to prevent draw (do after region init) */ | /* checks which buttons are visible, sets flags to prevent draw (do after region init) */ | ||||
| ui_popup_block_scrolltest(block); | ui_popup_block_scrolltest(block); | ||||
| /* adds subwindow */ | |||||
| ED_region_init(C, ar); | |||||
| /* get winmat now that we actually have the subwindow */ | /* get winmat now that we actually have the subwindow */ | ||||
| wmSubWindowSet(window, ar->swinid); | wmSubWindowSet(window, ar->swinid); | ||||
| Context not available. | |||||
| /* notify change and redraw */ | /* notify change and redraw */ | ||||
| ED_region_tag_redraw(ar); | ED_region_tag_redraw(ar); | ||||
| ED_region_update_rect(C, ar); | |||||
| copy_v2_v2_int(&window->eventstate->x, event_xy); | |||||
| return block; | |||||
| } | |||||
| uiPopupBlockHandle *ui_popup_block_create(bContext *C, ARegion *butregion, uiBut *but, | |||||
| uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, | |||||
| void *arg) | |||||
| { | |||||
| wmWindow *window = CTX_wm_window(C); | |||||
| static ARegionType type; | |||||
| ARegion *ar; | |||||
| uiBlock *block; | |||||
| uiPopupBlockHandle *handle; | |||||
| /* create handle */ | |||||
| handle = MEM_callocN(sizeof(uiPopupBlockHandle), "uiPopupBlockHandle"); | |||||
| /* store context for operator */ | |||||
| handle->ctx_area = CTX_wm_area(C); | |||||
| handle->ctx_region = CTX_wm_region(C); | |||||
| /* store vars to refresh popup (RGN_DRAW_REFRESH_UI) */ | |||||
| handle->popup_create_vars.create_func = create_func; | |||||
| handle->popup_create_vars.handle_create_func = handle_create_func; | |||||
| handle->popup_create_vars.arg = arg; | |||||
| handle->popup_create_vars.butregion = but ? butregion : NULL; | |||||
| copy_v2_v2_int(handle->popup_create_vars.event_xy, &window->eventstate->x); | |||||
| /* create area region */ | |||||
| ar = ui_add_temporary_region(CTX_wm_screen(C)); | |||||
| handle->region = ar; | |||||
| memset(&type, 0, sizeof(ARegionType)); | |||||
| type.draw = ui_block_region_draw; | |||||
| type.regionid = RGN_TYPE_TEMPORARY; | |||||
| ar->type = &type; | |||||
| UI_add_region_handlers(&ar->handlers); | |||||
| block = ui_popup_block_refresh(C, handle, butregion, but); | |||||
| handle = block->handle; | |||||
| return handle; | return handle; | ||||
| } | } | ||||
| void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle) | void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle) | ||||
| { | { | ||||
| ui_remove_temporary_region(C, CTX_wm_screen(C), handle->region); | ui_popup_block_remove(C, handle); | ||||
| if (handle->scrolltimer) | |||||
| WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), handle->scrolltimer); | |||||
| MEM_freeN(handle); | MEM_freeN(handle); | ||||
| } | } | ||||
| Context not available. | |||||
| if (pup->slideout) | if (pup->slideout) | ||||
| uiBlockSetDirection(block, UI_RIGHT); | uiBlockSetDirection(block, UI_RIGHT); | ||||
| uiEndBlock(C, block); | |||||
| return pup->block; | return pup->block; | ||||
| } | } | ||||
| Context not available. | |||||