diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-19 02:37:04 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-19 02:37:04 +0400 |
commit | ae25aa22105b060294095357692f2aed4c650ce8 (patch) | |
tree | 06548276f86326f21943f8ec7ef92765a97b5ab5 /source/blender/editors/interface | |
parent | 29b7b344fc48ed31b1e36818ab4767090691d6e2 (diff) | |
parent | 03762409cd4f812d152e42de9c4f9853df91be0b (diff) |
svn merge ^/trunk/blender -r55372:55392
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 66 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 64 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 100 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 14 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 28 |
7 files changed, 225 insertions, 49 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 5486e12c6bf..7fc5c21f052 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -42,6 +42,7 @@ #include "BLI_utildefines.h" #include "BKE_colortools.h" +#include "BKE_node.h" #include "BKE_texture.h" #include "BKE_tracking.h" @@ -1685,6 +1686,71 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc glDisable(GL_BLEND); } +void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti) +{ + static const float size = 5.0f; + + /* 16 values of sin function */ + static float si[16] = { + 0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f, + 0.99871650f, 0.89780453f, 0.65137248f, 0.29936312f, + -0.10116832f, -0.48530196f, -0.79077573f, -0.96807711f, + -0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f + }; + /* 16 values of cos function */ + static float co[16] = { + 1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f, + -0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f, + -0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f, + 0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f, + }; + + unsigned char *col = but->col; + int a; + GLint scissor[4]; + rcti scissor_new; + float x, y; + + x = 0.5f * (recti->xmin + recti->xmax); + y = 0.5f * (recti->ymin + recti->ymax); + + /* need scissor test, can draw outside of boundary */ + glGetIntegerv(GL_VIEWPORT, scissor); + scissor_new.xmin = ar->winrct.xmin + recti->xmin; + scissor_new.ymin = ar->winrct.ymin + recti->ymin; + scissor_new.xmax = ar->winrct.xmin + recti->xmax; + scissor_new.ymax = ar->winrct.ymin + recti->ymax; + BLI_rcti_isect(&scissor_new, &ar->winrct, &scissor_new); + glScissor(scissor_new.xmin, + scissor_new.ymin, + BLI_rcti_size_x(&scissor_new), + BLI_rcti_size_y(&scissor_new)); + + glColor4ubv(col); + + glEnable(GL_BLEND); + glBegin(GL_POLYGON); + for (a = 0; a < 16; a++) + glVertex2f(x + size * si[a], y + size * co[a]); + glEnd(); + glDisable(GL_BLEND); + + glColor4ub(0, 0, 0, 150); + + glEnable(GL_BLEND); + glEnable(GL_LINE_SMOOTH); + glBegin(GL_LINE_LOOP); + for (a = 0; a < 16; a++) + glVertex2f(x + size * si[a], y + size * co[a]); + glEnd(); + glDisable(GL_LINE_SMOOTH); + glDisable(GL_BLEND); + glLineWidth(1.0f); + + /* restore scissortest */ + glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); +} + /* ****************************************************** */ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 39aef38fadb..54a173af603 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -5434,6 +5434,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent * case LISTROW: case BUT_IMAGE: case PROGRESSBAR: + case NODESOCKET: retval = ui_do_but_EXIT(C, but, data, event); break; case HISTOGRAM: diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 6065fcfe574..19b863dd6fa 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -510,6 +510,7 @@ 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); void ui_draw_but_IMAGE(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); +void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, struct uiWidgetColors *wcol, rcti *rect); /* interface_handlers.c */ extern void ui_pan_to_scroll(const struct wmEvent *event, int *type, int *val); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index afb44101910..f376d42e7a8 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -32,6 +32,7 @@ #include "MEM_guardedalloc.h" #include "DNA_dynamicpaint_types.h" +#include "DNA_node_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" #include "DNA_object_force.h" @@ -57,6 +58,7 @@ #include "BKE_main.h" #include "BKE_material.h" #include "BKE_modifier.h" +#include "BKE_node.h" #include "BKE_object.h" #include "BKE_packedFile.h" #include "BKE_particle.h" @@ -3073,3 +3075,65 @@ void uiTemplateColormanagedViewSettings(uiLayout *layout, bContext *UNUSED(C), P if (view_settings->flag & COLORMANAGE_VIEW_USE_CURVES) uiTemplateCurveMapping(col, &view_transform_ptr, "curve_mapping", 'c', TRUE, 0); } + +/********************************* Component Menu *************************************/ + +typedef struct ComponentMenuArgs { + PointerRNA ptr; + char propname[64]; /* XXX arbitrary */ +} ComponentMenuArgs; +/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */ +static uiBlock *component_menu(bContext *C, ARegion *ar, void *args_v) +{ + ComponentMenuArgs *args = (ComponentMenuArgs *)args_v; + uiBlock *block; + uiLayout *layout; + + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); + + layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, UI_GetStyle()), 0); + + uiItemR(layout, &args->ptr, args->propname, UI_ITEM_R_EXPAND, "", ICON_NONE); + + uiBoundsBlock(block, 6); + uiBlockSetDirection(block, UI_DOWN); + uiEndBlock(C, block); + + return block; +} +void uiTemplateComponentMenu(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name) +{ + ComponentMenuArgs *args = MEM_callocN(sizeof(ComponentMenuArgs), "component menu template args"); + uiBlock *block; + + args->ptr = *ptr; + BLI_strncpy(args->propname, propname, sizeof(args->propname)); + + block = uiLayoutGetBlock(layout); + uiBlockBeginAlign(block); + + uiDefBlockButN(block, component_menu, args, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, ""); + + uiBlockEndAlign(block); +} + +/************************* Node Socket Icon **************************/ + +void uiTemplateNodeSocket(uiLayout *layout, bContext *UNUSED(C), float *color) +{ + uiBlock *block; + uiBut *but; + + block = uiLayoutGetBlock(layout); + uiBlockBeginAlign(block); + + /* XXX using explicit socket colors is not quite ideal. + * Eventually it should be possible to use theme colors for this purpose, + * but this requires a better design for extendable color palettes in user prefs. + */ + but = uiDefBut(block, NODESOCKET, 0, "", 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); + rgba_float_to_uchar(but->col, color); + + uiBlockEndAlign(block); +} diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 78b6d2541fd..f2e553bd140 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -767,7 +767,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) const unsigned char tcol[4] = {wcol->outline[0], wcol->outline[1], wcol->outline[2], - UCHAR_MAX / WIDGET_AA_JITTER}; + wcol->outline[3] / WIDGET_AA_JITTER}; widget_verts_to_quad_strip(wtb, wtb->totvert, quad_strip); @@ -1184,7 +1184,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b but->drawstr[selend_tmp] = ch; - glColor3ubv((unsigned char *)wcol->item); + glColor4ubv((unsigned char *)wcol->item); glRects(rect->xmin + selsta_draw, rect->ymin + 2, rect->xmin + selwidth_draw, rect->ymax - 2); } } @@ -1224,7 +1224,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b } } - glColor3ubv((unsigned char *)wcol->text); + glColor4ubv((unsigned char *)wcol->text); uiStyleFontDrawExt(fstyle, rect, but->drawstr + but->ofs, &font_xofs, &font_yofs); @@ -1272,6 +1272,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b /* draws text and icons for buttons */ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) { + float alpha = (float)wcol->text[3] / 255.0f; char password_str[UI_MAX_DRAW_STR]; if (but == NULL) @@ -1311,12 +1312,12 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB dualset = UI_BITBUT_TEST(*(((int *)but->poin) + 1), but->bitnr); } - widget_draw_icon(but, ICON_DOT, dualset ? 1.0f : 0.25f, rect); + widget_draw_icon(but, ICON_DOT, dualset ? alpha : 0.25f, rect); } else if (but->type == MENU && (but->flag & UI_BUT_NODE_LINK)) { int tmp = rect->xmin; rect->xmin = rect->xmax - BLI_rcti_size_y(rect) - 1; - widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect); + widget_draw_icon(but, ICON_LAYER_USED, alpha, rect); rect->xmin = tmp; } @@ -1324,7 +1325,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB * and offset the text label to accommodate it */ if (but->flag & UI_HAS_ICON) { - widget_draw_icon(but, but->icon + but->iconadd, 1.0f, rect); + widget_draw_icon(but, but->icon + but->iconadd, alpha, rect); /* icons default draw 0.8f x height */ rect->xmin += (int)(0.8f * BLI_rcti_size_y(rect)); @@ -1342,7 +1343,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB rcti temp = *rect; temp.xmin = temp.xmax - BLI_rcti_size_y(rect); - widget_draw_icon(but, ICON_X, 1.0f, &temp); + widget_draw_icon(but, ICON_X, alpha, &temp); } /* always draw text for textbutton cursor */ @@ -1379,12 +1380,12 @@ static struct uiWidgetStateColors wcol_state_colors = { }; /* uiWidgetColors - * float outline[3]; - * float inner[4]; - * float inner_sel[4]; - * float item[3]; - * float text[3]; - * float text_sel[3]; + * char outline[3]; + * char inner[4]; + * char inner_sel[4]; + * char item[3]; + * char text[3]; + * char text_sel[3]; * * short shaded; * float shadetop, shadedown; @@ -2873,12 +2874,7 @@ static void widget_box(uiBut *but, uiWidgetColors *wcol, rcti *rect, int UNUSED( round_box_edges(&wtb, roundboxalign, rect, rad); widgetbase_draw(&wtb, wcol); - - /* store the box bg as gl clearcolor, to retrieve later when drawing semi-transparent rects - * over the top to indicate disabled buttons */ - /* XXX, this doesnt work right since the color applies to buttons outside the box too. */ - glClearColor(wcol->inner[0] / 255.0, wcol->inner[1] / 255.0, wcol->inner[2] / 255.0, 1.0); - + copy_v3_v3_char(wcol->inner, old_col); } @@ -2941,24 +2937,6 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType * } - -static void widget_disabled(const rcti *rect) -{ - float col[4]; - - glEnable(GL_BLEND); - - /* can't use theme TH_BACK or TH_PANEL... undefined */ - glGetFloatv(GL_COLOR_CLEAR_VALUE, col); - glColor4f(col[0], col[1], col[2], 0.5f); - - /* need -1 and +1 to make it work right for aligned buttons, - * but problem may be somewhere else? */ - glRectf(rect->xmin - 1, rect->ymin - 1, rect->xmax, rect->ymax + 1); - - glDisable(GL_BLEND); -} - static uiWidgetType *widget_type(uiWidgetTypeEnum type) { bTheme *btheme = UI_GetTheme(); @@ -3171,6 +3149,23 @@ static int widget_roundbox_set(uiBut *but, rcti *rect) return roundbox; } +/* put all widget colors on half alpha, use local storage */ +static void ui_widget_color_disabled(uiWidgetType *wt) +{ + static uiWidgetColors wcol_theme_s; + + wcol_theme_s = *wt->wcol_theme; + + wcol_theme_s.outline[3] *= 0.5; + wcol_theme_s.inner[3] *= 0.5; + wcol_theme_s.inner_sel[3] *= 0.5; + wcol_theme_s.item[3] *= 0.5; + wcol_theme_s.text[3] *= 0.5; + wcol_theme_s.text_sel[3] *= 0.5; + + wt->wcol_theme = &wcol_theme_s; +} + /* conversion from old to new buttons, so still messy */ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rcti *rect) { @@ -3367,30 +3362,47 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct ui_draw_but_TRACKPREVIEW(ar, but, &tui->wcol_regular, rect); break; + case NODESOCKET: + ui_draw_but_NODESOCKET(ar, but, &tui->wcol_regular, rect); + break; + default: wt = widget_type(UI_WTYPE_REGULAR); } } if (wt) { - rcti disablerect = *rect; /* rect gets clipped smaller for text */ + //rcti disablerect = *rect; /* rect gets clipped smaller for text */ int roundboxalign, state; + bool disabled = FALSE; roundboxalign = widget_roundbox_set(but, rect); state = but->flag; if (but->editstr) state |= UI_TEXTINPUT; + if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) + if (but->dt != UI_EMBOSSP) + disabled = TRUE; + + if (disabled) + ui_widget_color_disabled(wt); + wt->state(wt, state); if (wt->custom) wt->custom(but, &wt->wcol, rect, state, roundboxalign); else if (wt->draw) wt->draw(&wt->wcol, rect, state, roundboxalign); + + if (disabled) + glEnable(GL_BLEND); wt->text(fstyle, &wt->wcol, but, rect); + if (disabled) + glDisable(GL_BLEND); - if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) - if (but->dt != UI_EMBOSSP) - widget_disabled(&disablerect); +// if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) +// if (but->dt != UI_EMBOSSP) +// widget_disabled(&disablerect); } } @@ -3474,7 +3486,7 @@ void ui_draw_menu_item(uiFontStyle *fstyle, rcti *rect, const char *name, int ic rect->xmax -= BLF_width(fstyle->uifont_id, cpoin + 1) + 10; } - glColor3ubv((unsigned char *)wt->wcol.text); + glColor4ubv((unsigned char *)wt->wcol.text); uiStyleFontDraw(fstyle, rect, name); /* part text right aligned */ @@ -3541,9 +3553,9 @@ void ui_draw_preview_item(uiFontStyle *fstyle, rcti *rect, const char *name, int glDisable(GL_BLEND); if (state == UI_ACTIVE) - glColor3ubv((unsigned char *)wt->wcol.text); + glColor4ubv((unsigned char *)wt->wcol.text); else - glColor3ubv((unsigned char *)wt->wcol.text_sel); + glColor4ubv((unsigned char *)wt->wcol.text_sel); uiStyleFontDraw(fstyle, &trect, name); } diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 09122737373..658d89abea3 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -395,6 +395,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp = ts->syntaxv; break; case TH_NODE_GROUP: cp = ts->syntaxc; break; + case TH_NODE_INTERFACE: + cp = ts->console_output; break; case TH_NODE_FRAME: cp = ts->movie; break; case TH_NODE_MATTE: @@ -961,7 +963,7 @@ void ui_theme_init_default(void) rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0); rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); /* sliders */ - /* space node, re-uses syntax color storage */ + /* space node, re-uses syntax and console color storage */ btheme->tnode = btheme->tv3d; rgba_char_args_set(btheme->tnode.edge_select, 255, 255, 255, 255); /* wire selected */ rgba_char_args_set(btheme->tnode.syntaxl, 155, 155, 155, 160); /* TH_NODE, backdrop */ @@ -970,6 +972,7 @@ void ui_theme_init_default(void) rgba_char_args_set(btheme->tnode.syntaxv, 104, 106, 117, 255); /* generator */ rgba_char_args_set(btheme->tnode.syntaxc, 105, 117, 110, 255); /* group */ rgba_char_args_set(btheme->tnode.movie, 155, 155, 155, 160); /* frame */ + rgba_char_args_set(btheme->tnode.console_output, 190, 190, 80, 255); /* group input/output */ btheme->tnode.noodle_curving = 5; /* space logic */ @@ -1545,7 +1548,7 @@ void init_userdef_do_versions(void) rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128); } if (U.coba_weight.tot == 0) - init_colorband(&U.coba_weight, 1); + init_colorband(&U.coba_weight, true); } if ((bmain->versionfile < 245) || (bmain->versionfile == 245 && bmain->subversionfile < 11)) { bTheme *btheme; @@ -2174,6 +2177,13 @@ void init_userdef_do_versions(void) } } + if (U.versionfile < 266 || (U.versionfile == 266 && U.subversionfile < 2)) { + bTheme *btheme; + for (btheme = U.themes.first; btheme; btheme = btheme->next) { + rgba_char_args_test_set(btheme->tnode.console_output, 223, 202, 53, 255); /* interface nodes */ + } + } + /* NOTE!! from now on use U.versionfile and U.subversionfile */ diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 8a6de9a549b..013b6d3c606 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1368,7 +1368,7 @@ void UI_view2d_constant_grid_draw(View2D *v2d) } /* Draw a multi-level grid in given 2d-region */ -void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totlevels) +void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_size, int totlevels) { int offset = -10; float lstep = step; @@ -1378,7 +1378,7 @@ void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totl int i; float start; - UI_ThemeColorShade(TH_BACK, offset); + UI_ThemeColorShade(colorid, offset); i = (v2d->cur.xmin >= 0.0f ? -(int)(-v2d->cur.xmin / lstep) : (int)(v2d->cur.xmin / lstep)); start = i * lstep; @@ -1402,7 +1402,7 @@ void UI_view2d_multi_grid_draw(View2D *v2d, float step, int level_size, int totl } /* X and Y axis */ - UI_ThemeColorShade(TH_BACK, offset - 8); + UI_ThemeColorShade(colorid, offset - 8); glVertex2f(0.0f, v2d->cur.ymin); glVertex2f(0.0f, v2d->cur.ymax); glVertex2f(v2d->cur.xmin, 0.0f); @@ -2075,6 +2075,28 @@ void UI_view2d_getscale_inverse(View2D *v2d, float *x, float *y) if (y) *y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); } +/* Simple functions for consistent center offset access. + * Used by node editor to shift view center for each individual node tree. + */ +void UI_view2d_getcenter(struct View2D *v2d, float *x, float *y) +{ + /* get center */ + if (x) *x = BLI_rctf_cent_x(&v2d->cur); + if (y) *y = BLI_rctf_cent_y(&v2d->cur); +} +void UI_view2d_setcenter(struct View2D *v2d, float x, float y) +{ + /* get delta from current center */ + float dx = x - BLI_rctf_cent_x(&v2d->cur); + float dy = y - BLI_rctf_cent_y(&v2d->cur); + + /* add to cur */ + BLI_rctf_translate(&v2d->cur, dx, dy); + + /* make sure that 'cur' rect is in a valid state as a result of these changes */ + UI_view2d_curRect_validate(v2d); +} + /* Check if mouse is within scrollers * - Returns appropriate code for match * 'h' = in horizontal scroller |