[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43376] trunk/blender: replace ANIM_OT_time_toggle operator with generic WM_OT_context_toggle operator

Campbell Barton ideasman42 at gmail.com
Sat Jan 14 15:17:24 CET 2012


Revision: 43376
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43376
Author:   campbellbarton
Date:     2012-01-14 14:17:12 +0000 (Sat, 14 Jan 2012)
Log Message:
-----------
replace ANIM_OT_time_toggle operator with generic WM_OT_context_toggle operator

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_dopesheet.py
    trunk/blender/release/scripts/startup/bl_ui/space_graph.py
    trunk/blender/release/scripts/startup/bl_ui/space_nla.py
    trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py
    trunk/blender/release/scripts/startup/bl_ui/space_time.py
    trunk/blender/source/blender/editors/animation/anim_ops.c
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_dopesheet.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_dopesheet.py	2012-01-14 13:02:20 UTC (rev 43375)
+++ trunk/blender/release/scripts/startup/bl_ui/space_dopesheet.py	2012-01-14 14:17:12 UTC (rev 43376)
@@ -152,10 +152,7 @@
         layout.prop(st, "use_auto_merge_keyframes")
         layout.prop(st, "use_marker_sync")
 
-        if st.show_seconds:
-            layout.operator("anim.time_toggle", text="Show Frames")
-        else:
-            layout.operator("anim.time_toggle", text="Show Seconds")
+        layout.prop(st, "show_seconds")
 
         layout.separator()
         layout.operator("anim.previewrange_set")

Modified: trunk/blender/release/scripts/startup/bl_ui/space_graph.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_graph.py	2012-01-14 13:02:20 UTC (rev 43375)
+++ trunk/blender/release/scripts/startup/bl_ui/space_graph.py	2012-01-14 14:17:12 UTC (rev 43376)
@@ -87,8 +87,9 @@
             layout.operator("graph.handles_view_toggle", icon='CHECKBOX_DEHLT', text="Show All Handles")
         layout.prop(st, "use_only_selected_curves_handles")
         layout.prop(st, "use_only_selected_keyframe_handles")
-        layout.operator("anim.time_toggle")
 
+        layout.prop(st, "show_seconds")
+
         layout.separator()
         layout.operator("anim.previewrange_set")
         layout.operator("anim.previewrange_clear")

Modified: trunk/blender/release/scripts/startup/bl_ui/space_nla.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_nla.py	2012-01-14 13:02:20 UTC (rev 43375)
+++ trunk/blender/release/scripts/startup/bl_ui/space_nla.py	2012-01-14 14:17:12 UTC (rev 43376)
@@ -62,7 +62,7 @@
         layout.prop(st, "use_realtime_update")
         layout.prop(st, "show_frame_indicator")
 
-        layout.operator("anim.time_toggle", text="Show Frames" if st.show_seconds else "Show Seconds")
+        layout.prop(st, "show_seconds")
 
         layout.prop(st, "show_strip_curves")
 

Modified: trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py	2012-01-14 13:02:20 UTC (rev 43375)
+++ trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py	2012-01-14 14:17:12 UTC (rev 43376)
@@ -114,10 +114,7 @@
 
         layout.operator("sequencer.view_selected")
 
-        if st.show_frames:
-            layout.operator("anim.time_toggle", text="Show Seconds")
-        else:
-            layout.operator("anim.time_toggle", text="Show Frames")
+        layout.prop(st, "show_seconds")
 
         layout.prop(st, "show_frame_indicator")
         if st.display_mode == 'IMAGE':

Modified: trunk/blender/release/scripts/startup/bl_ui/space_time.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_time.py	2012-01-14 13:02:20 UTC (rev 43375)
+++ trunk/blender/release/scripts/startup/bl_ui/space_time.py	2012-01-14 14:17:12 UTC (rev 43376)
@@ -109,7 +109,7 @@
 
         st = context.space_data
 
-        layout.operator("anim.time_toggle")
+        layout.prop(st, "show_seconds")
         layout.operator("time.view_all")
 
         layout.separator()

Modified: trunk/blender/source/blender/editors/animation/anim_ops.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_ops.c	2012-01-14 13:02:20 UTC (rev 43375)
+++ trunk/blender/source/blender/editors/animation/anim_ops.c	2012-01-14 14:17:12 UTC (rev 43376)
@@ -277,78 +277,12 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
-/* ****************** time display toggle operator ****************************/
-
-static int toggle_time_exec(bContext *C, wmOperator *UNUSED(op))
-{
-	ScrArea *curarea= CTX_wm_area(C);
-	
-	if (curarea == NULL)
-		return OPERATOR_CANCELLED;
-	
-	/* simply toggle draw frames flag in applicable spaces */
-	// XXX or should relevant spaces define their own version of this?
-	switch (curarea->spacetype) {
-		case SPACE_TIME: /* TimeLine */
-		{
-			SpaceTime *stime= CTX_wm_space_time(C);
-			stime->flag ^= TIME_DRAWFRAMES;
-		}
-			break;
-		case SPACE_ACTION: /* Action Editor */
-		{
-			SpaceAction *saction= CTX_wm_space_action(C);
-			saction->flag ^= SACTION_DRAWTIME;
-		}
-			break;
-		case SPACE_IPO: /* Graph Editor */
-		{
-			SpaceIpo *sipo= CTX_wm_space_graph(C);
-			sipo->flag ^= SIPO_DRAWTIME;
-		}
-			break;
-		case SPACE_NLA: /* NLA Editor */
-		{
-			SpaceNla *snla= CTX_wm_space_nla(C);
-			snla->flag ^= SNLA_DRAWTIME;
-		}
-			break;
-		case SPACE_SEQ: /* Sequencer */
-		{
-			SpaceSeq *sseq= CTX_wm_space_seq(C);
-			sseq->flag ^= SEQ_DRAWFRAMES;
-		}
-			break;
-			
-		default: /* editor doesn't show frames */
-			return OPERATOR_CANCELLED; // XXX or should we pass through instead?
-	}
-	
-	ED_area_tag_redraw(curarea);
-	
-	return OPERATOR_FINISHED;
-}
-
-static void ANIM_OT_time_toggle(wmOperatorType *ot)
-{
-	/* identifiers */
-	ot->name= "Toggle Frames/Seconds";
-	ot->idname= "ANIM_OT_time_toggle";
-	ot->description= "Toggle whether timing is displayed in frames or seconds for active timeline view";
-	
-	/* api callbacks */
-	ot->exec= toggle_time_exec;
-	
-	ot->poll= ED_operator_animview_active;
-}
-
 /* ************************** registration **********************************/
 
 void ED_operatortypes_anim(void)
 {
 	/* Animation Editors only -------------------------- */
 	WM_operatortype_append(ANIM_OT_change_frame);
-	WM_operatortype_append(ANIM_OT_time_toggle);
 	
 	WM_operatortype_append(ANIM_OT_previewrange_set);
 	WM_operatortype_append(ANIM_OT_previewrange_clear);
@@ -382,11 +316,14 @@
 void ED_keymap_anim(wmKeyConfig *keyconf)
 {
 	wmKeyMap *keymap= WM_keymap_find(keyconf, "Animation", 0, 0);
+	wmKeyMapItem *kmi;
 	
 	/* frame management */
 		/* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */
 	WM_keymap_add_item(keymap, "ANIM_OT_change_frame", ACTIONMOUSE, KM_PRESS, 0, 0);
-	WM_keymap_verify_item(keymap, "ANIM_OT_time_toggle", TKEY, KM_PRESS, KM_CTRL, 0);
+
+	kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TKEY, KM_PRESS, KM_CTRL, 0);
+	RNA_string_set(kmi->ptr, "data_path", "space_data.show_seconds");
 	
 	/* preview range */
 	WM_keymap_verify_item(keymap, "ANIM_OT_previewrange_set", PKEY, KM_PRESS, 0, 0);

Modified: trunk/blender/source/blender/makesrna/intern/rna_space.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_space.c	2012-01-14 13:02:20 UTC (rev 43375)
+++ trunk/blender/source/blender/makesrna/intern/rna_space.c	2012-01-14 14:17:12 UTC (rev 43376)
@@ -2139,7 +2139,6 @@
 	/* display */
 	prop= RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", SACTION_DRAWTIME);
-	RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now, only set with operator
 	RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames");
 	RNA_def_property_update(prop, NC_SPACE|ND_SPACE_DOPESHEET, NULL);
 	
@@ -2224,7 +2223,6 @@
 	/* display */
 	prop= RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_DRAWTIME);
-	RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now, only set with operator
 	RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames");
 	RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL);
 	
@@ -2322,7 +2320,6 @@
 	/* display */
 	prop= RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", SNLA_DRAWTIME);
-	RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now, only set with operator
 	RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames");
 	RNA_def_property_update(prop, NC_SPACE|ND_SPACE_NLA, NULL);
 	



More information about the Bf-blender-cvs mailing list