[Bf-blender-cvs] [364b6b2] master: New operator for action and graph editor that centers around current scene frame, bound to numberpad zero.

Antony Riakiotakis noreply at git.blender.org
Mon Apr 13 14:30:32 CEST 2015


Commit: 364b6b29ff2ea19a31fdfc8e08b75ce0d46df40b
Author: Antony Riakiotakis
Date:   Mon Apr 13 14:30:17 2015 +0200
Branches: master
https://developer.blender.org/rB364b6b29ff2ea19a31fdfc8e08b75ce0d46df40b

New operator for action and graph editor that centers around current
scene frame, bound to numberpad zero.

===================================================================

M	release/scripts/startup/bl_ui/space_dopesheet.py
M	release/scripts/startup/bl_ui/space_graph.py
M	source/blender/editors/include/UI_view2d.h
M	source/blender/editors/interface/view2d_ops.c
M	source/blender/editors/space_action/action_edit.c
M	source/blender/editors/space_action/action_intern.h
M	source/blender/editors/space_action/action_ops.c
M	source/blender/editors/space_graph/graph_edit.c
M	source/blender/editors/space_graph/graph_intern.h
M	source/blender/editors/space_graph/graph_ops.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_dopesheet.py b/release/scripts/startup/bl_ui/space_dopesheet.py
index e9818f6..13c3718 100644
--- a/release/scripts/startup/bl_ui/space_dopesheet.py
+++ b/release/scripts/startup/bl_ui/space_dopesheet.py
@@ -203,6 +203,7 @@ class DOPESHEET_MT_view(Menu):
         layout.separator()
         layout.operator("action.view_all")
         layout.operator("action.view_selected")
+        layout.operator("action.view_frame")
 
         layout.separator()
         layout.operator("screen.area_dupli")
diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py
index 4503a0f..27928ae 100644
--- a/release/scripts/startup/bl_ui/space_graph.py
+++ b/release/scripts/startup/bl_ui/space_graph.py
@@ -125,6 +125,7 @@ class GRAPH_MT_view(Menu):
         layout.separator()
         layout.operator("graph.view_all")
         layout.operator("graph.view_selected")
+        layout.operator("graph.view_frame")
 
         layout.separator()
         layout.operator("screen.area_dupli")
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 4d7446a..430093b 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -233,7 +233,7 @@ void ED_keymap_view2d(struct wmKeyConfig *keyconf);
 
 void UI_view2d_smooth_view(struct bContext *C, struct ARegion *ar,
                            const struct rctf *cur, const int smooth_viewtx);
-
+void UI_view2d_center_frame(struct bContext *C, int smooth_viewtx);
 #define UI_MARKER_MARGIN_Y (42 * UI_DPI_FAC)
 
 #endif /* __UI_VIEW2D_H__ */
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 88140d8..5730c96 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1462,6 +1462,21 @@ void UI_view2d_smooth_view(bContext *C, ARegion *ar,
 	}
 }
 
+void UI_view2d_center_frame(struct bContext *C, int smooth_viewtx)
+{
+	ARegion *ar = CTX_wm_region(C);
+	Scene *scene = CTX_data_scene(C);
+	float w = BLI_rctf_size_x(&ar->v2d.cur);
+	rctf newrct;
+
+	newrct.xmax = scene->r.cfra + (w / 2);
+	newrct.xmin = scene->r.cfra - (w / 2);
+	newrct.ymax = ar->v2d.cur.ymax;
+	newrct.ymin = ar->v2d.cur.ymin;
+
+	UI_view2d_smooth_view(C, ar, &newrct, smooth_viewtx);
+}
+
 /* only meant for timer usage */
 static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 {
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index 4b8ddac..d83137d 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -425,7 +425,15 @@ static int actkeys_viewsel_exec(bContext *C, wmOperator *UNUSED(op))
 	/* only selected */
 	return actkeys_viewall(C, true);
 }
- 
+
+static int actkeys_view_frame_exec(bContext *C, wmOperator *op)
+{
+	const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+	UI_view2d_center_frame(C, smooth_viewtx);
+
+	return OPERATOR_FINISHED;
+}
+
 void ACTION_OT_view_all(wmOperatorType *ot)
 {
 	/* identifiers */
@@ -456,6 +464,21 @@ void ACTION_OT_view_selected(wmOperatorType *ot)
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 }
 
+void ACTION_OT_view_frame(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "View Frame";
+	ot->idname = "ACTION_OT_view_frame";
+	ot->description = "Reset viewable area to show range around current frame";
+
+	/* api callbacks */
+	ot->exec = actkeys_view_frame_exec;
+	ot->poll = ED_operator_action_active; /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... */
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
 /* ************************************************************************** */
 /* GENERAL STUFF */
 
diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h
index 9f9b15c..17f1f40 100644
--- a/source/blender/editors/space_action/action_intern.h
+++ b/source/blender/editors/space_action/action_intern.h
@@ -77,6 +77,7 @@ enum eActKeys_ColumnSelect_Mode {
 void ACTION_OT_previewrange_set(struct wmOperatorType *ot);
 void ACTION_OT_view_all(struct wmOperatorType *ot);
 void ACTION_OT_view_selected(struct wmOperatorType *ot);
+void ACTION_OT_view_frame(struct wmOperatorType *ot);
 
 void ACTION_OT_copy(struct wmOperatorType *ot);
 void ACTION_OT_paste(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c
index 47a1200..59b147c 100644
--- a/source/blender/editors/space_action/action_ops.c
+++ b/source/blender/editors/space_action/action_ops.c
@@ -91,7 +91,8 @@ void action_operatortypes(void)
 	WM_operatortype_append(ACTION_OT_previewrange_set);
 	WM_operatortype_append(ACTION_OT_view_all);
 	WM_operatortype_append(ACTION_OT_view_selected);
-	
+	WM_operatortype_append(ACTION_OT_view_frame);
+
 	WM_operatortype_append(ACTION_OT_markers_make_local);
 }
 
@@ -228,6 +229,8 @@ static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
 	WM_keymap_add_item(keymap, "ACTION_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "ACTION_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "ACTION_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
+	WM_keymap_add_item(keymap, "ACTION_OT_view_frame", PAD0, KM_PRESS, 0, 0);
+
 	
 	/* animation module */
 	/* channels list
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index a26bfdd..0dba9cc 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -256,6 +256,14 @@ static int graphkeys_view_selected_exec(bContext *C, wmOperator *op)
 	return graphkeys_viewall(C, true, include_handles, smooth_viewtx);
 }
 
+static int graphkeys_view_frame_exec(bContext *C, wmOperator *op)
+{
+	const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+	UI_view2d_center_frame(C, smooth_viewtx);
+	return OPERATOR_FINISHED;
+}
+
+
 void GRAPH_OT_view_all(wmOperatorType *ot)
 {
 	/* identifiers */
@@ -294,6 +302,21 @@ void GRAPH_OT_view_selected(wmOperatorType *ot)
 	                           "Include handles of keyframes when calculating extents");
 }
 
+void GRAPH_OT_view_frame(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name = "View Frame";
+	ot->idname = "GRAPH_OT_view_frame";
+	ot->description = "Reset viewable area to show range around current frame";
+
+	/* api callbacks */
+	ot->exec = graphkeys_view_frame_exec;
+	ot->poll = ED_operator_graphedit_active; /* XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... */
+
+	/* flags */
+	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
 /* ******************** Create Ghost-Curves Operator *********************** */
 /* This operator samples the data of the selected F-Curves to F-Points, storing them
  * as 'ghost curves' in the active Graph Editor
diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h
index e2fab188f..a478a86 100644
--- a/source/blender/editors/space_graph/graph_intern.h
+++ b/source/blender/editors/space_graph/graph_intern.h
@@ -91,6 +91,7 @@ void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xma
 void GRAPH_OT_previewrange_set(struct wmOperatorType *ot);
 void GRAPH_OT_view_all(struct wmOperatorType *ot);
 void GRAPH_OT_view_selected(struct wmOperatorType *ot);
+void GRAPH_OT_view_frame(struct wmOperatorType *ot);
 
 void GRAPH_OT_click_insert(struct wmOperatorType *ot);
 void GRAPH_OT_keyframe_insert(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c
index 5c3fdce..3d1fa2c 100644
--- a/source/blender/editors/space_graph/graph_ops.c
+++ b/source/blender/editors/space_graph/graph_ops.c
@@ -380,6 +380,7 @@ void graphedit_operatortypes(void)
 	WM_operatortype_append(GRAPH_OT_view_all);
 	WM_operatortype_append(GRAPH_OT_view_selected);
 	WM_operatortype_append(GRAPH_OT_properties);
+	WM_operatortype_append(GRAPH_OT_view_frame);
 	
 	WM_operatortype_append(GRAPH_OT_ghost_curves_create);
 	WM_operatortype_append(GRAPH_OT_ghost_curves_clear);
@@ -594,7 +595,8 @@ static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap)
 	WM_keymap_add_item(keymap, "GRAPH_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "GRAPH_OT_view_all", NDOF_BUTTON_FIT, KM_PRESS, 0, 0);
 	WM_keymap_add_item(keymap, "GRAPH_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
-	
+	WM_keymap_add_item(keymap, "GRAPH_OT_view_frame", PAD0, KM_PRESS, 0, 0);
+
 	/* F-Modifiers */
 	kmi = WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
 	RNA_boolean_set(kmi->ptr, "only_active", false);




More information about the Bf-blender-cvs mailing list