diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-20 00:57:53 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-11-20 00:57:53 +0400 |
commit | 7217518179d9ed0c2aeda835402ac019884ee461 (patch) | |
tree | 2eac01328a59738a8a561b8d450476cd5303522e /source/blender/editors/interface | |
parent | 807a76d9430b6b6e30fd6f09d6000f093c37dea4 (diff) |
UI:
* Add theme option to show panel header background.
* Draw panel collapse widget a bit smaller.
* Add theme option to draw icons muted.
* Code tweak: replace U.themes.first by UI_GetTheme() calls.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_icons.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 59 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_style.c | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 6 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 14 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 4 |
7 files changed, 62 insertions, 28 deletions
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 089458f1da4..1b7308d328e 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -506,7 +506,7 @@ static void init_brush_icons(void) static void init_internal_icons(void) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); ImBuf *bbuf= NULL; int x, y, icontype; char iconfilestr[FILE_MAXDIR+FILE_MAXFILE]; @@ -950,6 +950,7 @@ static int get_draw_size(enum eIconSizes size) static void icon_draw_size(float x, float y, int icon_id, float aspect, float alpha, float *rgb, enum eIconSizes size, int draw_size, int UNUSED(nocreate), short is_preview) { + bTheme *btheme= UI_GetTheme(); Icon *icon = NULL; DrawInfo *di = NULL; IconImage *iimg; @@ -957,6 +958,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al int w, h; icon = BKE_icon_get(icon_id); + alpha *= btheme->tui.icon_alpha; if (icon==NULL) { if (G.f & G_DEBUG) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 16e0153b910..d6460f9046e 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -112,7 +112,7 @@ typedef enum { /* internal panel drawing defines */ #define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */ -#define PNL_HEADER UI_UNIT_Y /* 20 default */ +#define PNL_HEADER (UI_UNIT_Y + 4) /* 24 default */ /* panel->flag */ #define PNL_SELECT 1 diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index aa80cb632ec..ad79e550575 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -59,6 +59,7 @@ #include "ED_screen.h" #include "UI_interface.h" +#include "UI_resources.h" #include "interface_intern.h" @@ -173,7 +174,6 @@ static void ui_panel_copy_offset(Panel *pa, Panel *papar) Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int *open) { - uiStyle *style= UI_GetStyle(); Panel *pa, *patab, *palast, *panext; char *drawname= pt->label; char *idname= pt->idname; @@ -208,7 +208,7 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int } pa->ofsx= 0; - pa->ofsy= style->panelouter; + pa->ofsy= 0; pa->sizex= 0; pa->sizey= 0; pa->runtime_flag |= PNL_NEW_ADDED; @@ -482,6 +482,7 @@ static void rectf_scale(rctf *rect, float scale) /* panel integrated in buttonswindow, tool/property lists etc */ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) { + bTheme *btheme= UI_GetTheme(); Panel *panel= block->panel; rcti headrect; rctf itemrect; @@ -493,19 +494,37 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* calculate header rect */ /* + 0.001f to prevent flicker due to float inaccuracy */ headrect= *rect; - headrect.ymin= headrect.ymax; + headrect.ymin= headrect.ymax - 2.0f/block->aspect; headrect.ymax= headrect.ymin + floor(PNL_HEADER/block->aspect + 0.001f); - if(!(panel->runtime_flag & PNL_FIRST)) { - float minx= rect->xmin+5.0f/block->aspect; - float maxx= rect->xmax-5.0f/block->aspect; + { + float minx= rect->xmin; + float maxx= rect->xmax; float y= headrect.ymax; - + glEnable(GL_BLEND); - glColor4f(0.0f, 0.0f, 0.0f, 0.5f); - fdrawline(minx, y+1, maxx, y+1); - glColor4f(1.0f, 1.0f, 1.0f, 0.25f); - fdrawline(minx, y, maxx, y); + + if(btheme->tui.panel.show_header) { + /* draw with background color */ + glEnable(GL_BLEND); + glColor4ubv((unsigned char*)btheme->tui.panel.header); + glRectf(minx, headrect.ymin, maxx, y); + + fdrawline(minx, y, maxx, y); + fdrawline(minx, y, maxx, y); + } + else if(!(panel->runtime_flag & PNL_FIRST)) { + /* draw embossed separator */ + minx += 5.0f/block->aspect; + maxx -= 5.0f/block->aspect; + + glColor4f(0.0f, 0.0f, 0.0f, 0.5f); + fdrawline(minx, y+1, maxx, y+1); + glColor4f(1.0f, 1.0f, 1.0f, 0.25f); + fdrawline(minx, y, maxx, y); + glDisable(GL_BLEND); + } + glDisable(GL_BLEND); } @@ -518,7 +537,8 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) itemrect.xmin= itemrect.xmax - (headrect.ymax-headrect.ymin); itemrect.ymin= headrect.ymin; itemrect.ymax= headrect.ymax; - rectf_scale(&itemrect, 0.8f); + + rectf_scale(&itemrect, 0.7f); ui_draw_panel_dragwidget(&itemrect); } @@ -538,7 +558,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* in some occasions, draw a border */ if(panel->flag & PNL_SELECT) { if(panel->control & UI_PNL_SOLID) uiSetRoundBox(UI_CNR_ALL); - else uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); + else uiSetRoundBox(UI_CNR_NONE); UI_ThemeColorShade(TH_BACK, -120); uiRoundRect(0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax+1, 8); @@ -567,7 +587,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) itemrect.ymin= headrect.ymin; itemrect.ymax= headrect.ymax; - rectf_scale(&itemrect, 0.5f); + rectf_scale(&itemrect, 0.35f); if(panel->flag & PNL_CLOSEDY) ui_draw_tria_rect(&itemrect, 'h'); @@ -589,12 +609,12 @@ static int get_panel_header(Panel *pa) return PNL_HEADER; } -static int get_panel_size_y(uiStyle *style, Panel *pa) +static int get_panel_size_y(Panel *pa) { if(pa->type && (pa->type->flag & PNL_NO_HEADER)) return pa->sizey; - return PNL_HEADER + pa->sizey + style->panelouter; + return PNL_HEADER + pa->sizey; } /* this function is needed because uiBlock and Panel itself dont @@ -667,7 +687,6 @@ static int compare_panel(const void *a1, const void *a2) /* returns 1 when it did something */ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) { - uiStyle *style= UI_GetStyle(); Panel *pa; PanelSort *ps, *panelsort, *psnext; int a, tot=0, done; @@ -719,18 +738,18 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) /* no smart other default start loc! this keeps switching f5/f6/etc compatible */ ps= panelsort; ps->pa->ofsx= 0; - ps->pa->ofsy= -get_panel_size_y(style, ps->pa); + ps->pa->ofsy= -get_panel_size_y(ps->pa); for(a=0; a<tot-1; a++, ps++) { psnext= ps+1; if(align==BUT_VERTICAL) { psnext->pa->ofsx= ps->pa->ofsx; - psnext->pa->ofsy= get_panel_real_ofsy(ps->pa) - get_panel_size_y(style, psnext->pa); + psnext->pa->ofsy= get_panel_real_ofsy(ps->pa) - get_panel_size_y(psnext->pa); } else { psnext->pa->ofsx= get_panel_real_ofsx(ps->pa); - psnext->pa->ofsy= ps->pa->ofsy + get_panel_size_y(style, ps->pa) - get_panel_size_y(style, psnext->pa); + psnext->pa->ofsy= ps->pa->ofsy + get_panel_size_y(ps->pa) - get_panel_size_y(psnext->pa); } } diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 0e9dbaf3022..3caafe308d0 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -124,7 +124,6 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id style->buttonspacex= 8; style->buttonspacey= 2; style->panelspace= 8; - style->panelouter= 4; return style; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index c9fcb7f1d24..9a438070e1e 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1617,7 +1617,7 @@ static void widget_state_option_menu(uiWidgetType *wt, int state) if(state & UI_SELECT) UI_GetThemeColor4ubv(TH_TEXT_HI, (unsigned char *)wt->wcol.text); else { - bTheme *btheme= U.themes.first; /* XXX */ + bTheme *btheme= UI_GetTheme(); /* XXX */ copy_v3_v3_char(wt->wcol.text, btheme->tui.wcol_menu_back.text); } @@ -2760,7 +2760,7 @@ static void widget_disabled(rcti *rect) static uiWidgetType *widget_type(uiWidgetTypeEnum type) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); static uiWidgetType wt; /* defaults */ @@ -2945,7 +2945,7 @@ static int widget_roundbox_set(uiBut *but, rcti *rect) /* conversion from old to new buttons, so still messy */ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); ThemeUI *tui= &btheme->tui; uiFontStyle *fstyle= &style->widget; uiWidgetType *wt= NULL; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 738531e3bad..66add6d8f0c 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -839,6 +839,11 @@ void UI_SetTheme(int spacetype, int regionid) } } +bTheme *UI_GetTheme() +{ + return U.themes.first; +} + // for space windows only void UI_ThemeColor(int colorid) { @@ -1668,6 +1673,15 @@ void init_userdef_do_versions(void) } } + if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 5)) { + bTheme *btheme; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + SETCOL(btheme->tui.panel.header, 0, 0, 0, 25); + btheme->tui.icon_alpha= 1.0; + } + } + /* GL Texture Garbage Collection (variable abused above!) */ if (U.textimeout == 0) { U.texcollectrate = 60; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 5e97e01aed6..c2c482b0a2c 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1558,7 +1558,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v if (scroll & V2D_SCROLL_HORIZONTAL) { /* only draw scrollbar when it doesn't fill the entire space */ if(vs->horfull==0) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); uiWidgetColors wcol= btheme->tui.wcol_scroll; rcti slider; int state; @@ -1669,7 +1669,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v if (scroll & V2D_SCROLL_VERTICAL) { /* only draw scrollbar when it doesn't fill the entire space */ if(vs->vertfull==0) { - bTheme *btheme= U.themes.first; + bTheme *btheme= UI_GetTheme(); uiWidgetColors wcol= btheme->tui.wcol_scroll; rcti slider; int state; |