diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-03-25 23:49:15 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-03-25 23:49:15 +0300 |
commit | d93fd9ffc132cf094dec0d3c65bd0726718c66a5 (patch) | |
tree | 6d4206f183f06c37f1d61138ddf777bdfb9a16e5 /source/blender/editors/interface | |
parent | 985a4c1e5ed9c00face5bcf69048bf108ff99aaf (diff) |
UI:
* Screen level regions created for menus are now a separate
CTX_wm_menu in the context, so they don't interfere with
existing regions.
* Fix context in popup menus to always come from the area
and region the popup was opened from.
* Removed some unused context stuff: tasks and reports.
The places that were using context reports were using it
wrong anyway.
* Fix F6 closing immediately after editing a button, by
making uiBlockSetFlag not clear existing flags anymore.
* Don't use ":" in boolean X/Y/Z buttons.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 23 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 49 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 23 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 6 |
4 files changed, 65 insertions, 36 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2f78c4e8fff..5bb7ca05fee 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -634,9 +634,14 @@ void uiEndBlock(const bContext *C, uiBlock *block) void uiDrawBlock(const bContext *C, uiBlock *block) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar; uiBut *but; + /* get menu region or area region */ + ar= CTX_wm_menu(C); + if(!ar) + ar= CTX_wm_region(C); + if(!block->endblock) uiEndBlock(C, block); @@ -646,11 +651,11 @@ void uiDrawBlock(const bContext *C, uiBlock *block) if(block->flag & UI_BLOCK_LOOP) uiDrawMenuBox(block->minx, block->miny, block->maxx, block->maxy, block->flag, block->direction); else if(block->panel) - ui_draw_panel(CTX_wm_region(C), block); + ui_draw_panel(ar, block); if(block->drawextra) block->drawextra(C, block); - for (but= block->buttons.first; but; but= but->next) + for(but= block->buttons.first; but; but= but->next) ui_draw_but(ar, but); ui_draw_links(block); @@ -2306,7 +2311,11 @@ uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, char *str, short x1, if(prop) { but->rnapoin= *ptr; but->rnaprop= prop; - but->rnaindex= index; + + if(RNA_property_array_length(&but->rnapoin, but->rnaprop)) + but->rnaindex= index; + else + but->rnaindex= 0; } if (!prop || !RNA_property_editable(&but->rnapoin, prop)) { @@ -2851,7 +2860,11 @@ void uiBlockFlipOrder(uiBlock *block) void uiBlockSetFlag(uiBlock *block, int flag) { - block->flag= flag; + block->flag|= flag; +} +void uiBlockClearFlag(uiBlock *block, int flag) +{ + block->flag&= ~flag; } void uiBlockSetXOfs(uiBlock *block, int xofs) { diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index d7437565c9d..de1d14c14c6 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -2642,16 +2642,17 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) /* verify if we can edit this button */ if(ELEM(event->type, LEFTMOUSE, RETKEY)) { + /* this should become disabled button .. */ if(but->lock) { if(but->lockstr) { - BKE_report(CTX_reports(C), RPT_WARNING, but->lockstr); + BKE_report(NULL, RPT_WARNING, but->lockstr); button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } } else if(but->pointype && but->poin==0) { /* there's a pointer needed */ - BKE_reportf(CTX_reports(C), RPT_WARNING, "DoButton pointer error: %s", but->str); + BKE_reportf(NULL, RPT_WARNING, "DoButton pointer error: %s", but->str); button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } @@ -3306,20 +3307,20 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men return menu->dotowards; } - /* verify that we are moving closer towards one of the edges - * of the menu block, in other words, in the triangle formed - * by the initial mouse location and two edge points. */ - p1[0]= block->minx; - p1[1]= block->miny; + /* verify that we are moving towards one of the edges of the + * menu block, in other words, in the triangle formed by the + * initial mouse location and two edge points. */ + p1[0]= block->minx-20; + p1[1]= block->miny-20; - p2[0]= block->maxx; - p2[1]= block->miny; + p2[0]= block->maxx+20; + p2[1]= block->miny-20; - p3[0]= block->maxx; - p3[1]= block->maxy; + p3[0]= block->maxx+20; + p3[1]= block->maxy+20; - p4[0]= block->minx; - p4[1]= block->maxy; + p4[0]= block->minx-20; + p4[1]= block->maxy+20; oldp[0]= menu->towardsx; oldp[1]= menu->towardsy; @@ -3327,11 +3328,14 @@ static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *men newp[0]= mx; newp[1]= my; + if(Vec2Lenf(oldp, newp) < 4.0f) + return menu->dotowards; + closer= 0; - closer |= (PdistVL2Dfl(newp, p1, p2) < PdistVL2Dfl(oldp, p1, p2) + 4); - closer |= (PdistVL2Dfl(newp, p2, p3) < PdistVL2Dfl(oldp, p2, p3) + 4); - closer |= (PdistVL2Dfl(newp, p3, p4) < PdistVL2Dfl(oldp, p3, p4) + 4); - closer |= (PdistVL2Dfl(newp, p4, p1) < PdistVL2Dfl(oldp, p4, p1) + 4); + closer |= IsectPT2Df(newp, oldp, p1, p2); + closer |= IsectPT2Df(newp, oldp, p2, p3); + closer |= IsectPT2Df(newp, oldp, p3, p4); + closer |= IsectPT2Df(newp, oldp, p4, p1); if(!closer) menu->dotowards= 0; @@ -3398,7 +3402,7 @@ int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle *menu, else but= ui_but_first(block); } - if(but && but->type==BLOCK) + if(but && ELEM(but->type, BLOCK, HMENU)) ui_handle_button_activate(C, ar, but, BUTTON_ACTIVATE_OPEN); } @@ -3720,7 +3724,10 @@ static int ui_handler_region_menu(bContext *C, wmEvent *event, void *userdata) /* here we handle buttons at the window level, modal, for example * while number sliding, text editing, or when a menu block is open */ - ar= CTX_wm_region(C); + ar= CTX_wm_menu(C); + if(!ar) + ar= CTX_wm_region(C); + but= ui_but_find_activated(ar); if(but) { @@ -3811,8 +3818,8 @@ void UI_add_region_handlers(ListBase *handlers) WM_event_add_ui_handler(NULL, handlers, ui_handler_region, ui_handler_remove_region, NULL); } -void UI_add_popup_handlers(ListBase *handlers, uiPopupBlockHandle *menu) +void UI_add_popup_handlers(bContext *C, ListBase *handlers, uiPopupBlockHandle *menu) { - WM_event_add_ui_handler(NULL, handlers, ui_handler_popup, ui_handler_remove_popup, menu); + WM_event_add_ui_handler(C, handlers, ui_handler_popup, ui_handler_remove_popup, menu); } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 0abf952a8a4..ea26bafc1f8 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -210,19 +210,28 @@ static void ui_item_array(uiBlock *block, uiItemRNA *rnaitem, int len, int x, in } else if(len <= 4 && ELEM3(subtype, PROP_ROTATION, PROP_VECTOR, PROP_COLOR)) { /* layout for known array subtypes */ - static char *vectoritem[4]= {"X:", "Y:", "Z:", "W:"}; - static char *quatitem[4]= {"W:", "X:", "Y:", "Z:"}; - static char *coloritem[4]= {"R:", "G:", "B:", "A:"}; + static char vectoritem[4]= {'X', 'Y', 'Z', 'W'}; + static char quatitem[4]= {'W', 'X', 'Y', 'Z'}; + static char coloritem[4]= {'R', 'G', 'B', 'A'}; + char str[3]; for(a=0; a<len; a++) { if(len == 4 && subtype == PROP_ROTATION) - name= quatitem[a]; + str[0]= quatitem[a]; else if(subtype == PROP_VECTOR || subtype == PROP_ROTATION) - name= vectoritem[a]; + str[0]= vectoritem[a]; else - name= coloritem[a]; + str[0]= coloritem[a]; - uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, name, 0, x, y+(len-a-1)*YIC, w, YIC); + if(type == PROP_BOOLEAN) { + str[1]= '\0'; + } + else { + str[1]= ':'; + str[2]= '\0'; + } + + uiDefAutoButR(block, &rnaitem->ptr, rnaitem->prop, a, str, 0, x, y+(len-a-1)*YIC, w, YIC); } } else { diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 06fddc48013..f9a7934d5b3 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2223,7 +2223,7 @@ void uiPupMenuEnd(bContext *C, uiMenuItem *head) menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_MENU_ITEM, &info); menu->popup= 1; - UI_add_popup_handlers(&window->handlers, menu); + UI_add_popup_handlers(C, &window->handlers, menu); WM_event_add_mousemove(C); BLI_freelistN(&head->items); @@ -2248,7 +2248,7 @@ static uiPopupBlockHandle *ui_pup_menu(bContext *C, int maxrow, uiMenuHandleFunc menu= ui_popup_block_create(C, NULL, NULL, NULL, ui_block_func_PUPMENU, &info); menu->popup= 1; - UI_add_popup_handlers(&window->handlers, menu); + UI_add_popup_handlers(C, &window->handlers, menu); WM_event_add_mousemove(C); menu->popup_func= func; @@ -2399,7 +2399,7 @@ void uiPupBlockO(bContext *C, uiBlockCreateFunc func, void *arg, char *opname, i handle->opname= opname; handle->opcontext= opcontext; - UI_add_popup_handlers(&window->handlers, handle); + UI_add_popup_handlers(C, &window->handlers, handle); WM_event_add_mousemove(C); } |