[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37262] trunk/blender/source/blender/ editors/space_outliner/outliner.c: 2.5 todo:

Ton Roosendaal ton at blender.org
Mon Jun 6 20:04:57 CEST 2011


Revision: 37262
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37262
Author:   ton
Date:     2011-06-06 18:04:57 +0000 (Mon, 06 Jun 2011)
Log Message:
-----------
2.5 todo:

User setting "DPI" now works for outliner too.
(todo: color picker, brush menu, nodes, fileselect path buttons, view2d sliders, ...)

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_outliner/outliner.c

Modified: trunk/blender/source/blender/editors/space_outliner/outliner.c
===================================================================
--- trunk/blender/source/blender/editors/space_outliner/outliner.c	2011-06-06 17:52:57 UTC (rev 37261)
+++ trunk/blender/source/blender/editors/space_outliner/outliner.c	2011-06-06 18:04:57 UTC (rev 37262)
@@ -106,21 +106,17 @@
 #include "outliner_intern.h"
 
 
-
-#define OL_H	19
-#define OL_X	18
-
 #define OL_Y_OFFSET	2
 
-#define OL_TOG_RESTRICT_VIEWX	54
-#define OL_TOG_RESTRICT_SELECTX	36
-#define OL_TOG_RESTRICT_RENDERX	18
+#define OL_TOG_RESTRICT_VIEWX	(UI_UNIT_X*3)
+#define OL_TOG_RESTRICT_SELECTX	(UI_UNIT_X*2)
+#define OL_TOG_RESTRICT_RENDERX	UI_UNIT_X
 
 #define OL_TOGW OL_TOG_RESTRICT_VIEWX
 
-#define OL_RNA_COLX			300
-#define OL_RNA_COL_SIZEX	150
-#define OL_RNA_COL_SPACEX	50
+#define OL_RNA_COLX			(UI_UNIT_X*15)
+#define OL_RNA_COL_SIZEX	(UI_UNIT_X*7.5)
+#define OL_RNA_COL_SPACEX	(UI_UNIT_X*2.5)
 
 #define TS_CHUNK	128
 
@@ -260,7 +256,7 @@
 		TreeStoreElem *tselem= TREESTORE(te);
 		if((tselem->flag & TSE_CLOSED)==0) 
 			outliner_height(soops, &te->subtree, h);
-		(*h) += OL_H;
+		(*h) += UI_UNIT_Y;
 		te= te->next;
 	}
 }
@@ -297,7 +293,7 @@
 			*w = startx+100;
 
 		if((tselem->flag & TSE_CLOSED)==0)
-			outliner_rna_width(soops, &te->subtree, w, startx+OL_X);
+			outliner_rna_width(soops, &te->subtree, w, startx+UI_UNIT_X);
 		te= te->next;
 	}
 }
@@ -2485,13 +2481,13 @@
 static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2])
 {
 	
-	if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
+	if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) {
 		TreeStoreElem *tselem= TREESTORE(te);
 		int openclose= 0;
 
 		/* open close icon */
 		if((te->flag & TE_ICONROW)==0) {				// hidden icon, no open/close
-			if( mval[0]>te->xs && mval[0]<te->xs+OL_X) 
+			if( mval[0]>te->xs && mval[0]<te->xs+UI_UNIT_X) 
 				openclose= 1;
 		}
 
@@ -2510,7 +2506,7 @@
 			return 1;
 		}
 		/* name and first icon */
-		else if(mval[0]>te->xs+OL_X && mval[0]<te->xend) {
+		else if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) {
 			
 			/* always makes active object */
 			if(tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP)
@@ -2597,7 +2593,7 @@
 		int row;
 		
 		/* get row number - 100 here is just a dummy value since we don't need the column */
-		UI_view2d_listview_view_to_cell(&ar->v2d, 1000, OL_H, 0.0f, OL_Y_OFFSET, 
+		UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, 
 						fmval[0], fmval[1], NULL, &row);
 		
 		/* select relevant row */
@@ -2631,7 +2627,7 @@
 static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, const float mval[2])
 {
 	
-	if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
+	if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) {
 		TreeStoreElem *tselem= TREESTORE(te);
 
 		/* all below close/open? */
@@ -2696,11 +2692,11 @@
 static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2])
 {
 	
-	if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
+	if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) {
 		TreeStoreElem *tselem= TREESTORE(te);
 		
 		/* name and first icon */
-		if(mval[0]>te->xs+OL_X && mval[0]<te->xend) {
+		if(mval[0]>te->xs+UI_UNIT_X && mval[0]<te->xend) {
 			
 			/* can't rename rna datablocks entries */
 			if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))
@@ -2861,12 +2857,12 @@
 	/* store coord and continue, we need coordinates for elements outside view too */
 	te->xs= (float)startx;
 	te->ys= (float)(*starty);
-	*starty-= OL_H;
+	*starty-= UI_UNIT_Y;
 	
 	if((tselem->flag & TSE_CLOSED)==0) {
 		TreeElement *ten;
 		for(ten= te->subtree.first; ten; ten= ten->next) {
-			outliner_set_coordinates_element(soops, ten, startx+OL_X, starty);
+			outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty);
 		}
 	}
 	
@@ -2876,7 +2872,7 @@
 static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops)
 {
 	TreeElement *te;
-	int starty= (int)(ar->v2d.tot.ymax)-OL_H;
+	int starty= (int)(ar->v2d.tot.ymax)-UI_UNIT_Y;
 	int startx= 0;
 	
 	for(te= soops->tree.first; te; te= te->next) {
@@ -3731,7 +3727,7 @@
 static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, wmEvent *event, const float mval[2])
 {
 	
-	if(mval[1]>te->ys && mval[1]<te->ys+OL_H) {
+	if(mval[1]>te->ys && mval[1]<te->ys+UI_UNIT_Y) {
 		int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0;
 		TreeStoreElem *tselem= TREESTORE(te);
 		
@@ -4309,7 +4305,10 @@
 	if(arg->x >= arg->xmax) 
 		UI_icon_draw(arg->x, arg->y, icon);
 	else {
-		uiBut *but= uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-4, arg->y, ICON_DEFAULT_WIDTH, ICON_DEFAULT_WIDTH, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : "");
+		/* XXX investigate: button placement of icons is way different than UI_icon_draw? */
+		float ufac= UI_UNIT_X/20.0f;
+		uiBut *but= uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-3.0f*ufac, arg->y, UI_UNIT_X-4.0f*ufac, UI_UNIT_Y-4.0f*ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : "");
+		
 		if(arg->id)
 			uiButSetDragID(but, arg->id);
 	}
@@ -4572,7 +4571,7 @@
 	for(te= lb->first; te; te= te->next) {
 		
 		/* exit drawing early */
-		if((*offsx) - OL_X > xmax)
+		if((*offsx) - UI_UNIT_X > xmax)
 			break;
 
 		tselem= TREESTORE(te);
@@ -4589,19 +4588,21 @@
 			else active= tree_element_type_active(NULL, scene, soops, te, tselem, 0);
 			
 			if(active) {
+				float ufac= UI_UNIT_X/20.0f;
+
 				uiSetRoundBox(15);
 				glColor4ub(255, 255, 255, 100);
-				uiRoundBox( (float)*offsx-0.5f, (float)ys-1.0f, (float)*offsx+OL_H-3.0f, (float)ys+OL_H-3.0f, OL_H/2.0f-2.0f);
+				uiRoundBox( (float)*offsx-0.5f*ufac, (float)ys-1.0f*ufac, (float)*offsx+UI_UNIT_Y-3.0f*ufac, (float)ys+UI_UNIT_Y-3.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac);
 				glEnable(GL_BLEND); /* roundbox disables */
 			}
 			
 			tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f);
 			te->xs= (float)*offsx;
 			te->ys= (float)ys;
-			te->xend= (short)*offsx+OL_X;
+			te->xend= (short)*offsx+UI_UNIT_X;
 			te->flag |= TE_ICONROW;	// for click
 			
-			(*offsx) += OL_X;
+			(*offsx) += UI_UNIT_X;
 		}
 		
 		/* this tree element always has same amount of branches, so dont draw */
@@ -4621,7 +4622,7 @@
 	te->ys= (float)(*starty);
 	
 	for(ten= te->subtree.first; ten; ten= ten->next) {
-		outliner_set_coord_tree_element(soops, ten, startx+OL_X, starty);
+		outliner_set_coord_tree_element(soops, ten, startx+UI_UNIT_X, starty);
 	}	
 }
 
@@ -4630,16 +4631,17 @@
 {
 	TreeElement *ten;
 	TreeStoreElem *tselem;
+	float ufac= UI_UNIT_X/20.0f;
 	int offsx= 0, active=0; // active=1 active obj, else active data
 	
 	tselem= TREESTORE(te);
 
-	if(*starty+2*OL_H >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) {
+	if(*starty+2*UI_UNIT_Y >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) {
 		int xmax= ar->v2d.cur.xmax;
 		
 		/* icons can be ui buts, we dont want it to overlap with restrict */
 		if((soops->flag & SO_HIDE_RESTRICTCOLS)==0)
-			xmax-= OL_TOGW+ICON_DEFAULT_WIDTH;
+			xmax-= OL_TOGW+UI_UNIT_X;
 		
 		glEnable(GL_BLEND);
 
@@ -4708,7 +4710,7 @@
 		/* active circle */
 		if(active) {
 			uiSetRoundBox(15);
-			uiRoundBox( (float)startx+OL_H-1.5f, (float)*starty+2.0f, (float)startx+2.0f*OL_H-4.0f, (float)*starty+OL_H-1.0f, OL_H/2.0f-2.0f);
+			uiRoundBox( (float)startx+UI_UNIT_Y-1.5f*ufac, (float)*starty+2.0f*ufac, (float)startx+2.0f*UI_UNIT_Y-4.0f*ufac, (float)*starty+UI_UNIT_Y-1.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac);
 			glEnable(GL_BLEND);	/* roundbox disables it */
 			
 			te->flag |= TE_ACTIVE; // for lookup in display hierarchies
@@ -4720,35 +4722,35 @@
 			if(tselem->type==0 && ELEM(te->idcode, ID_OB, ID_SCE))
 				icon_x = startx;
 			else
-				icon_x = startx+5;
+				icon_x = startx+5*ufac;
 
 				// icons a bit higher
 			if(tselem->flag & TSE_CLOSED) 
-				UI_icon_draw((float)icon_x, (float)*starty+2, ICON_DISCLOSURE_TRI_RIGHT);
+				UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT);
 			else
-				UI_icon_draw((float)icon_x, (float)*starty+2, ICON_DISCLOSURE_TRI_DOWN);
+				UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_DOWN);
 		}
-		offsx+= OL_X;
+		offsx+= UI_UNIT_X;
 		
 		/* datatype icon */
 		
 		if(!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) {
 			// icons a bit higher
-			tselem_draw_icon(block, xmax, (float)startx+offsx, (float)*starty+2, tselem, te, 1.0f);
+			tselem_draw_icon(block, xmax, (float)startx+offsx, (float)*starty+2*ufac, tselem, te, 1.0f);
 			
-			offsx+= OL_X;
+			offsx+= UI_UNIT_X;
 		}
 		else
-			offsx+= 2;
+			offsx+= 2*ufac;
 		
 		if(tselem->type==0 && tselem->id->lib) {
 			glPixelTransferf(GL_ALPHA_SCALE, 0.5f);
 			if(tselem->id->flag & LIB_INDIRECT)
-				UI_icon_draw((float)startx+offsx, (float)*starty+2, ICON_LIBRARY_DATA_INDIRECT);
+				UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_INDIRECT);
 			else
-				UI_icon_draw((float)startx+offsx, (float)*starty+2, ICON_LIBRARY_DATA_DIRECT);
+				UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_DIRECT);
 			glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
-			offsx+= OL_X;
+			offsx+= UI_UNIT_X;
 		}		
 		glDisable(GL_BLEND);
 
@@ -4757,9 +4759,9 @@
 		else if(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f);
 		else UI_ThemeColor(TH_TEXT);
 		
-		UI_DrawString(startx+offsx, *starty+5, te->name);
+		UI_DrawString(startx+offsx, *starty+5*ufac, te->name);
 		
-		offsx+= (int)(OL_X + UI_GetStringWidth(te->name));
+		offsx+= (int)(UI_UNIT_X + UI_GetStringWidth(te->name));
 		
 		/* closed item, we draw the icons, not when it's a scene, or master-server list though */
 		if(tselem->flag & TSE_CLOSED) {
@@ -4770,7 +4772,7 @@
 					
 					// divider
 					UI_ThemeColorShade(TH_BACK, -40);
-					glRecti(tempx -10, *starty+4, tempx -8, *starty+OL_H-4);
+					glRecti(tempx -10, *starty+4, tempx -8, *starty+UI_UNIT_Y-4);
 
 					glEnable(GL_BLEND);
 					glPixelTransferf(GL_ALPHA_SCALE, 0.5);
@@ -4789,16 +4791,16 @@
 	te->xend= startx+offsx;
 		
 	if((tselem->flag & TSE_CLOSED)==0) {
-		*starty-= OL_H;
+		*starty-= UI_UNIT_Y;
 		
 		for(ten= te->subtree.first; ten; ten= ten->next)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list