diff options
Diffstat (limited to 'source/blender/editors/interface/interface_panel.c')
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 278f7c026b1..72076175ad5 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -69,6 +69,8 @@ #define PNL_ACTIVE 2 #define PNL_WAS_ACTIVE 4 #define PNL_ANIM_ALIGN 8 +#define PNL_NEW_ADDED 16 +#define PNL_FIRST 32 typedef enum uiHandlePanelState { PANEL_STATE_DRAG, @@ -157,18 +159,20 @@ static void ui_panel_copy_offset(Panel *pa, Panel *papar) pa->ofsy= papar->ofsy + papar->sizey-pa->sizey; } -Panel *uiBeginPanel(ARegion *ar, uiBlock *block, PanelType *pt, int *open) +Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int *open) { uiStyle *style= U.uistyles.first; Panel *pa, *patab, *palast, *panext; - char *panelname= pt->label; - char *tabname= pt->label; + char *drawname= pt->label; + char *idname= pt->idname; + char *tabname= pt->idname; char *hookname= NULL; int newpanel; + int align= panel_aligned(sa, ar); /* check if Panel exists, then use that one */ for(pa=ar->panels.first; pa; pa=pa->next) - if(strncmp(pa->panelname, panelname, UI_MAX_NAME_STR)==0) + if(strncmp(pa->panelname, idname, UI_MAX_NAME_STR)==0) if(strncmp(pa->tabname, tabname, UI_MAX_NAME_STR)==0) break; @@ -181,13 +185,21 @@ Panel *uiBeginPanel(ARegion *ar, uiBlock *block, PanelType *pt, int *open) /* new panel */ pa= MEM_callocN(sizeof(Panel), "new panel"); pa->type= pt; - BLI_strncpy(pa->panelname, panelname, UI_MAX_NAME_STR); + BLI_strncpy(pa->panelname, idname, UI_MAX_NAME_STR); BLI_strncpy(pa->tabname, tabname, UI_MAX_NAME_STR); + + if(pt->flag & PNL_DEFAULT_CLOSED) { + if(align == BUT_VERTICAL) + pa->flag |= PNL_CLOSEDY; + else + pa->flag |= PNL_CLOSEDX; + } pa->ofsx= 0; pa->ofsy= style->panelouter; pa->sizex= 0; pa->sizey= 0; + pa->runtime_flag |= PNL_NEW_ADDED; BLI_addtail(&ar->panels, pa); @@ -207,6 +219,8 @@ Panel *uiBeginPanel(ARegion *ar, uiBlock *block, PanelType *pt, int *open) } } + BLI_strncpy(pa->drawname, drawname, UI_MAX_NAME_STR); + /* if a new panel is added, we insert it right after the panel * that was last added. this way new panels are inserted in the * right place between versions */ @@ -235,7 +249,6 @@ Panel *uiBeginPanel(ARegion *ar, uiBlock *block, PanelType *pt, int *open) if(pa->flag & PNL_CLOSED) return pa; *open= 1; - pa->drawname[0]= 0; /* otherwise closes panels show wrong title */ return pa; } @@ -244,13 +257,20 @@ void uiEndPanel(uiBlock *block, int width, int height) { Panel *pa= block->panel; - if(pa->sizex != width || pa->sizey != height) { - pa->runtime_flag |= PNL_ANIM_ALIGN; - pa->ofsy += pa->sizey-height; + if(pa->runtime_flag & PNL_NEW_ADDED) { + pa->runtime_flag &= ~PNL_NEW_ADDED; + pa->sizex= width; + pa->sizey= height; } + else if(!(width == 0 || height == 0)) { + if(pa->sizex != width || pa->sizey != height) { + pa->runtime_flag |= PNL_ANIM_ALIGN; + pa->ofsy += pa->sizey-height; + } - pa->sizex= width; - pa->sizey= height; + pa->sizex= width; + pa->sizey= height; + } } #if 0 @@ -509,7 +529,7 @@ static void rectf_scale(rctf *rect, float scale) /* panel integrated in buttonswindow, tool/property lists etc */ void ui_draw_aligned_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) { - Panel *panel= block->panel, *prev; + Panel *panel= block->panel; rcti headrect; rctf itemrect; int ofsx; @@ -522,14 +542,7 @@ void ui_draw_aligned_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *re headrect.ymin= headrect.ymax; headrect.ymax= headrect.ymin + floor(PNL_HEADER/block->aspect + 0.001f); - /* divider only when there's a previous panel */ - prev= panel->prev; - while(prev) { - if(prev->runtime_flag & PNL_ACTIVE) break; - prev= prev->prev; - } - - if(panel->sortorder != 0) { + if(!(panel->runtime_flag & PNL_FIRST)) { float minx= rect->xmin+5.0f/block->aspect; float maxx= rect->xmax-5.0f/block->aspect; float y= headrect.ymax; @@ -829,7 +842,7 @@ void uiEndPanels(const bContext *C, ARegion *ar) { ScrArea *sa= CTX_wm_area(C); uiBlock *block; - Panel *panot, *panew, *patest, *pa; + Panel *panot, *panew, *patest, *pa, *firstpa; /* offset contents */ for(block= ar->uiblocks.first; block; block= block->next) @@ -869,6 +882,16 @@ void uiEndPanels(const bContext *C, ARegion *ar) uiAlignPanelStep(sa, ar, 1.0, 0); } + /* tag first panel */ + firstpa= NULL; + for(block= ar->uiblocks.first; block; block=block->next) + if(block->active && block->panel) + if(!firstpa || block->panel->sortorder < firstpa->sortorder) + firstpa= block->panel; + + if(firstpa) + firstpa->runtime_flag |= PNL_FIRST; + /* draw panels, selected on top */ for(block= ar->uiblocks.first; block; block=block->next) { if(block->active && block->panel && !(block->panel->flag & PNL_SELECT)) { |