diff options
Diffstat (limited to 'source/blender/editors/interface/interface_panel.c')
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 84 |
1 files changed, 44 insertions, 40 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index bf4a2a49fcb..61694b859c5 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -39,8 +39,6 @@ #include "BLI_blenlib.h" #include "BLI_math.h" -#include "DNA_screen_types.h" -#include "DNA_space_types.h" #include "DNA_userdef_types.h" #include "BKE_context.h" @@ -56,7 +54,6 @@ #include "ED_screen.h" #include "UI_interface.h" -#include "UI_view2d.h" #include "interface_intern.h" @@ -288,32 +285,6 @@ void uiEndPanel(uiBlock *block, int width, int height) } } -#if 0 -void uiPanelToMouse(const bContext *C, Panel *pa) -{ - /* global control over this feature; UI_PNL_TO_MOUSE only called for hotkey panels */ - if(U.uiflag & USER_PANELPINNED); - else if(pa->control & UI_PNL_TO_MOUSE) { - int mx, my; - - mx= CTX_wm_window(C)->eventstate->x; - my= CTX_wm_window(C)->eventstate->y; - - pa->ofsx= mx-pa->sizex/2; - pa->ofsy= my-pa->sizey/2; - - if(pa->flag & PNL_CLOSED) pa->flag &= ~PNL_CLOSED; - } - - if(pa->control & UI_PNL_UNSTOW) { - if(pa->flag & PNL_CLOSEDY) { - pa->flag &= ~PNL_CLOSED; - } - } -} -#endif - - static void ui_offset_panel_block(uiBlock *block) { uiStyle *style= U.uistyles.first; @@ -659,6 +630,10 @@ static int find_highest_panel(const void *a1, const void *a2) { const PanelSort *ps1=a1, *ps2=a2; + /* stick uppermost header-less panels to the top of the region - + * prevent them from being sorted */ + if (ps1->pa->sortorder < ps2->pa->sortorder && ps1->pa->type->flag & PNL_NO_HEADER) return -1; + if(ps1->pa->ofsy+ps1->pa->sizey < ps2->pa->ofsy+ps2->pa->sizey) return 1; else if(ps1->pa->ofsy+ps1->pa->sizey > ps2->pa->ofsy+ps2->pa->sizey) return -1; else if(ps1->pa->sortorder > ps2->pa->sortorder) return 1; @@ -802,7 +777,7 @@ void uiBeginPanels(const bContext *C, ARegion *ar) { Panel *pa; - /* set all panels as inactive, so that at the end we know + /* set all panels as inactive, so that at the end we know * which ones were used */ for(pa=ar->panels.first; pa; pa=pa->next) { if(pa->runtime_flag & PNL_ACTIVE) @@ -867,6 +842,8 @@ void uiEndPanels(const bContext *C, ARegion *ar) if(firstpa) firstpa->runtime_flag |= PNL_FIRST; + UI_ThemeClearColor(TH_BACK); + /* draw panels, selected on top */ for(block= ar->uiblocks.first; block; block=block->next) { if(block->active && block->panel && !(block->panel->flag & PNL_SELECT)) { @@ -957,7 +934,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); @@ -969,7 +946,11 @@ 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(event==AKEY) + button= 1; + else if(block->panel->flag & PNL_CLOSEDX) { if(my >= block->maxy) button= 1; } else if(block->panel->control & UI_PNL_CLOSE) { @@ -1022,6 +1003,9 @@ 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); @@ -1030,11 +1014,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; @@ -1052,7 +1031,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 && !ELEM4(1, event->ctrl, event->oskey, event->shift, event->alt)) { + + 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) { @@ -1069,9 +1066,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, RETKEY); + break; + } + } + else if(event->type == LEFTMOUSE) { if(inside_header) { - ui_handle_panel_header(C, block, mx, my); + ui_handle_panel_header(C, block, mx, my, 0); break; } else if(inside_scale && !(pa->flag & PNL_CLOSED)) { |