diff options
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 54 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 46 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 42 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 380 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 17 |
6 files changed, 292 insertions, 251 deletions
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 76ed9891b8e..33aeb2df926 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -58,10 +58,9 @@ /* own include */ #include "interface_intern.h" -#define UI_RB_ALPHA 16 #define UI_DISABLED_ALPHA_OFFS -160 -static int roundboxtype= 15; +static int roundboxtype= UI_CNR_ALL; void uiSetRoundBox(int type) { @@ -69,13 +68,6 @@ void uiSetRoundBox(int type) * if this is undone, its not that big a deal, only makes curves edges * square for the */ roundboxtype= type; - - /* flags to set which corners will become rounded: - - 1------2 - | | - 8------4 - */ } @@ -98,7 +90,7 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r glBegin(mode); /* start with corner right-bottom */ - if(roundboxtype & 4) { + if(roundboxtype & UI_CNR_BOTTOM_RIGHT) { glVertex2f(maxx-rad, miny); for(a=0; a<7; a++) { glVertex2f(maxx-rad+vec[a][0], miny+vec[a][1]); @@ -108,7 +100,7 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r else glVertex2f(maxx, miny); /* corner right-top */ - if(roundboxtype & 2) { + if(roundboxtype & UI_CNR_TOP_RIGHT) { glVertex2f(maxx, maxy-rad); for(a=0; a<7; a++) { glVertex2f(maxx-vec[a][1], maxy-rad+vec[a][0]); @@ -118,7 +110,7 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r else glVertex2f(maxx, maxy); /* corner left-top */ - if(roundboxtype & 1) { + if(roundboxtype & UI_CNR_TOP_LEFT) { glVertex2f(minx+rad, maxy); for(a=0; a<7; a++) { glVertex2f(minx+rad-vec[a][0], maxy-vec[a][1]); @@ -128,7 +120,7 @@ void uiDrawBox(int mode, float minx, float miny, float maxx, float maxy, float r else glVertex2f(minx, maxy); /* corner left-bottom */ - if(roundboxtype & 8) { + if(roundboxtype & UI_CNR_BOTTOM_LEFT) { glVertex2f(minx, miny+rad); for(a=0; a<7; a++) { glVertex2f(minx+vec[a][1], miny+rad-vec[a][0]); @@ -180,7 +172,7 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl glBegin(mode); /* start with corner right-bottom */ - if(roundboxtype & 4) { + if(roundboxtype & UI_CNR_BOTTOM_RIGHT) { round_box_shade_col(coltop, coldown, 0.0); glVertex2f(maxx-rad, miny); @@ -199,7 +191,7 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl } /* corner right-top */ - if(roundboxtype & 2) { + if(roundboxtype & UI_CNR_TOP_RIGHT) { round_box_shade_col(coltop, coldown, (div-rad)*idiv); glVertex2f(maxx, maxy-rad); @@ -217,7 +209,7 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl } /* corner left-top */ - if(roundboxtype & 1) { + if(roundboxtype & UI_CNR_TOP_LEFT) { round_box_shade_col(coltop, coldown, 1.0); glVertex2f(minx+rad, maxy); @@ -236,7 +228,7 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl } /* corner left-bottom */ - if(roundboxtype & 8) { + if(roundboxtype & UI_CNR_BOTTOM_LEFT) { round_box_shade_col(coltop, coldown, rad*idiv); glVertex2f(minx, miny+rad); @@ -288,7 +280,7 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float glBegin(mode); /* start with corner right-bottom */ - if(roundboxtype & 4) { + if(roundboxtype & UI_CNR_BOTTOM_RIGHT) { round_box_shade_col(colLeft, colRight, 0.0); glVertex2f(maxx-rad, miny); @@ -306,7 +298,7 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float } /* corner right-top */ - if(roundboxtype & 2) { + if(roundboxtype & UI_CNR_TOP_RIGHT) { round_box_shade_col(colLeft, colRight, 0.0); glVertex2f(maxx, maxy-rad); @@ -324,7 +316,7 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float } /* corner left-top */ - if(roundboxtype & 1) { + if(roundboxtype & UI_CNR_TOP_LEFT) { round_box_shade_col(colLeft, colRight, (div-rad)*idiv); glVertex2f(minx+rad, maxy); @@ -342,7 +334,7 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float } /* corner left-bottom */ - if(roundboxtype & 8) { + if(roundboxtype & UI_CNR_BOTTOM_LEFT) { round_box_shade_col(colLeft, colRight, 1.0); glVertex2f(minx, miny+rad); @@ -709,7 +701,7 @@ static void draw_scope_end(rctf *rect, GLint *scissor) /* outline */ glColor4f(0.f, 0.f, 0.f, 0.5f); - uiSetRoundBox(15); + uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_LINE_LOOP, rect->xmin-1, rect->ymin, rect->xmax+1, rect->ymax+1, 3.0f); } @@ -768,9 +760,13 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.f, 0.f, 0.f, 0.3f); - uiSetRoundBox(15); + uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); - + + /* need scissor test, histogram can draw outside of boundary */ + glGetIntegerv(GL_VIEWPORT, scissor); + glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); + glColor4f(1.f, 1.f, 1.f, 0.08f); /* draw grid lines here */ for (i=1; i<4; i++) { @@ -778,10 +774,6 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) fdrawline(rect.xmin+(i/4.f)*w, rect.ymin, rect.xmin+(i/4.f)*w, rect.ymax); } - /* need scissor test, histogram can draw outside of boundary */ - glGetIntegerv(GL_VIEWPORT, scissor); - glScissor(ar->winrct.xmin + (rect.xmin-1), ar->winrct.ymin+(rect.ymin-1), (rect.xmax+1)-(rect.xmin-1), (rect.ymax+1)-(rect.ymin-1)); - if (hist->mode == HISTO_MODE_LUMA) histogram_draw_one(1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_luma, res); else { @@ -837,7 +829,7 @@ void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.f, 0.f, 0.f, 0.3f); - uiSetRoundBox(15); + uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); @@ -1048,7 +1040,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.f, 0.f, 0.f, 0.3f); - uiSetRoundBox(15); + uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_POLYGON, rect.xmin-1, rect.ymin-1, rect.xmax+1, rect.ymax+1, 3.0f); /* need scissor test, hvectorscope can draw outside of boundary */ @@ -1233,7 +1225,7 @@ void ui_draw_but_NORMAL(uiBut *but, uiWidgetColors *wcol, rcti *rect) /* backdrop */ glColor3ubv((unsigned char*)wcol->inner); - uiSetRoundBox(15); + uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_POLYGON, rect->xmin, rect->ymin, rect->xmax, rect->ymax, 5.0f); /* sphere color */ diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index f4e53e2aa52..5f15cf7e5f7 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -336,7 +336,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index) } /* create buttons for an item with an RNA array */ -static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int h, int expand, int slider, int toggle, int icon_only) +static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int UNUSED(h), int expand, int slider, int toggle, int icon_only) { uiStyle *style= layout->root->style; uiBut *but; @@ -409,7 +409,7 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, const char *name, in if (totdim != 2) return; /* only 2D matrices supported in UI so far */ w /= dim_size[0]; - h /= dim_size[1]; + /* h /= dim_size[1]; */ /* UNUSED */ for(a=0; a<len; a++) { col= a % dim_size[0]; @@ -632,7 +632,7 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, i if(!ot) { ui_item_disabled(layout, opname); - RNA_warning("uiItemFullO: unknown operator '%s'\n", opname); + RNA_warning("unknown operator '%s'", opname); return PointerRNA_NULL; } @@ -739,7 +739,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname if(!ot || !ot->srna) { ui_item_disabled(layout, opname); - RNA_warning("uiItemsFullEnumO: %s '%s'\n", ot ? "unknown operator" : "operator missing srna", opname); + RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname); return; } @@ -817,7 +817,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char /* pass */ } else { - RNA_warning("uiItemEnumO_value: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname); + RNA_warning("%s.%s not found.", RNA_struct_identifier(ptr.type), propname); return; } @@ -846,7 +846,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char RNA_property_enum_items(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free); if(item==NULL || RNA_enum_value_from_id(item, value_str, &value)==0) { if(free) MEM_freeN(item); - RNA_warning("uiItemEnumO_string: %s.%s, enum %s not found.\n", RNA_struct_identifier(ptr.type), propname, value_str); + RNA_warning("%s.%s, enum %s not found.", RNA_struct_identifier(ptr.type), propname, value_str); return; } @@ -854,7 +854,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char MEM_freeN(item); } else { - RNA_warning("uiItemEnumO_string: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname); + RNA_warning("%s.%s not found.", RNA_struct_identifier(ptr.type), propname); return; } @@ -1061,7 +1061,7 @@ void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag, if(!prop) { ui_item_disabled(layout, propname); - RNA_warning("uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } @@ -1074,7 +1074,7 @@ void uiItemEnumR(uiLayout *layout, const char *name, int icon, struct PointerRNA if(!prop || RNA_property_type(prop) != PROP_ENUM) { ui_item_disabled(layout, propname); - RNA_warning("uiItemEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } @@ -1089,7 +1089,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr if(!prop || RNA_property_type(prop) != PROP_ENUM) { ui_item_disabled(layout, propname); - RNA_warning("uiItemEnumR_string: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("enum property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } @@ -1098,7 +1098,7 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr if(!RNA_enum_value_from_id(item, value, &ivalue)) { if(free) MEM_freeN(item); ui_item_disabled(layout, propname); - RNA_warning("uiItemEnumR: enum property value not found: %s\n", value); + RNA_warning("enum property value not found: %s", value); return; } @@ -1123,12 +1123,12 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname if(!prop) { ui_item_disabled(layout, propname); - RNA_warning("uiItemsEnumR: enum property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("enum property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } if(RNA_property_type(prop) != PROP_ENUM) { - RNA_warning("uiItemsEnumR: not an enum property: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("not an enum property: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } else { @@ -1316,13 +1316,13 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna prop= RNA_struct_find_property(ptr, propname); if(!prop) { - RNA_warning("uiItemPointerR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } type= RNA_property_type(prop); if(!ELEM(type, PROP_POINTER, PROP_STRING)) { - RNA_warning("uiItemPointerR: property %s must be a pointer or string.\n", propname); + RNA_warning("property %s must be a pointer or string.", propname); return; } @@ -1330,11 +1330,11 @@ void uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propna if(!searchprop) { - RNA_warning("uiItemPointerR: search collection property not found: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname); + RNA_warning("search collection property not found: %s.%s", RNA_struct_identifier(ptr->type), searchpropname); return; } else if (RNA_property_type(searchprop) != PROP_COLLECTION) { - RNA_warning("uiItemPointerR: search collection property is not a collection type: %s.%s\n", RNA_struct_identifier(ptr->type), searchpropname); + RNA_warning("search collection property is not a collection type: %s.%s", RNA_struct_identifier(ptr->type), searchpropname); return; } @@ -1406,7 +1406,7 @@ static void ui_item_menu(uiLayout *layout, const char *name, int icon, uiMenuCre if(layout->root->type == UI_LAYOUT_HEADER) uiBlockSetEmboss(block, UI_EMBOSS); - else if(layout->root->type == UI_LAYOUT_PANEL) { + else if(ELEM(layout->root->type, UI_LAYOUT_PANEL, UI_LAYOUT_TOOLBAR)) { but->type= MENU; but->flag |= UI_TEXT_LEFT; } @@ -1419,7 +1419,7 @@ void uiItemM(uiLayout *layout, bContext *UNUSED(C), const char *menuname, const mt= WM_menutype_find(menuname, FALSE); if(mt==NULL) { - RNA_warning("uiItemM: not found %s\n", menuname); + RNA_warning("not found %s", menuname); return; } @@ -1528,7 +1528,7 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo { MenuItemLevel *lvl= (MenuItemLevel*)(((uiBut*)arg)->func_argN); - uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN); + uiLayoutSetOperatorContext(layout, lvl->opcontext); uiItemsEnumO(layout, lvl->opname, lvl->propname); } @@ -1539,12 +1539,12 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, if(!ot) { ui_item_disabled(layout, opname); - RNA_warning("uiItemMenuEnumO: unknown operator '%s'\n", opname); + RNA_warning("unknown operator '%s'", opname); return; } if(!ot->srna) { ui_item_disabled(layout, opname); - RNA_warning("uiItemMenuEnumO: operator missing srna '%s'\n", opname); + RNA_warning("operator missing srna '%s'", opname); return; } @@ -1577,7 +1577,7 @@ void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propn prop= RNA_struct_find_property(ptr, propname); if(!prop) { ui_item_disabled(layout, propname); - RNA_warning("uiItemMenuEnumR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 01dcdda97a1..d4f49d750ac 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -537,8 +537,8 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* in some occasions, draw a border */ if(panel->flag & PNL_SELECT) { - if(panel->control & UI_PNL_SOLID) uiSetRoundBox(15); - else uiSetRoundBox(3); + if(panel->control & UI_PNL_SOLID) uiSetRoundBox(UI_CNR_ALL); + else uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT); UI_ThemeColorShade(TH_BACK, -120); uiRoundRect(0.5f + rect->xmin, 0.5f + rect->ymin, 0.5f + rect->xmax, 0.5f + headrect.ymax+1, 8); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index e510d6bb38d..ec3173a42b2 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -245,7 +245,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) switch(event) { case UI_ID_BROWSE: case UI_ID_PIN: - RNA_warning("warning, id event %d shouldnt come here\n", event); + RNA_warning("warning, id event %d shouldnt come here", event); break; case UI_ID_OPEN: case UI_ID_ADD_NEW: @@ -488,7 +488,7 @@ static void ui_template_id(uiLayout *layout, bContext *C, PointerRNA *ptr, const prop= RNA_struct_find_property(ptr, propname); if(!prop || RNA_property_type(prop) != PROP_POINTER) { - RNA_warning("uiTemplateID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } @@ -549,11 +549,11 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co propType= RNA_struct_find_property(ptr, proptypename); if (!propID || RNA_property_type(propID) != PROP_POINTER) { - RNA_warning("uiTemplateAnyID: pointer property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } if (!propType || RNA_property_type(propType) != PROP_ENUM) { - RNA_warning("uiTemplateAnyID: pointer-type property not found: %s.%s\n", RNA_struct_identifier(ptr->type), proptypename); + RNA_warning("pointer-type property not found: %s.%s", RNA_struct_identifier(ptr->type), proptypename); return; } @@ -592,7 +592,7 @@ void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propna /* check that properties are valid */ propPath= RNA_struct_find_property(ptr, propname); if (!propPath || RNA_property_type(propPath) != PROP_STRING) { - RNA_warning("uiTemplatePathBuilder: path property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("path property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } @@ -855,7 +855,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) /* verify we have valid data */ if(!RNA_struct_is_a(ptr->type, &RNA_Modifier)) { - RNA_warning("uiTemplateModifier: Expected modifier on object.\n"); + RNA_warning("Expected modifier on object."); return NULL; } @@ -863,7 +863,7 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) md= ptr->data; if(!ob || !(GS(ob->id.name) == ID_OB)) { - RNA_warning("uiTemplateModifier: Expected modifier on object.\n"); + RNA_warning("expected modifier on object."); return NULL; } @@ -1084,7 +1084,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) /* verify we have valid data */ if(!RNA_struct_is_a(ptr->type, &RNA_Constraint)) { - RNA_warning("uiTemplateConstraint: Expected constraint on object.\n"); + RNA_warning("Expected constraint on object."); return NULL; } @@ -1092,7 +1092,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, PointerRNA *ptr) con= ptr->data; if(!ob || !(GS(ob->id.name) == ID_OB)) { - RNA_warning("uiTemplateConstraint: Expected constraint on object.\n"); + RNA_warning("Expected constraint on object."); return NULL; } @@ -1138,7 +1138,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M PointerRNA texture_ptr; if(id && !ELEM4(GS(id->name), ID_MA, ID_TE, ID_WO, ID_LA)) { - RNA_warning("uiTemplatePreview: Expected ID of type material, texture, lamp or world.\n"); + RNA_warning("expected ID of type material, texture, lamp or world."); return; } @@ -1844,12 +1844,14 @@ void uiTemplateCurveMapping(uiLayout *layout, PointerRNA *ptr, const char *propn PointerRNA cptr; if(!prop) { - RNA_warning("uiTemplateCurveMapping: curve property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("curve property not found: %s.%s", + RNA_struct_identifier(ptr->type), propname); return; } if(RNA_property_type(prop) != PROP_POINTER) { - RNA_warning("uiTemplateCurveMapping: curve is not a pointer: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("curve is not a pointer: %s.%s", + RNA_struct_identifier(ptr->type), propname); return; } @@ -1879,7 +1881,7 @@ void uiTemplateColorWheel(uiLayout *layout, PointerRNA *ptr, const char *propnam float softmin, softmax, step, precision; if (!prop) { - RNA_warning("uiTemplateColorWheel: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } @@ -1949,7 +1951,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, prop= RNA_struct_find_property(ptr, propname); if (!prop) { - RNA_warning("uiTemplateLayer: layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("layers property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } @@ -1966,7 +1968,7 @@ void uiTemplateLayers(uiLayout *layout, PointerRNA *ptr, const char *propname, if(used_ptr && used_propname) { used_prop= RNA_struct_find_property(used_ptr, used_propname); if (!used_prop) { - RNA_warning("uiTemplateLayer: used layers property not found: %s.%s\n", RNA_struct_identifier(ptr->type), used_propname); + RNA_warning("used layers property not found: %s.%s", RNA_struct_identifier(ptr->type), used_propname); return; } @@ -2157,7 +2159,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * pa= block->panel; if(!pa) { - RNA_warning("uiTemplateList: only works inside a panel.\n"); + RNA_warning("only works inside a panel."); return; } @@ -2167,28 +2169,28 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * if(ptr->data) { prop= RNA_struct_find_property(ptr, propname); if(!prop) { - RNA_warning("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname); + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } } activeprop= RNA_struct_find_property(activeptr, activepropname); if(!activeprop) { - RNA_warning("uiTemplateList: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), activepropname); + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), activepropname); return; } if(prop) { type= RNA_property_type(prop); if(type != PROP_COLLECTION) { - RNA_warning("uiTemplateList: Expected collection property.\n"); + RNA_warning("uiExpected collection property."); return; } } activetype= RNA_property_type(activeprop); if(activetype != PROP_INT) { - RNA_warning("uiTemplateList: Expected integer property.\n"); + RNA_warning("expected integer property."); return; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 5da875356ea..45829646145 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -79,19 +79,23 @@ /* it has outline, back, and two optional tria meshes */ typedef struct uiWidgetTrias { - int tot; + unsigned int tot; float vec[32][2]; - int (*index)[3]; + unsigned int (*index)[3]; } uiWidgetTrias; +/* max as used by round_box__edges */ +#define WIDGET_CURVE_RESOLU 9 +#define WIDGET_SIZE_MAX (WIDGET_CURVE_RESOLU*4) + typedef struct uiWidgetBase { int totvert, halfwayvert; - float outer_v[64][2]; - float inner_v[64][2]; - float inner_uv[64][2]; + float outer_v[WIDGET_SIZE_MAX][2]; + float inner_v[WIDGET_SIZE_MAX][2]; + float inner_uv[WIDGET_SIZE_MAX][2]; short inner, outline, emboss; /* set on/off */ short shadedir; @@ -123,7 +127,7 @@ typedef struct uiWidgetType { /* *********************** draw data ************************** */ -static float cornervec[9][2]= {{0.0, 0.0}, {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, +static float cornervec[WIDGET_CURVE_RESOLU][2]= {{0.0, 0.0}, {0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, {0.707, 0.293}, {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}, {1.0, 1.0}}; static float jit[8][2]= {{0.468813 , -0.481430}, {-0.155755 , -0.352820}, @@ -133,7 +137,7 @@ static float jit[8][2]= {{0.468813 , -0.481430}, {-0.155755 , -0.352820}, static float num_tria_vert[3][2]= { {-0.352077, 0.532607}, {-0.352077, -0.549313}, {0.330000, -0.008353}}; -static int num_tria_face[1][3]= { +static unsigned int num_tria_face[1][3]= { {0, 1, 2}}; static float scroll_circle_vert[16][2]= { @@ -142,7 +146,7 @@ static float scroll_circle_vert[16][2]= { {-0.382683, -0.923880}, {0.000000, -1.000000}, {0.382684, -0.923880}, {0.707107, -0.707107}, {0.923880, -0.382684}, {1.000000, -0.000000}, {0.923880, 0.382683}, {0.707107, 0.707107}}; -static int scroll_circle_face[14][3]= { +static unsigned int scroll_circle_face[14][3]= { {0, 1, 2}, {2, 0, 3}, {3, 0, 15}, {3, 15, 4}, {4, 15, 14}, {4, 14, 5}, {5, 14, 13}, {5, 13, 6}, {6, 13, 12}, {6, 12, 7}, {7, 12, 11}, {7, 11, 8}, {8, 11, 10}, {8, 10, 9}}; @@ -150,13 +154,13 @@ static float menu_tria_vert[6][2]= { {-0.41, 0.16}, {0.41, 0.16}, {0, 0.82}, {0, -0.82}, {-0.41, -0.16}, {0.41, -0.16}}; -static int menu_tria_face[2][3]= {{2, 0, 1}, {3, 5, 4}}; +static unsigned int menu_tria_face[2][3]= {{2, 0, 1}, {3, 5, 4}}; static float check_tria_vert[6][2]= { {-0.578579, 0.253369}, {-0.392773, 0.412794}, {-0.004241, -0.328551}, {-0.003001, 0.034320}, {1.055313, 0.864744}, {0.866408, 1.026895}}; -static int check_tria_face[4][3]= { +static unsigned int check_tria_face[4][3]= { {3, 2, 4}, {3, 4, 5}, {1, 0, 3}, {0, 2, 3}}; GLubyte checker_stipple_sml[32*32/8] = @@ -175,6 +179,7 @@ GLubyte checker_stipple_sml[32*32/8] = void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3) { + float tri_arr[3][2]= {{x1, y1}, {x2, y2}, {x3, y3}}; float color[4]; int j; @@ -182,20 +187,18 @@ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y glGetFloatv(GL_CURRENT_COLOR, color); color[3] *= 0.125f; glColor4fv(color); - + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, tri_arr); + /* for each AA step */ for(j=0; j<8; j++) { glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); - - glBegin(GL_POLYGON); - glVertex2f(x1, y1); - glVertex2f(x2, y2); - glVertex2f(x3, y3); - glEnd(); - + glDrawArrays(GL_TRIANGLES, 0, 3); glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); } + glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_BLEND); } @@ -216,7 +219,7 @@ static void widget_init(uiWidgetBase *wtb) /* return tot */ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int roundboxalign, float step) { - float vec[9][2]; + float vec[WIDGET_CURVE_RESOLU][2]; float minx, miny, maxx, maxy; int a, tot= 0; @@ -231,59 +234,59 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r maxy= rect->ymax+step; /* mult */ - for(a=0; a<9; a++) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++) { vec[a][0]= rad*cornervec[a][0]; vec[a][1]= rad*cornervec[a][1]; } /* start with left-top, anti clockwise */ - if(roundboxalign & 1) { - for(a=0; a<9; a++, tot++) { + if(roundboxalign & UI_CNR_TOP_LEFT) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= minx+rad-vec[a][0]; vert[tot][1]= maxy-vec[a][1]; } } else { - for(a=0; a<9; a++, tot++) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= minx; vert[tot][1]= maxy; } } - if(roundboxalign & 8) { - for(a=0; a<9; a++, tot++) { + if(roundboxalign & UI_CNR_BOTTOM_LEFT) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= minx+vec[a][1]; vert[tot][1]= miny+rad-vec[a][0]; } } else { - for(a=0; a<9; a++, tot++) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= minx; vert[tot][1]= miny; } } - if(roundboxalign & 4) { - for(a=0; a<9; a++, tot++) { + if(roundboxalign & UI_CNR_BOTTOM_RIGHT) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= maxx-rad+vec[a][0]; vert[tot][1]= miny+vec[a][1]; } } else { - for(a=0; a<9; a++, tot++) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= maxx; vert[tot][1]= miny; } } - if(roundboxalign & 2) { - for(a=0; a<9; a++, tot++) { + if(roundboxalign & UI_CNR_TOP_RIGHT) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= maxx-vec[a][1]; vert[tot][1]= maxy-rad+vec[a][0]; } } else { - for(a=0; a<9; a++, tot++) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { vert[tot][0]= maxx; vert[tot][1]= maxy; } @@ -294,7 +297,7 @@ static int round_box_shadow_edges(float (*vert)[2], rcti *rect, float rad, int r /* this call has 1 extra arg to allow mask outline */ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, float rad, float radi) { - float vec[9][2], veci[9][2]; + float vec[WIDGET_CURVE_RESOLU][2], veci[WIDGET_CURVE_RESOLU][2]; float minx= rect->xmin, miny= rect->ymin, maxx= rect->xmax, maxy= rect->ymax; float minxi= minx + 1.0f; /* boundbox inner */ float maxxi= maxx - 1.0f; @@ -303,8 +306,10 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl float facxi= (maxxi!=minxi) ? 1.0f/(maxxi-minxi) : 0.0f; /* for uv, can divide by zero */ float facyi= (maxyi!=minyi) ? 1.0f/(maxyi-minyi) : 0.0f; int a, tot= 0, minsize; - const int hnum= ((roundboxalign & (1|2))==(1|2) || (roundboxalign & (4|8))==(4|8)) ? 1 : 2; - const int vnum= ((roundboxalign & (1|8))==(1|8) || (roundboxalign & (2|4))==(2|4)) ? 1 : 2; + const int hnum= ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT))==(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT) || + (roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT))==(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT)) ? 1 : 2; + const int vnum= ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT))==(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) || + (roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT))==(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2; minsize= MIN2((rect->xmax-rect->xmin)*hnum, (rect->ymax-rect->ymin)*vnum); @@ -315,7 +320,7 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl radi= 0.5f*minsize - 1.0f; /* mult */ - for(a=0; a<9; a++) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++) { veci[a][0]= radi*cornervec[a][0]; veci[a][1]= radi*cornervec[a][1]; vec[a][0]= rad*cornervec[a][0]; @@ -323,9 +328,9 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl } /* corner left-bottom */ - if(roundboxalign & 8) { + if(roundboxalign & UI_CNR_BOTTOM_LEFT) { - for(a=0; a<9; a++, tot++) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { wt->inner_v[tot][0]= minxi+veci[a][1]; wt->inner_v[tot][1]= minyi+radi-veci[a][0]; @@ -350,9 +355,9 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl } /* corner right-bottom */ - if(roundboxalign & 4) { + if(roundboxalign & UI_CNR_BOTTOM_RIGHT) { - for(a=0; a<9; a++, tot++) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { wt->inner_v[tot][0]= maxxi-radi+veci[a][0]; wt->inner_v[tot][1]= minyi+veci[a][1]; @@ -379,9 +384,9 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl wt->halfwayvert= tot; /* corner right-top */ - if(roundboxalign & 2) { + if(roundboxalign & UI_CNR_TOP_RIGHT) { - for(a=0; a<9; a++, tot++) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { wt->inner_v[tot][0]= maxxi-veci[a][1]; wt->inner_v[tot][1]= maxyi-radi+veci[a][0]; @@ -406,9 +411,9 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl } /* corner left-top */ - if(roundboxalign & 1) { + if(roundboxalign & UI_CNR_TOP_LEFT) { - for(a=0; a<9; a++, tot++) { + for(a=0; a < WIDGET_CURVE_RESOLU; a++, tot++) { wt->inner_v[tot][0]= minxi+radi-veci[a][0]; wt->inner_v[tot][1]= maxyi-veci[a][1]; @@ -433,7 +438,9 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl tot++; } - + + BLI_assert(tot <= WIDGET_SIZE_MAX); + wt->totvert= tot; } @@ -516,16 +523,10 @@ static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize static void widget_trias_draw(uiWidgetTrias *tria) { - int a; - - glBegin(GL_TRIANGLES); - for(a=0; a<tria->tot; a++) { - glVertex2fv(tria->vec[ tria->index[a][0] ]); - glVertex2fv(tria->vec[ tria->index[a][1] ]); - glVertex2fv(tria->vec[ tria->index[a][2] ]); - } - glEnd(); - + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, tria->vec); + glDrawElements(GL_TRIANGLES, tria->tot*3, GL_UNSIGNED_INT, tria->index); + glDisableClientState(GL_VERTEX_ARRAY); } static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect) @@ -587,33 +588,48 @@ static void shadecolors4(char *coltop, char *coldown, const char *color, short s coldown[3]= color[3]; } -static void round_box_shade_col4(const char col1[4], const char col2[4], const float fac) +static void round_box_shade_col4_r(unsigned char col_r[4], const char col1[4], const char col2[4], const float fac) { - unsigned char col[4]; const int faci= FTOCHAR(fac); const int facm= 255-faci; - 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; + col_r[0]= (faci*col1[0] + facm*col2[0])>>8; + col_r[1]= (faci*col1[1] + facm*col2[1])>>8; + col_r[2]= (faci*col1[2] + facm*col2[2])>>8; + col_r[3]= (faci*col1[3] + facm*col2[3])>>8; +} - glColor4ubv(col); +static void widget_verts_to_quad_strip(uiWidgetBase *wtb, const int totvert, float quad_strip[WIDGET_SIZE_MAX*2+2][2]) +{ + int a; + for(a=0; a<totvert; a++) { + copy_v2_v2(quad_strip[a*2], wtb->outer_v[a]); + copy_v2_v2(quad_strip[a*2+1], wtb->inner_v[a]); + } + copy_v2_v2(quad_strip[a*2], wtb->outer_v[0]); + copy_v2_v2(quad_strip[a*2+1], wtb->inner_v[0]); } -static void widgetbase_outline(uiWidgetBase *wtb) +static void widget_verts_to_quad_strip_open(uiWidgetBase *wtb, const int totvert, float quad_strip[WIDGET_SIZE_MAX*2][2]) { int a; - - /* outline */ - glBegin(GL_QUAD_STRIP); - for(a=0; a<wtb->totvert; a++) { - glVertex2fv(wtb->outer_v[a]); - glVertex2fv(wtb->inner_v[a]); + for(a=0; a<totvert; a++) { + quad_strip[a*2][0]= wtb->outer_v[a][0]; + quad_strip[a*2][1]= wtb->outer_v[a][1]; + quad_strip[a*2+1][0]= wtb->outer_v[a][0]; + quad_strip[a*2+1][1]= wtb->outer_v[a][1] - 1.0f; } - glVertex2fv(wtb->outer_v[0]); - glVertex2fv(wtb->inner_v[0]); - glEnd(); +} + +static void widgetbase_outline(uiWidgetBase *wtb) +{ + float quad_strip[WIDGET_SIZE_MAX*2+2][2]; /* + 2 because the last pair is wrapped */ + widget_verts_to_quad_strip(wtb, wtb->totvert, quad_strip); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, quad_strip); + glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert*2 + 2); + glDisableClientState(GL_VERTEX_ARRAY); } static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) @@ -626,100 +642,124 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) if(wtb->inner) { if(wcol->shaded==0) { if (wcol->alpha_check) { + float inner_v_half[WIDGET_SIZE_MAX][2]; float x_mid= 0.0f; /* used for dumb clamping of values */ /* dark checkers */ glColor4ub(UI_TRANSP_DARK, UI_TRANSP_DARK, UI_TRANSP_DARK, 255); - glBegin(GL_POLYGON); - for(a=0; a<wtb->totvert; a++) { - glVertex2fv(wtb->inner_v[a]); - } - glEnd(); + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v); + glDrawArrays(GL_POLYGON, 0, wtb->totvert); + glDisableClientState(GL_VERTEX_ARRAY); /* light checkers */ glEnable(GL_POLYGON_STIPPLE); glColor4ub(UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, UI_TRANSP_LIGHT, 255); glPolygonStipple(checker_stipple_sml); - glBegin(GL_POLYGON); - for(a=0; a<wtb->totvert; a++) { - glVertex2fv(wtb->inner_v[a]); - } - glEnd(); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v); + glDrawArrays(GL_POLYGON, 0, wtb->totvert); + glDisableClientState(GL_VERTEX_ARRAY); + glDisable(GL_POLYGON_STIPPLE); /* alpha fill */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4ubv((unsigned char*)wcol->inner); - glBegin(GL_POLYGON); + glEnableClientState(GL_VERTEX_ARRAY); + for(a=0; a<wtb->totvert; a++) { - glVertex2fv(wtb->inner_v[a]); x_mid += wtb->inner_v[a][0]; } x_mid /= wtb->totvert; - glEnd(); + + glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v); + glDrawArrays(GL_POLYGON, 0, wtb->totvert); + glDisableClientState(GL_VERTEX_ARRAY); /* 1/2 solid color */ glColor4ub(wcol->inner[0], wcol->inner[1], wcol->inner[2], 255); - glBegin(GL_POLYGON); - for(a=0; a<wtb->totvert; a++) - glVertex2f(MIN2(wtb->inner_v[a][0], x_mid), wtb->inner_v[a][1]); - glEnd(); + + for(a=0; a<wtb->totvert; a++) { + inner_v_half[a][0]= MIN2(wtb->inner_v[a][0], x_mid); + inner_v_half[a][1]= wtb->inner_v[a][1]; + } + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, inner_v_half); + glDrawArrays(GL_POLYGON, 0, wtb->totvert); + glDisableClientState(GL_VERTEX_ARRAY); } else { /* simple fill */ glColor4ubv((unsigned char*)wcol->inner); - glBegin(GL_POLYGON); - for(a=0; a<wtb->totvert; a++) - glVertex2fv(wtb->inner_v[a]); - glEnd(); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v); + glDrawArrays(GL_POLYGON, 0, wtb->totvert); + glDisableClientState(GL_VERTEX_ARRAY); } } else { char col1[4], col2[4]; + unsigned char col_array[WIDGET_SIZE_MAX * 4]; + unsigned char *col_pt= col_array; shadecolors4(col1, col2, wcol->inner, wcol->shadetop, wcol->shadedown); glShadeModel(GL_SMOOTH); - glBegin(GL_POLYGON); - for(a=0; a<wtb->totvert; a++) { - round_box_shade_col4(col1, col2, wtb->inner_uv[a][wtb->shadedir]); - glVertex2fv(wtb->inner_v[a]); + for(a=0; a<wtb->totvert; a++, col_pt += 4) { + round_box_shade_col4_r(col_pt, col1, col2, wtb->inner_uv[a][wtb->shadedir]); } - glEnd(); + + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_COLOR_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, wtb->inner_v); + glColorPointer(4, GL_UNSIGNED_BYTE, 0, col_array); + glDrawArrays(GL_POLYGON, 0, wtb->totvert); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); + glShadeModel(GL_FLAT); } } /* for each AA step */ if(wtb->outline) { + float quad_strip[WIDGET_SIZE_MAX*2+2][2]; /* + 2 because the last pair is wrapped */ + float quad_strip_emboss[WIDGET_SIZE_MAX*2][2]; /* only for emboss */ + + widget_verts_to_quad_strip(wtb, wtb->totvert, quad_strip); + + if(wtb->emboss) { + widget_verts_to_quad_strip_open(wtb, wtb->halfwayvert, quad_strip_emboss); + } + + glEnableClientState(GL_VERTEX_ARRAY); + for(j=0; j<8; j++) { glTranslatef(1.0f * jit[j][0], 1.0f * jit[j][1], 0.0f); /* outline */ 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]); - glVertex2fv(wtb->inner_v[a]); - } - glVertex2fv(wtb->outer_v[0]); - glVertex2fv(wtb->inner_v[0]); - glEnd(); + + glVertexPointer(2, GL_FLOAT, 0, quad_strip); + glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert*2 + 2); /* emboss bottom shadow */ if(wtb->emboss) { glColor4f(1.0f, 1.0f, 1.0f, 0.02f); - glBegin(GL_QUAD_STRIP); - for(a=0; a<wtb->halfwayvert; a++) { - glVertex2fv(wtb->outer_v[a]); - glVertex2f(wtb->outer_v[a][0], wtb->outer_v[a][1]-1.0f); - } - glEnd(); + + glVertexPointer(2, GL_FLOAT, 0, quad_strip_emboss); + glDrawArrays(GL_QUAD_STRIP, 0, wtb->halfwayvert*2); } glTranslatef(-1.0f * jit[j][0], -1.0f * jit[j][1], 0.0f); } + + glDisableClientState(GL_VERTEX_ARRAY); } /* decoration */ @@ -1611,7 +1651,8 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float uiWidgetBase wtb; rcti rect1= *rect; float alpha, alphastep; - int step, tot, a; + int step, totvert; + float quad_strip[WIDGET_SIZE_MAX*2][2]; /* prevent tooltips to not show round shadow */ if( 2.0f*radout > 0.2f*(rect1.ymax-rect1.ymin) ) @@ -1620,31 +1661,32 @@ static void widget_softshadow(rcti *rect, int roundboxalign, float radin, float rect1.ymax -= 2.0f*radout; /* inner part */ - tot= round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & 12, 0.0f); - + totvert= round_box_shadow_edges(wtb.inner_v, &rect1, radin, roundboxalign & (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT), 0.0f); + /* inverse linear shadow alpha */ alpha= 0.15; alphastep= 0.67; + glEnableClientState(GL_VERTEX_ARRAY); + for(step= 1; step<=radout; step++, alpha*=alphastep) { - round_box_shadow_edges(wtb.outer_v, &rect1, radin, 15, (float)step); + round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step); glColor4f(0.0f, 0.0f, 0.0f, alpha); - - glBegin(GL_QUAD_STRIP); - for(a=0; a<tot; a++) { - glVertex2fv(wtb.outer_v[a]); - glVertex2fv(wtb.inner_v[a]); - } - glEnd(); + + widget_verts_to_quad_strip_open(&wtb, totvert, quad_strip); + + glVertexPointer(2, GL_FLOAT, 0, quad_strip); + glDrawArrays(GL_QUAD_STRIP, 0, totvert*2); } - + + glDisableClientState(GL_VERTEX_ARRAY); } static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int direction) { uiWidgetBase wtb; - int roundboxalign= 15; + int roundboxalign= UI_CNR_ALL; widget_init(&wtb); @@ -1654,11 +1696,11 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir //rect->ymax += 4.0; } else if (direction == UI_DOWN) { - roundboxalign= 12; + roundboxalign= (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); rect->ymin -= 4.0; } else if (direction == UI_TOP) { - roundboxalign= 3; + roundboxalign= UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT; rect->ymax += 4.0; } @@ -2008,7 +2050,7 @@ static void ui_draw_but_HSV_v(uiBut *but, rcti *rect) widget_init(&wtb); /* fully rounded */ - round_box_edges(&wtb, 15, rect, rad); + round_box_edges(&wtb, UI_CNR_ALL, rect, rad); /* setup temp colors */ wcol_tmp.outline[0]= wcol_tmp.outline[1]= wcol_tmp.outline[2]= 0; @@ -2107,17 +2149,15 @@ void ui_draw_link_bezier(rcti *rect) if(ui_link_bezier_points(rect, coord_array, LINK_RESOL)) { /* we can reuse the dist variable here to increment the GL curve eval amount*/ // const float dist= 1.0f/(float)LINK_RESOL; // UNUSED - int i; glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - - glBegin(GL_LINE_STRIP); - for(i=0; i<=LINK_RESOL; i++) { - glVertex2fv(coord_array[i]); - } - glEnd(); - + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(2, GL_FLOAT, 0, coord_array); + glDrawArrays(GL_LINE_STRIP, 0, LINK_RESOL); + glDisableClientState(GL_VERTEX_ARRAY); + glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); @@ -2148,7 +2188,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat if(horizontal) SWAP(short, wcol->shadetop, wcol->shadedown); - round_box_edges(&wtb, 15, rect, rad); + round_box_edges(&wtb, UI_CNR_ALL, rect, rad); widgetbase_draw(&wtb, wcol); /* slider */ @@ -2176,7 +2216,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat if (state & UI_SCROLL_NO_OUTLINE) SWAP(short, outline, wtb.outline); - round_box_edges(&wtb, 15, slider, rad); + round_box_edges(&wtb, UI_CNR_ALL, slider, rad); if(state & UI_SCROLL_ARROWS) { if(wcol->item[0] > 48) wcol->item[0]-= 48; @@ -2343,7 +2383,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s /* left part of slider, always rounded */ rect1.xmax= rect1.xmin + ceil(offs+1.0f); - round_box_edges(&wtb1, roundboxalign & ~6, &rect1, offs); + round_box_edges(&wtb1, roundboxalign & ~(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT), &rect1, offs); wtb1.outline= 0; widgetbase_draw(&wtb1, wcol); @@ -2354,7 +2394,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s offs*= (rect1.xmax + offs - rect->xmax)/offs; else offs= 0.0f; - round_box_edges(&wtb1, roundboxalign & ~9, &rect1, offs); + round_box_edges(&wtb1, roundboxalign & ~(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT), &rect1, offs); widgetbase_draw(&wtb1, wcol); VECCOPY(wcol->outline, outline); @@ -2436,7 +2476,7 @@ static void widget_icon_has_anim(uiBut *UNUSED(but), uiWidgetColors *wcol, rcti wtb.outline= 0; /* rounded */ - round_box_edges(&wtb, 15, rect, 10.0f); + round_box_edges(&wtb, UI_CNR_ALL, rect, 10.0f); widgetbase_draw(&wtb, wcol); } } @@ -2499,7 +2539,7 @@ static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int widget_init(&wtb); /* half rounded */ - round_box_edges(&wtb, 15, rect, rad); + round_box_edges(&wtb, UI_CNR_ALL, rect, rad); widgetbase_draw(&wtb, wcol); } @@ -2526,7 +2566,7 @@ static void widget_list_itembut(uiWidgetColors *wcol, rcti *rect, int UNUSED(sta /* rounded, but no outline */ wtb.outline= 0; - round_box_edges(&wtb, 15, rect, 4.0f); + round_box_edges(&wtb, UI_CNR_ALL, rect, 4.0f); widgetbase_draw(&wtb, wcol); } @@ -2550,7 +2590,7 @@ static void widget_optionbut(uiWidgetColors *wcol, rcti *rect, int state, int UN recttemp.ymax-= delta; /* half rounded */ - round_box_edges(&wtb, 15, &recttemp, 4.0f); + round_box_edges(&wtb, UI_CNR_ALL, &recttemp, 4.0f); /* decoration */ if(state & UI_SELECT) { @@ -2650,12 +2690,12 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType * UI_GetThemeColor3ubv(TH_BACK, col); glColor3ubv(col); - round_box__edges(&wtb, 15, rect, 0.0f, 4.0); + round_box__edges(&wtb, UI_CNR_ALL, rect, 0.0f, 4.0); widgetbase_outline(&wtb); } /* outline */ - round_box_edges(&wtb, 15, rect, 5.0f); + round_box_edges(&wtb, UI_CNR_ALL, rect, 5.0f); wtb.outline= 1; wtb.inner= 0; widgetbase_draw(&wtb, &wt->wcol); @@ -2836,37 +2876,27 @@ static int widget_roundbox_set(uiBut *but, rcti *rect) switch(but->flag & UI_BUT_ALIGN) { case UI_BUT_ALIGN_TOP: - return (12); - break; + return UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT; case UI_BUT_ALIGN_DOWN: - return (3); - break; + return UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT; case UI_BUT_ALIGN_LEFT: - return (6); - break; + return UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT; case UI_BUT_ALIGN_RIGHT: - return (9); - break; - - case UI_BUT_ALIGN_DOWN|UI_BUT_ALIGN_RIGHT: - return (1); - break; - case UI_BUT_ALIGN_DOWN|UI_BUT_ALIGN_LEFT: - return (2); - break; - case UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_RIGHT: - return (8); - break; - case UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_LEFT: - return (4); - break; - + return UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT; + case UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_RIGHT: + return UI_CNR_TOP_LEFT; + case UI_BUT_ALIGN_DOWN | UI_BUT_ALIGN_LEFT: + return UI_CNR_TOP_RIGHT; + case UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_RIGHT: + return UI_CNR_BOTTOM_LEFT; + case UI_BUT_ALIGN_TOP | UI_BUT_ALIGN_LEFT: + return UI_CNR_BOTTOM_RIGHT; default: - return (0); - break; + return 0; } - } - return 15; + } + + return UI_CNR_ALL; } /* conversion from old to new buttons, so still messy */ @@ -3104,14 +3134,14 @@ void ui_draw_search_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) uiWidgetType *wt= widget_type(UI_WTYPE_BOX); glEnable(GL_BLEND); - widget_softshadow(rect, 15, 5.0f, 8.0f); + widget_softshadow(rect, UI_CNR_ALL, 5.0f, 8.0f); glDisable(GL_BLEND); wt->state(wt, 0); if(block) - wt->draw(&wt->wcol, rect, block->flag, 15); + wt->draw(&wt->wcol, rect, block->flag, UI_CNR_ALL); else - wt->draw(&wt->wcol, rect, 0, 15); + wt->draw(&wt->wcol, rect, 0, UI_CNR_ALL); } diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 692c8940a21..9b9237f70cf 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -1039,6 +1039,23 @@ void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char c glColor3ub(r, g, b); } +void UI_GetColorPtrShade3ubv(const unsigned char cp[3], unsigned char col[3], int offset) +{ + int r, g, b; + + r= offset+(int)cp[0]; + g= offset+(int)cp[1]; + b= offset+(int)cp[2]; + + CLAMP(r, 0, 255); + CLAMP(g, 0, 255); + CLAMP(b, 0, 255); + + col[0] = r; + col[1] = g; + col[2] = b; +} + // get a 3 byte color, blended and shaded between two other char color pointers void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset) { |