- Hhighlight active nurb in edit mode

- Replaced hardcoded nurbcol array with theme colors
- Send notification in duplicate curve operator (this operator could
  reset/change active nurb)
- Edge seam color added to the user preferences dialog
This commit is contained in:
Sergey Sharybin 2010-03-12 16:43:04 +00:00
parent a19e542db2
commit 4a8849b030
8 changed files with 323 additions and 34 deletions

@ -658,6 +658,19 @@ class USERPREF_PT_theme(bpy.types.Panel):
col.prop(v3d, "object_grouped")
col.prop(v3d, "object_grouped_active")
col.prop(v3d, "transform")
col.prop(v3d, "nurb_uline")
col.prop(v3d, "nurb_vline")
col.prop(v3d, "nurb_sel_uline")
col.prop(v3d, "nurb_sel_vline")
col.prop(v3d, "handle_free")
col.prop(v3d, "handle_auto")
col.prop(v3d, "handle_vect")
col.prop(v3d, "handle_align")
col.prop(v3d, "handle_sel_free")
col.prop(v3d, "handle_sel_auto")
col.prop(v3d, "handle_sel_vect")
col.prop(v3d, "handle_sel_align")
col.prop(v3d, "act_spline")
col = split.column()
col.prop(v3d, "vertex")
@ -666,6 +679,7 @@ class USERPREF_PT_theme(bpy.types.Panel):
col.prop(v3d, "vertex_normal")
col.prop(v3d, "bone_solid")
col.prop(v3d, "bone_pose")
col.prop(v3d, "edge_seam")
#col.prop(v3d, "edge") Doesn't seem to work
elif theme.theme_area == 'GRAPH_EDITOR':

@ -4255,6 +4255,7 @@ static int duplicate_exec(bContext *C, wmOperator *op)
Object *obedit= CTX_data_edit_object(C);
adduplicateflagNurb(obedit, 1);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}

@ -164,6 +164,22 @@ enum {
TH_FACE_DOT,
TH_FACEDOT_SIZE,
TH_CFRAME,
TH_NURB_ULINE,
TH_NURB_VLINE,
TH_NURB_SEL_ULINE,
TH_NURB_SEL_VLINE,
/* this eight colors should be in one block */
TH_HANDLE_FREE,
TH_HANDLE_AUTO,
TH_HANDLE_VECT,
TH_HANDLE_ALIGN,
TH_HANDLE_SEL_FREE,
TH_HANDLE_SEL_AUTO,
TH_HANDLE_SEL_VECT,
TH_HANDLE_SEL_ALIGN,
TH_ACTIVE_SPLINE,
TH_SYNTAX_B,
TH_SYNTAX_V,

@ -305,7 +305,33 @@ char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
cp= ts->strip_select; break;
case TH_CFRAME:
cp= ts->cframe; break;
case TH_NURB_ULINE:
cp= ts->nurb_uline; break;
case TH_NURB_VLINE:
cp= ts->nurb_vline; break;
case TH_NURB_SEL_ULINE:
cp= ts->nurb_sel_uline; break;
case TH_NURB_SEL_VLINE:
cp= ts->nurb_sel_vline; break;
case TH_ACTIVE_SPLINE:
cp= ts->act_spline; break;
case TH_HANDLE_FREE:
cp= ts->handle_free; break;
case TH_HANDLE_AUTO:
cp= ts->handle_auto; break;
case TH_HANDLE_VECT:
cp= ts->handle_vect; break;
case TH_HANDLE_ALIGN:
cp= ts->handle_align; break;
case TH_HANDLE_SEL_FREE:
cp= ts->handle_sel_free; break;
case TH_HANDLE_SEL_AUTO:
cp= ts->handle_sel_auto; break;
case TH_HANDLE_SEL_VECT:
cp= ts->handle_sel_vect; break;
case TH_HANDLE_SEL_ALIGN:
cp= ts->handle_sel_align; break;
case TH_SYNTAX_B:
cp= ts->syntaxb; break;
case TH_SYNTAX_V:
@ -495,6 +521,22 @@ void ui_theme_init_userdef(void)
btheme->tv3d.facedot_size= 4;
SETCOL(btheme->tv3d.cframe, 0x60, 0xc0, 0x40, 255);
SETCOL(btheme->tv3d.nurb_uline, 0x90, 0x90, 0x00, 255);
SETCOL(btheme->tv3d.nurb_vline, 0x80, 0x30, 0x60, 255);
SETCOL(btheme->tv3d.nurb_sel_uline, 0xf0, 0xff, 0x40, 255);
SETCOL(btheme->tv3d.nurb_sel_vline, 0xf0, 0x90, 0xa0, 255);
SETCOL(btheme->tv3d.handle_free, 0, 0, 0, 255);
SETCOL(btheme->tv3d.handle_auto, 0x90, 0x90, 0x00, 255);
SETCOL(btheme->tv3d.handle_vect, 0x40, 0x90, 0x30, 255);
SETCOL(btheme->tv3d.handle_align, 0x80, 0x30, 0x60, 255);
SETCOL(btheme->tv3d.handle_sel_free, 0, 0, 0, 255);
SETCOL(btheme->tv3d.handle_sel_auto, 0xf0, 0xff, 0x40, 255);
SETCOL(btheme->tv3d.handle_sel_vect, 0x40, 0xc0, 0x30, 255);
SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80); // alpha 80 is not meant editable, used for wire+action draw

@ -357,7 +357,6 @@ static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu)
* note: draw_fcurve_handles_check must be checked before running this. */
static void draw_fcurve_handles (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
{
extern unsigned int nurbcol[];
int sel, b;
/* a single call to GL_LINES here around these calls should be sufficient to still
@ -371,8 +370,9 @@ static void draw_fcurve_handles (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar,
*/
for (sel= 0; sel < 2; sel++) {
BezTriple *bezt=fcu->bezt, *prevbezt=NULL;
unsigned int *col= (sel)? (nurbcol+4) : (nurbcol);
int basecol= (sel)? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE;
float *fp;
char col[4];
/* if only selected keyframes have handles shown, skip the first round */
if ((sel == 0) && (sipo->flag & SIPO_SELVHANDLESONLY))
@ -390,19 +390,24 @@ static void draw_fcurve_handles (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar,
/* draw handle with appropriate set of colors if selection is ok */
if ((bezt->f2 & SELECT)==sel) {
fp= bezt->vec[0];
/* only draw first handle if previous segment had handles */
if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) )
{
cpackA(col[(unsigned char)bezt->h1], drawFCurveFade(fcu));
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
col[3]= drawFCurveFade(fcu) * 255;
glColor4ubv((GLubyte *)col);
glVertex2fv(fp); glVertex2fv(fp+3);
}
/* only draw second handle if this segment is bezier */
if (bezt->ipo == BEZT_IPO_BEZ)
{
cpackA(col[(unsigned char)bezt->h2], drawFCurveFade(fcu));
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
col[3]= drawFCurveFade(fcu) * 255;
glColor4ubv((GLubyte *)col);
glVertex2fv(fp+3); glVertex2fv(fp+6);
}
}
@ -412,8 +417,10 @@ static void draw_fcurve_handles (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar,
( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) )
{
fp= bezt->vec[0];
cpackA(col[(unsigned char)bezt->h1], drawFCurveFade(fcu));
UI_GetThemeColor3ubv(basecol + bezt->h1, col);
col[3]= drawFCurveFade(fcu) * 255;
glColor4ubv((GLubyte *)col);
glVertex2fv(fp); glVertex2fv(fp+3);
}
@ -422,8 +429,10 @@ static void draw_fcurve_handles (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar,
(bezt->ipo == BEZT_IPO_BEZ) )
{
fp= bezt->vec[1];
cpackA(col[(unsigned char)bezt->h2], drawFCurveFade(fcu));
UI_GetThemeColor3ubv(basecol + bezt->h2, col);
col[3]= drawFCurveFade(fcu) * 255;
glColor4ubv((GLubyte *)col);
glVertex2fv(fp); glVertex2fv(fp+3);
}
}

@ -2854,8 +2854,7 @@ static void drawDispListsolid(ListBase *lb, Object *ob, int glsl)
case DL_POLY:
if(ob->type==OB_SURF) {
int nr;
UI_ThemeColor(TH_WIRE);
glDisable(GL_LIGHTING);
/* for some reason glDrawArrays crashes here in half of the platforms (not osx) */
@ -4254,23 +4253,21 @@ static void ob_draw_RE_motion(float com[3],float rotscale[3][3],float itw,float
}
/*place to add drawers */
unsigned int nurbcol[8]= {
0, 0x9090, 0x409030, 0x603080, 0, 0x40fff0, 0x40c033, 0xA090F0 };
static void tekenhandlesN(Nurb *nu, short sel, short hide_handles)
{
BezTriple *bezt;
float *fp;
unsigned int *col;
int basecol;
int a;
if(nu->hide || hide_handles) return;
glBegin(GL_LINES);
if(nu->type == CU_BEZIER) {
if(sel) col= nurbcol+4;
else col= nurbcol;
if(sel) basecol= TH_HANDLE_SEL_FREE;
else basecol= TH_HANDLE_FREE;
bezt= nu->bezt;
a= nu->pntsu;
@ -4278,26 +4275,26 @@ static void tekenhandlesN(Nurb *nu, short sel, short hide_handles)
if(bezt->hide==0) {
if( (bezt->f2 & SELECT)==sel) {
fp= bezt->vec[0];
cpack(col[(int)bezt->h1]);
UI_ThemeColor(basecol + bezt->h1);
glVertex3fv(fp);
glVertex3fv(fp+3);
cpack(col[(int)bezt->h2]);
UI_ThemeColor(basecol + bezt->h2);
glVertex3fv(fp+3);
glVertex3fv(fp+6);
}
else if( (bezt->f1 & SELECT)==sel) {
fp= bezt->vec[0];
cpack(col[(int)bezt->h1]);
UI_ThemeColor(basecol + bezt->h1);
glVertex3fv(fp);
glVertex3fv(fp+3);
}
else if( (bezt->f3 & SELECT)==sel) {
fp= bezt->vec[1];
cpack(col[(int)bezt->h2]);
UI_ThemeColor(basecol + bezt->h2);
glVertex3fv(fp);
glVertex3fv(fp+3);
}
@ -4308,6 +4305,41 @@ static void tekenhandlesN(Nurb *nu, short sel, short hide_handles)
glEnd();
}
static void tekenhandlesN_active(Nurb *nu)
{
BezTriple *bezt;
float *fp;
int a;
if(nu->hide) return;
UI_ThemeColor(TH_ACTIVE_SPLINE);
glLineWidth(2);
glBegin(GL_LINES);
if(nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
while(a--) {
if(bezt->hide==0) {
fp= bezt->vec[0];
glVertex3fv(fp);
glVertex3fv(fp+3);
glVertex3fv(fp+3);
glVertex3fv(fp+6);
}
bezt++;
}
}
glEnd();
glColor3ub(0,0,0);
glLineWidth(1);
}
static void tekenvertsN(Nurb *nu, short sel, short hide_handles)
{
BezTriple *bezt;
@ -4357,18 +4389,94 @@ static void tekenvertsN(Nurb *nu, short sel, short hide_handles)
glPointSize(1.0);
}
static void editnurb_draw_active_poly(Nurb *nu)
{
BPoint *bp;
int a, b;
UI_ThemeColor(TH_ACTIVE_SPLINE);
glLineWidth(2);
bp= nu->bp;
for(b=0; b<nu->pntsv; b++) {
if(nu->flagu & 1) glBegin(GL_LINE_LOOP);
else glBegin(GL_LINE_STRIP);
for(a=0; a<nu->pntsu; a++, bp++) {
glVertex3fv(bp->vec);
}
glEnd();
}
glColor3ub(0,0,0);
glLineWidth(1);
}
static void editnurb_draw_active_nurbs(Nurb *nu)
{
BPoint *bp, *bp1;
int a, b, ofs;
UI_ThemeColor(TH_ACTIVE_SPLINE);
glLineWidth(2);
glBegin(GL_LINES);
bp= nu->bp;
for(b=0; b<nu->pntsv; b++) {
bp1= bp;
bp++;
for(a=nu->pntsu-1; a>0; a--, bp++) {
if(bp->hide==0 && bp1->hide==0) {
glVertex3fv(bp->vec);
glVertex3fv(bp1->vec);
}
bp1= bp;
}
}
if(nu->pntsv > 1) { /* surface */
ofs= nu->pntsu;
for(b=0; b<nu->pntsu; b++) {
bp1= nu->bp+b;
bp= bp1+ofs;
for(a=nu->pntsv-1; a>0; a--, bp+=ofs) {
if(bp->hide==0 && bp1->hide==0) {
glVertex3fv(bp->vec);
glVertex3fv(bp1->vec);
}
bp1= bp;
}
}
}
glEnd();
glColor3ub(0,0,0);
glLineWidth(1);
}
static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
{
Nurb *nu;
BPoint *bp, *bp1;
int a, b, ofs;
int a, b, ofs, index;
Curve *cu= (Curve*)ob->data;
index= 0;
nu= nurb;
while(nu) {
if(nu->hide==0) {
switch(nu->type) {
case CU_POLY:
cpack(nurbcol[3]);
if (!sel && index== cu->actnu) {
/* we should draw active spline highlight below everything */
editnurb_draw_active_poly(nu);
}
UI_ThemeColor(TH_NURB_ULINE);
bp= nu->bp;
for(b=0; b<nu->pntsv; b++) {
if(nu->flagu & 1) glBegin(GL_LINE_LOOP);
@ -4382,6 +4490,10 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
}
break;
case CU_NURBS:
if (!sel && index== cu->actnu) {
/* we should draw active spline highlight below everything */
editnurb_draw_active_nurbs(nu);
}
bp= nu->bp;
for(b=0; b<nu->pntsv; b++) {
@ -4391,7 +4503,7 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
if(bp->hide==0 && bp1->hide==0) {
if(sel) {
if( (bp->f1 & SELECT) && ( bp1->f1 & SELECT ) ) {
cpack(nurbcol[5]);
UI_ThemeColor(TH_NURB_SEL_ULINE);
glBegin(GL_LINE_STRIP);
glVertex3fv(bp->vec);
@ -4402,7 +4514,7 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
else {
if( (bp->f1 & SELECT) && ( bp1->f1 & SELECT) );
else {
cpack(nurbcol[1]);
UI_ThemeColor(TH_NURB_ULINE);
glBegin(GL_LINE_STRIP);
glVertex3fv(bp->vec);
@ -4424,7 +4536,7 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
if(bp->hide==0 && bp1->hide==0) {
if(sel) {
if( (bp->f1 & SELECT) && ( bp1->f1 & SELECT) ) {
cpack(nurbcol[7]);
UI_ThemeColor(TH_NURB_SEL_VLINE);
glBegin(GL_LINE_STRIP);
glVertex3fv(bp->vec);
@ -4435,7 +4547,7 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
else {
if( (bp->f1 & SELECT) && ( bp1->f1 & SELECT) );
else {
cpack(nurbcol[3]);
UI_ThemeColor(TH_NURB_VLINE);
glBegin(GL_LINE_STRIP);
glVertex3fv(bp->vec);
@ -4452,6 +4564,8 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel)
break;
}
}
++index;
nu= nu->next;
}
}
@ -4464,6 +4578,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
Nurb *nu;
BevList *bl;
short hide_handles = (cu->drawflag & CU_HIDE_HANDLES);
int index;
// XXX retopo_matrix_update(v3d);
@ -4473,11 +4588,15 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
if(v3d->zbuf) glDisable(GL_DEPTH_TEST);
/* first non-selected handles */
/* first non-selected and active handles */
index= 0;
for(nu=nurb; nu; nu=nu->next) {
if(nu->type == CU_BEZIER) {
if (index == cu->actnu && !hide_handles)
tekenhandlesN_active(nu);
tekenhandlesN(nu, 0, hide_handles);
}
++index;
}
draw_editnurb(ob, nurb, 0);
draw_editnurb(ob, nurb, 1);

@ -200,6 +200,10 @@ typedef struct ThemeSpace {
char bone_solid[4], bone_pose[4];
char strip[4], strip_select[4];
char cframe[4];
char nurb_uline[4], nurb_vline[4];
char act_spline[4], nurb_sel_uline[4], nurb_sel_vline[4];
char handle_free[4], handle_auto[4], handle_vect[4], handle_align[4];
char handle_sel_free[4], handle_sel_auto[4], handle_sel_vect[4], handle_sel_align[4];
char ds_channel[4], ds_subchannel[4]; // dopesheet
char console_output[4], console_input[4], console_info[4], console_error[4];

@ -715,6 +715,89 @@ static void rna_def_userdef_theme_spaces_face(StructRNA *srna)
RNA_def_property_update(prop, 0, "rna_userdef_update");
}
static void rna_def_userdef_theme_spaces_curves(StructRNA *srna)
{
PropertyRNA *prop;
prop= RNA_def_property(srna, "nurb_uline", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "nurb_uline");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Nurb U-lines", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "nurb_vline", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "nurb_vline");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Nurb V-lines", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "nurb_sel_uline", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "nurb_sel_uline");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Nurb active U-lines", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "nurb_sel_vline", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "nurb_sel_vline");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Nurb active V-lines", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "act_spline", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "act_spline");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Active spline", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "handle_free", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "handle_free");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Free handle color", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "handle_auto", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "handle_auto");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Auto handle color", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "handle_vect", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "handle_vect");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Vector handle color", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "handle_align", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "handle_align");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Align handle color", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "handle_sel_free", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "handle_sel_free");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Free handle selected color", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "handle_sel_auto", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "handle_sel_auto");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Auto handle selected color", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "handle_sel_vect", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "handle_sel_vect");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Vector handle selected color", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
prop= RNA_def_property(srna, "handle_sel_align", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "handle_sel_align");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Align handle selected color", "");
RNA_def_property_update(prop, 0, "rna_userdef_update");
}
static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
{
StructRNA *srna;
@ -780,6 +863,7 @@ static void rna_def_userdef_theme_space_view3d(BlenderRNA *brna)
rna_def_userdef_theme_spaces_vertex(srna);
rna_def_userdef_theme_spaces_edge(srna);
rna_def_userdef_theme_spaces_face(srna);
rna_def_userdef_theme_spaces_curves(srna);
prop= RNA_def_property(srna, "editmesh_active", PROP_FLOAT, PROP_COLOR);
RNA_def_property_array(prop, 4);