UI: added support for enable buttons in the panel header.
This commit is contained in:
@@ -297,16 +297,16 @@ static void ui_offset_panel_block(uiBlock *block)
|
||||
{
|
||||
uiStyle *style= U.uistyles.first;
|
||||
uiBut *but;
|
||||
int space= style->panelspace;
|
||||
int ofsy;
|
||||
|
||||
/* buttons min/max centered, offset calculated */
|
||||
/* compute bounds and offset */
|
||||
ui_bounds_block(block);
|
||||
|
||||
ofsy= block->panel->sizey - style->panelspace;
|
||||
|
||||
for(but= block->buttons.first; but; but=but->next) {
|
||||
but->x1= space + (but->x1-block->minx);
|
||||
but->y1= space + (but->y1-block->miny);
|
||||
but->x2= space + (but->x2-block->minx);
|
||||
but->y2= space + (but->y2-block->miny);
|
||||
but->y1 += ofsy;
|
||||
but->y2 += ofsy;
|
||||
}
|
||||
|
||||
block->maxx= block->panel->sizex;
|
||||
@@ -453,6 +453,8 @@ static void ui_draw_aligned_panel_header(ARegion *ar, uiStyle *style, uiBlock *b
|
||||
/* + 0.001f to avoid flirting with float inaccuracy */
|
||||
if(panel->control & UI_PNL_CLOSE) pnl_icons=(2*PNL_ICON+5)/block->aspect + 0.001f;
|
||||
else pnl_icons= (PNL_ICON+5)/block->aspect + 0.001f;
|
||||
|
||||
pnl_icons += panel->labelofs;
|
||||
|
||||
if(nr==1) {
|
||||
|
||||
@@ -831,7 +833,7 @@ void uiEndPanels(const bContext *C, ARegion *ar)
|
||||
uiBlock *block;
|
||||
Panel *panot, *panew, *patest, *pa;
|
||||
|
||||
/* scaling contents */
|
||||
/* offset contents */
|
||||
for(block= ar->uiblocks.first; block; block= block->next)
|
||||
if(block->active && block->panel)
|
||||
ui_offset_panel_block(block);
|
||||
|
||||
@@ -968,7 +968,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
|
||||
Panel *panel;
|
||||
View2D *v2d= &ar->v2d;
|
||||
float col[3];
|
||||
int xco, yco, x, y, miny=0, w, em, header, open;
|
||||
int xco, yco, x, y, miny=0, w, em, header, triangle, open;
|
||||
|
||||
if(vertical) {
|
||||
w= v2d->cur.xmax - v2d->cur.xmin;
|
||||
@@ -980,6 +980,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
|
||||
}
|
||||
|
||||
header= 20; // XXX
|
||||
triangle= 22;
|
||||
x= 0;
|
||||
y= -style->panelouter;
|
||||
|
||||
@@ -1003,18 +1004,17 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, char *contex
|
||||
if(vertical)
|
||||
y -= header;
|
||||
|
||||
/* XXX enable buttons test */
|
||||
#if 0
|
||||
panel->layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
|
||||
header+style->panelspace, header+style->panelspace, header, 1, style);
|
||||
if(pt->draw_header) {
|
||||
/* for enabled buttons */
|
||||
panel->layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER,
|
||||
triangle, header+style->panelspace, header, 1, style);
|
||||
|
||||
if(pt->draw_header)
|
||||
pt->draw_header(C, panel);
|
||||
else
|
||||
uiItemL(panel->layout, pt->label, 0);
|
||||
|
||||
panel->layout= NULL;
|
||||
#endif
|
||||
uiBlockLayoutResolve(C, block, &xco, &yco);
|
||||
panel->labelofs= xco - triangle;
|
||||
panel->layout= NULL;
|
||||
}
|
||||
|
||||
if(open) {
|
||||
panel->type= pt;
|
||||
@@ -1143,6 +1143,5 @@ void ED_region_header(const bContext *C, ARegion *ar)
|
||||
void ED_region_header_init(ARegion *ar)
|
||||
{
|
||||
UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
|
||||
ar->v2d.flag &= ~(V2D_PIXELOFS_X|V2D_PIXELOFS_Y); // XXX temporary
|
||||
}
|
||||
|
||||
|
||||
@@ -97,10 +97,11 @@ typedef struct Panel { /* the part from uiBlock that needs saved in file */
|
||||
char panelname[64], tabname[64]; /* defined as UI_MAX_NAME_STR */
|
||||
char drawname[64]; /* panelname is identifier for restoring location */
|
||||
short ofsx, ofsy, sizex, sizey;
|
||||
short labelofs, pad;
|
||||
short flag, runtime_flag;
|
||||
short control;
|
||||
short snap;
|
||||
int sortorder, pad; /* panels are aligned according to increasing sortorder */
|
||||
int sortorder; /* panels are aligned according to increasing sortorder */
|
||||
struct Panel *paneltab; /* this panel is tabbed in *paneltab */
|
||||
void *activedata; /* runtime for panel manipulation */
|
||||
} Panel;
|
||||
|
||||
Reference in New Issue
Block a user