Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2009-07-12 11:28:25 +0400
committerJoshua Leung <aligorith@gmail.com>2009-07-12 11:28:25 +0400
commit345be5cbbc8c78228b2ded7c2dcb7278c38631b1 (patch)
tree05d742b7db5161536e08f13d7745457d04973b43 /source
parentfa8bd34d95d91712ffa6dc9066c255e9ee40e7e4 (diff)
2.5 - Tweaks for Split Strips in NLA and Graph Editor view ranges
* Split strips now uses the current frame as the splitting-point for selected strips if the current frame falls within in the bounds of the strip. Otherwise, the code defaults to splitting by the midpoints of the strips. * Time-range for Graph Editor is saner now when there is only a single keyframe or none at all.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_graph/space_graph.c10
-rw-r--r--source/blender/editors/space_nla/nla_edit.c59
2 files changed, 44 insertions, 25 deletions
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index a5578e88076..c36d790f0be 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -68,14 +68,16 @@ ARegion *graph_has_buttons_region(ScrArea *sa)
{
ARegion *ar, *arnew;
- for(ar= sa->regionbase.first; ar; ar= ar->next)
+ for (ar= sa->regionbase.first; ar; ar= ar->next) {
if(ar->regiontype==RGN_TYPE_UI)
return ar;
+ }
/* add subdiv level; after main window */
- for(ar= sa->regionbase.first; ar; ar= ar->next)
+ for (ar= sa->regionbase.first; ar; ar= ar->next) {
if(ar->regiontype==RGN_TYPE_WINDOW)
break;
+ }
/* is error! */
if(ar==NULL) return NULL;
@@ -246,7 +248,9 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar)
/* XXX the slow way to set tot rect... but for nice sliders needed (ton) */
get_graph_keyframe_extents(&ac, &v2d->tot.xmin, &v2d->tot.xmax, &v2d->tot.ymin, &v2d->tot.ymax);
-
+ /* extra offset so that these items are visible */
+ v2d->tot.xmin -= 10.0f;
+ v2d->tot.xmax += 10.0f;
}
/* only free grid after drawing data, as we need to use it to determine sampling rate */
diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c
index 9ddd8daab0d..01871d3d9d5 100644
--- a/source/blender/editors/space_nla/nla_edit.c
+++ b/source/blender/editors/space_nla/nla_edit.c
@@ -747,25 +747,37 @@ void NLA_OT_delete (wmOperatorType *ot)
// - variable-length splits?
/* split a given Action-Clip strip */
-static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip *strip)
+static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, float cfra)
{
NlaStrip *nstrip;
- float midframe, midaframe, len;
+ float splitframe, splitaframe;
- /* calculate the frames to do the splitting at */
- /* strip extents */
- len= strip->end - strip->start;
- if (IS_EQ(len, 0.0f))
- return;
- else
- midframe= strip->start + (len / 2.0f);
-
- /* action range */
- len= strip->actend - strip->actstart;
- if (IS_EQ(len, 0.0f))
- midaframe= strip->actend;
- else
- midaframe= strip->actstart + (len / 2.0f);
+ /* calculate the frames to do the splitting at
+ * - use current frame if within extents of strip
+ */
+ if ((cfra > strip->start) && (cfra < strip->end)) {
+ /* use the current frame */
+ splitframe= cfra;
+ splitaframe= nlastrip_get_frame(strip, cfra, NLATIME_CONVERT_UNMAP);
+ }
+ else {
+ /* split in the middle */
+ float len;
+
+ /* strip extents */
+ len= strip->end - strip->start;
+ if (IS_EQ(len, 0.0f))
+ return;
+ else
+ splitframe= strip->start + (len / 2.0f);
+
+ /* action range */
+ len= strip->actend - strip->actstart;
+ if (IS_EQ(len, 0.0f))
+ splitaframe= strip->actend;
+ else
+ splitaframe= strip->actstart + (len / 2.0f);
+ }
/* make a copy (assume that this is possible) and append
* it immediately after the current strip
@@ -774,13 +786,16 @@ static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip
BLI_insertlinkafter(&nlt->strips, strip, nstrip);
/* set the endpoint of the first strip and the start of the new strip
- * to the midframe values calculated above
+ * to the splitframe values calculated above
*/
- strip->end= midframe;
- nstrip->start= midframe;
+ strip->end= splitframe;
+ nstrip->start= splitframe;
- strip->actend= midaframe;
- nstrip->actstart= midaframe;
+ if ((splitaframe > strip->actstart) && (splitaframe < strip->actend)) {
+ /* only do this if we're splitting down the middle... */
+ strip->actend= splitaframe;
+ nstrip->actstart= splitaframe;
+ }
/* clear the active flag from the copy */
nstrip->flag &= ~NLASTRIP_FLAG_ACTIVE;
@@ -828,7 +843,7 @@ static int nlaedit_split_exec (bContext *C, wmOperator *op)
/* splitting method depends on the type of strip */
switch (strip->type) {
case NLASTRIP_TYPE_CLIP: /* action-clip */
- nlaedit_split_strip_actclip(adt, nlt, strip);
+ nlaedit_split_strip_actclip(adt, nlt, strip, (float)ac.scene->r.cfra);
break;
case NLASTRIP_TYPE_META: /* meta-strips need special handling */