diff options
author | Ton Roosendaal <ton@blender.org> | 2009-04-12 17:40:29 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-04-12 17:40:29 +0400 |
commit | 5cb480cef44bc4ec3d191f114622af04bba6285d (patch) | |
tree | 788654e26024cfacb0431314d716362bd317f4f1 /source/blender/editors/interface | |
parent | 1fec143198d34dd50a55ef313f2daf55a75cd414 (diff) |
2.5
Various ui fixes:
- panel drawing now correctly follows scaled view
- made imagewindow buttons using TH_PANEL color back (was too dark)
- click on open/close panel was wrong
- menu items disabling now draws correct
- curve/hsv widgets didn't draw on right locations
- numsliders have nicer interior slider decoration
- new type TOGBUT to enforce old style toggle button (not new type
'option button' with checkmark
- (temp) disabled live updating while using Curve widget, was
too slow to be fun. Needs general solution :)
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 130 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 107 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 55 |
6 files changed, 181 insertions, 124 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index a41fa2d5cb5..3ce658a174f 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -710,7 +710,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block) glPushMatrix(); glLoadIdentity(); - wmOrtho2(0.0f, ar->winx, 0.0f, ar->winy); + wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); /* back */ if(block->flag & UI_BLOCK_LOOP) @@ -760,6 +760,7 @@ static void ui_is_but_sel(uiBut *but) case KEYEVT: if (value==-1) push= 1; break; + case TOGBUT: case TOG: case TOGR: case TOG3: diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index fd99e6b84a0..8dba795d2cf 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -509,17 +509,17 @@ static void ui_draw_but_CHARTAB(uiBut *but) charmax = G.charmax = 0xffff; /* Calculate the size of the button */ - width = abs(but->x2 - but->x1); - height = abs(but->y2 - but->y1); + width = abs(rect->xmax - rect->xmin); + height = abs(rect->ymax - rect->ymin); butw = floor(width / 12); buth = floor(height / 6); /* Initialize variables */ - sx = but->x1; - ex = but->x1 + butw; - sy = but->y1 + height - buth; - ey = but->y1 + height; + sx = rect->xmin; + ex = rect->xmin + butw; + sy = rect->ymin + height - buth; + ey = rect->ymin + height; cs = G.charstart; @@ -555,7 +555,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) glShadeModel(GL_SMOOTH); glColor3ub(200, 200, 200); - glRectf((but->x1), (but->y1), (but->x2), (but->y2)); + glRectf((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax)); glColor3ub(0, 0, 0); for(y = 0; y < 6; y++) @@ -633,8 +633,8 @@ static void ui_draw_but_CHARTAB(uiBut *but) /* Add the y position and reset x position */ sy -= buth; ey -= buth; - sx = but->x1; - ex = but->x1 + butw; + sx = rect->xmin; + ex = rect->xmin + butw; } glShadeModel(GL_FLAT); @@ -663,7 +663,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) #endif // INTERNATIONAL #endif -void ui_draw_but_COLORBAND(uiBut *but) +void ui_draw_but_COLORBAND(uiBut *but, rcti *rect) { ColorBand *coba; CBData *cbd; @@ -674,10 +674,10 @@ void ui_draw_but_COLORBAND(uiBut *but) coba= (ColorBand *)(but->editcoba? but->editcoba: but->poin); if(coba==NULL) return; - x1= but->x1; - y1= but->y1; - sizex= but->x2-x1; - sizey= but->y2-y1; + x1= rect->xmin; + y1= rect->ymin; + sizex= rect->xmax-x1; + sizey= rect->ymax-y1; /* first background, to show tranparency */ dx= sizex/12.0; @@ -790,7 +790,7 @@ void ui_draw_but_COLORBAND(uiBut *but) glEnd(); } -void ui_draw_but_NORMAL(uiBut *but) +void ui_draw_but_NORMAL(uiBut *but, rcti *rect) { static GLuint displist=0; int a, old[8]; @@ -804,7 +804,7 @@ void ui_draw_but_NORMAL(uiBut *but) /* backdrop */ UI_ThemeColor(TH_BUT_NEUTRAL); uiSetRoundBox(15); - gl_round_box(GL_POLYGON, but->x1, but->y1, but->x2, but->y2, 5.0f); + gl_round_box(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f); /* sphere color */ glMaterialfv(GL_FRONT, GL_DIFFUSE, diffn); @@ -830,8 +830,8 @@ void ui_draw_but_NORMAL(uiBut *but) /* transform to button */ glPushMatrix(); - glTranslatef(but->x1 + 0.5f*(but->x2-but->x1), but->y1+ 0.5f*(but->y2-but->y1), 0.0f); - size= (but->x2-but->x1)/200.f; + glTranslatef(rect->xmin + 0.5f*(rect->xmax-rect->xmin), rect->ymin+ 0.5f*(rect->ymax-rect->ymin), 0.0f); + size= (rect->xmax-rect->xmin)/200.f; glScalef(size, size, size); if(displist==0) { @@ -866,38 +866,38 @@ void ui_draw_but_NORMAL(uiBut *but) } } -static void ui_draw_but_curve_grid(uiBut *but, float zoomx, float zoomy, float offsx, float offsy, float step) +static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float offsx, float offsy, float step) { float dx, dy, fx, fy; glBegin(GL_LINES); dx= step*zoomx; - fx= but->x1 + zoomx*(-offsx); - if(fx > but->x1) fx -= dx*( floor(fx-but->x1)); - while(fx < but->x2) { - glVertex2f(fx, but->y1); - glVertex2f(fx, but->y2); + fx= rect->xmin + zoomx*(-offsx); + if(fx > rect->xmin) fx -= dx*( floor(fx-rect->xmin)); + while(fx < rect->xmax) { + glVertex2f(fx, rect->ymin); + glVertex2f(fx, rect->ymax); fx+= dx; } dy= step*zoomy; - fy= but->y1 + zoomy*(-offsy); - if(fy > but->y1) fy -= dy*( floor(fy-but->y1)); - while(fy < but->y2) { - glVertex2f(but->x1, fy); - glVertex2f(but->x2, fy); + fy= rect->ymin + zoomy*(-offsy); + if(fy > rect->ymin) fy -= dy*( floor(fy-rect->ymin)); + while(fy < rect->ymax) { + glVertex2f(rect->xmin, fy); + glVertex2f(rect->xmax, fy); fy+= dy; } glEnd(); } -void ui_draw_but_CURVE(ARegion *ar, uiBut *but) +void ui_draw_but_CURVE(ARegion *ar, uiBut *but, rcti *rect) { CurveMapping *cumap; CurveMap *cuma; CurveMapPoint *cmp; - float fx, fy, dx, dy, fac[2], zoomx, zoomy, offsx, offsy; + float fx, fy, fac[2], zoomx, zoomy, offsx, offsy; GLint scissor[4]; int a; @@ -906,46 +906,42 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but) /* need scissor test, curve can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); - fx= but->x1; fy= but->y1; - ui_block_to_window_fl(ar, but->block, &fx, &fy); - dx= but->x2; dy= but->y2; - ui_block_to_window_fl(ar, but->block, &dx, &dy); - glScissor((int)floor(fx), (int)floor(fy), (int)ceil(dx-fx), (int)ceil(dy-fy)); + glScissor(ar->winrct.xmin + rect->xmin, ar->winrct.ymin+rect->ymin, rect->xmax-rect->xmin, rect->ymax-rect->ymin); /* calculate offset and zoom */ - zoomx= (but->x2-but->x1-2.0*but->aspect)/(cumap->curr.xmax - cumap->curr.xmin); - zoomy= (but->y2-but->y1-2.0*but->aspect)/(cumap->curr.ymax - cumap->curr.ymin); + zoomx= (rect->xmax-rect->xmin-2.0*but->aspect)/(cumap->curr.xmax - cumap->curr.xmin); + zoomy= (rect->ymax-rect->ymin-2.0*but->aspect)/(cumap->curr.ymax - cumap->curr.ymin); offsx= cumap->curr.xmin-but->aspect/zoomx; offsy= cumap->curr.ymin-but->aspect/zoomy; /* backdrop */ if(cumap->flag & CUMA_DO_CLIP) { UI_ThemeColorShade(TH_BUT_NEUTRAL, -20); - glRectf(but->x1, but->y1, but->x2, but->y2); + glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); UI_ThemeColor(TH_BUT_NEUTRAL); - glRectf(but->x1 + zoomx*(cumap->clipr.xmin-offsx), - but->y1 + zoomy*(cumap->clipr.ymin-offsy), - but->x1 + zoomx*(cumap->clipr.xmax-offsx), - but->y1 + zoomy*(cumap->clipr.ymax-offsy)); + glRectf(rect->xmin + zoomx*(cumap->clipr.xmin-offsx), + rect->ymin + zoomy*(cumap->clipr.ymin-offsy), + rect->xmin + zoomx*(cumap->clipr.xmax-offsx), + rect->ymin + zoomy*(cumap->clipr.ymax-offsy)); } else { UI_ThemeColor(TH_BUT_NEUTRAL); - glRectf(but->x1, but->y1, but->x2, but->y2); + glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); } /* grid, every .25 step */ UI_ThemeColorShade(TH_BUT_NEUTRAL, -16); - ui_draw_but_curve_grid(but, zoomx, zoomy, offsx, offsy, 0.25f); + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); /* grid, every 1.0 step */ UI_ThemeColorShade(TH_BUT_NEUTRAL, -24); - ui_draw_but_curve_grid(but, zoomx, zoomy, offsx, offsy, 1.0f); + ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f); /* axes */ UI_ThemeColorShade(TH_BUT_NEUTRAL, -50); glBegin(GL_LINES); - glVertex2f(but->x1, but->y1 + zoomy*(-offsy)); - glVertex2f(but->x2, but->y1 + zoomy*(-offsy)); - glVertex2f(but->x1 + zoomx*(-offsx), but->y1); - glVertex2f(but->x1 + zoomx*(-offsx), but->y2); + glVertex2f(rect->xmin, rect->ymin + zoomy*(-offsy)); + glVertex2f(rect->xmax, rect->ymin + zoomy*(-offsy)); + glVertex2f(rect->xmin + zoomx*(-offsx), rect->ymin); + glVertex2f(rect->xmin + zoomx*(-offsx), rect->ymax); glEnd(); /* cfra option */ @@ -953,8 +949,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but) if(cumap->flag & CUMA_DRAW_CFRA) { glColor3ub(0x60, 0xc0, 0x40); glBegin(GL_LINES); - glVertex2f(but->x1 + zoomx*(cumap->sample[0]-offsx), but->y1); - glVertex2f(but->x1 + zoomx*(cumap->sample[0]-offsx), but->y2); + glVertex2f(rect->xmin + zoomx*(cumap->sample[0]-offsx), rect->ymin); + glVertex2f(rect->xmin + zoomx*(cumap->sample[0]-offsx), rect->ymax); glEnd(); }*/ /* sample option */ @@ -965,8 +961,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but) glColor3ub(240, 240, 240); glBegin(GL_LINES); - glVertex2f(but->x1 + zoomx*(lum-offsx), but->y1); - glVertex2f(but->x1 + zoomx*(lum-offsx), but->y2); + glVertex2f(rect->xmin + zoomx*(lum-offsx), rect->ymin); + glVertex2f(rect->xmin + zoomx*(lum-offsx), rect->ymax); glEnd(); } else { @@ -978,8 +974,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but) glColor3ub(100, 100, 240); glBegin(GL_LINES); - glVertex2f(but->x1 + zoomx*(cumap->sample[cumap->cur]-offsx), but->y1); - glVertex2f(but->x1 + zoomx*(cumap->sample[cumap->cur]-offsx), but->y2); + glVertex2f(rect->xmin + zoomx*(cumap->sample[cumap->cur]-offsx), rect->ymin); + glVertex2f(rect->xmin + zoomx*(cumap->sample[cumap->cur]-offsx), rect->ymax); glEnd(); } }*/ @@ -996,23 +992,23 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but) /* first point */ if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) - glVertex2f(but->x1, but->y1 + zoomy*(cmp[0].y-offsy)); + glVertex2f(rect->xmin, rect->ymin + zoomy*(cmp[0].y-offsy)); else { - fx= but->x1 + zoomx*(cmp[0].x-offsx + cuma->ext_in[0]); - fy= but->y1 + zoomy*(cmp[0].y-offsy + cuma->ext_in[1]); + fx= rect->xmin + zoomx*(cmp[0].x-offsx + cuma->ext_in[0]); + fy= rect->ymin + zoomy*(cmp[0].y-offsy + cuma->ext_in[1]); glVertex2f(fx, fy); } for(a=0; a<=CM_TABLE; a++) { - fx= but->x1 + zoomx*(cmp[a].x-offsx); - fy= but->y1 + zoomy*(cmp[a].y-offsy); + fx= rect->xmin + zoomx*(cmp[a].x-offsx); + fy= rect->ymin + zoomy*(cmp[a].y-offsy); glVertex2f(fx, fy); } /* last point */ if((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) - glVertex2f(but->x2, but->y1 + zoomy*(cmp[CM_TABLE].y-offsy)); + glVertex2f(rect->xmax, rect->ymin + zoomy*(cmp[CM_TABLE].y-offsy)); else { - fx= but->x1 + zoomx*(cmp[CM_TABLE].x-offsx - cuma->ext_out[0]); - fy= but->y1 + zoomy*(cmp[CM_TABLE].y-offsy - cuma->ext_out[1]); + fx= rect->xmin + zoomx*(cmp[CM_TABLE].x-offsx - cuma->ext_out[0]); + fy= rect->ymin + zoomy*(cmp[CM_TABLE].y-offsy - cuma->ext_out[1]); glVertex2f(fx, fy); } glEnd(); @@ -1028,8 +1024,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); - fac[0]= but->x1 + zoomx*(cmp[a].x-offsx); - fac[1]= but->y1 + zoomy*(cmp[a].y-offsy); + fac[0]= rect->xmin + zoomx*(cmp[a].x-offsx); + fac[1]= rect->ymin + zoomy*(cmp[a].y-offsy); bglVertex2fv(fac); } bglEnd(); @@ -1040,7 +1036,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but) /* outline */ UI_ThemeColor(TH_BUT_OUTLINE); - fdrawbox(but->x1, but->y1, but->x2, but->y2); + fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 437948c86e8..924d7df8c45 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -564,6 +564,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut case TEX: ui_apply_but_TEX(C, but, data); break; + case TOGBUT: case TOG: case TOGR: case ICONTOG: @@ -2658,6 +2659,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) case KEYEVT: retval= ui_do_but_KEYEVT(C, but, data, event); break; + case TOGBUT: case TOG: case TOGR: case ICONTOG: @@ -2972,7 +2974,7 @@ static void button_activate_init(bContext *C, ARegion *ar, uiBut *but, uiButtonA data= MEM_callocN(sizeof(uiHandleButtonData), "uiHandleButtonData"); data->window= CTX_wm_window(C); data->region= ar; - data->interactive= 1; + data->interactive= but->type==BUT_CURVE?0:1; // XXX temp data->state = BUTTON_STATE_INIT; /* activate button */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index bbc3cac05dd..776f36551c9 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -373,9 +373,9 @@ extern void gl_round_box(int mode, float minx, float miny, float maxx, float max extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadetop, float shadedown); extern void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, float maxy, float rad, float shadeLeft, float shadeRight); -void ui_draw_but_COLORBAND(uiBut *but); -void ui_draw_but_NORMAL(uiBut *but); -void ui_draw_but_CURVE(ARegion *ar, uiBut *but); +void ui_draw_but_COLORBAND(uiBut *but, rcti *rect); +void ui_draw_but_NORMAL(uiBut *but, rcti *rect); +void ui_draw_but_CURVE(ARegion *ar, uiBut *but, rcti *rect); /* interface_handlers.c */ diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 5f365d3d7dc..ea1ab0566a5 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -458,6 +458,19 @@ void ui_draw_tria_icon(float x, float y, char dir) } } +/* triangle 'icon' inside rect */ +void ui_draw_tria_rect(rctf *rect, char dir) +{ + if(dir=='h') { + float half= 0.5f*(rect->ymax - rect->ymin); + ui_draw_anti_tria(rect->xmin, rect->ymin, rect->xmin, rect->ymax, rect->xmax, rect->ymin+half); + } + else { + float half= 0.5f*(rect->xmax - rect->xmin); + ui_draw_anti_tria(rect->xmin, rect->ymax, rect->xmax, rect->ymax, rect->xmin+half, rect->ymin); + } +} + void ui_draw_anti_x(float x1, float y1, float x2, float y2) { @@ -512,15 +525,15 @@ static void ui_draw_panel_scalewidget(rcti *rect) glDisable(GL_BLEND); } -static void ui_draw_panel_dragwidget(rcti *rect) +static void ui_draw_panel_dragwidget(rctf *rect) { float xmin, xmax, dx; float ymin, ymax, dy; - xmin= rect->xmax-10-PNL_HEADER+8; - xmax= rect->xmax-10; - ymin= rect->ymax+4; - ymax= rect->ymax+PNL_HEADER-4; + xmin= rect->xmin; + xmax= rect->xmax; + ymin= rect->ymin; + ymax= rect->ymax; dx= 0.333f*(xmax-xmin); dy= 0.333f*(ymax-ymin); @@ -539,8 +552,9 @@ static void ui_draw_panel_dragwidget(rcti *rect) } -static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, Panel *panel, rcti *rect) +static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) { + Panel *panel= block->panel; Panel *pa; rcti hrect; float width; @@ -548,16 +562,14 @@ static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, Panel *panel char *activename= panel->drawname[0]?panel->drawname:panel->panelname; char *panelname; - ui_draw_panel_dragwidget(rect); - /* count */ for(pa= ar->panels.first; pa; pa=pa->next) if(pa->active) if(pa->paneltab==panel) nr++; - pnl_icons= PNL_ICON+8; - if(panel->control & UI_PNL_CLOSE) pnl_icons+= PNL_ICON; + if(panel->control & UI_PNL_CLOSE) pnl_icons=(2*PNL_ICON+10)/block->aspect; + else pnl_icons= (PNL_ICON+10)/block->aspect; if(nr==1) { @@ -565,17 +577,15 @@ static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, Panel *panel /* draw text label */ UI_ThemeColor(TH_TEXT); + hrect= *rect; hrect.xmin= rect->xmin+pnl_icons; - hrect.ymin= rect->ymax; - hrect.xmax= rect->xmax; - hrect.ymax= rect->ymax + PNL_HEADER; uiStyleFontDraw(&style->paneltitle, &hrect, activename); return; } a= 0; - width= (panel->sizex - 3 - pnl_icons - PNL_ICON)/nr; + width= (rect->xmax-rect->xmin - 3 - pnl_icons - PNL_ICON)/nr; for(pa= ar->panels.first; pa; pa=pa->next) { panelname= pa->drawname[0]?pa->drawname:pa->panelname; @@ -586,10 +596,9 @@ static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, Panel *panel else UI_ThemeColorBlend(TH_TEXT, TH_BACK, 0.5f); + hrect= *rect; hrect.xmin= rect->xmin+pnl_icons + a*width; - hrect.ymin= rect->ymax; hrect.xmax= hrect.xmin + width; - hrect.ymax= hrect.ymin + PNL_HEADER; uiStyleFontDraw(&style->paneltitle, &hrect, panelname); a++; @@ -597,13 +606,33 @@ static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, Panel *panel } } +static void rectf_scale(rctf *rect, float scale) +{ + float centx= 0.5f*(rect->xmin+rect->xmax); + float centy= 0.5f*(rect->ymin+rect->ymax); + float sizex= 0.5f*scale*(rect->xmax - rect->xmin); + float sizey= 0.5f*scale*(rect->ymax - rect->ymin); + + rect->xmin= centx - sizex; + rect->xmax= centx + sizex; + rect->ymin= centy - sizey; + rect->ymax= centy + sizey; +} + void ui_draw_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) { Panel *panel= block->panel, *prev; + rcti headrect; + rctf itemrect; int ofsx; if(panel->paneltab) return; + /* calculate header rect */ + headrect= *rect; + headrect.ymin= headrect.ymax; + headrect.ymax= headrect.ymin + floor(PNL_HEADER/block->aspect); + /* divider only when there's a previous panel */ prev= panel->prev; while(prev) { @@ -612,21 +641,29 @@ void ui_draw_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) } if(prev) { - float minx= rect->xmin+10; - float maxx= rect->xmax-10; - float y= rect->ymax + PNL_HEADER; + float minx= rect->xmin+10.0f/block->aspect; + float maxx= rect->xmax-10.0f/block->aspect; + float y= headrect.ymax; glEnable(GL_BLEND); glColor4f(0.0f, 0.0f, 0.0f, 0.5f); - fdrawline(minx, y, maxx, y); + fdrawline(minx, y+1, maxx, y+1); glColor4f(1.0f, 1.0f, 1.0f, 0.25f); - fdrawline(minx, y-1, maxx, y-1); + fdrawline(minx, y, maxx, y); glDisable(GL_BLEND); } /* title */ if(!(panel->flag & PNL_CLOSEDX)) { - ui_draw_panel_header_style(ar, style, panel, rect); + ui_draw_panel_header_style(ar, style, block, &headrect); + + /* itemrect smaller */ + itemrect.xmax= headrect.xmax - 10.0f/block->aspect; + itemrect.xmin= itemrect.xmax - (headrect.ymax-headrect.ymin); + itemrect.ymin= headrect.ymin; + itemrect.ymax= headrect.ymax; + rectf_scale(&itemrect, 0.8f); + ui_draw_panel_dragwidget(&itemrect); } /* if the panel is minimized vertically: @@ -654,14 +691,14 @@ void ui_draw_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) else uiSetRoundBox(3); UI_ThemeColorShade(TH_HEADER, -120); - uiRoundRect(rect->xmin, rect->ymin, rect->xmax, rect->ymax+PNL_HEADER, 8); + uiRoundRect(rect->xmin, rect->ymin, rect->xmax, headrect.ymax+1, 8); } if(panel->flag & PNL_OVERLAP) { if(panel->control & UI_PNL_SOLID) uiSetRoundBox(15); else uiSetRoundBox(3); UI_ThemeColor(TH_TEXT_HI); - uiRoundRect(rect->xmin, rect->ymin, rect->xmax, rect->ymax+PNL_HEADER, 8); + uiRoundRect(rect->xmin, rect->ymin, rect->xmax, headrect.ymax+1, 8); } if(panel->control & UI_PNL_SCALE) @@ -680,12 +717,20 @@ void ui_draw_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) /* draw collapse icon */ UI_ThemeColor(TH_TEXT); + /* itemrect smaller */ + itemrect.xmin= headrect.xmin + 10.0f/block->aspect; + itemrect.xmax= itemrect.xmin + (headrect.ymax-headrect.ymin); + itemrect.ymin= headrect.ymin; + itemrect.ymax= headrect.ymax; + + rectf_scale(&itemrect, 0.7f); + if(panel->flag & PNL_CLOSEDY) - ui_draw_tria_icon(rect->xmin+6+ofsx, rect->ymax+3, 'h'); + ui_draw_tria_rect(&itemrect, 'h'); else if(panel->flag & PNL_CLOSEDX) - ui_draw_tria_icon(rect->xmin+7, rect->ymax+3, 'h'); + ui_draw_tria_rect(&itemrect, 'h'); else - ui_draw_tria_icon(rect->xmin+6+ofsx, rect->ymax+3, 'v'); + ui_draw_tria_rect(&itemrect, 'v'); } @@ -1252,15 +1297,17 @@ static void ui_handle_panel_header(bContext *C, uiBlock *block, int mx, int my) /* mouse coordinates in panel space! */ + /* XXX weak code, currently it assumes layout style for location of widgets */ + /* check open/collapsed button */ if(block->panel->flag & PNL_CLOSEDX) { if(my >= block->maxy) button= 1; } else if(block->panel->control & UI_PNL_CLOSE) { - if(mx <= block->minx+PNL_ICON-2) button= 2; - else if(mx <= block->minx+2*PNL_ICON+2) button= 1; + if(mx <= block->minx+10+PNL_ICON-2) button= 2; + else if(mx <= block->minx+10+2*PNL_ICON+2) button= 1; } - else if(mx <= block->minx+PNL_ICON+2) { + else if(mx <= block->minx+10+PNL_ICON+2) { button= 1; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index d3512a67eed..72ad7f6eb22 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1159,7 +1159,12 @@ static void widget_state_menu_item(uiWidgetType *wt, int state) { wt->wcol= *(wt->wcol_theme); - if(state & UI_ACTIVE) { + if(state & UI_BUT_DISABLED) { + wt->wcol.text[0]= 0.5f*(wt->wcol.text[0]+wt->wcol.text_sel[0]); + wt->wcol.text[1]= 0.5f*(wt->wcol.text[1]+wt->wcol.text_sel[1]); + wt->wcol.text[2]= 0.5f*(wt->wcol.text[2]+wt->wcol.text_sel[2]); + } + else if(state & UI_ACTIVE) { QUATCOPY(wt->wcol.inner, wt->wcol.inner_sel); VECCOPY(wt->wcol.text, wt->wcol.text_sel); @@ -1236,7 +1241,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir /* ************ custom buttons, old stuff ************** */ /* draws in resolution of 20x4 colors */ -static void ui_draw_but_HSVCUBE(uiBut *but) +static void ui_draw_but_HSVCUBE(uiBut *but, rcti *rect) { int a; float h,s,v; @@ -1314,10 +1319,10 @@ static void ui_draw_but_HSVCUBE(uiBut *but) } // rect - sx1= but->x1 + dx*(but->x2-but->x1); - sx2= but->x1 + (dx+0.05)*(but->x2-but->x1); - sy= but->y1; - dy= (but->y2-but->y1)/3.0; + sx1= rect->xmin + dx*(rect->xmax-rect->xmin); + sx2= rect->xmin + (dx+0.05)*(rect->xmax-rect->xmin); + sy= rect->ymin; + dy= (rect->ymax-rect->ymin)/3.0; glBegin(GL_QUADS); for(a=0; a<3; a++, sy+=dy) { @@ -1339,16 +1344,16 @@ static void ui_draw_but_HSVCUBE(uiBut *but) glShadeModel(GL_FLAT); /* cursor */ - x= but->x1 + x*(but->x2-but->x1); - y= but->y1 + y*(but->y2-but->y1); - CLAMP(x, but->x1+3.0, but->x2-3.0); - CLAMP(y, but->y1+3.0, but->y2-3.0); + x= rect->xmin + x*(rect->xmax-rect->xmin); + y= rect->ymin + y*(rect->ymax-rect->ymin); + CLAMP(x, rect->xmin+3.0, rect->xmax-3.0); + CLAMP(y, rect->ymin+3.0, rect->ymax-3.0); fdrawXORcirc(x, y, 3.1); /* outline */ glColor3ub(0, 0, 0); - fdrawbox((but->x1), (but->y1), (but->x2), (but->y2)); + fdrawbox((rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax)); } @@ -1381,7 +1386,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s uiWidgetBase wtb, wtb1; rcti rect1; double value; - float offs, fac, inner[3]; + float offs, fac, outline[3]; widget_init(&wtb); widget_init(&wtb1); @@ -1396,21 +1401,22 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s widgetbase_draw(&wtb, wcol); /* slider part */ - roundboxalign &= ~6; rect1= *rect; value= ui_get_but_val(but); fac= (value-but->softmin)*(rect1.xmax - rect1.xmin - 2.0f*offs)/(but->softmax - but->softmin); - rect1.xmax= rect1.xmin + fac + offs; + rect1.xmax= rect1.xmin + fac + 2.0f*offs; round_box_edges(&wtb1, roundboxalign, &rect1, offs); - wtb1.outline= 0; - VECCOPY(inner, wcol->inner); + VECCOPY(outline, wcol->outline); + VECCOPY(wcol->outline, wcol->item); VECCOPY(wcol->inner, wcol->item); + SWAP(float, wcol->shadetop, wcol->shadedown); widgetbase_draw(&wtb1, wcol); - VECCOPY(wcol->inner, inner); + VECCOPY(wcol->outline, outline); + SWAP(float, wcol->shadetop, wcol->shadedown); /* outline */ wtb.outline= 1; @@ -1787,6 +1793,9 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) case TEX: wt= widget_type(UI_WTYPE_NAME); break; + case TOGBUT: + wt= widget_type(UI_WTYPE_TOGGLE); + break; case TOG: case TOGN: case TOG3: @@ -1818,16 +1827,16 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) // XXX four old button types case HSVCUBE: - ui_draw_but_HSVCUBE(but); + ui_draw_but_HSVCUBE(but, rect); break; case BUT_COLORBAND: - ui_draw_but_COLORBAND(but); + ui_draw_but_COLORBAND(but, rect); break; case BUT_NORMAL: - ui_draw_but_NORMAL(but); + ui_draw_but_NORMAL(but, rect); break; case BUT_CURVE: - ui_draw_but_CURVE(ar, but); + ui_draw_but_CURVE(ar, but, rect); break; default: @@ -1836,6 +1845,7 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) } if(wt) { + rcti disablerect= *rect; /* rect gets clipped smaller for text */ int roundboxalign, state; roundboxalign= widget_roundbox_set(but, rect); @@ -1850,7 +1860,8 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) wt->text(&style->widget, but, rect, wt->wcol.text); if(state & UI_BUT_DISABLED) - widget_disabled(rect); + if(but->dt!=UI_EMBOSSP) + widget_disabled(&disablerect); } } |