[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39533] trunk/blender/source/blender/ editors: misc changes to unterface & undo

Campbell Barton ideasman42 at gmail.com
Thu Aug 18 21:07:37 CEST 2011


Revision: 39533
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39533
Author:   campbellbarton
Date:     2011-08-18 19:07:37 +0000 (Thu, 18 Aug 2011)
Log Message:
-----------
misc changes to unterface & undo
- operator strings were doing undo pushes (in fileselector text for example), this is dumb since the operators themselves handle undo.
- interface code checks rna props are arrays rather then checking the array length.
- disable properties window pin undoing.
- sequencer refresh was calling undo, disable since this is clearnign global data not handled by undo.
- added commented out code for drawing mesh vertex index/key index, useful for debugging shapekey - hook issyes.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_layout.c
    trunk/blender/source/blender/editors/space_buttons/buttons_context.c
    trunk/blender/source/blender/editors/space_sequencer/sequencer_edit.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2011-08-18 18:42:42 UTC (rev 39532)
+++ trunk/blender/source/blender/editors/interface/interface.c	2011-08-18 19:07:37 UTC (rev 39533)
@@ -710,6 +710,27 @@
 	return 1;
 }
 
+/* use to check if we need to disable undo, but dont make any changes
+ * returns FALSE if undo needs to be disabled. */
+static int ui_but_is_rna_undo(uiBut *but)
+{
+	if(but->rnapoin.id.data) {
+		/* avoid undo push for buttons who's ID are screen or wm level
+		 * we could disable undo for buttons with no ID too but may have
+		 * unforseen conciquences, so best check for ID's we _know_ are not
+		 * handled by undo - campbell */
+		ID *id= but->rnapoin.id.data;
+		if(ELEM(GS(id->name), ID_SCR, ID_WM)) {
+			return FALSE;
+		}
+		else {
+			return TRUE;
+		}
+	}
+
+	return TRUE;
+}
+
 /* assigns automatic keybindings to menu items for fast access
  * (underline key in menu) */
 static void ui_menu_block_set_keyaccels(uiBlock *block)
@@ -1245,12 +1266,14 @@
 
 int ui_is_but_unit(uiBut *but)
 {
-	Scene *scene= CTX_data_scene((bContext *)but->block->evil_C);
-	int unit_type= uiButGetUnitType(but);
+	const int unit_type= uiButGetUnitType(but);
+	Scene *scene; /* avoid getting the scene on non unit buttons */
 
 	if(unit_type == PROP_UNIT_NONE)
 		return 0;
 
+	scene= CTX_data_scene((bContext *)but->block->evil_C);
+
 #if 1 // removed so angle buttons get correct snapping
 	if (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS && unit_type == PROP_UNIT_ROTATION)
 		return 0;
@@ -1293,19 +1316,19 @@
 
 		switch(RNA_property_type(prop)) {
 			case PROP_BOOLEAN:
-				if(RNA_property_array_length(&but->rnapoin, prop))
+				if(RNA_property_array_check(prop))
 					value= RNA_property_boolean_get_index(&but->rnapoin, prop, but->rnaindex);
 				else
 					value= RNA_property_boolean_get(&but->rnapoin, prop);
 				break;
 			case PROP_INT:
-				if(RNA_property_array_length(&but->rnapoin, prop))
+				if(RNA_property_array_check(prop))
 					value= RNA_property_int_get_index(&but->rnapoin, prop, but->rnaindex);
 				else
 					value= RNA_property_int_get(&but->rnapoin, prop);
 				break;
 			case PROP_FLOAT:
-				if(RNA_property_array_length(&but->rnapoin, prop))
+				if(RNA_property_array_check(prop))
 					value= RNA_property_float_get_index(&but->rnapoin, prop, but->rnaindex);
 				else
 					value= RNA_property_float_get(&but->rnapoin, prop);
@@ -2506,12 +2529,10 @@
 
 static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2,  const char *tip)
 {
+	const PropertyType proptype= RNA_property_type(prop);
 	uiBut *but;
-	PropertyType proptype;
 	int freestr= 0, icon= 0;
 
-	proptype= RNA_property_type(prop);
-
 	/* use rna values if parameters are not specified */
 	if(!str) {
 		if(type == MENU && proptype == PROP_ENUM) {
@@ -2636,20 +2657,14 @@
 		UI_DEF_BUT_RNA_DISABLE(but);
 	}
 
-	/* avoid undo push for buttons who's ID are screen or wm level
-	 * we could disable undo for buttons with no ID too but but may have
-	 * unforseen conciquences, so best check for ID's we _know_ are not
-	 * handled by undo - campbell */
-	if (but->flag & UI_BUT_UNDO) {
-		ID *id= ptr->id.data;
-		if(id && ELEM(GS(id->name), ID_SCR, ID_WM)) {
-			but->flag &= ~UI_BUT_UNDO;
-		}
+	if (but->flag & UI_BUT_UNDO && (ui_but_is_rna_undo(but) == FALSE)) {
+		but->flag &= ~UI_BUT_UNDO;
 	}
 
 	/* If this button uses units, calculate the step from this */
-	if(ui_is_but_unit(but))
+	if((proptype == PROP_FLOAT) && ui_is_but_unit(but)) {
 		but->a1= ui_get_but_step_unit(but, but->a1);
+	}
 
 	if(freestr)
 		MEM_freeN((void *)str);
@@ -2693,6 +2708,7 @@
 	but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip);
 	but->optype= ot;
 	but->opcontext= opcontext;
+	but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */
 
 	if(!ot) {
 		but->flag |= UI_BUT_DISABLED;
@@ -2722,6 +2738,7 @@
 	but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, poin, min, max, a1, a2, tip);
 	but->optype= ot;
 	but->opcontext= opcontext;
+	but->flag &= ~UI_BUT_UNDO; /* no need for ui_but_is_undo(), we never need undo here */
 
 	if(!ot) {
 		but->flag |= UI_BUT_DISABLED;

Modified: trunk/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_layout.c	2011-08-18 18:42:42 UTC (rev 39532)
+++ trunk/blender/source/blender/editors/interface/interface_layout.c	2011-08-18 19:07:37 UTC (rev 39533)
@@ -1017,12 +1017,10 @@
 		ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only);
 	/* enum item */
 	else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) {
-		const char *identifier= RNA_property_identifier(prop);
-
 		if(icon && name[0] && !icon_only)
 			uiDefIconTextButR_prop(block, ROW, 0, icon, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
 		else if(icon)
-			uiDefIconButR(block, ROW, 0, icon, 0, 0, w, h, ptr, identifier, -1, 0, value, -1, -1, NULL);
+			uiDefIconButR_prop(block, ROW, 0, icon, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
 		else
 			uiDefButR_prop(block, ROW, 0, name, 0, 0, w, h, ptr, prop, -1, 0, value, -1, -1, NULL);
 	}

Modified: trunk/blender/source/blender/editors/space_buttons/buttons_context.c
===================================================================
--- trunk/blender/source/blender/editors/space_buttons/buttons_context.c	2011-08-18 18:42:42 UTC (rev 39532)
+++ trunk/blender/source/blender/editors/space_buttons/buttons_context.c	2011-08-18 19:07:37 UTC (rev 39533)
@@ -904,6 +904,7 @@
 	block= uiLayoutGetBlock(row);
 	uiBlockSetEmboss(block, UI_EMBOSSN);
 	but= uiDefIconButBitC(block, ICONTOG, SB_PIN_CONTEXT, 0, ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, 0, 0, 0, 0, "Follow context or keep fixed datablock displayed");
+	uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
 	uiButSetFunc(but, pin_cb, NULL, NULL);
 
 	for(a=0; a<path->len; a++) {

Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_edit.c	2011-08-18 18:42:42 UTC (rev 39532)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_edit.c	2011-08-18 19:07:37 UTC (rev 39533)
@@ -1228,9 +1228,6 @@
 	/* api callbacks */
 	ot->exec= sequencer_refresh_all_exec;
 	ot->poll= sequencer_edit_poll;
-	
-	/* flags */
-	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
 static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op)

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2011-08-18 18:42:42 UTC (rev 39532)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2011-08-18 19:07:37 UTC (rev 39533)
@@ -2367,7 +2367,20 @@
 			}
 		}
 	}
-	
+
+	/* useful for debugging index vs shape key index */
+#if 0
+	{
+		EditVert *eve;
+		int j;
+		UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col);
+		for(eve= em->verts.first, j= 0; eve; eve= eve->next, j++) {
+			sprintf(val, "%d:%d", j, eve->keyindex);
+			view3d_cached_text_draw_add(eve->co, val, 0, V3D_CACHE_TEXT_ASCII, col);
+		}
+	}
+#endif
+
 	if(v3d->zbuf) {
 		glEnable(GL_DEPTH_TEST);
 		bglPolygonOffset(rv3d->dist, 0.0f);




More information about the Bf-blender-cvs mailing list