[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51164] trunk/blender/source/blender/ editors: Display enum descriptions in tooltips for operators using a "type" or "mode"

Joshua Leung aligorith at gmail.com
Mon Oct 8 07:57:53 CEST 2012


Revision: 51164
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51164
Author:   aligorith
Date:     2012-10-08 05:57:52 +0000 (Mon, 08 Oct 2012)
Log Message:
-----------
Display enum descriptions in tooltips for operators using a "type" or "mode"
property

Changes:
This commit adds a second line to the tooltips (below the generic operator
description) showing the appropriate description for each enum option. This
brings it more into line enum properties in Blender which also show this sort of
information.

Rationale:
Operators such as Snap and Mirror in the Action and Graph Editors use an enum to
control their behaviour (respectively, "how to snap" or "what to use as the
mirror line"). In the menus, these options are displayed using a submenu, but
hovering over each of these items for more information from a tooltip only shows
the (relatively unhelpful) generic operator tooltip/description.

Another area where these descriptions are useful is for Keying Sets, where it's
now possible to see the descriptions for what each Keying Set
does/affects/requires. Again, this is more helpful than just the generic
tooltip, which would be something like "Insert keyframes using a Keying Set".

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/space_action/action_edit.c
    trunk/blender/source/blender/editors/space_graph/graph_edit.c

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2012-10-08 04:42:06 UTC (rev 51163)
+++ trunk/blender/source/blender/editors/interface/interface.c	2012-10-08 05:57:52 UTC (rev 51164)
@@ -3889,6 +3889,37 @@
 						tmp = BLI_strdup(item->description);
 				}
 			}
+			else if (but->optype) {
+				PointerRNA *opptr = uiButGetOperatorPtrRNA(but);
+				wmOperatorType *ot = but->optype;
+				
+				/* if the default property of the operator is enum and it is set, 
+				 * fetch the tooltip of the selected value so that "Snap" and "Mirror"
+				 * operator menus in the Anim Editors will show tooltips for the different
+				 * operations instead of the meaningless generic operator tooltip
+				 */
+				if (ot->prop && RNA_property_type(ot->prop) == PROP_ENUM) {
+					if (RNA_struct_contains_property(opptr, ot->prop)) {
+						int value = RNA_property_enum_get(opptr, ot->prop);
+						int i;
+						
+						RNA_property_enum_items_gettexted(C, opptr, ot->prop, &items, &totitems, &free_items);
+						for (i = 0, item = items; i < totitems; i++, item++) {
+							if (item->identifier[0] && item->value == value)
+								break;
+						}
+						
+						if (item && item->identifier) {
+							if (type == BUT_GET_RNAENUM_IDENTIFIER)
+								tmp = BLI_strdup(item->identifier);
+							else if (type == BUT_GET_RNAENUM_LABEL)
+								tmp = BLI_strdup(item->name);
+							else if (item->description && item->description[0])
+								tmp = BLI_strdup(item->description);
+						}
+					}
+				}
+			}
 		}
 		else if (type == BUT_GET_OP_KEYMAP) {
 			if (but->optype && !(but->block->flag & UI_BLOCK_LOOP)) {

Modified: trunk/blender/source/blender/editors/space_action/action_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_action/action_edit.c	2012-10-08 04:42:06 UTC (rev 51163)
+++ trunk/blender/source/blender/editors/space_action/action_edit.c	2012-10-08 05:57:52 UTC (rev 51164)
@@ -1369,10 +1369,14 @@
 
 /* defines for snap keyframes tool */
 static EnumPropertyItem prop_actkeys_snap_types[] = {
-	{ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", ""},
-	{ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry?
-	{ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, // XXX as single entry?
-	{ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""},
+	{ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", 
+	 "Snap selected keyframes to the current frame"},
+	{ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", 
+	 "Snap selected keyframes to the nearest (whole) frame. Use to fix accidental sub-frame offsets"},
+	{ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", 
+	 "Snap selected keyframes to the nearest second"},
+	{ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", 
+	 "Snap selected keyframes to the nearest marker"},
 	{0, NULL, 0, NULL, NULL}
 };
 
@@ -1473,9 +1477,12 @@
 
 /* defines for mirror keyframes tool */
 static EnumPropertyItem prop_actkeys_mirror_types[] = {
-	{ACTKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current frame", ""},
-	{ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", ""},
-	{ACTKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", ""},
+	{ACTKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current frame", 
+	 "Flip times of selected keyframes using the current frame as the mirror line"},
+	{ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", 
+	 "Flip values of selected keyframes (i.e. negative values become positive, and vica versa)"},
+	{ACTKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", 
+	 "Flip times of selected keyframes using the first selected marker as the reference point"},
 	{0, NULL, 0, NULL, NULL}
 };
 
@@ -1497,12 +1504,8 @@
 	/* for 'first selected marker' mode, need to find first selected marker first! */
 	// XXX should this be made into a helper func in the API?
 	if (mode == ACTKEYS_MIRROR_MARKER) {
-		TimeMarker *marker = NULL;
+		TimeMarker *marker = ED_markers_get_first_selected(ac->markers);
 		
-		/* find first selected marker */
-		marker = ED_markers_get_first_selected(ac->markers);
-		
-		/* store marker's time (if available) */
 		if (marker)
 			ked.f1 = (float)marker->frame;
 		else

Modified: trunk/blender/source/blender/editors/space_graph/graph_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_edit.c	2012-10-08 04:42:06 UTC (rev 51163)
+++ trunk/blender/source/blender/editors/space_graph/graph_edit.c	2012-10-08 05:57:52 UTC (rev 51164)
@@ -1824,12 +1824,18 @@
 
 /* defines for snap keyframes tool */
 static EnumPropertyItem prop_graphkeys_snap_types[] = {
-	{GRAPHKEYS_SNAP_CFRA, "CFRA", 0, "Current Frame", ""},
-	{GRAPHKEYS_SNAP_VALUE, "VALUE", 0, "Cursor Value", ""},
-	{GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", ""}, // XXX as single entry?
-	{GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", ""}, // XXX as single entry?
-	{GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", ""},
-	{GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", 0, "Flatten Handles", ""},
+	{GRAPHKEYS_SNAP_CFRA, "CFRA", 0, "Current Frame", 
+	 "Snap selected keyframes to the current frame"},
+	{GRAPHKEYS_SNAP_VALUE, "VALUE", 0, "Cursor Value", 
+	 "Set values of selected keyframes to the cursor value (Y/Horizontal component)"},
+	{GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", 
+	 "Snap selected keyframes to the nearest (whole) frame. Use to fix accidental sub-frame offsets"},
+	{GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", 
+	 "Snap selected keyframes to the nearest second"},
+	{GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", 
+	 "Snap selected keyframes to the nearest marker"},
+	{GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", 0, "Flatten Handles", 
+	 "Flatten handles for a smoother transition"},
 	{0, NULL, 0, NULL, NULL}
 };
 
@@ -1932,11 +1938,16 @@
 
 /* defines for mirror keyframes tool */
 static EnumPropertyItem prop_graphkeys_mirror_types[] = {
-	{GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current Frame", ""},
-	{GRAPHKEYS_MIRROR_VALUE, "VALUE", 0, "By Values over Cursor Value", ""},
-	{GRAPHKEYS_MIRROR_YAXIS, "YAXIS", 0, "By Times over Time=0", ""},
-	{GRAPHKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", ""},
-	{GRAPHKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", ""},
+	{GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current Frame", 
+	 "Flip times of selected keyframes using the current frame as the mirror line"},
+	{GRAPHKEYS_MIRROR_VALUE, "VALUE", 0, "By Values over Cursor Value", 
+	 "Flip values of selectd keyframes using the cursor value (Y/Horizontal component) as the mirror line"},
+	{GRAPHKEYS_MIRROR_YAXIS, "YAXIS", 0, "By Times over Time=0", 
+	 "Flip times of selected keyframes, effectively reversing the order they appear in"},
+	{GRAPHKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", 
+	 "Flip values of selected keyframes (i.e. negative values become positive, and vica versa)"},
+	{GRAPHKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", 
+	 "Flip times of selected keyframes using the first selected marker as the reference point"},
 	{0, NULL, 0, NULL, NULL}
 };
 




More information about the Bf-blender-cvs mailing list