diff options
author | Ton Roosendaal <ton@blender.org> | 2009-04-08 20:51:35 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2009-04-08 20:51:35 +0400 |
commit | d979085614629c05f87715f1cc78bb2640498a21 (patch) | |
tree | 9ff15c32430d80d79df4ef738ab00b727a47e7bc /source/blender | |
parent | 9b3b52dfd6229d5456d818e2b919acae9d6ab47b (diff) |
2.5
- Updated panel tabbing code to at least make it work again
- And some more minor UI tweaks
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 125 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 15 |
2 files changed, 121 insertions, 19 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 788d31e699a..70c5e1887c2 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -653,6 +653,33 @@ static void ui_draw_panel_scalewidget(uiBlock *block) glDisable(GL_BLEND); } +static void ui_draw_panel_dragwidget(uiBlock *block) +{ + float xmin, xmax, dx; + float ymin, ymax, dy; + + xmin= block->maxx-10-PNL_HEADER+8; + xmax= block->maxx-10; + ymin= block->maxy+4; + ymax= block->maxy+PNL_HEADER-4; + + dx= 0.333f*(xmax-xmin); + dy= 0.333f*(ymax-ymin); + + glEnable(GL_BLEND); + glColor4ub(255, 255, 255, 50); + fdrawline(xmin, ymax, xmax, ymin); + fdrawline(xmin+dx, ymax, xmax, ymin+dy); + fdrawline(xmin+2*dx, ymax, xmax, ymin+2*dy); + + glColor4ub(0, 0, 0, 50); + fdrawline(xmin, ymax+block->aspect, xmax, ymin+block->aspect); + fdrawline(xmin+dx, ymax+block->aspect, xmax, ymin+dy+block->aspect); + fdrawline(xmin+2*dx, ymax+block->aspect, xmax, ymin+2*dy+block->aspect); + glDisable(GL_BLEND); +} + + static void ui_draw_panel_old(ARegion *ar, uiBlock *block) { Panel *panel= block->panel; @@ -834,17 +861,89 @@ static void ui_draw_panel_old(ARegion *ar, uiBlock *block) ui_draw_tria_icon(block->minx+6+ofsx, block->maxy+5, block->aspect, 'v'); } +static void ui_draw_panel_header_style(ARegion *ar, uiBlock *block) +{ + Panel *pa, *panel= block->panel; + float width; + int a, nr= 1, pnl_icons; + char *activename= panel->drawname[0]?panel->drawname:panel->panelname; + char *panelname, *str; + + ui_draw_panel_dragwidget(block); + + /* 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(nr==1) { + /* active tab */ + /* draw text label */ + UI_ThemeColor(TH_TEXT); + ui_rasterpos_safe(4.0f+block->minx+pnl_icons, block->maxy+5.0f, block->aspect); + UI_DrawString(block->curfont, activename, ui_translate_buttons()); + return; + } + + a= 0; + width= (panel->sizex - 3 - pnl_icons - PNL_ICON)/nr; + for(pa= ar->panels.first; pa; pa=pa->next) { + panelname= pa->drawname[0]?pa->drawname:pa->panelname; + if(a == 0) + activename= panelname; + + if(pa->active==0); + else if(pa==panel) { + /* active tab */ + + /* draw the active text label */ + UI_ThemeColor(TH_TEXT); + ui_rasterpos_safe(16+pnl_icons+a*width, panel->sizey+4, block->aspect); + if(panelname != activename && strstr(panelname, activename) == panelname) + str= ui_block_cut_str(block, panelname+strlen(activename), (short)(width-10)); + else + str= ui_block_cut_str(block, panelname, (short)(width-10)); + UI_DrawString(block->curfont, str, ui_translate_buttons()); + + a++; + } + else if(pa->paneltab==panel) { + + /* draw an inactive tab label */ + UI_ThemeColorBlend(TH_TEXT, TH_BACK, 0.5f); + ui_rasterpos_safe(16+pnl_icons+a*width, panel->sizey+4, block->aspect); + if(panelname != activename && strstr(panelname, activename) == panelname) + str= ui_block_cut_str(block, panelname+strlen(activename), (short)(width-10)); + else + str= ui_block_cut_str(block, panelname, (short)(width-10)); + UI_DrawString(block->curfont, str, ui_translate_buttons()); + + a++; + } + } +} + + /* XXX has follow style definitions still */ static void ui_draw_panel_style(ARegion *ar, uiBlock *block) { - Panel *panel= block->panel; + Panel *panel= block->panel, *prev; int ofsx; - char *panelname= panel->drawname[0]?panel->drawname:panel->panelname; if(panel->paneltab) return; - /* divider */ - if(panel->prev) { + /* divider only when there's a previous panel */ + prev= panel->prev; + while(prev) { + if(prev->active) break; + prev= prev->prev; + } + + if(prev) { float minx= block->minx+10; float maxx= block->maxx-10; float y= block->maxy + PNL_HEADER; @@ -859,11 +958,7 @@ static void ui_draw_panel_style(ARegion *ar, uiBlock *block) /* title */ if(!(panel->flag & PNL_CLOSEDX)) { - ofsx= PNL_ICON+8; - if(panel->control & UI_PNL_CLOSE) ofsx+= PNL_ICON; - UI_ThemeColor(TH_TEXT); - ui_rasterpos_safe(4+block->minx+ofsx, block->maxy+2, block->aspect); - UI_DrawString(block->curfont, panelname, ui_translate_buttons()); + ui_draw_panel_header_style(ar, block); } /* if the panel is minimized vertically: @@ -944,6 +1039,7 @@ static int get_panel_real_ofsy(Panel *pa) { if(pa->flag & PNL_CLOSEDY) return pa->ofsy+pa->sizey; else if(pa->paneltab && (pa->paneltab->flag & PNL_CLOSEDY)) return pa->ofsy+pa->sizey; + else if(pa->paneltab) return pa->paneltab->ofsy; else return pa->ofsy; } @@ -1471,9 +1567,16 @@ static void panel_clicked_tabs(bContext *C, ScrArea *sa, ARegion *ar, uiBlock *b pa= pa->next; } + /* copy locations to tabs */ + for(pa= ar->panels.first; pa; pa= pa->next) { + if(pa->paneltab && pa->active) { + copy_panel_offset(pa, pa->paneltab); + } + } + /* panels now differ size.. */ if(panel_aligned(sa, ar)) - uiAlignPanelStep(sa, ar, 1.0); + panel_activate_state(C, tabsel, PANEL_STATE_ANIMATION); ED_region_tag_redraw(ar); } @@ -1690,7 +1793,7 @@ static void panel_activate_state(bContext *C, Panel *pa, uiHandlePanelState stat uiHandlePanelData *data= pa->activedata; wmWindow *win= CTX_wm_window(C); ARegion *ar= CTX_wm_region(C); - + if(data && data->state == state) return; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index cabebf19e3a..dc409be3058 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -516,16 +516,15 @@ static void widget_check_trias(uiWidgetTrias *tria, rcti *rect) /* prepares shade colors */ static void shadecolors4(float *coltop, float *coldown, float *color, float shadetop, float shadedown) { - float hue, sat, val, valshade; - rgb_to_hsv(color[0], color[1], color[2], &hue, &sat, &val); - - valshade= CLAMPIS(val+shadetop, 0.0f, 1.0f); - hsv_to_rgb(hue, sat, valshade, coltop, coltop+1, coltop+2); + coltop[0]= CLAMPIS(color[0]+shadetop, 0.0f, 1.0f); + coltop[1]= CLAMPIS(color[1]+shadetop, 0.0f, 1.0f); + coltop[2]= CLAMPIS(color[2]+shadetop, 0.0f, 1.0f); coltop[3]= color[3]; - valshade= CLAMPIS(val+shadedown, 0.0f, 1.0f); - hsv_to_rgb(hue, sat, valshade, coldown, coldown+1, coldown+2); + coldown[0]= CLAMPIS(color[0]+shadedown, 0.0f, 1.0f); + coldown[1]= CLAMPIS(color[1]+shadedown, 0.0f, 1.0f); + coldown[2]= CLAMPIS(color[2]+shadedown, 0.0f, 1.0f); coldown[3]= color[3]; } @@ -969,7 +968,7 @@ static struct uiWidgetColors wcol_pulldown= { static struct uiWidgetColors wcol_menu_item= { {0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 0.3}, - {0.23f, 0.53f, 0.9f, 0.9f}, + {0.23f, 0.53f, 0.9f, 1.0f}, {0.45, 0.75, 0.3f, 1.0f}, {0.35, 0.65, 0.2f, 1.0f}, {0.95, 0.9, 0.4f, 1.0f}, |