From 10900f1de816a22a616d9626523d181fb982ec0a Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 8 Nov 2009 06:43:08 +0000 Subject: Graph Editor Drawing Tweaks: * When there is only a single keyframe for a F-Curve, the handles aren't shown anymore. This looks nicer than the fat orange blobs that appeared * Tweaked the management of GL_BLEND when drawing animation channels in the Graph Editor in an attempt to fix some of the missing text drawn issues. * Converted the properties panel to use layout engine + added color selectors --- .../editors/animation/anim_channels_defines.c | 3 ++ source/blender/editors/animation/anim_ipo_utils.c | 60 ++++++++-------------- source/blender/editors/animation/drivers.c | 6 ++- source/blender/editors/include/ED_anim_api.h | 8 +-- source/blender/editors/space_graph/graph_buttons.c | 47 ++++++++++------- source/blender/editors/space_graph/graph_draw.c | 6 ++- 6 files changed, 64 insertions(+), 66 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index efbdd505bcb..e8bfbf7fe52 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -2200,6 +2200,9 @@ void ANIM_channel_draw (bAnimContext *ac, bAnimListElem *ale, float yminc, float UI_icon_draw(offset, ymid, acf->icon(ale)); offset += ICON_WIDTH; } + + /* turn off blending, since not needed anymore... */ + glDisable(GL_BLEND); /* step 4) draw special toggles ................................. * - in Graph Editor, checkboxes for visibility in curves area diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index 088fddd2e7e..d707ea0a2c4 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -61,53 +61,24 @@ /* ----------------------- Getter functions ----------------------- */ -/* gets the appropriate icon for the given blocktype */ -// XXX some of these will be depreceated? -int geticon_anim_blocktype(short blocktype) -{ - switch (blocktype) { - case ID_OB: - return ICON_OBJECT_DATA; - case ID_PO: - return ICON_POSE_HLT; - case ID_KE: - return ICON_SHAPEKEY_DATA; - case ID_MA: - return ICON_MATERIAL; - case ID_WO: - return ICON_WORLD; - case ID_CU: - return ICON_CURVE_DATA; - case ID_CA: - return ICON_CAMERA; - case ID_LA: - return ICON_LAMP; - case ID_TE: - return ICON_TEXTURE; - case ID_CO: - return ICON_CONSTRAINT; - case ID_FLUIDSIM: - return ICON_WORLD; // uggh - default: - return 0; // what about blank icon? - } -} - -/* Write into "name" buffer, the name of the property (retrieved using RNA from the curve's settings) +/* Write into "name" buffer, the name of the property (retrieved using RNA from the curve's settings), + * and return the icon used for the struct that this property refers to * WARNING: name buffer we're writing to cannot exceed 256 chars (check anim_channels_defines.c for details) */ -void getname_anim_fcurve(char *name, ID *id, FCurve *fcu) +int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) { + int icon = 0; + /* sanity checks */ if (name == NULL) - return; + return icon; else if ELEM3(NULL, id, fcu, fcu->rna_path) { if (fcu == NULL) sprintf(name, ""); else if (fcu->rna_path == NULL) sprintf(name, ""); else /* id == NULL */ - BLI_snprintf(name, 128, "%s[%d]", fcu->rna_path, fcu->array_index); + BLI_snprintf(name, 256, "%s[%d]", fcu->rna_path, fcu->array_index); } else { PointerRNA id_ptr, ptr; @@ -182,17 +153,30 @@ void getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* putting this all together into the buffer */ // XXX we need to check for invalid names... - BLI_snprintf(name, 128, "%s%s (%s)", arrayname, propname, structname); + BLI_snprintf(name, 256, "%s%s (%s)", arrayname, propname, structname); /* free temp name if nameprop is set */ if (free_structname) MEM_freeN(structname); + + + /* Icon for this property's owner: + * use the struct's icon if it is set + */ + icon= RNA_struct_ui_icon(ptr.type); } else { /* invalid path */ - BLI_snprintf(name, 128, "\"%s[%d]\"", fcu->rna_path, fcu->array_index); + BLI_snprintf(name, 256, "\"%s[%d]\"", fcu->rna_path, fcu->array_index); + + /* icon for this should be the icon for the base ID */ + // TODO: or should we just use the error icon? + icon= RNA_struct_ui_icon(id_ptr.type); } } + + /* return the icon that the active data had */ + return icon; } /* ------------------------------- Color Codes for F-Curve Channels ---------------------------- */ diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index c08bf443851..13f38dae6ea 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -148,6 +148,7 @@ short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short fla PropertyRNA *prop; FCurve *fcu; int array_index_max = array_index+1; + int done = 0; /* validate pointer first - exit if failure */ RNA_id_pointer_create(id, &id_ptr); @@ -198,10 +199,13 @@ short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short fla } } } + + /* set the done status */ + done += (fcu != NULL); } /* done */ - return (fcu != NULL); + return done; } /* Main Driver Management API calls: diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 316f1b58d33..f90d28cd175 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -424,12 +424,8 @@ void ANIM_uiTemplate_fmodifier_draw(struct uiLayout *layout, struct ID *id, List /* ------------ Animation F-Curves <-> Icons/Names Mapping ------------ */ /* anim_ipo_utils.c */ -/* Get icon for type of setting F-Curve is for */ -// XXX include this in the getname() method via RNA? -int geticon_anim_blocktype(short blocktype); - -/* Get name for channel-list displays for F-Curve */ -void getname_anim_fcurve(char *name, struct ID *id, struct FCurve *fcu); +/* Get icon + name for channel-list displays for F-Curve */ +int getname_anim_fcurve(char *name, struct ID *id, struct FCurve *fcu); /* Automatically determine a color for the nth F-Curve */ void ipo_rainbow(int cur, int tot, float *out); diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index b5d69934ad5..a4c98ecbf8e 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -173,31 +173,40 @@ static void graph_panel_properties(const bContext *C, Panel *pa) { bAnimListElem *ale; FCurve *fcu; + PointerRNA fcu_ptr; + uiLayout *layout = pa->layout; + uiLayout *col, *row, *subrow; uiBlock *block; - char name[128]; + char name[256]; + int icon = 0; - if(!graph_panel_context(C, &ale, &fcu)) + if (!graph_panel_context(C, &ale, &fcu)) return; - - block= uiLayoutAbsoluteBlock(pa->layout); + + block= uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL); - - /* Info - Active F-Curve */ - uiDefBut(block, LABEL, 1, "Active F-Curve:", 10, 200, 150, 19, NULL, 0.0, 0.0, 0, 0, ""); - if (ale->id) { - // icon of active blocktype - is this really necessary? - int icon= geticon_anim_blocktype(GS(ale->id->name)); - - // xxx type of icon-but is currently "LABEL", as that one is plain... - uiDefIconBut(block, LABEL, 1, icon, 10, 180, 20, 19, NULL, 0, 0, 0, 0, "ID-type that F-Curve belongs to"); - } + /* F-Curve pointer */ + RNA_pointer_create(ale->id, &RNA_FCurve, fcu, &fcu_ptr); - getname_anim_fcurve(name, ale->id, fcu); - uiDefBut(block, LABEL, 1, name, 40, 180, 300, 19, NULL, 0.0, 0.0, 0, 0, "Name of Active F-Curve"); + /* user-friendly 'name' for F-Curve */ + // TODO: only show the path if this is invalid? + col= uiLayoutColumn(layout, 0); + icon= getname_anim_fcurve(name, ale->id, fcu); + uiItemL(col, name, icon); + + /* color settings */ + col= uiLayoutColumn(layout, 1); + uiItemL(col, "Display Color:", 0); + + row= uiLayoutRow(col, 1); + uiItemR(row, "", 0, &fcu_ptr, "color_mode", 0); + + subrow= uiLayoutRow(row, 1); + uiLayoutSetEnabled(subrow, (fcu->color_mode==FCURVE_COLOR_CUSTOM)); + uiItemR(subrow, "", 0, &fcu_ptr, "color", 0); /* TODO: the following settings could be added here - * - F-Curve coloring mode - mode selector + color selector * - Access details (ID-block + RNA-Path + Array Index) * - ... */ @@ -448,13 +457,13 @@ void graph_buttons_register(ARegionType *art) pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel view"); strcpy(pt->idname, "GRAPH_PT_view"); - strcpy(pt->label, "View"); + strcpy(pt->label, "View Properties"); pt->draw= graph_panel_view; BLI_addtail(&art->paneltypes, pt); pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"); strcpy(pt->idname, "GRAPH_PT_properties"); - strcpy(pt->label, "Properties"); + strcpy(pt->label, "Active F-Curve"); pt->draw= graph_panel_properties; pt->poll= graph_panel_poll; BLI_addtail(&art->paneltypes, pt); diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 052c5c4a743..40b7c071141 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -308,8 +308,10 @@ void draw_fcurve_vertices (SpaceIpo *sipo, ARegion *ar, FCurve *fcu) glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE)); - /* draw the two handles first (if they're shown, and if curve is being edited) */ - if ((fcu->flag & FCURVE_PROTECTED)==0 && (fcu->flag & FCURVE_INT_VALUES)==0 && (sipo->flag & SIPO_NOHANDLES)==0) { + /* draw the two handles first (if they're shown, the curve doesn't have just a single keyframe, and the curve is being edited) */ + if ((fcu->flag & FCURVE_PROTECTED)==0 && (fcu->flag & FCURVE_INT_VALUES)==0 && + (sipo->flag & SIPO_NOHANDLES)==0 && (fcu->totvert > 1)) + { set_fcurve_vertex_color(sipo, fcu, 0); draw_fcurve_vertices_handles(fcu, v2d, 0); -- cgit v1.2.3