Durian Graph Editor Request: Only show handles of selected keyframes
This option for the Graph Editor means that only the handles for selected keyframes get shown in the view, eliminating clutter. Currently, the selection code isn't aware of this option, so clicking anywhere near where a handle might be may often trigger it to show up. This may/may not be desireable, but we'll see how Lee goes with this first :)
This commit is contained in:
@@ -235,7 +235,7 @@ static void draw_fcurve_handle_control (float x, float y, float xscale, float ys
|
||||
}
|
||||
|
||||
/* helper func - draw handle vertices only for an F-Curve (if it is not protected) */
|
||||
static void draw_fcurve_vertices_handles (FCurve *fcu, View2D *v2d, short sel)
|
||||
static void draw_fcurve_vertices_handles (SpaceIpo *sipo, FCurve *fcu, View2D *v2d, short sel)
|
||||
{
|
||||
BezTriple *bezt= fcu->bezt;
|
||||
BezTriple *prevbezt = NULL;
|
||||
@@ -255,19 +255,24 @@ static void draw_fcurve_vertices_handles (FCurve *fcu, View2D *v2d, short sel)
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
for (i=0; i < fcu->totvert; i++, prevbezt=bezt, bezt++) {
|
||||
/* Draw the editmode handels for a bezier curve (others don't have handles)
|
||||
/* Draw the editmode handles for a bezier curve (others don't have handles)
|
||||
* if their selection status matches the selection status we're drawing for
|
||||
* - first handle only if previous beztriple was bezier-mode
|
||||
* - second handle only if current beztriple is bezier-mode
|
||||
*
|
||||
* Also, need to take into account whether the keyframe was selected
|
||||
* if a Graph Editor option to only show handles of selected keys is on.
|
||||
*/
|
||||
if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) {
|
||||
if ((bezt->f1 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/
|
||||
draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize);
|
||||
}
|
||||
|
||||
if (bezt->ipo==BEZT_IPO_BEZ) {
|
||||
if ((bezt->f3 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/
|
||||
draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize);
|
||||
if ( !(sipo->flag & SIPO_SELVHANDLESONLY) || BEZSELECTED(bezt) ) {
|
||||
if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) {
|
||||
if ((bezt->f1 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/
|
||||
draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize);
|
||||
}
|
||||
|
||||
if (bezt->ipo==BEZT_IPO_BEZ) {
|
||||
if ((bezt->f3 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/
|
||||
draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,10 +318,10 @@ void draw_fcurve_vertices (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
(sipo->flag & SIPO_NOHANDLES)==0 && (fcu->totvert > 1))
|
||||
{
|
||||
set_fcurve_vertex_color(sipo, fcu, 0);
|
||||
draw_fcurve_vertices_handles(fcu, v2d, 0);
|
||||
draw_fcurve_vertices_handles(sipo, fcu, v2d, 0);
|
||||
|
||||
set_fcurve_vertex_color(sipo, fcu, 1);
|
||||
draw_fcurve_vertices_handles(fcu, v2d, 1);
|
||||
draw_fcurve_vertices_handles(sipo, fcu, v2d, 1);
|
||||
}
|
||||
|
||||
/* draw keyframes over the handles */
|
||||
@@ -347,13 +352,28 @@ static void draw_fcurve_handles (SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
*/
|
||||
glBegin(GL_LINES);
|
||||
|
||||
/* slightly hacky, but we want to draw unselected points before selected ones */
|
||||
/* slightly hacky, but we want to draw unselected points before selected ones
|
||||
* so that selected points are clearly visible
|
||||
*/
|
||||
for (sel= 0; sel < 2; sel++) {
|
||||
BezTriple *bezt=fcu->bezt, *prevbezt=NULL;
|
||||
unsigned int *col= (sel)? (nurbcol+4) : (nurbcol);
|
||||
float *fp;
|
||||
|
||||
/* if only selected keyframes have handles shown, skip the first round */
|
||||
if ((sel == 0) && (sipo->flag & SIPO_SELVHANDLESONLY))
|
||||
continue;
|
||||
|
||||
for (b= 0; b < fcu->totvert; b++, prevbezt=bezt, bezt++) {
|
||||
/* if only selected keyframes can get their handles shown,
|
||||
* check that keyframe is selected
|
||||
*/
|
||||
if (sipo->flag & SIPO_SELVHANDLESONLY) {
|
||||
if (BEZSELECTED(bezt) == 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* draw handle with appropriate set of colors if selection is ok */
|
||||
if ((bezt->f2 & SELECT)==sel) {
|
||||
fp= bezt->vec[0];
|
||||
|
||||
|
||||
@@ -91,6 +91,7 @@ static void graph_viewmenu(bContext *C, uiLayout *layout, void *arg_unused)
|
||||
uiItemO(layout, "Show Handles", ICON_CHECKBOX_HLT, "GRAPH_OT_handles_view_toggle");
|
||||
|
||||
uiItemR(layout, NULL, 0, &spaceptr, "only_selected_curves_handles", 0);
|
||||
uiItemR(layout, NULL, 0, &spaceptr, "only_selected_keyframe_handles", 0);
|
||||
|
||||
|
||||
if (sipo->flag & SIPO_DRAWTIME)
|
||||
|
||||
@@ -726,6 +726,7 @@ enum FileSortTypeE {
|
||||
#define SIPO_DRAWNAMES (1<<6)
|
||||
#define SIPO_SLIDERS (1<<7)
|
||||
#define SIPO_NODRAWCURSOR (1<<8)
|
||||
#define SIPO_SELVHANDLESONLY (1<<9)
|
||||
|
||||
/* SpaceIpo->mode (Graph Editor Mode) */
|
||||
enum {
|
||||
|
||||
@@ -93,6 +93,7 @@ static EnumPropertyItem transform_orientation_items[] = {
|
||||
#include "BKE_brush.h"
|
||||
#include "BKE_colortools.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_paint.h"
|
||||
|
||||
#include "ED_image.h"
|
||||
@@ -1308,6 +1309,11 @@ static void rna_def_space_graph(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Only Selected Curve Keyframes", "Only keyframes of selected F-Curves are visible and editable.");
|
||||
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
|
||||
|
||||
prop= RNA_def_property(srna, "only_selected_keyframe_handles", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_SELVHANDLESONLY);
|
||||
RNA_def_property_ui_text(prop, "Only Selected Keyframes Handles", "Only show and edit handles of selected keyframes.");
|
||||
RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
|
||||
|
||||
/* editing */
|
||||
prop= RNA_def_property(srna, "automerge_keyframes", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SIPO_NOTRANSKEYCULL);
|
||||
|
||||
Reference in New Issue
Block a user