Button panels need to get handlers and keymaps... but for now sneaked

in a handy key : Akey in buttons window on a panel will
open or close it.
This commit is contained in:
Ton Roosendaal 2010-04-12 17:45:51 +00:00
parent 919565f196
commit 7814d42ec7
2 changed files with 24 additions and 8 deletions

@ -5587,8 +5587,7 @@ static int ui_handler_region(bContext *C, wmEvent *event, void *userdata)
/* either handle events for already activated button or try to activate */
but= ui_but_find_activated(ar);
if(!but || !button_modal_state(but->active->state))
retval= ui_handler_panel_region(C, event);
retval= ui_handler_panel_region(C, event);
if(retval == WM_UI_HANDLER_CONTINUE)
retval= ui_handle_list_event(C, event, ar);

@ -970,6 +970,8 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
/* check open/collapsed button */
if(event==RETKEY)
button= 1;
else if(event==AKEY)
button= 1;
else if(block->panel->flag & PNL_CLOSEDX) {
if(my >= block->maxy) button= 1;
}
@ -1024,6 +1026,8 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
}
/* XXX should become modal keymap */
/* AKey is opening/closing panels, independent of button state now */
int ui_handler_panel_region(bContext *C, wmEvent *event)
{
ARegion *ar= CTX_wm_region(C);
@ -1032,11 +1036,6 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
int retval, mx, my, inside_header= 0, inside_scale= 0, inside;
retval= WM_UI_HANDLER_CONTINUE;
/* buttons get priority */
if(ui_button_is_active(ar))
return retval;
for(block=ar->uiblocks.last; block; block=block->prev) {
mx= event->x;
my= event->y;
@ -1054,7 +1053,25 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
if(block->minx <= mx && block->maxx >= mx)
if(block->miny <= my && block->maxy+PNL_HEADER >= my)
inside= 1;
if(inside && event->val==KM_PRESS) {
if(event->type == AKEY) {
if(pa->flag & PNL_CLOSEDY) {
if((block->maxy <= my) && (block->maxy+PNL_HEADER >= my))
ui_handle_panel_header(C, block, mx, my, event->type);
}
else
ui_handle_panel_header(C, block, mx, my, event->type);
continue;
}
}
/* on active button, do not handle panels */
if(ui_button_is_active(ar))
continue;
if(inside) {
/* clicked at panel header? */
if(pa->flag & PNL_CLOSEDX) {