[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21982] branches/blender2.5/blender/source /blender/editors/interface: 2.5: UI

Brecht Van Lommel brecht at blender.org
Tue Jul 28 20:00:01 CEST 2009


Revision: 21982
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21982
Author:   blendix
Date:     2009-07-28 19:59:59 +0200 (Tue, 28 Jul 2009)

Log Message:
-----------
2.5: UI

* Text editing in buttons now hides the label, to give more space.
* Tweak slider buttons text clipping, happened a bit too early.
* Move editing text closer to the left, because the < > buttons
  are not visible then anyway.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/interface/interface.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-07-28 17:53:01 UTC (rev 21981)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface.c	2009-07-28 17:59:59 UTC (rev 21982)
@@ -1887,10 +1887,8 @@
 	}
 
 	/* if we are doing text editing, this will override the drawstr */
-	if(but->editstr) {
-		strcpy(but->drawstr, but->str);
-		strcat(but->drawstr, but->editstr);
-	}
+	if(but->editstr)
+		strcpy(but->drawstr, but->editstr);
 	
 	/* text clipping moved to widget drawing code itself */
 }

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c	2009-07-28 17:53:01 UTC (rev 21981)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c	2009-07-28 17:59:59 UTC (rev 21982)
@@ -1045,15 +1045,17 @@
 	
 	/* XXX solve generic */
 	if(but->type==NUM || but->type==NUMSLI)
-		startx += 20;
+		startx += (int)(0.5f*(but->y2 - but->y1));
+	else if(but->type==TEX)
+		startx += 5;
 	
+	/* XXX does not take zoom level into account */
 	while((BLF_width(origstr+but->ofs) + startx) > x) {
 		if (but->pos <= 0) break;
 		but->pos--;
 		origstr[but->pos+but->ofs] = 0;
 	}
 	
-	but->pos -= strlen(but->str);
 	but->pos += but->ofs;
 	if(but->pos<0) but->pos= 0;
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	2009-07-28 17:53:01 UTC (rev 21981)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c	2009-07-28 17:59:59 UTC (rev 21982)
@@ -749,7 +749,7 @@
 		
 		/* textbut exception */
 		if(but->editstr && but->pos != -1) {
-			int pos= but->pos+strlen(but->str);
+			int pos= but->pos+1;
 			
 			if(pos-1 < but->ofs) {
 				pos= but->ofs-pos+1;
@@ -784,44 +784,46 @@
 		short selsta_tmp, selend_tmp, selsta_draw, selwidth_draw;
 		
 		if ((but->selend - but->selsta) > 0) {
-			/* XXX weak, why is this? (ton) */
-			t= but->str[0]?1:-2;
-			
 			/* text button selection */
-			selsta_tmp = but->selsta + strlen(but->str);
-			selend_tmp = but->selend + strlen(but->str);
+			selsta_tmp = but->selsta;
+			selend_tmp = but->selend;
 			
 			if(but->drawstr[0]!=0) {
 				ch= but->drawstr[selsta_tmp];
 				but->drawstr[selsta_tmp]= 0;
 				
-				selsta_draw = BLF_width(but->drawstr+but->ofs) + t;
+				selsta_draw = BLF_width(but->drawstr+but->ofs);
 				
 				but->drawstr[selsta_tmp]= ch;
 				
 				ch= but->drawstr[selend_tmp];
 				but->drawstr[selend_tmp]= 0;
 				
-				selwidth_draw = BLF_width(but->drawstr+but->ofs) + t;
+				selwidth_draw = BLF_width(but->drawstr+but->ofs);
 				
 				but->drawstr[selend_tmp]= ch;
+
+				/* if at pos 0, leave a bit more to the left */
+				t= (pos == 0)? 0: 1;
 				
 				glColor3ubv((unsigned char*)wcol->item);
 				glRects(rect->xmin+selsta_draw+1, rect->ymin+2, rect->xmin+selwidth_draw+1, rect->ymax-2);
 			}
 		} else {
 			/* text cursor */
-			pos= but->pos+strlen(but->str);
+			pos= but->pos;
 			if(pos >= but->ofs) {
 				if(but->drawstr[0]!=0) {
 					ch= but->drawstr[pos];
 					but->drawstr[pos]= 0;
 					
-					t= BLF_width(but->drawstr+but->ofs) + 1;
+					t= BLF_width(but->drawstr+but->ofs);
 					
 					but->drawstr[pos]= ch;
 				}
-				else t= 1;
+
+				/* if at pos 0, leave a bit more to the left */
+				t += (pos == 0)? 0: 1;
 				
 				glColor3ub(255,0,0);
 				glRects(rect->xmin+t, rect->ymin+2, rect->xmin+t+2, rect->ymax-2);
@@ -857,7 +859,7 @@
 	if(but==NULL) return;
 	
 	/* cutting off from left part */
-	if ELEM3(but->type, NUM, NUMABS, TEX) {	
+	if ELEM5(but->type, NUM, NUMABS, NUMSLI, SLI, TEX) {	
 		ui_text_leftclip(fstyle, but, rect);
 	}
 	else but->ofs= 0;
@@ -889,7 +891,7 @@
 			if(but->editstr || (but->flag & UI_TEXT_LEFT)) 
 				rect->xmin += 5;
 		}
-		else if(but->flag & UI_TEXT_LEFT)
+		else if((but->flag & UI_TEXT_LEFT)) 
 			rect->xmin += 5;
 		
 		/* always draw text for textbutton cursor */
@@ -1599,6 +1601,7 @@
 {
 	uiWidgetBase wtb;
 	float rad= 0.5f*(rect->ymax - rect->ymin);
+	int textoffs;
 	
 	widget_init(&wtb);
 	
@@ -1613,9 +1616,15 @@
 	widgetbase_draw(&wtb, wcol);
 	
 	/* text space */
-	rect->xmin += (rect->ymax-rect->ymin);
-	rect->xmax -= (rect->ymax-rect->ymin);
-
+	if(!(state & UI_TEXTINPUT)) {
+		rect->xmin += (rect->ymax-rect->ymin);
+		rect->xmax -= (rect->ymax-rect->ymin);
+	}
+	else {
+		textoffs= rad;
+		rect->xmin += textoffs;
+		rect->xmax -= textoffs;
+	}
 }
 
 
@@ -1822,6 +1831,7 @@
 	rcti rect1;
 	double value;
 	float offs, fac;
+	int textoffs;
 	char outline[3];
 	
 	widget_init(&wtb);
@@ -1831,6 +1841,7 @@
 	
 	/* fully rounded */
 	offs= 0.5f*(rect->ymax - rect->ymin);
+	textoffs= offs;
 	round_box_edges(&wtb, roundboxalign, rect, offs);
 
 	wtb.outline= 0;
@@ -1872,9 +1883,8 @@
 	widgetbase_draw(&wtb, wcol);
 	
 	/* text space */
-	rect->xmin += (rect->ymax-rect->ymin);
-	rect->xmax -= (rect->ymax-rect->ymin);
-	
+	rect->xmin += textoffs;
+	rect->xmax -= textoffs;
 }
 
 static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)





More information about the Bf-blender-cvs mailing list