Long outstanding panel feature: press ENTER with mouse on header will

open/close it. Will allow quicker inspections without mouse strains.
This commit is contained in:
Ton Roosendaal 2010-04-11 11:52:39 +00:00
parent 5c24ce16b2
commit 4c5fe03c9f

@ -956,7 +956,7 @@ static void ui_do_drag(const bContext *C, wmEvent *event, Panel *panel)
/* this function is supposed to call general window drawing too */
/* also it supposes a block has panel, and isnt a menu */
static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, int my)
static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, int my, int event)
{
ScrArea *sa= CTX_wm_area(C);
ARegion *ar= CTX_wm_region(C);
@ -968,7 +968,9 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
/* XXX weak code, currently it assumes layout style for location of widgets */
/* check open/collapsed button */
if(block->panel->flag & PNL_CLOSEDX) {
if(event==RETKEY)
button= 1;
else if(block->panel->flag & PNL_CLOSEDX) {
if(my >= block->maxy) button= 1;
}
else if(block->panel->control & UI_PNL_CLOSE) {
@ -1021,6 +1023,7 @@ static void ui_handle_panel_header(const bContext *C, uiBlock *block, int mx, in
}
}
/* XXX should become modal keymap */
int ui_handler_panel_region(bContext *C, wmEvent *event)
{
ARegion *ar= CTX_wm_region(C);
@ -1068,9 +1071,16 @@ int ui_handler_panel_region(bContext *C, wmEvent *event)
}
if(event->val==KM_PRESS) {
if(event->type == LEFTMOUSE) {
/* open close on header */
if(ELEM(event->type, RETKEY, PADENTER)) {
if(inside_header) {
ui_handle_panel_header(C, block, mx, my);
ui_handle_panel_header(C, block, mx, my, RETKEY);
break;
}
}
else if(event->type == LEFTMOUSE) {
if(inside_header) {
ui_handle_panel_header(C, block, mx, my, 0);
break;
}
else if(inside_scale && !(pa->flag & PNL_CLOSED)) {