diff options
25 files changed, 1301 insertions, 1100 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5c176c4a72b..c8484a63b62 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -178,7 +178,7 @@ READ - read associated 'direct data' - link direct data (internal and to LibBlock) - read FileGlobal -- read USER data, only when indicated (file is ~/.B.blend) +- read USER data, only when indicated (file is ~/.B.blend or .B25.blend) - free file - per Library (per Main) - read file diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index f93ad5eaf2b..b690c708dc3 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2240,8 +2240,7 @@ int BLO_write_file(Main *mainvar, char *dir, int write_flags, ReportList *report return 0; } - BLI_make_file_string(G.sce, userfilename, BLI_gethome(), ".B.blend"); - + BLI_make_file_string(G.sce, userfilename, BLI_gethome(), ".B25.blend"); write_user_block= BLI_streq(dir, userfilename); err= write_file_handle(mainvar, file, NULL,NULL, write_user_block, write_flags); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index c491dee6ba6..ea1a8efe9fc 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -589,6 +589,7 @@ void uiRegionHeaderLayout(const struct bContext *C, struct ARegion *ar); void uiAnimContextProperty(const struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA **prop, int *index); + /* Styled text draw */ void uiStyleFontSet(struct uiFontStyle *fs); void uiStyleFontDraw(struct uiFontStyle *fs, struct rcti *rect, char *str); diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index c1b009fffac..1315e22133b 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -794,45 +794,31 @@ typedef enum { } BIFColorID; -/* XXX WARNING: this is saved in file, so do not change order! */ enum { - TH_AUTO, /* for buttons, to signal automatic color assignment */ - -// uibutton colors - TH_BUT_OUTLINE, - TH_BUT_NEUTRAL, - TH_BUT_ACTION, - TH_BUT_SETTING, - TH_BUT_SETTING1, - TH_BUT_SETTING2, - TH_BUT_NUM, - TH_BUT_TEXTFIELD, - TH_BUT_POPUP, - TH_BUT_TEXT, - TH_BUT_TEXT_HI, - TH_MENU_BACK, - TH_MENU_ITEM, - TH_MENU_HILITE, - TH_MENU_TEXT, - TH_MENU_TEXT_HI, - - TH_BUT_DRAWTYPE, - TH_REDALERT, - TH_CUSTOM, - - TH_BUT_TEXTFIELD_HI, - TH_ICONFILE, - + TH_THEMEUI, // common colors among spaces TH_BACK, TH_TEXT, TH_TEXT_HI, + TH_TITLE, + TH_HEADER, TH_HEADERDESEL, + TH_HEADER_TEXT, + TH_HEADER_TEXT_HI, + + /* float panels */ TH_PANEL, + TH_PANEL_TEXT, + TH_PANEL_TEXT_HI, + + TH_BUTBACK, + TH_BUTBACK_TEXT, + TH_BUTBACK_TEXT_HI, + TH_SHADE1, TH_SHADE2, TH_HILITE, @@ -947,13 +933,8 @@ void UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, in // get pointer from RNA pointer int UI_GetIconRNA(struct PointerRNA *ptr); -struct ScrArea; - // internal (blender) usage only, for init and set active -void UI_SetTheme(struct ScrArea *sa); -void ui_theme_init_userdef (void); -void ui_resources_init (void); -void ui_resources_free (void); +void UI_SetTheme(int spacetype, int regionid); /* only for buttons in theme editor! */ char *UI_ThemeGetColorPtr(struct bTheme *btheme, int spacetype, int colorid); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 221ad23a846..22ecd8ee2f8 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -650,7 +650,7 @@ void uiDrawBlock(const bContext *C, uiBlock *block) if(block->flag & UI_BLOCK_LOOP) ui_draw_menu_back(&style, block, &rect); else if(block->panel) - ui_draw_panel(ar, &style, block, &rect); + ui_draw_aligned_panel(ar, &style, block, &rect); if(block->drawextra) block->drawextra(C, block); @@ -1970,12 +1970,6 @@ void uiBlockEndAlign(uiBlock *block) { uiBut *prev, *but=NULL, *next; int flag= 0, cols=0, rows=0; - int theme= UI_GetThemeValue(TH_BUT_DRAWTYPE); - - if ( !(ELEM4(theme, TH_MINIMAL, TH_SHADED, TH_ROUNDED, TH_ROUNDSHADED)) ) { - block->flag &= ~UI_BUT_ALIGN; // all 4 flags - return; - } /* auto align: - go back to first button of align start (ALIGN_DOWN) @@ -3052,10 +3046,15 @@ void UI_init(void) ui_resources_init(); } -void UI_init_userdef() +/* after reading userdef file */ +void UI_init_userdef(void) { - uiStyleInit(); + /* fix saved themes */ + init_userdef_do_versions(); + /* set default colors in default theme */ ui_theme_init_userdef(); + + uiStyleInit(); } void UI_exit(void) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 153db7aa77d..8be2084ab01 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -61,10 +61,7 @@ void uiSetRoundBox(int type) /* Not sure the roundbox function is the best place to change this * if this is undone, its not that big a deal, only makes curves edges * square for the */ - if (UI_GetThemeValue(TH_BUT_DRAWTYPE) == TH_MINIMAL) - roundboxtype= 0; - else - roundboxtype= type; + roundboxtype= type; /* flags to set which corners will become rounded: @@ -77,10 +74,7 @@ void uiSetRoundBox(int type) int uiGetRoundBox(void) { - if (ELEM3(UI_GetThemeValue(TH_BUT_DRAWTYPE), TH_MINIMAL, TH_SHADED, TH_OLDSKOOL)) - return 0; - else - return roundboxtype; + return roundboxtype; } void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad) @@ -176,10 +170,8 @@ void gl_round_box_shade(int mode, float minx, float miny, float maxx, float maxy coldown[1]= color[1]+shadedown; if(coldown[1]<0.0) coldown[1]= 0.0; coldown[2]= color[2]+shadedown; if(coldown[2]<0.0) coldown[2]= 0.0; - if (UI_GetThemeValue(TH_BUT_DRAWTYPE) != TH_MINIMAL) { - glShadeModel(GL_SMOOTH); - glBegin(mode); - } + glShadeModel(GL_SMOOTH); + glBegin(mode); /* start with corner right-bottom */ if(roundboxtype & 4) { @@ -285,10 +277,8 @@ void gl_round_box_vertical_shade(int mode, float minx, float miny, float maxx, f colRight[1]= color[1]+shadeRight; if(colRight[1]<0.0) colRight[1]= 0.0; colRight[2]= color[2]+shadeRight; if(colRight[2]<0.0) colRight[2]= 0.0; - if (UI_GetThemeValue(TH_BUT_DRAWTYPE) != TH_MINIMAL) { - glShadeModel(GL_SMOOTH); - glBegin(mode); - } + glShadeModel(GL_SMOOTH); + glBegin(mode); /* start with corner right-bottom */ if(roundboxtype & 4) { @@ -379,10 +369,8 @@ void uiRoundRect(float minx, float miny, float maxx, float maxy, float rad) } /* set antialias line */ - if (UI_GetThemeValue(TH_BUT_DRAWTYPE) != TH_MINIMAL) { - glEnable( GL_LINE_SMOOTH ); - glEnable( GL_BLEND ); - } + glEnable( GL_LINE_SMOOTH ); + glEnable( GL_BLEND ); gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad); @@ -435,10 +423,8 @@ void uiRoundBox(float minx, float miny, float maxx, float maxy, float rad) gl_round_box(GL_POLYGON, minx, miny, maxx, maxy, rad); /* set antialias line */ - if (UI_GetThemeValue(TH_BUT_DRAWTYPE) != TH_MINIMAL) { - glEnable( GL_LINE_SMOOTH ); - glEnable( GL_BLEND ); - } + glEnable( GL_LINE_SMOOTH ); + glEnable( GL_BLEND ); gl_round_box(GL_LINE_LOOP, minx, miny, maxx, maxy, rad); @@ -663,7 +649,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) #endif // INTERNATIONAL #endif -void ui_draw_but_COLORBAND(uiBut *but, rcti *rect) +void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *wcol, rcti *rect) { ColorBand *coba; CBData *cbd; @@ -790,7 +776,7 @@ void ui_draw_but_COLORBAND(uiBut *but, rcti *rect) glEnd(); } -void ui_draw_but_NORMAL(uiBut *but, rcti *rect) +void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) { static GLuint displist=0; int a, old[8]; @@ -802,7 +788,7 @@ void ui_draw_but_NORMAL(uiBut *but, rcti *rect) glGetMaterialfv(GL_FRONT, GL_DIFFUSE, diff); /* backdrop */ - UI_ThemeColor(TH_BUT_NEUTRAL); + glColor3ubv(wcol->inner); uiSetRoundBox(15); gl_round_box(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f); @@ -892,7 +878,14 @@ static void ui_draw_but_curve_grid(rcti *rect, float zoomx, float zoomy, float o } -void ui_draw_but_CURVE(ARegion *ar, uiBut *but, rcti *rect) +static void glColor3ubvShade(char *col, int shade) +{ + glColor3ub(col[0]-shade>0?col[0]-shade:0, + col[1]-shade>0?col[1]-shade:0, + col[2]-shade>0?col[2]-shade:0); +} + +void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect) { CurveMapping *cumap; CurveMap *cuma; @@ -916,27 +909,27 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, rcti *rect) /* backdrop */ if(cumap->flag & CUMA_DO_CLIP) { - UI_ThemeColorShade(TH_BUT_NEUTRAL, -20); + glColor3ubvShade(wcol->inner, -20); glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); - UI_ThemeColor(TH_BUT_NEUTRAL); + glColor3ubv(wcol->inner); 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); + glColor3ubv(wcol->inner); glRectf(rect->xmin, rect->ymin, rect->xmax, rect->ymax); } /* grid, every .25 step */ - UI_ThemeColorShade(TH_BUT_NEUTRAL, -16); + glColor3ubvShade(wcol->inner, -16); ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 0.25f); /* grid, every 1.0 step */ - UI_ThemeColorShade(TH_BUT_NEUTRAL, -24); + glColor3ubvShade(wcol->inner, -24); ui_draw_but_curve_grid(rect, zoomx, zoomy, offsx, offsy, 1.0f); /* axes */ - UI_ThemeColorShade(TH_BUT_NEUTRAL, -50); + glColor3ubvShade(wcol->inner, -50); glBegin(GL_LINES); glVertex2f(rect->xmin, rect->ymin + zoomy*(-offsy)); glVertex2f(rect->xmax, rect->ymin + zoomy*(-offsy)); @@ -981,7 +974,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, rcti *rect) }*/ /* the curve */ - UI_ThemeColorBlend(TH_TEXT, TH_BUT_NEUTRAL, 0.35); + glColor3ubv(wcol->item); glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); glBegin(GL_LINE_STRIP); @@ -1035,7 +1028,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, rcti *rect) glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); /* outline */ - UI_ThemeColor(TH_BUT_OUTLINE); + glColor3ubv(wcol->outline); fdrawbox(rect->xmin, rect->ymin, rect->xmax, rect->ymax); } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 06041dc202e..8aaec7f31b0 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -40,6 +40,7 @@ struct uiHandleButtonData; struct wmEvent; struct wmWindow; struct uiStyle; +struct uiWidgetColors; /* ****************** general defines ************** */ @@ -47,6 +48,7 @@ struct uiStyle; /* for time being separated from functional types */ typedef enum { /* standard set */ + UI_WTYPE_LABEL, UI_WTYPE_TOGGLE, UI_WTYPE_OPTION, UI_WTYPE_RADIO, @@ -353,7 +355,7 @@ void autocomplete_end(struct AutoComplete *autocpl, char *autoname); /* interface_panel.c */ extern int ui_handler_panel_region(struct bContext *C, struct wmEvent *event); -extern void ui_draw_panel(struct ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect); +extern void ui_draw_aligned_panel(struct ARegion *ar, struct uiStyle *style, uiBlock *block, rcti *rect); /* interface_draw.c */ extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select); @@ -362,9 +364,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, rcti *rect); -void ui_draw_but_NORMAL(uiBut *but, rcti *rect); -void ui_draw_but_CURVE(ARegion *ar, uiBut *but, rcti *rect); +void ui_draw_but_COLORBAND(uiBut *but, struct uiWidgetColors *wcol, rcti *rect); +void ui_draw_but_NORMAL(uiBut *but, struct uiWidgetColors *wcol, rcti *rect); +void ui_draw_but_CURVE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); /* interface_handlers.c */ @@ -374,11 +376,20 @@ extern void ui_button_active_cancel(const struct bContext *C, uiBut *but); void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); extern void ui_draw_but(ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); + /* theme color init */ +struct ThemeUI; +void ui_widget_color_init(struct ThemeUI *tui); /* interface_style.c */ void uiStyleInit(void); void uiStyleExit(void); +/* resources.c */ +void init_userdef_do_versions(void); +void ui_theme_init_userdef(void); +void ui_resources_init(void); +void ui_resources_free(void); + /* interface_anim.c */ void ui_but_anim_flag(uiBut *but, float cfra); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 56acd755205..f9e08d29370 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1722,7 +1722,7 @@ void uiRegionPanelLayout(const bContext *C, ARegion *ar, int vertical, char *con // XXX this only hides cruft /* clear */ - UI_GetThemeColor3fv(TH_HEADER, col); + UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 7d1f8d59552..9f86917217c 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -575,7 +575,6 @@ void ui_draw_anti_x(float x1, float y1, float x2, float y2) /* x 'icon' for panel header */ static void ui_draw_x_icon(float x, float y) { - UI_ThemeColor(TH_TEXT_HI); ui_draw_anti_x(x, y, x+9.375, y+9.375); @@ -634,7 +633,7 @@ static void ui_draw_panel_dragwidget(rctf *rect) } -static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) +static void ui_draw_aligned_panel_header(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) { Panel *panel= block->panel; Panel *pa; @@ -657,7 +656,7 @@ static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, uiBlock *blo /* active tab */ /* draw text label */ - UI_ThemeColor(TH_TEXT); + UI_ThemeColor(TH_TITLE); hrect= *rect; hrect.xmin= rect->xmin+pnl_icons; @@ -674,7 +673,7 @@ static void ui_draw_panel_header_style(ARegion *ar, uiStyle *style, uiBlock *blo if((pa->runtime_flag & PNL_ACTIVE) && (pa==panel || pa->paneltab==panel)) { float col[3]; - UI_GetThemeColor3fv(TH_TEXT, col); + UI_GetThemeColor3fv(TH_TITLE, col); /* active tab */ if(pa==panel) @@ -705,7 +704,8 @@ static void rectf_scale(rctf *rect, float scale) rect->ymax= centy + sizey; } -void ui_draw_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) +/* 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; rcti headrect; @@ -741,7 +741,7 @@ void ui_draw_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) /* title */ if(!(panel->flag & PNL_CLOSEDX)) { - ui_draw_panel_header_style(ar, style, block, &headrect); + ui_draw_aligned_panel_header(ar, style, block, &headrect); /* itemrect smaller */ itemrect.xmax= headrect.xmax - 10.0f/block->aspect; @@ -776,7 +776,7 @@ void ui_draw_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) if(panel->control & UI_PNL_SOLID) uiSetRoundBox(15); else uiSetRoundBox(3); - UI_ThemeColorShade(TH_HEADER, -120); + UI_ThemeColorShade(TH_BACK, -120); uiRoundRect(rect->xmin, rect->ymin, rect->xmax, headrect.ymax+1, 8); } if(panel->flag & PNL_OVERLAP) { @@ -796,6 +796,7 @@ void ui_draw_panel(ARegion *ar, uiStyle *style, uiBlock *block, rcti *rect) ofsx= 6; if(panel->control & UI_PNL_CLOSE) { + UI_ThemeColor(TH_TEXT); ui_draw_x_icon(rect->xmin+2+ofsx, rect->ymax+2); ofsx= 22; } diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index 3bb7581b16c..67cca059d77 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -55,6 +55,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "interface_intern.h" + #define DEF_BUT_WIDTH 150 #define DEF_ICON_BUT_WIDTH 20 #define DEF_BUT_HEIGHT 20 @@ -326,6 +328,45 @@ int uiDefAutoButsRNA(const bContext *C, uiBlock *block, PointerRNA *ptr) return -y; } +/* temp call, single collumn, test for toolbar only */ +int uiDefAutoButsRNA_single(const bContext *C, uiBlock *block, PointerRNA *ptr) +{ + CollectionPropertyIterator iter; + PropertyRNA *iterprop, *prop; + uiLayout *layout; + char *name; + int x= 0, y= 0; + + layout= uiLayoutBegin(UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y, block->panel->sizex, 20); + + uiLayoutColumn(layout); + uiItemL(layout, (char*)RNA_struct_ui_name(ptr->type), 0); + + iterprop= RNA_struct_iterator_property(ptr->type); + RNA_property_collection_begin(ptr, iterprop, &iter); + + for(; iter.valid; RNA_property_collection_next(&iter)) { + prop= iter.ptr.data; + + if(strcmp(RNA_property_identifier(prop), "rna_type") == 0) + continue; + + uiLayoutSplit(layout, 1, 0); + uiLayoutColumn(uiLayoutSub(layout, 0)); + + name= (char*)RNA_property_ui_name(prop); + uiItemL(uiLayoutSub(layout, 0), name, 0); + + uiItemFullR(uiLayoutSub(layout, 0), "", 0, ptr, prop, -1, 0, 0); + } + + RNA_property_collection_end(&iter); + uiLayoutEnd(C, block, layout, &x, &y); + + return -y; +} + + /***************************** ID Utilities *******************************/ typedef struct uiIDPoinParams { diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 45faab19dbe..703328345e9 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -85,26 +85,14 @@ typedef struct uiWidgetTrias { } uiWidgetTrias; typedef struct uiWidgetStateColors { - float inner_anim[4]; - float inner_anim_sel[4]; - float inner_key[4]; - float inner_key_sel[4]; - float inner_driven[4]; - float inner_driven_sel[4]; + char inner_anim[4]; + char inner_anim_sel[4]; + char inner_key[4]; + char inner_key_sel[4]; + char inner_driven[4]; + char inner_driven_sel[4]; } uiWidgetStateColors; -typedef struct uiWidgetColors { - float outline[3]; - float inner[4]; - float inner_sel[4]; - float item[3]; - float text[3]; - float text_sel[3]; - short shaded; - float shadetop, shadedown; - -} uiWidgetColors; - typedef struct uiWidgetBase { int totvert, halfwayvert; @@ -133,7 +121,7 @@ typedef struct uiWidgetType { void (*state)(struct uiWidgetType *, int state); void (*draw)(uiWidgetColors *, rcti *, int state, int roundboxalign); void (*custom)(uiBut *, uiWidgetColors *, rcti *, int state, int roundboxalign); - void (*text)(uiFontStyle *, uiBut *, rcti *, float *col); + void (*text)(uiFontStyle *, uiWidgetColors *, uiBut *, rcti *); } uiWidgetType; @@ -518,30 +506,34 @@ 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) +static void shadecolors4(char *coltop, char *coldown, char *color, short shadetop, short shadedown) { - 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[0]= CLAMPIS(color[0]+shadetop, 0, 255); + coltop[1]= CLAMPIS(color[1]+shadetop, 0, 255); + coltop[2]= CLAMPIS(color[2]+shadetop, 0, 255); coltop[3]= color[3]; - 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[0]= CLAMPIS(color[0]+shadedown, 0, 255); + coldown[1]= CLAMPIS(color[1]+shadedown, 0, 255); + coldown[2]= CLAMPIS(color[2]+shadedown, 0, 255); coldown[3]= color[3]; } -static void round_box_shade_col4(float *col1, float *col2, float fac) +static void round_box_shade_col4(char *col1, char *col2, float fac) { - float col[4]; + int faci, facm; + char col[4]; - col[0]= (fac*col1[0] + (1.0-fac)*col2[0]); - col[1]= (fac*col1[1] + (1.0-fac)*col2[1]); - col[2]= (fac*col1[2] + (1.0-fac)*col2[2]); - col[3]= (fac*col1[3] + (1.0-fac)*col2[3]); + faci= floor(255.1f*fac); + facm= 255-faci; - glColor4fv(col); + col[0]= (faci*col1[0] + facm*col2[0])>>8; + col[1]= (faci*col1[1] + facm*col2[1])>>8; + col[2]= (faci*col1[2] + facm*col2[2])>>8; + col[3]= (faci*col1[3] + facm*col2[3])>>8; + + glColor4ubv(col); } static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) @@ -554,14 +546,14 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) if(wtb->inner) { if(wcol->shaded==0) { /* filled center, solid */ - glColor4fv(wcol->inner); + glColor4ubv(wcol->inner); glBegin(GL_POLYGON); for(a=0; a<wtb->totvert; a++) glVertex2fv(wtb->inner_v[a]); glEnd(); } else { - float col1[4], col2[4]; + char col1[4], col2[4]; shadecolors4(col1, col2, wcol->inner, wcol->shadetop, wcol->shadedown); @@ -582,7 +574,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glTranslatef(1.0*jit[j][0], 1.0*jit[j][1], 0.0f); /* outline */ - glColor4f(wcol->outline[0], wcol->outline[1], wcol->outline[2], 0.125); + glColor4ub(wcol->outline[0], wcol->outline[1], wcol->outline[2], 32); glBegin(GL_QUAD_STRIP); for(a=0; a<wtb->totvert; a++) { glVertex2fv(wtb->outer_v[a]); @@ -614,11 +606,11 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glTranslatef(1.0*jit[j][0], 1.0*jit[j][1], 0.0f); if(wtb->tria1.tot) { - glColor4f(wcol->item[0], wcol->item[1], wcol->item[2], 0.125); + glColor4ub(wcol->item[0], wcol->item[1], wcol->item[2], 32); widget_trias_draw(&wtb->tria1); } if(wtb->tria2.tot) { - glColor4f(wcol->item[0], wcol->item[1], wcol->item[2], 0.125); + glColor4ub(wcol->item[0], wcol->item[1], wcol->item[2], 32); widget_trias_draw(&wtb->tria2); } @@ -766,7 +758,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiBut *but, rcti *rect) } /* draws text and icons for buttons */ -static void widget_draw_text_icon(uiFontStyle *fstyle, uiBut *but, rcti *rect, float *col) +static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) { short t, pos, ch; short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw; @@ -811,7 +803,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiBut *but, rcti *rect, f but->drawstr[selend_tmp]= ch; - UI_ThemeColor(TH_BUT_TEXTFIELD_HI); + glColor3ubv(wcol->item); glRects(rect->xmin+selsta_draw+1, rect->ymin+2, rect->xmin+selwidth_draw+1, rect->ymax-2); } } else { @@ -862,7 +854,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiBut *but, rcti *rect, f else if(but->flag & UI_TEXT_LEFT) rect->xmin += 5; - glColor3fv(col); + glColor3ubv(wcol->text); widget_draw_text(fstyle, but, rect); } @@ -879,22 +871,22 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiBut *but, rcti *rect, f /* uiWidgetStateColors - float inner_anim[4]; - float inner_anim_sel[4]; - float inner_key[4]; - float inner_key_sel[4]; - float inner_driven[4]; - float inner_driven_sel[4]; + char inner_anim[4]; + char inner_anim_sel[4]; + char inner_key[4]; + char inner_key_sel[4]; + char inner_driven[4]; + char inner_driven_sel[4]; */ static struct uiWidgetStateColors wcol_state= { - {0.45, 0.75, 0.3f, 1.0f}, - {0.35, 0.65, 0.2f, 1.0f}, - {0.95, 0.9, 0.4f, 1.0f}, - {0.85, 0.8, 0.3f, 1.0f}, - {0.7f, 0.0, 1.0f, 1.0f}, - {0.6f, 0.0, 0.9f, 1.0f} + {115, 190, 76, 255}, + {90, 166, 51, 255}, + {240, 235, 100, 255}, + {148, 204, 76, 255}, + {180, 0, 255, 255}, + {153, 0, 230, 255} }; /* uiWidgetColors @@ -910,153 +902,172 @@ static struct uiWidgetStateColors wcol_state= { */ static struct uiWidgetColors wcol_num= { - {0.1f, 0.1f, 0.1f}, - {0.7f, 0.7f, 0.7f, 1.0f}, - {0.6f, 0.6f, 0.6f, 1.0f}, - {0.35f, 0.35f, 0.35f}, + {25, 25, 25, 255}, + {180, 180, 180, 255}, + {153, 153, 153, 255}, + {90, 90, 90, 255}, - {0.0f, 0.0f, 0.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {255, 255, 255, 255}, 1, - -0.08f, 0.0f + -20, 0 }; static struct uiWidgetColors wcol_numslider= { - {0.1f, 0.1f, 0.1f}, - {0.7f, 0.7f, 0.7f, 1.0f}, - {0.6f, 0.6f, 0.6f, 1.0f}, - {0.5f, 0.5f, 0.5f}, + {25, 25, 25, 255}, + {180, 180, 180, 255}, + {153, 153, 153, 255}, + {128, 128, 128, 255}, - {0.0f, 0.0f, 0.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {255, 255, 255, 255}, 1, - -0.08f, 0.0f + -20, 0 }; static struct uiWidgetColors wcol_text= { - {0.1f, 0.1f, 0.1f}, - {0.6f, 0.6f, 0.6f, 1.0f}, - {0.6f, 0.6f, 0.6f, 1.0f}, - {0.35f, 0.35f, 0.35f}, + {25, 25, 25, 255}, + {153, 153, 153, 255}, + {153, 153, 153, 255}, + {90, 90, 90, 255}, - {0.0f, 0.0f, 0.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {255, 255, 255, 255}, 1, - 0.0f, 0.1f + 0, 25 }; static struct uiWidgetColors wcol_option= { - {0.0f, 0.0f, 0.0f}, - {0.25f, 0.25f, 0.25f, 1.0f}, - {0.25f, 0.25f, 0.25f, 1.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {63, 63, 63, 255}, + {63, 63, 63, 255}, + {255, 255, 255, 255}, - {0.0f, 0.0f, 0.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {255, 255, 255, 255}, 1, - 0.1f, -0.08f + 25, -20 }; /* button that shows popup */ static struct uiWidgetColors wcol_menu= { - {0.0f, 0.0f, 0.0f}, - {0.25f, 0.25f, 0.25f, 1.0f}, - {0.25f, 0.25f, 0.25f, 1.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {63, 63, 63, 255}, + {63, 63, 63, 255}, + {255, 255, 255, 255}, - {1.0f, 1.0f, 1.0f}, - {0.8f, 0.8f, 0.8f}, + {255, 255, 255, 255}, + {204, 204, 204, 255}, 1, - 0.1f, -0.08f + 25, -20 }; /* button that starts pulldown */ static struct uiWidgetColors wcol_pulldown= { - {0.0f, 0.0f, 0.0f}, - {0.25f, 0.25f, 0.25f, 1.0f}, - {0.18f, 0.48f, 0.85f, 1.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {63, 63, 63, 255}, + {46, 124, 217, 255}, + {255, 255, 255, 255}, - {1.0f, 1.0f, 1.0f}, - {0.0f, 0.0f, 0.0f}, + {255, 255, 255, 255}, + {0, 0, 0, 255}, 0, - 0.1f, -0.08f + 25, -20 }; /* button inside menu */ 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, 1.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {0, 0, 0, 76}, + {59, 135, 230, 255}, + {255, 255, 255, 255}, - {1.0f, 1.0f, 1.0f}, - {0.0f, 0.0f, 0.0f}, + {255, 255, 255, 255}, + {0, 0, 0, 255}, 0, - 0.15f, 0.0f + 38, 0 }; /* backdrop menu + title text color */ static struct uiWidgetColors wcol_menu_back= { - {0.0f, 0.0f, 0.0f}, - {0.0f, 0.0f, 0.0f, 0.6}, - {0.18f, 0.48f, 0.85f, 0.8f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {0, 0, 0, 153}, + {46, 124, 217, 204}, + {255, 255, 255, 255}, - {1.0f, 1.0f, 1.0f}, - {0.0f, 0.0f, 0.0f}, + {255, 255, 255, 255}, + {0, 0, 0, 255}, 0, - 0.1f, -0.08f + 25, -20 }; static struct uiWidgetColors wcol_radio= { - {0.0f, 0.0f, 0.0f}, - {0.25f, 0.25f, 0.25f, 1.0f}, - {0.34f, 0.5f, 0.76f, 1.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {63, 63, 63, 255}, + {86, 128, 194, 255}, + {255, 255, 255, 255}, - {1.0f, 1.0f, 1.0f}, - {0.0f, 0.0f, 0.0f}, + {255, 255, 255, 255}, + {0, 0, 0, 255}, 1, - 0.1f, -0.1f + 25, -25 }; static struct uiWidgetColors wcol_regular= { - {0.1f, 0.1f, 0.1f}, - {0.6f, 0.6f, 0.6f, 1.0f}, - {0.4f, 0.4f, 0.4f, 1.0f}, - {0.1f, 0.1f, 0.1f}, + {25, 25, 25, 255}, + {153, 153, 153, 255}, + {100, 100, 100, 255}, + {25, 25, 25, 255}, - {0.0f, 0.0f, 0.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {255, 255, 255, 255}, 0, - 0.0f, 0.0f + 0, 0 }; -static struct uiWidgetColors wcol_regular_shade= { - {0.1f, 0.1f, 0.1f}, - {0.6f, 0.6f, 0.6f, 1.0f}, - {0.4f, 0.4f, 0.4f, 1.0f}, - {0.1f, 0.1f, 0.1f}, +static struct uiWidgetColors wcol_tool= { + {25, 25, 25, 255}, + {153, 153, 153, 255}, + {100, 100, 100, 255}, + {25, 25, 25, 255}, - {0.0f, 0.0f, 0.0f}, - {1.0f, 1.0f, 1.0f}, + {0, 0, 0, 255}, + {255, 255, 255, 255}, 1, - 0.1f, -0.1f + 25, -25 }; +/* called for theme init (new theme) and versions */ +void ui_widget_color_init(ThemeUI *tui) +{ + + tui->wcol_regular= wcol_regular; + tui->wcol_tool= wcol_tool; + tui->wcol_radio= wcol_radio; + tui->wcol_text= wcol_text; + tui->wcol_option= wcol_option; + tui->wcol_num= wcol_num; + tui->wcol_numslider= wcol_numslider; + tui->wcol_menu= wcol_menu; + tui->wcol_pulldown= wcol_pulldown; + tui->wcol_menu_back= wcol_menu_back; + tui->wcol_menu_item= wcol_menu_item; + + tui->iconfile[0]= 0; +} + /* ************ button callbacks, state ***************** */ /* copy colors from theme, and set changes in it based on state */ @@ -1078,7 +1089,7 @@ static void widget_state(uiWidgetType *wt, int state) /* only flip shade if it's not "pushed in" already */ if(wt->wcol.shaded && wt->wcol.shadetop>wt->wcol.shadedown) { - SWAP(float, wt->wcol.shadetop, wt->wcol.shadedown); + SWAP(short, wt->wcol.shadetop, wt->wcol.shadedown); } } else { @@ -1089,11 +1100,28 @@ static void widget_state(uiWidgetType *wt, int state) else if(state & UI_BUT_DRIVEN) QUATCOPY(wt->wcol.inner, wcol_state.inner_driven) - if(state & UI_ACTIVE) /* mouse over? */ - VecMulf(wt->wcol.inner, 1.1f); + if(state & UI_ACTIVE) { /* mouse over? */ + wt->wcol.inner[0]= wt->wcol.inner[0]>=240? 255 : wt->wcol.inner[0]+15; + wt->wcol.inner[1]= wt->wcol.inner[1]>=240? 255 : wt->wcol.inner[1]+15; + wt->wcol.inner[2]= wt->wcol.inner[2]>=240? 255 : wt->wcol.inner[2]+15; + } } } +/* labels use theme colors for text */ +static void widget_state_label(uiWidgetType *wt, int state) +{ + /* call this for option button */ + widget_state(wt, state); + + if(state & UI_SELECT) + UI_GetThemeColor4ubv(TH_TEXT_HI, wt->wcol.text); + else + UI_GetThemeColor4ubv(TH_TEXT, wt->wcol.text); + +} + + /* special case, button that calls pulldown */ static void widget_state_pulldown(uiWidgetType *wt, int state) { @@ -1342,7 +1370,8 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s uiWidgetBase wtb, wtb1; rcti rect1; double value; - float offs, fac, outline[3]; + float offs, fac; + char outline[3]; widget_init(&wtb); widget_init(&wtb1); @@ -1368,11 +1397,11 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s VECCOPY(outline, wcol->outline); VECCOPY(wcol->outline, wcol->item); VECCOPY(wcol->inner, wcol->item); - SWAP(float, wcol->shadetop, wcol->shadedown); + SWAP(short, wcol->shadetop, wcol->shadedown); widgetbase_draw(&wtb1, wcol); VECCOPY(wcol->outline, outline); - SWAP(float, wcol->shadetop, wcol->shadedown); + SWAP(short, wcol->shadetop, wcol->shadedown); /* outline */ wtb.outline= 1; @@ -1384,13 +1413,17 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign) { uiWidgetBase wtb; + float col[4]; widget_init(&wtb); /* half rounded */ round_box_edges(&wtb, roundboxalign, rect, 4.0f); - ui_get_but_vectorf(but, wcol->inner); + ui_get_but_vectorf(but, col); + wcol->inner[0]= FTOCHAR(col[0]); + wcol->inner[1]= FTOCHAR(col[1]); + wcol->inner[2]= FTOCHAR(col[2]); widgetbase_draw(&wtb, wcol); @@ -1545,48 +1578,55 @@ static void widget_disabled(rcti *rect) static uiWidgetType *widget_type(uiWidgetTypeEnum type) { + bTheme *btheme= U.themes.first; static uiWidgetType wt; /* defaults */ - wt.wcol_theme= &wcol_regular; + wt.wcol_theme= &btheme->tui.wcol_regular; wt.state= widget_state; wt.draw= widget_but; wt.custom= NULL; wt.text= widget_draw_text_icon; switch(type) { + case UI_WTYPE_LABEL: + wt.draw= NULL; + wt.state= widget_state_label; + break; + case UI_WTYPE_TOGGLE: break; case UI_WTYPE_OPTION: - wt.wcol_theme= &wcol_option; + wt.wcol_theme= &btheme->tui.wcol_option; wt.draw= widget_optionbut; + wt.state= widget_state_label; break; case UI_WTYPE_RADIO: - wt.wcol_theme= &wcol_radio; + wt.wcol_theme= &btheme->tui.wcol_radio; wt.draw= widget_radiobut; break; case UI_WTYPE_NUMBER: - wt.wcol_theme= &wcol_num; + wt.wcol_theme= &btheme->tui.wcol_num; wt.draw= widget_numbut; break; case UI_WTYPE_SLIDER: - wt.wcol_theme= &wcol_numslider; + wt.wcol_theme= &btheme->tui.wcol_numslider; wt.custom= widget_numslider; break; case UI_WTYPE_EXEC: - wt.wcol_theme= &wcol_regular_shade; + wt.wcol_theme= &btheme->tui.wcol_tool; wt.draw= widget_roundbut; break; /* strings */ case UI_WTYPE_NAME: - wt.wcol_theme= &wcol_text; + wt.wcol_theme= &btheme->tui.wcol_text; wt.draw= widget_textbut; break; @@ -1602,31 +1642,31 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type) /* start menus */ case UI_WTYPE_MENU_RADIO: - wt.wcol_theme= &wcol_menu; + wt.wcol_theme= &btheme->tui.wcol_menu; wt.draw= widget_menubut; break; case UI_WTYPE_MENU_POINTER_LINK: - wt.wcol_theme= &wcol_menu; + wt.wcol_theme= &btheme->tui.wcol_menu; wt.draw= widget_menubut; break; case UI_WTYPE_PULLDOWN: - wt.wcol_theme= &wcol_pulldown; + wt.wcol_theme= &btheme->tui.wcol_pulldown; wt.draw= widget_pulldownbut; wt.state= widget_state_pulldown; break; /* in menus */ case UI_WTYPE_MENU_ITEM: - wt.wcol_theme= &wcol_menu_item; + wt.wcol_theme= &btheme->tui.wcol_menu_item; wt.draw= widget_menu_itembut; wt.state= widget_state_menu_item; break; case UI_WTYPE_MENU_BACK: - wt.wcol_theme= &wcol_menu_back; + wt.wcol_theme= &btheme->tui.wcol_menu_back; wt.draw= widget_menu_back; break; @@ -1698,13 +1738,16 @@ static int widget_roundbox_set(uiBut *but, rcti *rect) /* conversion from old to new buttons, so still messy */ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) { + bTheme *btheme= U.themes.first; + ThemeUI *tui= &btheme->tui; + uiFontStyle *fstyle= &style->widget; uiWidgetType *wt= NULL; /* handle menus seperately */ if(but->dt==UI_EMBOSSP) { switch (but->type) { case LABEL: - widget_draw_text_icon(&style->widgetlabel, but, rect, wcol_menu_back.text); + widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); break; case SEPR: break; @@ -1722,9 +1765,11 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) switch (but->type) { case LABEL: if(but->block->flag & UI_BLOCK_LOOP) - widget_draw_text_icon(&style->widgetlabel, but, rect, wcol_menu_back.text); - else - widget_draw_text_icon(&style->widgetlabel, but, rect, wcol_regular.text); + widget_draw_text_icon(&style->widgetlabel, &tui->wcol_menu_back, but, rect); + else { + wt= widget_type(UI_WTYPE_LABEL); + fstyle= &style->widgetlabel; + } break; case SEPR: break; @@ -1781,13 +1826,13 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) ui_draw_but_HSVCUBE(but, rect); break; case BUT_COLORBAND: - ui_draw_but_COLORBAND(but, rect); + ui_draw_but_COLORBAND(but, &tui->wcol_regular, rect); break; case BUT_NORMAL: - ui_draw_but_NORMAL(but, rect); + ui_draw_but_NORMAL(but, &tui->wcol_regular, rect); break; case BUT_CURVE: - ui_draw_but_CURVE(ar, but, rect); + ui_draw_but_CURVE(ar, but, &tui->wcol_regular, rect); break; default: @@ -1808,7 +1853,7 @@ void ui_draw_but(ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) wt->custom(but, &wt->wcol, rect, state, roundboxalign); else if(wt->draw) wt->draw(&wt->wcol, rect, state, roundboxalign); - wt->text(&style->widget, but, rect, wt->wcol.text); + wt->text(fstyle, &wt->wcol, but, rect); if(state & UI_BUT_DISABLED) if(but->dt!=UI_EMBOSSP) @@ -1828,39 +1873,4 @@ void ui_draw_menu_back(uiStyle *style, uiBlock *block, rcti *rect) } -/* test function only */ -void drawnewstuff() -{ - rcti rect; - - rect.xmin= 10; rect.xmax= 10+100; - rect.ymin= -30; rect.ymax= -30+18; - widget_numbut(&wcol_num, &rect, 0, 15); - - rect.xmin= 120; rect.xmax= 120+100; - rect.ymin= -30; rect.ymax= -30+20; - widget_numbut(&wcol_num, &rect, 0, 15); - - rect.xmin= 10; rect.xmax= 10+100; - rect.ymin= -60; rect.ymax= -60+20; - widget_menubut(&wcol_menu, &rect, 0, 15); - - rect.xmin= 120; rect.xmax= 120+100; - widget_but(&wcol_regular, &rect, 0, 15); - - rect.xmin= 10; rect.xmax= 10+100; - rect.ymin= -90; rect.ymax= -90+20; - widget_radiobut(&wcol_radio, &rect, 1, 9); - - rect.xmin= 109; rect.xmax= 110+100; - rect.ymin= -90; rect.ymax= -90+20; - widget_radiobut(&wcol_radio, &rect, 0, 6); - - rect.xmin= 240; rect.xmax= 240+30; - rect.ymin= -90; rect.ymax= -90+30; - widget_roundbut(&wcol_regular_shade, &rect, 0, 15); -} - - - diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 039ebcc91f9..332705f9066 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -40,30 +40,38 @@ #include "MEM_guardedalloc.h" + +#include "DNA_curve_types.h" #include "DNA_listBase.h" #include "DNA_userdef_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "BLI_blenlib.h" + #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" +#include "BKE_DerivedMesh.h" +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_texture.h" #include "BKE_utildefines.h" #include "BIF_gl.h" +#include "UI_interface.h" #include "UI_resources.h" #include "UI_interface_icons.h" -//#include "UI_icons.h" -#include "BLI_blenlib.h" +#include "interface_intern.h" /* global for themes */ typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha); static bTheme *theme_active=NULL; static int theme_spacetype= SPACE_VIEW3D; - +static int theme_regionid= RGN_TYPE_WINDOW; void ui_resources_init(void) { @@ -86,7 +94,6 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) static char error[4]={240, 0, 240, 255}; static char alert[4]={240, 60, 60, 255}; static char headerdesel[4]={0,0,0,255}; - static char custom[4]={0,0,0,255}; char *cp= error; @@ -96,51 +103,9 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) if(colorid < TH_THEMEUI) { switch(colorid) { - case TH_BUT_OUTLINE: - cp= btheme->tui.outline; break; - case TH_BUT_NEUTRAL: - cp= btheme->tui.neutral; break; - case TH_BUT_ACTION: - cp= btheme->tui.action; break; - case TH_BUT_SETTING: - cp= btheme->tui.setting; break; - case TH_BUT_SETTING1: - cp= btheme->tui.setting1; break; - case TH_BUT_SETTING2: - cp= btheme->tui.setting2; break; - case TH_BUT_NUM: - cp= btheme->tui.num; break; - case TH_BUT_TEXTFIELD: - cp= btheme->tui.textfield; break; - case TH_BUT_TEXTFIELD_HI: - cp= btheme->tui.textfield_hi; break; - case TH_BUT_POPUP: - cp= btheme->tui.popup; break; - case TH_BUT_TEXT: - cp= btheme->tui.text; break; - case TH_BUT_TEXT_HI: - cp= btheme->tui.text_hi; break; - case TH_MENU_BACK: - cp= btheme->tui.menu_back; break; - case TH_MENU_ITEM: - cp= btheme->tui.menu_item; break; - case TH_MENU_HILITE: - cp= btheme->tui.menu_hilite; break; - case TH_MENU_TEXT: - cp= btheme->tui.menu_text; break; - case TH_MENU_TEXT_HI: - cp= btheme->tui.menu_text_hi; break; - - case TH_BUT_DRAWTYPE: - cp= &btheme->tui.but_drawtype; break; - case TH_ICONFILE: - cp= btheme->tui.iconfile; break; - case TH_REDALERT: cp= alert; break; - case TH_CUSTOM: - cp= custom; break; } } else { @@ -198,11 +163,46 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) switch(colorid) { case TH_BACK: - cp= ts->back; break; + if(theme_regionid==RGN_TYPE_WINDOW) + cp= ts->back; + else if(theme_regionid==RGN_TYPE_CHANNELS) + cp= ts->list; + else if(theme_regionid==RGN_TYPE_HEADER) + cp= ts->header; + else + cp= ts->button; + break; case TH_TEXT: - cp= ts->text; break; + if(theme_regionid==RGN_TYPE_WINDOW) + cp= ts->text; + else if(theme_regionid==RGN_TYPE_CHANNELS) + cp= ts->list_text; + else if(theme_regionid==RGN_TYPE_HEADER) + cp= ts->header_text; + else + cp= ts->button_text; + break; case TH_TEXT_HI: - cp= ts->text_hi; break; + if(theme_regionid==RGN_TYPE_WINDOW) + cp= ts->text_hi; + else if(theme_regionid==RGN_TYPE_CHANNELS) + cp= ts->list_text_hi; + else if(theme_regionid==RGN_TYPE_HEADER) + cp= ts->header_text_hi; + else + cp= ts->button_text_hi; + break; + case TH_TITLE: + if(theme_regionid==RGN_TYPE_WINDOW) + cp= ts->title; + else if(theme_regionid==RGN_TYPE_CHANNELS) + cp= ts->list_title; + else if(theme_regionid==RGN_TYPE_HEADER) + cp= ts->header_title; + else + cp= ts->button_title; + break; + case TH_HEADER: cp= ts->header; break; case TH_HEADERDESEL: @@ -213,8 +213,25 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) headerdesel[2]= cp[2]>10?cp[2]-10:0; cp= headerdesel; break; + case TH_HEADER_TEXT: + cp= ts->header_text; break; + case TH_HEADER_TEXT_HI: + cp= ts->header_text_hi; break; + case TH_PANEL: cp= ts->panel; break; + case TH_PANEL_TEXT: + cp= ts->panel_text; break; + case TH_PANEL_TEXT_HI: + cp= ts->panel_text_hi; break; + + case TH_BUTBACK: + cp= ts->button; break; + case TH_BUTBACK_TEXT: + cp= ts->button_text; break; + case TH_BUTBACK_TEXT_HI: + cp= ts->button_text_hi; break; + case TH_SHADE1: cp= ts->shade1; break; case TH_SHADE2: @@ -340,11 +357,55 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) return cp; } +#define SETCOLTEST(col, r, g, b, a) if(col[3]==0) {col[0]=r; col[1]=g; col[2]= b; col[3]= a;} + +/* use this call to init new variables in themespace, if they're same for all */ +static void ui_theme_init_new_do(ThemeSpace *ts) +{ + SETCOLTEST(ts->header_text, 0, 0, 0, 255); + SETCOLTEST(ts->header_title, 0, 0, 0, 255); + SETCOLTEST(ts->header_text_hi, 255, 255, 255, 255); + + SETCOLTEST(ts->panel_text, 0, 0, 0, 255); + SETCOLTEST(ts->panel_title, 0, 0, 0, 255); + SETCOLTEST(ts->panel_text_hi, 255, 255, 255, 255); + + SETCOLTEST(ts->button, 145, 145, 145, 245); + SETCOLTEST(ts->button_title, 0, 0, 0, 255); + SETCOLTEST(ts->button_text, 0, 0, 0, 255); + SETCOLTEST(ts->button_text_hi, 255, 255, 255, 255); + + SETCOLTEST(ts->list, 165, 165, 165, 255); + SETCOLTEST(ts->list_title, 0, 0, 0, 255); + SETCOLTEST(ts->list_text, 0, 0, 0, 255); + SETCOLTEST(ts->list_text_hi, 255, 255, 255, 255); +} + +static void ui_theme_init_new(bTheme *btheme) +{ + ui_theme_init_new_do(&btheme->tbuts); + ui_theme_init_new_do(&btheme->tv3d); + ui_theme_init_new_do(&btheme->tfile); + ui_theme_init_new_do(&btheme->tipo); + ui_theme_init_new_do(&btheme->tinfo); + ui_theme_init_new_do(&btheme->tsnd); + ui_theme_init_new_do(&btheme->tact); + ui_theme_init_new_do(&btheme->tnla); + ui_theme_init_new_do(&btheme->tseq); + ui_theme_init_new_do(&btheme->tima); + ui_theme_init_new_do(&btheme->timasel); + ui_theme_init_new_do(&btheme->text); + ui_theme_init_new_do(&btheme->toops); + ui_theme_init_new_do(&btheme->ttime); + ui_theme_init_new_do(&btheme->tnode); + +} + #define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a; -/* initialize +/* initialize default theme, can't be edited Note: when you add new colors, created & saved themes need initialized - in usiblender.c, search for "versionfile" + use function below, init_userdef_do_versions() */ void ui_theme_init_userdef(void) { @@ -361,39 +422,22 @@ void ui_theme_init_userdef(void) strcpy(btheme->name, "Default"); } - UI_SetTheme(NULL); // make sure the global used in this file is set + UI_SetTheme(0, 0); // make sure the global used in this file is set /* UI buttons */ - SETCOL(btheme->tui.outline, 130, 130, 130, 255); - SETCOL(btheme->tui.neutral, 165, 165, 165, 255); - SETCOL(btheme->tui.action, 165, 165, 165, 255); - SETCOL(btheme->tui.setting, 165, 165, 165, 255); - SETCOL(btheme->tui.setting1, 165, 165, 165, 255); - SETCOL(btheme->tui.setting2, 165, 165, 165, 255); - SETCOL(btheme->tui.num, 165, 165, 165, 255); - SETCOL(btheme->tui.textfield, 143, 142, 143, 255); - SETCOL(btheme->tui.textfield_hi,255, 151, 26, 255); - SETCOL(btheme->tui.popup, 174, 174, 174, 255); - - SETCOL(btheme->tui.text, 0,0,0, 255); - SETCOL(btheme->tui.text_hi, 255, 255, 255, 255); - - SETCOL(btheme->tui.menu_back, 220, 220, 220, 235); - SETCOL(btheme->tui.menu_item, 255, 255, 255, 20); - SETCOL(btheme->tui.menu_hilite, 110, 110, 110, 255); - SETCOL(btheme->tui.menu_text, 0, 0, 0, 255); - SETCOL(btheme->tui.menu_text_hi, 255, 255, 255, 255); - - btheme->tui.but_drawtype= TH_ROUNDSHADED; - BLI_strncpy(btheme->tui.iconfile, "", sizeof(btheme->tui.iconfile)); + ui_widget_color_init(&btheme->tui); + /* common (new) variables */ + ui_theme_init_new(btheme); + /* space view3d */ SETCOL(btheme->tv3d.back, 90, 90, 90, 255); SETCOL(btheme->tv3d.text, 0, 0, 0, 255); SETCOL(btheme->tv3d.text_hi, 255, 255, 255, 255); + SETCOL(btheme->tv3d.header, 185, 185, 185, 255); SETCOL(btheme->tv3d.panel, 165, 165, 165, 127); - + SETCOL(btheme->tv3d.shade1, 160, 160, 160, 100); SETCOL(btheme->tv3d.shade2, 0x7f, 0x70, 0x70, 100); @@ -583,188 +627,19 @@ void ui_theme_init_userdef(void) } -char *UI_ThemeColorsPup(int spacetype) -{ - char *cp= MEM_callocN(32*32, "theme pup"); - char *str = cp; - - if(spacetype==0) { - str += sprintf(str, "Outline %%x%d|", TH_BUT_OUTLINE); - str += sprintf(str, "Neutral %%x%d|", TH_BUT_NEUTRAL); - str += sprintf(str, "Action %%x%d|", TH_BUT_ACTION); - str += sprintf(str, "Setting %%x%d|", TH_BUT_SETTING); - str += sprintf(str, "Special Setting 1%%x%d|", TH_BUT_SETTING1); - str += sprintf(str, "Special Setting 2 %%x%d|", TH_BUT_SETTING2); - str += sprintf(str, "Number Input %%x%d|", TH_BUT_NUM); - str += sprintf(str, "Text Input %%x%d|", TH_BUT_TEXTFIELD); - str += sprintf(str, "Text Input Highlight %%x%d|", TH_BUT_TEXTFIELD_HI); - str += sprintf(str, "Popup %%x%d|", TH_BUT_POPUP); - str += sprintf(str, "Text %%x%d|", TH_BUT_TEXT); - str += sprintf(str, "Text Highlight %%x%d|", TH_BUT_TEXT_HI); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Menu Background %%x%d|", TH_MENU_BACK); - str += sprintf(str, "Menu Item %%x%d|", TH_MENU_ITEM); - str += sprintf(str, "Menu Item Highlight %%x%d|", TH_MENU_HILITE); - str += sprintf(str, "Menu Text %%x%d|", TH_MENU_TEXT); - str += sprintf(str, "Menu Text Highlight %%x%d|", TH_MENU_TEXT_HI); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Drawtype %%x%d|", TH_BUT_DRAWTYPE); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Icon File %%x%d|", TH_ICONFILE); - } - else { - // first defaults for each space - str += sprintf(str, "Background %%x%d|", TH_BACK); - str += sprintf(str, "Text %%x%d|", TH_TEXT); - str += sprintf(str, "Text Highlight %%x%d|", TH_TEXT_HI); - str += sprintf(str, "Header %%x%d|", TH_HEADER); - - switch(spacetype) { - case SPACE_VIEW3D: - str += sprintf(str, "Panel %%x%d|", TH_PANEL); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Grid %%x%d|", TH_GRID); - str += sprintf(str, "Wire %%x%d|", TH_WIRE); - str += sprintf(str, "Lamp %%x%d|", TH_LAMP); - str += sprintf(str, "Object Selected %%x%d|", TH_SELECT); - str += sprintf(str, "Object Active %%x%d|", TH_ACTIVE); - str += sprintf(str, "Object Grouped %%x%d|", TH_GROUP); - str += sprintf(str, "Object Grouped Active %%x%d|", TH_GROUP_ACTIVE); - str += sprintf(str, "Transform %%x%d|", TH_TRANSFORM); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Vertex %%x%d|", TH_VERTEX); - str += sprintf(str, "Vertex Selected %%x%d|", TH_VERTEX_SELECT); - str += sprintf(str, "Vertex Size %%x%d|", TH_VERTEX_SIZE); - str += sprintf(str, "Edge Selected %%x%d|", TH_EDGE_SELECT); - str += sprintf(str, "Edge Seam %%x%d|", TH_EDGE_SEAM); - str += sprintf(str, "Edge Sharp %%x%d|", TH_EDGE_SHARP); - str += sprintf(str, "Edge UV Face Select %%x%d|", TH_EDGE_FACESEL); - str += sprintf(str, "Face (transp) %%x%d|", TH_FACE); - str += sprintf(str, "Face Selected (transp) %%x%d|", TH_FACE_SELECT); - str += sprintf(str, "Face Dot Selected %%x%d|", TH_FACE_DOT); - str += sprintf(str, "Face Dot Size %%x%d|", TH_FACEDOT_SIZE); - str += sprintf(str, "Active Vert/Edge/Face %%x%d|", TH_EDITMESH_ACTIVE); - str += sprintf(str, "Normal %%x%d|", TH_NORMAL); - str += sprintf(str, "Bone Solid %%x%d|", TH_BONE_SOLID); - str += sprintf(str, "Bone Pose %%x%d", TH_BONE_POSE); - str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); - break; - case SPACE_IPO: - str += sprintf(str, "Panel %%x%d|", TH_PANEL); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Grid %%x%d|", TH_GRID); - str += sprintf(str, "Window Sliders %%x%d|", TH_SHADE1); - str += sprintf(str, "Ipo Channels %%x%d|", TH_SHADE2); - str += sprintf(str, "Vertex %%x%d|", TH_VERTEX); - str += sprintf(str, "Vertex Selected %%x%d|", TH_VERTEX_SELECT); - str += sprintf(str, "Vertex Size %%x%d|", TH_VERTEX_SIZE); - str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); - break; - case SPACE_FILE: - str += sprintf(str, "Selected file %%x%d", TH_HILITE); - break; - case SPACE_NLA: - //str += sprintf(str, "Panel %%x%d|", TH_PANEL); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Grid %%x%d|", TH_GRID); - str += sprintf(str, "View Sliders %%x%d|", TH_SHADE1); - str += sprintf(str, "Bars %%x%d|", TH_SHADE2); - str += sprintf(str, "Bars selected %%x%d|", TH_HILITE); - str += sprintf(str, "Strips %%x%d|", TH_STRIP); - str += sprintf(str, "Strips selected %%x%d|", TH_STRIP_SELECT); - str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); - break; - case SPACE_ACTION: - //str += sprintf(str, "Panel %%x%d|", TH_PANEL); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Grid %%x%d|", TH_GRID); - str += sprintf(str, "RVK Sliders %%x%d|", TH_FACE); - str += sprintf(str, "View Sliders %%x%d|", TH_SHADE1); - str += sprintf(str, "Channels %%x%d|", TH_SHADE2); - str += sprintf(str, "Channels Selected %%x%d|", TH_HILITE); - str += sprintf(str, "Long Key %%x%d|", TH_STRIP); - str += sprintf(str, "Long Key selected %%x%d|", TH_STRIP_SELECT); - str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); - break; - case SPACE_IMAGE: - str += sprintf(str, "%%l|"); - str += sprintf(str, "Vertex %%x%d|", TH_VERTEX); - str += sprintf(str, "Vertex Selected %%x%d|", TH_VERTEX_SELECT); - str += sprintf(str, "Vertex Size %%x%d|", TH_VERTEX_SIZE); - str += sprintf(str, "Face %%x%d|", TH_FACE); - str += sprintf(str, "Face Selected %%x%d", TH_FACE_SELECT); - break; - case SPACE_SEQ: - str += sprintf(str, "Grid %%x%d|", TH_GRID); - str += sprintf(str, "Window Sliders %%x%d|", TH_SHADE1); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Movie Strip %%x%d|", TH_SEQ_MOVIE); - str += sprintf(str, "Image Strip %%x%d|", TH_SEQ_IMAGE); - str += sprintf(str, "Scene Strip %%x%d|", TH_SEQ_SCENE); - str += sprintf(str, "Audio Strip %%x%d|", TH_SEQ_AUDIO); - str += sprintf(str, "Effect Strip %%x%d|", TH_SEQ_EFFECT); - str += sprintf(str, "Plugin Strip %%x%d|", TH_SEQ_PLUGIN); - str += sprintf(str, "Transition Strip %%x%d|", TH_SEQ_TRANSITION); - str += sprintf(str, "Meta Strip %%x%d|", TH_SEQ_META); - str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); - break; - case SPACE_SOUND: - str += sprintf(str, "Grid %%x%d|", TH_GRID); - str += sprintf(str, "Window Slider %%x%d|", TH_SHADE1); - str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); - break; - case SPACE_BUTS: - str += sprintf(str, "Panel %%x%d|", TH_PANEL); - break; - case SPACE_IMASEL: - str += sprintf(str, "Tiles %%x%d|", TH_PANEL); - str += sprintf(str, "Scrollbar %%x%d|", TH_SHADE1); - str += sprintf(str, "Scroll Handle %%x%d|", TH_SHADE2); - str += sprintf(str, "Selected File %%x%d|", TH_HILITE); - str += sprintf(str, "Active File %%x%d|", TH_ACTIVE); - str += sprintf(str, "Active File Text%%x%d|", TH_GRID); - break; - case SPACE_TEXT: - str += sprintf(str, "Scroll Bar %%x%d|", TH_SHADE1); - str += sprintf(str, "Selected Text %%x%d|", TH_SHADE2); - str += sprintf(str, "Cursor %%x%d|", TH_HILITE); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Syntax Builtin %%x%d|", TH_SYNTAX_B); - str += sprintf(str, "Syntax Special %%x%d|", TH_SYNTAX_V); - str += sprintf(str, "Syntax Comment %%x%d|", TH_SYNTAX_C); - str += sprintf(str, "Syntax Strings %%x%d|", TH_SYNTAX_L); - str += sprintf(str, "Syntax Numbers %%x%d|", TH_SYNTAX_N); - break; - case SPACE_TIME: - str += sprintf(str, "Grid %%x%d|", TH_GRID); - str += sprintf(str, "Current Frame %%x%d", TH_CFRAME); - break; - case SPACE_NODE: - str += sprintf(str, "Wires %%x%d|", TH_WIRE); - str += sprintf(str, "Wires Select %%x%d|", TH_EDGE_SELECT); - str += sprintf(str, "%%l|"); - str += sprintf(str, "Node Backdrop %%x%d|", TH_NODE); - str += sprintf(str, "In/Out Node %%x%d|", TH_NODE_IN_OUT); - str += sprintf(str, "Convertor Node %%x%d|", TH_NODE_CONVERTOR); - str += sprintf(str, "Operator Node %%x%d|", TH_NODE_OPERATOR); - str += sprintf(str, "Group Node %%x%d|", TH_NODE_GROUP); - break; - } - } - return cp; -} -void UI_SetTheme(ScrArea *sa) +void UI_SetTheme(int spacetype, int regionid) { - if(sa==NULL) { // called for safety, when delete themes + if(spacetype==0) { // called for safety, when delete themes theme_active= U.themes.first; theme_spacetype= SPACE_VIEW3D; + theme_regionid= RGN_TYPE_WINDOW; } else { // later on, a local theme can be found too theme_active= U.themes.first; - theme_spacetype= sa->spacetype; - + theme_spacetype= spacetype; + theme_regionid= regionid; } } @@ -985,3 +860,395 @@ void UI_GetColorPtrBlendShade3ubv(char *cp1, char *cp2, char *col, float fac, in col[2] = b; } + +/* ************************************************************* */ + +/* patching UserDef struct and Themes */ +void init_userdef_do_versions(void) +{ +// countall(); + + /* the UserDef struct is not corrected with do_versions() .... ugh! */ + if(U.wheellinescroll == 0) U.wheellinescroll = 3; + if(U.menuthreshold1==0) { + U.menuthreshold1= 5; + U.menuthreshold2= 2; + } + if(U.tb_leftmouse==0) { + U.tb_leftmouse= 5; + U.tb_rightmouse= 5; + } + if(U.mixbufsize==0) U.mixbufsize= 2048; + if (BLI_streq(U.tempdir, "/")) { + char *tmp= getenv("TEMP"); + + strcpy(U.tempdir, tmp?tmp:"/tmp/"); + } + if (U.savetime <= 0) { + U.savetime = 1; +// XXX error(".B.blend is buggy, please consider removing it.\n"); + } + /* transform widget settings */ + if(U.tw_hotspot==0) { + U.tw_hotspot= 14; + U.tw_size= 20; // percentage of window size + U.tw_handlesize= 16; // percentage of widget radius + } + if(U.pad_rot_angle==0) + U.pad_rot_angle= 15; + + if(U.flag & USER_CUSTOM_RANGE) + vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */ + + if (G.main->versionfile <= 191) { + strcpy(U.plugtexdir, U.textudir); + strcpy(U.sounddir, "/"); + } + + /* patch to set Dupli Armature */ + if (G.main->versionfile < 220) { + U.dupflag |= USER_DUP_ARM; + } + + /* added seam, normal color, undo */ + if (G.main->versionfile <= 234) { + bTheme *btheme; + + U.uiflag |= USER_GLOBALUNDO; + if (U.undosteps==0) U.undosteps=32; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* check for alpha==0 is safe, then color was never set */ + if(btheme->tv3d.edge_seam[3]==0) { + SETCOL(btheme->tv3d.edge_seam, 230, 150, 50, 255); + } + if(btheme->tv3d.normal[3]==0) { + SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255); + } + if(btheme->tv3d.face_dot[3]==0) { + SETCOL(btheme->tv3d.face_dot, 255, 138, 48, 255); + btheme->tv3d.facedot_size= 4; + } + } + } + if (G.main->versionfile <= 235) { + /* illegal combo... */ + if (U.flag & USER_LMOUSESELECT) + U.flag &= ~USER_TWOBUTTONMOUSE; + } + if (G.main->versionfile <= 236) { + bTheme *btheme; + /* new space type */ + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* check for alpha==0 is safe, then color was never set */ + if(btheme->ttime.back[3]==0) { + btheme->ttime = btheme->tsnd; // copy from sound + } + if(btheme->text.syntaxn[3]==0) { + SETCOL(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/ + SETCOL(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */ + SETCOL(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */ + SETCOL(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */ + SETCOL(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */ + } + } + } + if (G.main->versionfile <= 237) { + bTheme *btheme; + /* bone colors */ + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* check for alpha==0 is safe, then color was never set */ + if(btheme->tv3d.bone_solid[3]==0) { + SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255); + SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80); + } + } + } + if (G.main->versionfile <= 238) { + bTheme *btheme; + /* bone colors */ + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* check for alpha==0 is safe, then color was never set */ + if(btheme->tnla.strip[3]==0) { + SETCOL(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255); + SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255); + } + } + } + if (G.main->versionfile <= 239) { + bTheme *btheme; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* Lamp theme, check for alpha==0 is safe, then color was never set */ + if(btheme->tv3d.lamp[3]==0) { + SETCOL(btheme->tv3d.lamp, 0, 0, 0, 40); +/* TEMPORAL, remove me! (ton) */ + U.uiflag |= USER_PLAINMENUS; + } + + } + if(U.obcenter_dia==0) U.obcenter_dia= 6; + } + if (G.main->versionfile <= 241) { + bTheme *btheme; + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* Node editor theme, check for alpha==0 is safe, then color was never set */ + if(btheme->tnode.syntaxn[3]==0) { + /* re-uses syntax color storage */ + btheme->tnode= btheme->tv3d; + SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255); + SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */ + SETCOL(btheme->tnode.syntaxn, 129, 131, 144, 255); /* in/output */ + SETCOL(btheme->tnode.syntaxb, 127,127,127, 255); /* operator */ + SETCOL(btheme->tnode.syntaxv, 142, 138, 145, 255); /* generator */ + SETCOL(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */ + } + /* Group theme colors */ + if(btheme->tv3d.group[3]==0) { + SETCOL(btheme->tv3d.group, 0x10, 0x40, 0x10, 255); + SETCOL(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255); + } + /* Sequence editor theme*/ + if(btheme->tseq.movie[3]==0) { + SETCOL(btheme->tseq.movie, 81, 105, 135, 255); + SETCOL(btheme->tseq.image, 109, 88, 129, 255); + SETCOL(btheme->tseq.scene, 78, 152, 62, 255); + SETCOL(btheme->tseq.audio, 46, 143, 143, 255); + SETCOL(btheme->tseq.effect, 169, 84, 124, 255); + SETCOL(btheme->tseq.plugin, 126, 126, 80, 255); + SETCOL(btheme->tseq.transition, 162, 95, 111, 255); + SETCOL(btheme->tseq.meta, 109, 145, 131, 255); + } + } + + /* set defaults for 3D View rotating axis indicator */ + /* since size can't be set to 0, this indicates it's not saved in .B.blend */ + if (U.rvisize == 0) { + U.rvisize = 15; + U.rvibright = 8; + U.uiflag |= USER_SHOW_ROTVIEWICON; + } + + } + if (G.main->versionfile <= 242) { + bTheme *btheme; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* long keyframe color */ + /* check for alpha==0 is safe, then color was never set */ + if(btheme->tact.strip[3]==0) { + SETCOL(btheme->tv3d.edge_sharp, 255, 32, 32, 255); + SETCOL(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204); + SETCOL(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204); + } + + /* IPO-Editor - Vertex Size*/ + if(btheme->tipo.vertex_size == 0) { + btheme->tipo.vertex_size= 3; + } + } + } + if (G.main->versionfile <= 243) { + /* set default number of recently-used files (if not set) */ + if (U.recent_files == 0) U.recent_files = 10; + } + if (G.main->versionfile < 245 || (G.main->versionfile == 245 && G.main->subversionfile < 3)) { + bTheme *btheme; + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128); + } + if(U.coba_weight.tot==0) + init_colorband(&U.coba_weight, 1); + } + if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 11)) { + bTheme *btheme; + for (btheme= U.themes.first; btheme; btheme= btheme->next) { + /* these should all use the same colour */ + SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255); + } + } + if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 11)) { + bTheme *btheme; + for (btheme= U.themes.first; btheme; btheme= btheme->next) { + /* these should all use the same color */ + SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255); + SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255); + } + } + if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 13)) { + bTheme *btheme; + for (btheme= U.themes.first; btheme; btheme= btheme->next) { + /* action channel groups (recolor anyway) */ + SETCOL(btheme->tact.group, 0x39, 0x7d, 0x1b, 255); + SETCOL(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255); + + /* bone custom-color sets */ + // FIXME: this check for initialised colors is bad + if (btheme->tarm[0].solid[3] == 0) { + /* set 1 */ + SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255); + SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255); + SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255); + /* set 2 */ + SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255); + SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255); + SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255); + /* set 3 */ + SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255); + SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255); + SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255); + /* set 4 */ + SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255); + SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255); + SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255); + /* set 5 */ + SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255); + SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255); + SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255); + /* set 6 */ + SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255); + SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255); + SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255); + /* set 7 */ + SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255); + SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255); + SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255); + /* set 8 */ + SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255); + SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255); + SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255); + /* set 9 */ + SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255); + SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255); + SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255); + /* set 10 */ + SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255); + SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255); + SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255); + /* set 11 */ + SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255); + SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255); + SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255); + /* set 12 */ + SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255); + SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255); + SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255); + /* set 13 */ + SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255); + SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255); + SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255); + /* set 14 */ + SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255); + SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255); + SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255); + /* set 15 */ + SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255); + SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255); + SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255); + } + } + } + if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 16)) { + U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE; + } + if ((G.main->versionfile < 247) || (G.main->versionfile == 247 && G.main->subversionfile <= 2)) { + bTheme *btheme; + + /* adjust themes */ + for (btheme= U.themes.first; btheme; btheme= btheme->next) { + char *col; + + /* IPO Editor: Handles/Vertices */ + col = btheme->tipo.vertex; + SETCOL(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255); + col = btheme->tipo.vertex_select; + SETCOL(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255); + btheme->tipo.handle_vertex_size= btheme->tipo.vertex_size; + + /* Sequence/Image Editor: colors for GPencil text */ + col = btheme->tv3d.bone_pose; + SETCOL(btheme->tseq.bone_pose, col[0], col[1], col[2], 255); + SETCOL(btheme->tima.bone_pose, col[0], col[1], col[2], 255); + col = btheme->tv3d.vertex_select; + SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255); + } + } + if (G.main->versionfile < 250) { + bTheme *btheme; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + /* this was not properly initialized in 2.45 */ + if(btheme->tima.face_dot[3]==0) { + SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128); + SETCOL(btheme->tima.face_dot, 255, 133, 0, 255); + btheme->tima.facedot_size= 2; + } + + /* DopeSheet - (Object) Channel color */ + SETCOL(btheme->tact.ds_channel, 82, 96, 110, 255); + SETCOL(btheme->tact.ds_subchannel, 124, 137, 150, 255); + /* DopeSheet - Group Channel color (saner version) */ + SETCOL(btheme->tact.group, 79, 101, 73, 255); + SETCOL(btheme->tact.group_active, 135, 177, 125, 255); + + /* Graph Editor - (Object) Channel color */ + SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255); + SETCOL(btheme->tipo.ds_subchannel, 124, 137, 150, 255); + /* Graph Editor - Group Channel color */ + SETCOL(btheme->tipo.group, 79, 101, 73, 255); + SETCOL(btheme->tipo.group_active, 135, 177, 125, 255); + } + + /* adjust grease-pencil distances */ + U.gp_manhattendist= 1; + U.gp_euclideandist= 2; + + /* adjust default interpolation for new IPO-curves */ + U.ipo_new= BEZT_IPO_BEZ; + } + + if (G.main->versionfile < 250 || (G.main->versionfile == 250 && G.main->subversionfile < 1)) { + bTheme *btheme; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + + /* common (new) variables, it checks for alpha==0 */ + ui_theme_init_new(btheme); + + if(btheme->tui.wcol_num.outline[3]==0) + ui_widget_color_init(&btheme->tui); + } + } + + /* GL Texture Garbage Collection (variable abused above!) */ + if (U.textimeout == 0) { + U.texcollectrate = 60; + U.textimeout = 120; + } + if (U.memcachelimit <= 0) { + U.memcachelimit = 32; + } + if (U.frameserverport == 0) { + U.frameserverport = 8080; + } + + /* funny name, but it is GE stuff, moves userdef stuff to engine */ +// XXX space_set_commmandline_options(); + /* this timer uses U */ +// XXX reset_autosave(); + +} + + + diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 54775c4e5ab..f7d1723b689 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -65,12 +65,15 @@ /* general area and region code */ -static void region_draw_emboss(ARegion *ar) +static void region_draw_emboss(ARegion *ar, rcti *scirct) { - short winx, winy; + rcti rect; - winx= ar->winrct.xmax-ar->winrct.xmin; - winy= ar->winrct.ymax-ar->winrct.ymin; + /* translate scissor rect to region space */ + rect.xmin= scirct->xmin - ar->winrct.xmin; + rect.ymin= scirct->ymin - ar->winrct.ymin; + rect.xmax= scirct->xmax - ar->winrct.xmin; + rect.ymax= scirct->ymax - ar->winrct.ymin; /* set transp line */ glEnable( GL_BLEND ); @@ -78,19 +81,19 @@ static void region_draw_emboss(ARegion *ar) /* right */ glColor4ub(0,0,0, 50); - sdrawline(winx, 0, winx, winy); + sdrawline(rect.xmax, rect.ymin, rect.xmax, rect.ymax); /* bottom */ glColor4ub(0,0,0, 80); - sdrawline(0, 0, winx, 0); + sdrawline(rect.xmin, rect.ymin, rect.xmax, rect.ymin); /* top */ glColor4ub(255,255,255, 60); - sdrawline(0, winy, winx, winy); + sdrawline(rect.xmin, rect.ymax, rect.xmax, rect.ymax); /* left */ glColor4ub(255,255,255, 50); - sdrawline(0, 0, 0, winy); + sdrawline(rect.xmin, rect.ymin, rect.xmin, rect.ymax); glDisable( GL_BLEND ); } @@ -190,49 +193,75 @@ void ED_area_overdraw(bContext *C) } +/* get scissor rect, checking overlapping regions */ +static void region_scissor_winrct(ARegion *ar, rcti *winrct) +{ + *winrct= ar->winrct; + + if(ELEM(ar->alignment, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) + return; + + while(ar->prev) { + ar= ar->prev; + + if(ar->flag & RGN_FLAG_HIDDEN); + else if(ar->alignment==RGN_OVERLAP_LEFT) { + winrct->xmin= ar->winrct.xmax + 1; + } + else if(ar->alignment==RGN_OVERLAP_RIGHT) { + winrct->xmax= ar->winrct.xmin - 1; + } + else break; + } +} + /* only exported for WM */ void ED_region_do_draw(bContext *C, ARegion *ar) { wmWindow *win= CTX_wm_window(C); ScrArea *sa= CTX_wm_area(C); ARegionType *at= ar->type; - + rcti winrct; + + /* checks other overlapping regions */ + region_scissor_winrct(ar, &winrct); + /* if no partial draw rect set, full rect */ if(ar->drawrct.xmin == ar->drawrct.xmax) - ar->drawrct= ar->winrct; - - /* extra clip for safety */ - ar->drawrct.xmin= MAX2(ar->winrct.xmin, ar->drawrct.xmin); - ar->drawrct.ymin= MAX2(ar->winrct.ymin, ar->drawrct.ymin); - ar->drawrct.xmax= MIN2(ar->winrct.xmax, ar->drawrct.xmax); - ar->drawrct.ymax= MIN2(ar->winrct.ymax, ar->drawrct.ymax); + ar->drawrct= winrct; + else { + /* extra clip for safety */ + ar->drawrct.xmin= MAX2(winrct.xmin, ar->drawrct.xmin); + ar->drawrct.ymin= MAX2(winrct.ymin, ar->drawrct.ymin); + ar->drawrct.xmax= MIN2(winrct.xmax, ar->drawrct.xmax); + ar->drawrct.ymax= MIN2(winrct.ymax, ar->drawrct.ymax); + } /* note; this sets state, so we can use wmOrtho and friends */ wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct); + UI_SetTheme(sa?sa->spacetype:0, ar->type?ar->type->regionid:0); + /* optional header info instead? */ if(ar->headerstr) { float col[3]; - UI_SetTheme(sa); UI_GetThemeColor3fv(TH_HEADER, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); - UI_ThemeColor(TH_MENU_TEXT); + UI_ThemeColor(TH_TEXT); glRasterPos2i(20, 6); BMF_DrawString(G.font, ar->headerstr); } else if(at->draw) { - UI_SetTheme(sa); at->draw(C, ar); - UI_SetTheme(NULL); } - if(sa) - region_draw_emboss(ar); - uiFreeInactiveBlocks(C, &ar->uiblocks); + if(sa) + region_draw_emboss(ar, &winrct); + /* XXX test: add convention to end regions always in pixel space, for drawing of borders/gestures etc */ ED_region_pixelspace(ar); diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index a551b4f463c..6eae581aa40 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -999,7 +999,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) /* get theme colors */ - UI_GetThemeColor3ubv(TH_SHADE2, col2); + UI_GetThemeColor3ubv(TH_BACK, col2); UI_GetThemeColor3ubv(TH_HILITE, col1); UI_GetThemeColor3ubv(TH_GROUP, col2a); UI_GetThemeColor3ubv(TH_GROUP_ACTIVE, col1a); diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 782611aaad7..66ebc145621 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -293,7 +293,7 @@ static void graph_channel_area_draw(const bContext *C, ARegion *ar) float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_SHADE2, col); + UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); @@ -359,7 +359,7 @@ static void graph_buttons_area_draw(const bContext *C, ARegion *ar) float col[3]; /* clear */ - UI_GetThemeColor3fv(TH_HEADER, col); + UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 493ef6954b5..775f46b8e04 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -201,7 +201,7 @@ static void node_channel_area_draw(const bContext *C, ARegion *ar) float col[3]; /* clear and setup matrix */ - UI_GetThemeColor3fv(TH_SHADE2, col); + UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index b7682225fe3..0c41d6b4917 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -88,7 +88,34 @@ ARegion *view3d_has_buttons_region(ScrArea *sa) BLI_insertlinkafter(&sa->regionbase, ar, arnew); arnew->regiontype= RGN_TYPE_UI; - arnew->alignment= RGN_ALIGN_LEFT; + arnew->alignment= RGN_ALIGN_RIGHT; + + arnew->flag = RGN_FLAG_HIDDEN; + + return arnew; +} + +ARegion *view3d_has_tools_region(ScrArea *sa) +{ + ARegion *ar, *arnew; + + for(ar= sa->regionbase.first; ar; ar= ar->next) + if(ar->regiontype==RGN_TYPE_TOOLS) + return ar; + + /* add subdiv level; after header */ + for(ar= sa->regionbase.first; ar; ar= ar->next) + if(ar->regiontype==RGN_TYPE_HEADER) + break; + + /* is error! */ + if(ar==NULL) return NULL; + + arnew= MEM_callocN(sizeof(ARegion), "tools for view3d"); + + BLI_insertlinkafter(&sa->regionbase, ar, arnew); + arnew->regiontype= RGN_TYPE_TOOLS; + arnew->alignment= RGN_OVERLAP_LEFT; arnew->flag = RGN_FLAG_HIDDEN; @@ -96,6 +123,7 @@ ARegion *view3d_has_buttons_region(ScrArea *sa) } + /* ******************** default callbacks for view3d space ***************** */ static SpaceLink *view3d_new(const bContext *C) @@ -474,7 +502,7 @@ static void view3d_buttons_area_draw(const bContext *C, ARegion *ar) float col[3]; /* clear */ - UI_GetThemeColor3fv(TH_HEADER, col); + UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0.0); glClear(GL_COLOR_BUFFER_BIT); @@ -517,6 +545,40 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) } } +/* add handlers, stuff you only do once or on area/region changes */ +static void view3d_tools_area_init(wmWindowManager *wm, ARegion *ar) +{ + ListBase *keymap; + + keymap= WM_keymap_listbase(wm, "View2D Buttons List", 0, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); + keymap= WM_keymap_listbase(wm, "View3D Generic", SPACE_VIEW3D, 0); + WM_event_add_keymap_handler(&ar->handlers, keymap); + // XXX +20 temp... need init for this + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx+20, ar->winy); +} + + +static void view3d_tools_area_draw(const bContext *C, ARegion *ar) +{ + float col[3]; + + /* clear */ + UI_GetThemeColor3fv(TH_BACK, col); + + glClearColor(col[0], col[1], col[2], 0.0); + glClear(GL_COLOR_BUFFER_BIT); + + /* set view2d view matrix for scrolling (without scrollers) */ + UI_view2d_view_ortho(C, &ar->v2d); + + view3d_tools_area_defbuts(C, ar); + + /* restore view matrix? */ + UI_view2d_view_restore(C); +} + + /* * Returns true if the Object is a from an external blend file (libdata) */ @@ -788,6 +850,18 @@ void ED_spacetype_view3d(void) art->init= view3d_buttons_area_init; art->draw= view3d_buttons_area_draw; BLI_addhead(&st->regiontypes, art); + + /* regions: tool(bar) */ + art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); + art->regionid = RGN_TYPE_TOOLS; + art->minsizex= 120; // XXX + art->minsizey= 50; // XXX + art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; + art->listener= view3d_buttons_area_listener; + art->init= view3d_tools_area_init; + art->draw= view3d_tools_area_draw; + BLI_addhead(&st->regiontypes, art); + /* regions: header */ art= MEM_callocN(sizeof(ARegionType), "spacetype view3d region"); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index f1a748dff3a..5dad3f8cc7d 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -984,7 +984,6 @@ static void view3d_panel_transform_spaces(const bContext *C, ARegion *ar, short for (index = V3D_MANIP_CUSTOM, ts = transform_spaces->first ; ts ; ts = ts->next, index++) { - UI_ThemeColor(TH_BUT_ACTION); if (v3d->twmode == index) { but = uiDefIconButS(block,ROW, B_REDR, ICON_CHECKBOX_HLT, xco,yco,XIC,YIC, &v3d->twmode, 5.0, (float)index, 0, 0, "Use this Custom Transform Orientation"); } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index ae77b4293bf..927773bf2ec 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -134,9 +134,12 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d); /* view3d_buttons.c */ void VIEW3D_OT_properties(struct wmOperatorType *ot); - void view3d_buttons_area_defbuts(const struct bContext *C, ARegion *ar); +/* view3d_buttons.c */ +void VIEW3D_OT_toolbar(struct wmOperatorType *ot); +void view3d_tools_area_defbuts(const struct bContext *C, ARegion *ar); + /* view3d_snap.c */ int minmax_verts(Object *obedit, float *min, float *max); @@ -150,6 +153,7 @@ void VIEW3D_OT_snap_menu(struct wmOperatorType *ot); /* space_view3d.c */ ARegion *view3d_has_buttons_region(ScrArea *sa); +ARegion *view3d_has_tools_region(ScrArea *sa); #endif /* ED_VIEW3D_INTERN_H */ diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index f4c8607d174..0ed43bead17 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -84,10 +84,12 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_setcameratoview); WM_operatortype_append(VIEW3D_OT_drawtype); WM_operatortype_append(VIEW3D_OT_editmesh_face_toolbox); - WM_operatortype_append(VIEW3D_OT_properties); WM_operatortype_append(VIEW3D_OT_localview); WM_operatortype_append(VIEW3D_OT_layers); + WM_operatortype_append(VIEW3D_OT_properties); + WM_operatortype_append(VIEW3D_OT_toolbar); + WM_operatortype_append(VIEW3D_OT_snap_selected_to_grid); WM_operatortype_append(VIEW3D_OT_snap_selected_to_cursor); WM_operatortype_append(VIEW3D_OT_snap_selected_to_center); @@ -108,6 +110,7 @@ void view3d_keymap(wmWindowManager *wm) WM_keymap_add_item(keymap, "PAINT_OT_weight_paint_toggle", TABKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "VIEW3D_OT_properties", NKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "VIEW3D_OT_toolbar", TKEY, KM_PRESS, 0, 0); /* only for region 3D window */ keymap= WM_keymap_listbase(wm, "View3D", SPACE_VIEW3D, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index d03586da2d5..9c4f0b576da 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -765,7 +765,7 @@ void VIEW3D_OT_select_lasso(wmOperatorType *ot) ot->poll= WM_operator_winactive; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_UNDO; RNA_def_collection_runtime(ot->srna, "path", &RNA_OperatorMousePath, "Path", ""); RNA_def_enum(ot->srna, "type", lasso_select_types, 0, "Type", ""); @@ -1546,7 +1546,7 @@ void VIEW3D_OT_select_border(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_UNDO; /* rna */ RNA_def_int(ot->srna, "event_type", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX); @@ -1599,7 +1599,7 @@ void VIEW3D_OT_select(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "type", prop_select_types, 0, "Type", ""); @@ -1834,7 +1834,7 @@ void VIEW3D_OT_select_circle(wmOperatorType *ot) ot->poll= ED_operator_view3d_active; /* flags */ - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag= OPTYPE_UNDO; RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX); diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 77b0d6e2d49..7a6e48f2ca9 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -217,6 +217,7 @@ typedef struct ARegion { #define RGN_TYPE_CHANNELS 2 #define RGN_TYPE_TEMPORARY 3 #define RGN_TYPE_UI 4 +#define RGN_TYPE_TOOLS 5 /* region alignment */ #define RGN_ALIGN_NONE 0 diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index c1a0e72256f..91c81023c8c 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -98,41 +98,62 @@ typedef struct uiStyle { } uiStyle; - -/* global, button colors */ -typedef struct ThemeUI { +typedef struct uiWidgetColors { char outline[4]; - char neutral[4]; - char action[4]; - char setting[4]; - char setting1[4]; - char setting2[4]; - char num[4]; - char textfield[4]; - char textfield_hi[4]; - char popup[4]; + char inner[4]; + char inner_sel[4]; + char item[4]; char text[4]; - char text_hi[4]; - char menu_back[4]; - char menu_item[4]; - char menu_hilite[4]; - char menu_text[4]; - char menu_text_hi[4]; + char text_sel[4]; + short shaded; + short shadetop, shadedown; + short pad; +} uiWidgetColors; + +typedef struct ThemeUI { + + /* Interface Elements (buttons, menus, icons) */ + uiWidgetColors wcol_regular, wcol_tool, wcol_radio, wcol_text, wcol_option; + uiWidgetColors wcol_num, wcol_numslider; + uiWidgetColors wcol_menu, wcol_pulldown, wcol_menu_back, wcol_menu_item; - char but_drawtype; - char pad[3]; char iconfile[80]; // FILE_MAXFILE length + } ThemeUI; /* try to put them all in one, if needed a special struct can be created as well * for example later on, when we introduce wire colors for ob types or so... */ typedef struct ThemeSpace { + /* main window colors */ char back[4]; + char title[4]; char text[4]; char text_hi[4]; + + /* header colors */ char header[4]; + char header_title[4]; + char header_text[4]; + char header_text_hi[4]; + + /* button/tool regions */ + char button[4]; + char button_title[4]; + char button_text[4]; + char button_text_hi[4]; + + /* listview regions */ + char list[4]; + char list_title[4]; + char list_text[4]; + char list_text_hi[4]; + + /* float panel */ char panel[4]; + char panel_title[4]; + char panel_text[4]; + char panel_text_hi[4]; char shade1[4]; char shade2[4]; @@ -166,8 +187,12 @@ typedef struct ThemeSpace { char handle_vertex[4]; char handle_vertex_select[4]; + char handle_vertex_size; char hpad[3]; + + char pad[4]; + } ThemeSpace; @@ -190,7 +215,6 @@ typedef struct bTheme { struct bTheme *next, *prev; char name[32]; - /* Interface Elements (buttons, menus, icons) */ ThemeUI tui; /* Individual Spacetypes */ @@ -213,7 +237,7 @@ typedef struct bTheme { /* 20 sets of bone colors for this theme */ ThemeWireColor tarm[20]; /*ThemeWireColor tobj[20];*/ - + } bTheme; typedef struct SolidLight { diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 74faa0f4a96..37fb11ee039 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -30,8 +30,11 @@ #include "rna_internal.h" #include "DNA_curve_types.h" +#include "DNA_space_types.h" #include "DNA_userdef_types.h" +#include "BKE_utildefines.h" + #ifdef RNA_RUNTIME static void rna_userdef_lmb_select_set(struct PointerRNA *ptr,int value) @@ -118,130 +121,264 @@ static PointerRNA rna_UserDef_system_get(PointerRNA *ptr) #else -static void rna_def_userdef_theme_ui(BlenderRNA *brna) +static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + + srna= RNA_def_struct(brna, "ThemeFontStyle", NULL); + RNA_def_struct_sdna(srna, "uiFontStyle"); + RNA_def_struct_ui_text(srna, "Font Style", "Theme settings for Font."); + + prop= RNA_def_property(srna, "points", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 6, 48); + RNA_def_property_ui_text(prop, "Points", ""); + + prop= RNA_def_property(srna, "shadow", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, 5); + RNA_def_property_ui_text(prop, "Shadow Size", "Shadow size in pixels (0, 3 and 5 supported)"); + + prop= RNA_def_property(srna, "shadx", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, -10, 10); + RNA_def_property_ui_text(prop, "Shadow X Offset", "Shadow offset in pixels"); + + prop= RNA_def_property(srna, "shady", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, -10, 10); + RNA_def_property_ui_text(prop, "Shadow Y Offset", "Shadow offset in pixels"); - static EnumPropertyItem button_theme_styles[] = { - {TH_MINIMAL, "MINIMAL", "Minimal", ""}, - {TH_SHADED, "SHADED", "Shaded", ""}, - {TH_ROUNDED, "ROUNDED", "Rounded", ""}, - {TH_ROUNDSHADED, "ROUNDSHADED", "Round Shaded", ""}, - {TH_OLDSKOOL, "OLDSKOOL", "Old Skool", ""}, - {0, NULL, NULL, NULL}}; - - srna= RNA_def_struct(brna, "ThemeUserInterface", NULL); - RNA_def_struct_sdna(srna, "ThemeUI"); - RNA_def_struct_ui_text(srna, "Theme User Interface", "Theme settings for user interface elements."); - - prop= RNA_def_property(srna, "outline", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Outline", ""); - - prop= RNA_def_property(srna, "neutral", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Neutral", ""); - - prop= RNA_def_property(srna, "action", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Action", ""); - - prop= RNA_def_property(srna, "setting", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Setting", ""); - - prop= RNA_def_property(srna, "special_setting_1", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "setting1"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Special Setting 1", ""); - - prop= RNA_def_property(srna, "special_setting_2", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "setting2"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Special Setting 2", ""); + prop= RNA_def_property(srna, "shadowalpha", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Shadow Alpha", ""); - prop= RNA_def_property(srna, "number_input", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "num"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Number Input", ""); + prop= RNA_def_property(srna, "shadowcolor", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Shadow Brightness", "Shadow color in grey value"); +} - prop= RNA_def_property(srna, "text_field", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "textfield"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Text Field", ""); - prop= RNA_def_property(srna, "textfield_highlight", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "textfield_hi"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Text Field Highlight", ""); +static void rna_def_userdef_theme_ui_style(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + rna_def_userdef_theme_ui_font_style(brna); + + srna= RNA_def_struct(brna, "ThemeStyle", NULL); + RNA_def_struct_sdna(srna, "uiStyle"); + RNA_def_struct_ui_text(srna, "Style", "Theme settings for style sets."); + + prop= RNA_def_property(srna, "paneltitle", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "paneltitle"); + RNA_def_property_struct_type(prop, "ThemeFontStyle"); + RNA_def_property_ui_text(prop, "Panel Font", ""); + + prop= RNA_def_property(srna, "grouplabel", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "grouplabel"); + RNA_def_property_struct_type(prop, "ThemeFontStyle"); + RNA_def_property_ui_text(prop, "Group Label Font", ""); + + prop= RNA_def_property(srna, "widgetlabel", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "widgetlabel"); + RNA_def_property_struct_type(prop, "ThemeFontStyle"); + RNA_def_property_ui_text(prop, "Widget Label Font", ""); + + prop= RNA_def_property(srna, "widget", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "widget"); + RNA_def_property_struct_type(prop, "ThemeFontStyle"); + RNA_def_property_ui_text(prop, "Widget Font", ""); + +} - prop= RNA_def_property(srna, "popup", PROP_FLOAT, PROP_COLOR); +static void rna_def_userdef_theme_ui_wcol(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna= RNA_def_struct(brna, "ThemeWidgetColors", NULL); + RNA_def_struct_sdna(srna, "uiWidgetColors"); + RNA_def_struct_ui_text(srna, "Theme Widget Color Set", "Theme settings for widget color sets."); + + prop= RNA_def_property(srna, "outline", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Popup", ""); - + RNA_def_property_ui_text(prop, "Outline", ""); + + prop= RNA_def_property(srna, "inner", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Inner", ""); + + prop= RNA_def_property(srna, "inner_sel", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Inner Selected", ""); + + prop= RNA_def_property(srna, "item", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Item", ""); + prop= RNA_def_property(srna, "text", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Text", ""); - - prop= RNA_def_property(srna, "text_highlight", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "text_hi"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Text highlight", ""); - - prop= RNA_def_property(srna, "menu_background", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "menu_back"); - RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Menu Background", ""); - - prop= RNA_def_property(srna, "menu_item", PROP_FLOAT, PROP_COLOR); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Menu Item", ""); - - prop= RNA_def_property(srna, "menu_highlight", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "menu_hilite"); - RNA_def_property_array(prop, 4); - RNA_def_property_ui_text(prop, "Menu Highlight", ""); - - prop= RNA_def_property(srna, "menu_text", PROP_FLOAT, PROP_COLOR); + + prop= RNA_def_property(srna, "text_sel", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Menu Text", ""); + RNA_def_property_ui_text(prop, "Text Selected", ""); + + prop= RNA_def_property(srna, "shaded", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "shaded", 1); + RNA_def_property_ui_text(prop, "Shaded", ""); + + prop= RNA_def_property(srna, "shadetop", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, -100, 100); + RNA_def_property_ui_text(prop, "Shade Top", ""); + + prop= RNA_def_property(srna, "shadedown", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, -100, 100); + RNA_def_property_ui_text(prop, "Shade Down", ""); + +} - prop= RNA_def_property(srna, "menu_text_highlight", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "menu_text_hi"); - RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Menu Text Highlight", ""); +static void rna_def_userdef_theme_ui(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; - prop= RNA_def_property(srna, "button_draw_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "but_drawtype"); - RNA_def_property_enum_items(prop, button_theme_styles); - RNA_def_property_ui_text(prop, "Button Draw Type", ""); + rna_def_userdef_theme_ui_wcol(brna); + + srna= RNA_def_struct(brna, "ThemeUserInterface", NULL); + RNA_def_struct_sdna(srna, "ThemeUI"); + RNA_def_struct_ui_text(srna, "Theme User Interface", "Theme settings for user interface elements."); + prop= RNA_def_property(srna, "wcol_regular", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_regular"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Regular Widget Colors", ""); + + prop= RNA_def_property(srna, "wcol_tool", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_tool"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Tool Widget Colors", ""); + + prop= RNA_def_property(srna, "wcol_radio", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_radio"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Radio Widget Colors", ""); + + prop= RNA_def_property(srna, "wcol_text", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_text"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Text Widget Colors", ""); + + prop= RNA_def_property(srna, "wcol_option", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_option"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Option Widget Colors", ""); + + prop= RNA_def_property(srna, "wcol_num", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_num"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Number Widget Colors", ""); + + prop= RNA_def_property(srna, "wcol_numslider", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_numslider"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Slider Widget Colors", ""); + + prop= RNA_def_property(srna, "wcol_menu", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_menu"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Menu Widget Colors", ""); + + prop= RNA_def_property(srna, "wcol_pulldown", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_pulldown"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Pulldown Widget Colors", ""); + + prop= RNA_def_property(srna, "wcol_menu_back", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_menu_back"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Menu Backdrop Colors", ""); + + prop= RNA_def_property(srna, "wcol_menu_item", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "wcol_menu_item"); + RNA_def_property_struct_type(prop, "ThemeWidgetColors"); + RNA_def_property_ui_text(prop, "Menu Item Colors", ""); + + prop= RNA_def_property(srna, "icon_file", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "iconfile"); RNA_def_property_ui_text(prop, "Icon File", ""); } -static void rna_def_userdef_theme_spaces_main(StructRNA *srna) +static void rna_def_userdef_theme_spaces_main(StructRNA *srna, int spacetype) { PropertyRNA *prop; + /* window */ prop= RNA_def_property(srna, "back", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Back", ""); + RNA_def_property_ui_text(prop, "Window Back", ""); + prop= RNA_def_property(srna, "title", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Window Title", ""); + prop= RNA_def_property(srna, "text", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Text", ""); + RNA_def_property_ui_text(prop, "Window Text", ""); - prop= RNA_def_property(srna, "text_highlight", PROP_FLOAT, PROP_COLOR); - RNA_def_property_float_sdna(prop, NULL, "text_hi"); + prop= RNA_def_property(srna, "text_hi", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); - RNA_def_property_ui_text(prop, "Text Highlight", ""); + RNA_def_property_ui_text(prop, "Window Text Highlight", ""); + /* header */ prop= RNA_def_property(srna, "header", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Header", ""); + + prop= RNA_def_property(srna, "header_text", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Header Text", ""); + + prop= RNA_def_property(srna, "header_text_hi", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Header Text Highlight", ""); + + /* buttons */ + if(! ELEM(spacetype, SPACE_BUTS, SPACE_OUTLINER)) { + prop= RNA_def_property(srna, "button", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Button Back", ""); + + prop= RNA_def_property(srna, "button_title", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Button Title", ""); + + prop= RNA_def_property(srna, "button_text", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Button Text", ""); + + prop= RNA_def_property(srna, "button_text_hi", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Button Text Highlight", ""); + } + + /* list/channels */ + if(ELEM4(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA, SPACE_NODE)) { + prop= RNA_def_property(srna, "list", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "List Back", ""); + + prop= RNA_def_property(srna, "list_title", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "List Title", ""); + + prop= RNA_def_property(srna, "list_text", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "List Text", ""); + + prop= RNA_def_property(srna, "list_text_hi", PROP_FLOAT, PROP_COLOR); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "List Text Highlight", ""); + } } static void rna_def_userdef_theme_spaces_vertex(StructRNA *srna) @@ -314,7 +451,7 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme 3D View", "Theme settings for the 3D View."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_VIEW3D); prop= RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); @@ -382,18 +519,18 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Current Frame", ""); } -static void rna_def_userdef_theme_space_ipo(BlenderRNA *brna) +static void rna_def_userdef_theme_space_graph(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - /* space_ipo */ + /* space_graph */ srna= RNA_def_struct(brna, "ThemeGraphEditor", NULL); RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme Graph Editor", "Theme settings for the Ipo Editor."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_IPO); prop= RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); @@ -464,7 +601,7 @@ static void rna_def_userdef_theme_space_file(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme File Browser", "Theme settings for the File Browser."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_FILE); prop= RNA_def_property(srna, "selected_file", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "hilite"); @@ -497,17 +634,17 @@ static void rna_def_userdef_theme_space_file(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Active File Text", ""); } -static void rna_def_userdef_theme_space_oops(BlenderRNA *brna) +static void rna_def_userdef_theme_space_outliner(BlenderRNA *brna) { StructRNA *srna; - /* space_oops */ + /* space_outliner */ srna= RNA_def_struct(brna, "ThemeOutliner", NULL); RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme Outliner", "Theme settings for the Outliner."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_OUTLINER); } static void rna_def_userdef_theme_space_info(BlenderRNA *brna) @@ -520,7 +657,7 @@ static void rna_def_userdef_theme_space_info(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme User Preferences", "Theme settings for the User Preferences."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_INFO); } static void rna_def_userdef_theme_space_text(BlenderRNA *brna) @@ -534,7 +671,7 @@ static void rna_def_userdef_theme_space_text(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme Text Editor", "Theme settings for the Text Editor."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_TEXT); prop= RNA_def_property(srna, "line_numbers_background", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "grid"); @@ -593,7 +730,7 @@ static void rna_def_userdef_theme_space_node(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme Node Editor", "Theme settings for the Node Editor."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_NODE); prop= RNA_def_property(srna, "wires", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "wire"); @@ -647,7 +784,7 @@ static void rna_def_userdef_theme_space_buts(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme Buttons Window", "Theme settings for the Buttons Window."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_BUTS); prop= RNA_def_property(srna, "panel", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); @@ -665,7 +802,7 @@ static void rna_def_userdef_theme_space_time(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme Timeline", "Theme settings for the Timeline."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_TIME); prop= RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); @@ -688,7 +825,7 @@ static void rna_def_userdef_theme_space_sound(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme Audio Window", "Theme settings for the Audio Window."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_SOUND); prop= RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); @@ -716,7 +853,7 @@ static void rna_def_userdef_theme_space_image(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme Image Editor", "Theme settings for the Image Editor."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_IMAGE); rna_def_userdef_theme_spaces_vertex(srna); rna_def_userdef_theme_spaces_face(srna); @@ -812,7 +949,7 @@ static void rna_def_userdef_theme_space_action(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme DopeSheet", "Theme settings for the DopeSheet."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_ACTION); prop= RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); @@ -885,7 +1022,7 @@ static void rna_def_userdef_theme_space_nla(BlenderRNA *brna) RNA_def_struct_sdna(srna, "ThemeSpace"); RNA_def_struct_ui_text(srna, "Theme NLA Editor", "Theme settings for the NLA Editor."); - rna_def_userdef_theme_spaces_main(srna); + rna_def_userdef_theme_spaces_main(srna, SPACE_NLA); prop= RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR); RNA_def_property_array(prop, 3); @@ -1041,9 +1178,12 @@ static void rna_def_userdef_themes(BlenderRNA *brna) static void rna_def_userdef_dothemes(BlenderRNA *brna) { + + rna_def_userdef_theme_ui_style(brna); rna_def_userdef_theme_ui(brna); + rna_def_userdef_theme_space_view3d(brna); - rna_def_userdef_theme_space_ipo(brna); + rna_def_userdef_theme_space_graph(brna); rna_def_userdef_theme_space_file(brna); rna_def_userdef_theme_space_nla(brna); rna_def_userdef_theme_space_action(brna); @@ -1053,7 +1193,7 @@ static void rna_def_userdef_dothemes(BlenderRNA *brna) rna_def_userdef_theme_space_text(brna); rna_def_userdef_theme_space_time(brna); rna_def_userdef_theme_space_node(brna); - rna_def_userdef_theme_space_oops(brna); + rna_def_userdef_theme_space_outliner(brna); rna_def_userdef_theme_space_info(brna); rna_def_userdef_theme_space_sound(brna); rna_def_userdef_theme_colorset(brna); @@ -1791,6 +1931,11 @@ void RNA_def_userdef(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "themes", NULL); RNA_def_property_struct_type(prop, "Theme"); RNA_def_property_ui_text(prop, "Themes", ""); + + prop= RNA_def_property(srna, "uistyles", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "uistyles", NULL); + RNA_def_property_struct_type(prop, "ThemeStyle"); + RNA_def_property_ui_text(prop, "Styles", ""); /* nested structs */ prop= RNA_def_property(srna, "view", PROP_POINTER, PROP_NEVER_NULL); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 066b1321947..5e27b0da70d 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -94,400 +94,6 @@ #include "wm.h" #include "wm_window.h" -/***/ - -/* define for setting colors in theme below */ -#define SETCOL(col, r, g, b, a) {col[0]=r; col[1]=g; col[2]= b; col[3]= a;} - -/* patching UserDef struct and Themes */ -static void init_userdef_themes(void) -{ -// countall(); - - /* the UserDef struct is not corrected with do_versions() .... ugh! */ - if(U.wheellinescroll == 0) U.wheellinescroll = 3; - if(U.menuthreshold1==0) { - U.menuthreshold1= 5; - U.menuthreshold2= 2; - } - if(U.tb_leftmouse==0) { - U.tb_leftmouse= 5; - U.tb_rightmouse= 5; - } - if(U.mixbufsize==0) U.mixbufsize= 2048; - if (BLI_streq(U.tempdir, "/")) { - char *tmp= getenv("TEMP"); - - strcpy(U.tempdir, tmp?tmp:"/tmp/"); - } - if (U.savetime <= 0) { - U.savetime = 1; -// XXX error(".B.blend is buggy, please consider removing it.\n"); - } - /* transform widget settings */ - if(U.tw_hotspot==0) { - U.tw_hotspot= 14; - U.tw_size= 20; // percentage of window size - U.tw_handlesize= 16; // percentage of widget radius - } - if(U.pad_rot_angle==0) - U.pad_rot_angle= 15; - - if(U.flag & USER_CUSTOM_RANGE) - vDM_ColorBand_store(&U.coba_weight); /* signal for derivedmesh to use colorband */ - - if (G.main->versionfile <= 191) { - strcpy(U.plugtexdir, U.textudir); - strcpy(U.sounddir, "/"); - } - - /* patch to set Dupli Armature */ - if (G.main->versionfile < 220) { - U.dupflag |= USER_DUP_ARM; - } - - /* added seam, normal color, undo */ - if (G.main->versionfile <= 234) { - bTheme *btheme; - - U.uiflag |= USER_GLOBALUNDO; - if (U.undosteps==0) U.undosteps=32; - - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - /* check for alpha==0 is safe, then color was never set */ - if(btheme->tv3d.edge_seam[3]==0) { - SETCOL(btheme->tv3d.edge_seam, 230, 150, 50, 255); - } - if(btheme->tv3d.normal[3]==0) { - SETCOL(btheme->tv3d.normal, 0x22, 0xDD, 0xDD, 255); - } - if(btheme->tv3d.face_dot[3]==0) { - SETCOL(btheme->tv3d.face_dot, 255, 138, 48, 255); - btheme->tv3d.facedot_size= 4; - } - } - } - if (G.main->versionfile <= 235) { - /* illegal combo... */ - if (U.flag & USER_LMOUSESELECT) - U.flag &= ~USER_TWOBUTTONMOUSE; - } - if (G.main->versionfile <= 236) { - bTheme *btheme; - /* new space type */ - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - /* check for alpha==0 is safe, then color was never set */ - if(btheme->ttime.back[3]==0) { - btheme->ttime = btheme->tsnd; // copy from sound - } - if(btheme->text.syntaxn[3]==0) { - SETCOL(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/ - SETCOL(btheme->text.syntaxl, 100, 0, 0, 255); /* Strings red */ - SETCOL(btheme->text.syntaxc, 0, 100, 50, 255); /* Comments greenish */ - SETCOL(btheme->text.syntaxv, 95, 95, 0, 255); /* Special */ - SETCOL(btheme->text.syntaxb, 128, 0, 80, 255); /* Builtin, red-purple */ - } - } - } - if (G.main->versionfile <= 237) { - bTheme *btheme; - /* bone colors */ - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - /* check for alpha==0 is safe, then color was never set */ - if(btheme->tv3d.bone_solid[3]==0) { - SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255); - SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80); - } - } - } - if (G.main->versionfile <= 238) { - bTheme *btheme; - /* bone colors */ - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - /* check for alpha==0 is safe, then color was never set */ - if(btheme->tnla.strip[3]==0) { - SETCOL(btheme->tnla.strip_select, 0xff, 0xff, 0xaa, 255); - SETCOL(btheme->tnla.strip, 0xe4, 0x9c, 0xc6, 255); - } - } - } - if (G.main->versionfile <= 239) { - bTheme *btheme; - - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - /* Lamp theme, check for alpha==0 is safe, then color was never set */ - if(btheme->tv3d.lamp[3]==0) { - SETCOL(btheme->tv3d.lamp, 0, 0, 0, 40); -/* TEMPORAL, remove me! (ton) */ - U.uiflag |= USER_PLAINMENUS; - } - - /* check for text field selection highlight, set it to text editor highlight by default */ - if(btheme->tui.textfield_hi[3]==0) { - SETCOL(btheme->tui.textfield_hi, - btheme->text.shade2[0], - btheme->text.shade2[1], - btheme->text.shade2[2], - 255); - } - } - if(U.obcenter_dia==0) U.obcenter_dia= 6; - } - if (G.main->versionfile <= 241) { - bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - /* Node editor theme, check for alpha==0 is safe, then color was never set */ - if(btheme->tnode.syntaxn[3]==0) { - /* re-uses syntax color storage */ - btheme->tnode= btheme->tv3d; - SETCOL(btheme->tnode.edge_select, 255, 255, 255, 255); - SETCOL(btheme->tnode.syntaxl, 150, 150, 150, 255); /* TH_NODE, backdrop */ - SETCOL(btheme->tnode.syntaxn, 129, 131, 144, 255); /* in/output */ - SETCOL(btheme->tnode.syntaxb, 127,127,127, 255); /* operator */ - SETCOL(btheme->tnode.syntaxv, 142, 138, 145, 255); /* generator */ - SETCOL(btheme->tnode.syntaxc, 120, 145, 120, 255); /* group */ - } - /* Group theme colors */ - if(btheme->tv3d.group[3]==0) { - SETCOL(btheme->tv3d.group, 0x10, 0x40, 0x10, 255); - SETCOL(btheme->tv3d.group_active, 0x66, 0xFF, 0x66, 255); - } - /* Sequence editor theme*/ - if(btheme->tseq.movie[3]==0) { - SETCOL(btheme->tseq.movie, 81, 105, 135, 255); - SETCOL(btheme->tseq.image, 109, 88, 129, 255); - SETCOL(btheme->tseq.scene, 78, 152, 62, 255); - SETCOL(btheme->tseq.audio, 46, 143, 143, 255); - SETCOL(btheme->tseq.effect, 169, 84, 124, 255); - SETCOL(btheme->tseq.plugin, 126, 126, 80, 255); - SETCOL(btheme->tseq.transition, 162, 95, 111, 255); - SETCOL(btheme->tseq.meta, 109, 145, 131, 255); - } - if(!(btheme->tui.iconfile)) { - BLI_strncpy(btheme->tui.iconfile, "", sizeof(btheme->tui.iconfile)); - } - } - - /* set defaults for 3D View rotating axis indicator */ - /* since size can't be set to 0, this indicates it's not saved in .B.blend */ - if (U.rvisize == 0) { - U.rvisize = 15; - U.rvibright = 8; - U.uiflag |= USER_SHOW_ROTVIEWICON; - } - - } - if (G.main->versionfile <= 242) { - bTheme *btheme; - - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - /* long keyframe color */ - /* check for alpha==0 is safe, then color was never set */ - if(btheme->tact.strip[3]==0) { - SETCOL(btheme->tv3d.edge_sharp, 255, 32, 32, 255); - SETCOL(btheme->tact.strip_select, 0xff, 0xff, 0xaa, 204); - SETCOL(btheme->tact.strip, 0xe4, 0x9c, 0xc6, 204); - } - - /* IPO-Editor - Vertex Size*/ - if(btheme->tipo.vertex_size == 0) { - btheme->tipo.vertex_size= 3; - } - } - } - if (G.main->versionfile <= 243) { - /* set default number of recently-used files (if not set) */ - if (U.recent_files == 0) U.recent_files = 10; - } - if (G.main->versionfile < 245 || (G.main->versionfile == 245 && G.main->subversionfile < 3)) { - bTheme *btheme; - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128); - } - if(U.coba_weight.tot==0) - init_colorband(&U.coba_weight, 1); - } - if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 11)) { - bTheme *btheme; - for (btheme= U.themes.first; btheme; btheme= btheme->next) { - /* these should all use the same colour */ - SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255); - } - } - if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 11)) { - bTheme *btheme; - for (btheme= U.themes.first; btheme; btheme= btheme->next) { - /* these should all use the same color */ - SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->tipo.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->tact.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->tnla.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->tseq.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->tsnd.cframe, 0x60, 0xc0, 0x40, 255); - SETCOL(btheme->ttime.cframe, 0x60, 0xc0, 0x40, 255); - } - } - if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 13)) { - bTheme *btheme; - for (btheme= U.themes.first; btheme; btheme= btheme->next) { - /* action channel groups (recolor anyway) */ - SETCOL(btheme->tact.group, 0x39, 0x7d, 0x1b, 255); - SETCOL(btheme->tact.group_active, 0x7d, 0xe9, 0x60, 255); - - /* bone custom-color sets */ - // FIXME: this check for initialised colors is bad - if (btheme->tarm[0].solid[3] == 0) { - /* set 1 */ - SETCOL(btheme->tarm[0].solid, 0x9a, 0x00, 0x00, 255); - SETCOL(btheme->tarm[0].select, 0xbd, 0x11, 0x11, 255); - SETCOL(btheme->tarm[0].active, 0xf7, 0x0a, 0x0a, 255); - /* set 2 */ - SETCOL(btheme->tarm[1].solid, 0xf7, 0x40, 0x18, 255); - SETCOL(btheme->tarm[1].select, 0xf6, 0x69, 0x13, 255); - SETCOL(btheme->tarm[1].active, 0xfa, 0x99, 0x00, 255); - /* set 3 */ - SETCOL(btheme->tarm[2].solid, 0x1e, 0x91, 0x09, 255); - SETCOL(btheme->tarm[2].select, 0x59, 0xb7, 0x0b, 255); - SETCOL(btheme->tarm[2].active, 0x83, 0xef, 0x1d, 255); - /* set 4 */ - SETCOL(btheme->tarm[3].solid, 0x0a, 0x36, 0x94, 255); - SETCOL(btheme->tarm[3].select, 0x36, 0x67, 0xdf, 255); - SETCOL(btheme->tarm[3].active, 0x5e, 0xc1, 0xef, 255); - /* set 5 */ - SETCOL(btheme->tarm[4].solid, 0xa9, 0x29, 0x4e, 255); - SETCOL(btheme->tarm[4].select, 0xc1, 0x41, 0x6a, 255); - SETCOL(btheme->tarm[4].active, 0xf0, 0x5d, 0x91, 255); - /* set 6 */ - SETCOL(btheme->tarm[5].solid, 0x43, 0x0c, 0x78, 255); - SETCOL(btheme->tarm[5].select, 0x54, 0x3a, 0xa3, 255); - SETCOL(btheme->tarm[5].active, 0x87, 0x64, 0xd5, 255); - /* set 7 */ - SETCOL(btheme->tarm[6].solid, 0x24, 0x78, 0x5a, 255); - SETCOL(btheme->tarm[6].select, 0x3c, 0x95, 0x79, 255); - SETCOL(btheme->tarm[6].active, 0x6f, 0xb6, 0xab, 255); - /* set 8 */ - SETCOL(btheme->tarm[7].solid, 0x4b, 0x70, 0x7c, 255); - SETCOL(btheme->tarm[7].select, 0x6a, 0x86, 0x91, 255); - SETCOL(btheme->tarm[7].active, 0x9b, 0xc2, 0xcd, 255); - /* set 9 */ - SETCOL(btheme->tarm[8].solid, 0xf4, 0xc9, 0x0c, 255); - SETCOL(btheme->tarm[8].select, 0xee, 0xc2, 0x36, 255); - SETCOL(btheme->tarm[8].active, 0xf3, 0xff, 0x00, 255); - /* set 10 */ - SETCOL(btheme->tarm[9].solid, 0x1e, 0x20, 0x24, 255); - SETCOL(btheme->tarm[9].select, 0x48, 0x4c, 0x56, 255); - SETCOL(btheme->tarm[9].active, 0xff, 0xff, 0xff, 255); - /* set 11 */ - SETCOL(btheme->tarm[10].solid, 0x6f, 0x2f, 0x6a, 255); - SETCOL(btheme->tarm[10].select, 0x98, 0x45, 0xbe, 255); - SETCOL(btheme->tarm[10].active, 0xd3, 0x30, 0xd6, 255); - /* set 12 */ - SETCOL(btheme->tarm[11].solid, 0x6c, 0x8e, 0x22, 255); - SETCOL(btheme->tarm[11].select, 0x7f, 0xb0, 0x22, 255); - SETCOL(btheme->tarm[11].active, 0xbb, 0xef, 0x5b, 255); - /* set 13 */ - SETCOL(btheme->tarm[12].solid, 0x8d, 0x8d, 0x8d, 255); - SETCOL(btheme->tarm[12].select, 0xb0, 0xb0, 0xb0, 255); - SETCOL(btheme->tarm[12].active, 0xde, 0xde, 0xde, 255); - /* set 14 */ - SETCOL(btheme->tarm[13].solid, 0x83, 0x43, 0x26, 255); - SETCOL(btheme->tarm[13].select, 0x8b, 0x58, 0x11, 255); - SETCOL(btheme->tarm[13].active, 0xbd, 0x6a, 0x11, 255); - /* set 15 */ - SETCOL(btheme->tarm[14].solid, 0x08, 0x31, 0x0e, 255); - SETCOL(btheme->tarm[14].select, 0x1c, 0x43, 0x0b, 255); - SETCOL(btheme->tarm[14].active, 0x34, 0x62, 0x2b, 255); - } - } - } - if ((G.main->versionfile < 245) || (G.main->versionfile == 245 && G.main->subversionfile < 16)) { - U.flag |= USER_ADD_VIEWALIGNED|USER_ADD_EDITMODE; - } - if ((G.main->versionfile < 247) || (G.main->versionfile == 247 && G.main->subversionfile <= 2)) { - bTheme *btheme; - - /* adjust themes */ - for (btheme= U.themes.first; btheme; btheme= btheme->next) { - char *col; - - /* IPO Editor: Handles/Vertices */ - col = btheme->tipo.vertex; - SETCOL(btheme->tipo.handle_vertex, col[0], col[1], col[2], 255); - col = btheme->tipo.vertex_select; - SETCOL(btheme->tipo.handle_vertex_select, col[0], col[1], col[2], 255); - btheme->tipo.handle_vertex_size= btheme->tipo.vertex_size; - - /* Sequence/Image Editor: colors for GPencil text */ - col = btheme->tv3d.bone_pose; - SETCOL(btheme->tseq.bone_pose, col[0], col[1], col[2], 255); - SETCOL(btheme->tima.bone_pose, col[0], col[1], col[2], 255); - col = btheme->tv3d.vertex_select; - SETCOL(btheme->tseq.vertex_select, col[0], col[1], col[2], 255); - } - } - if (G.main->versionfile < 250) { - bTheme *btheme; - - for(btheme= U.themes.first; btheme; btheme= btheme->next) { - /* this was not properly initialized in 2.45 */ - if(btheme->tima.face_dot[3]==0) { - SETCOL(btheme->tima.editmesh_active, 255, 255, 255, 128); - SETCOL(btheme->tima.face_dot, 255, 133, 0, 255); - btheme->tima.facedot_size= 2; - } - - /* DopeSheet - (Object) Channel color */ - SETCOL(btheme->tact.ds_channel, 82, 96, 110, 255); - SETCOL(btheme->tact.ds_subchannel, 124, 137, 150, 255); - /* DopeSheet - Group Channel color (saner version) */ - SETCOL(btheme->tact.group, 79, 101, 73, 255); - SETCOL(btheme->tact.group_active, 135, 177, 125, 255); - - /* Graph Editor - (Object) Channel color */ - SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255); - SETCOL(btheme->tipo.ds_subchannel, 124, 137, 150, 255); - /* Graph Editor - Group Channel color */ - SETCOL(btheme->tipo.group, 79, 101, 73, 255); - SETCOL(btheme->tipo.group_active, 135, 177, 125, 255); - } - - /* adjust grease-pencil distances */ - U.gp_manhattendist= 1; - U.gp_euclideandist= 2; - - /* adjust default interpolation for new IPO-curves */ - U.ipo_new= BEZT_IPO_BEZ; - } - - /* GL Texture Garbage Collection (variable abused above!) */ - if (U.textimeout == 0) { - U.texcollectrate = 60; - U.textimeout = 120; - } - if (U.memcachelimit <= 0) { - U.memcachelimit = 32; - } - if (U.frameserverport == 0) { - U.frameserverport = 8080; - } - - MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024); - - // sets themes, fonts, .. from userdef - UI_init_userdef(); - - /* funny name, but it is GE stuff, moves userdef stuff to engine */ -// XXX space_set_commmandline_options(); - /* this timer uses U */ -// XXX reset_autosave(); - -} /* To be able to read files without windows closing, opening, moving we try to prepare for worst case: @@ -612,6 +218,14 @@ static void wm_window_match_do(bContext *C, ListBase *oldwmlist) } } +/* in case UserDef was read, we re-initialize all, and do versioning */ +static void wm_init_userdef() +{ + UI_init_userdef(); + MEM_CacheLimiter_set_maximum(U.memcachelimit * 1024 * 1024); + +} + void WM_read_file(bContext *C, char *name, ReportList *reports) { int retval; @@ -639,7 +253,7 @@ void WM_read_file(bContext *C, char *name, ReportList *reports) // XXX mainwindow_set_filename_to_title(G.main->name); // XXX sound_initialize_sounds(); - if(retval==2) init_userdef_themes(); // in case a userdef is read from regular .blend + if(retval==2) wm_init_userdef(); // in case a userdef is read from regular .blend if (retval!=0) G.relbase_valid = 1; @@ -663,6 +277,7 @@ void WM_read_file(bContext *C, char *name, ReportList *reports) /* called on startup, (context entirely filled with NULLs) */ /* or called for 'Erase All' */ +/* op can be NULL */ int WM_read_homefile(bContext *C, wmOperator *op) { ListBase wmbase; @@ -676,7 +291,11 @@ int WM_read_homefile(bContext *C, wmOperator *op) free_ttfont(); /* still weird... what does it here? */ G.relbase_valid = 0; - if (!from_memory) BLI_make_file_string(G.sce, tstr, home, ".B.blend"); + if (!from_memory) { + BLI_make_file_string(G.sce, tstr, home, ".B25.blend"); + if(!BLI_exists(tstr)) + BLI_make_file_string(G.sce, tstr, home, ".B.blend"); + } strcpy(scestr, G.sce); /* temporary store */ /* prevent loading no UI */ @@ -697,7 +316,7 @@ int WM_read_homefile(bContext *C, wmOperator *op) strcpy(G.sce, scestr); /* restore */ - init_userdef_themes(); + wm_init_userdef(); /* When loading factory settings, the reset solid OpenGL lights need to be applied. */ GPU_default_lights(); @@ -987,7 +606,7 @@ int WM_write_homefile(bContext *C, wmOperator *op) char tstr[FILE_MAXDIR+FILE_MAXFILE]; int write_flags; - BLI_make_file_string("/", tstr, BLI_gethome(), ".B.blend"); + BLI_make_file_string("/", tstr, BLI_gethome(), ".B25.blend"); /* force save as regular blend file */ write_flags = G.fileflags & ~(G_FILE_COMPRESS | G_FILE_LOCK | G_FILE_SIGN); |