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

Ton Roosendaal ton at blender.org
Tue Feb 17 14:11:10 CET 2009


Revision: 19005
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19005
Author:   ton
Date:     2009-02-17 14:11:09 +0100 (Tue, 17 Feb 2009)

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

Small fixes for filewindow;
- on resize area/window, the load button disappeared. 
- made scrollers indicate what direction works
- mousewheel scroll switches to horizontal automatically now

(assuming we keep filelists horiz, previews vertical scrolled)

View2d got hacked a bit by me for it; i guess for some cases
the scroll value should become customizable. Will come back
later!

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c
    branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c
    branches/blender2.5/blender/source/blender/editors/space_file/space_file.c

Modified: branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c	2009-02-17 10:58:40 UTC (rev 19004)
+++ branches/blender2.5/blender/source/blender/editors/interface/view2d_ops.c	2009-02-17 13:11:09 UTC (rev 19005)
@@ -367,9 +367,16 @@
 		return OPERATOR_PASS_THROUGH;
 	}
 	
-	/* set RNA-Props - only movement in positive x-direction */
-	RNA_int_set(op->ptr, "deltax", 0);
-	RNA_int_set(op->ptr, "deltay", -20);
+	/* set RNA-Props */
+	/* automatically fall back to horizontal on this exception: */
+	if( ELEM(vpd->v2d->scroll, V2D_SCROLL_BOTTOM, V2D_SCROLL_TOP) ) {
+		RNA_int_set(op->ptr, "deltax", -20);
+		RNA_int_set(op->ptr, "deltay", 0);
+	}
+	else {
+		RNA_int_set(op->ptr, "deltax", 0);
+		RNA_int_set(op->ptr, "deltay", -20);
+	}
 	
 	/* apply movement, then we're done */
 	view_pan_apply(C, op);
@@ -413,9 +420,16 @@
 		return OPERATOR_PASS_THROUGH;
 	}
 	
-	/* set RNA-Props - only movement in negative x-direction */
-	RNA_int_set(op->ptr, "deltax", 0);
-	RNA_int_set(op->ptr, "deltay", 20);
+	/* set RNA-Props */
+	/* automatically fall back to horizontal on this exception: */
+	if( ELEM(vpd->v2d->scroll, V2D_SCROLL_BOTTOM, V2D_SCROLL_TOP) ) {
+		RNA_int_set(op->ptr, "deltax", 20);
+		RNA_int_set(op->ptr, "deltay", 0);
+	}
+	else {
+		RNA_int_set(op->ptr, "deltax", 0);
+		RNA_int_set(op->ptr, "deltay", 20);
+	}
 	
 	/* apply movement, then we're done */
 	view_pan_apply(C, op);

Modified: branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c	2009-02-17 10:58:40 UTC (rev 19004)
+++ branches/blender2.5/blender/source/blender/editors/space_file/file_draw.c	2009-02-17 13:11:09 UTC (rev 19005)
@@ -103,6 +103,7 @@
 	}
 }
 
+/* note; this function uses pixelspace (0, 0, winx, winy), not view2d */
 void file_draw_buttons(const bContext *C, ARegion *ar)
 {
 	SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
@@ -118,14 +119,14 @@
 
 	int filebuty1, filebuty2;
 
-	float xmin = ar->v2d.mask.xmin + 10;
-	float xmax = ar->v2d.mask.xmax - 10;
+	float xmin = 10;
+	float xmax = ar->winx - 10;
 
-	filebuty1= ar->v2d.mask.ymax - IMASEL_BUTTONS_HEIGHT;
+	filebuty1= ar->winy - IMASEL_BUTTONS_HEIGHT;
 	filebuty2= filebuty1+IMASEL_BUTTONS_HEIGHT/2 -6;
 
 	/* HEADER */
-	sprintf(name, "win %d", 1); // XXX sa-win???
+	sprintf(name, "win %p", ar);
 	block = uiBeginBlock(C, ar, name, UI_EMBOSS, UI_HELV);
 	uiBlockSetHandleFunc(block, do_file_buttons, NULL);
 
@@ -136,7 +137,7 @@
 	/* space available for load/save buttons? */
 	slen = UI_GetStringWidth(G.font, sfile->params->title, 0);
 	loadbutton= slen > 60 ? slen + 20 : MAX2(80, 20+UI_GetStringWidth(G.font, params->title, 0));
-	if(ar->v2d.cur.xmax-ar->v2d.cur.xmin > loadbutton+20) {
+	if(ar->winx > loadbutton+20) {
 		if(params->title[0]==0) {
 			loadbutton= 0;
 		}

Modified: branches/blender2.5/blender/source/blender/editors/space_file/space_file.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_file/space_file.c	2009-02-17 10:58:40 UTC (rev 19004)
+++ branches/blender2.5/blender/source/blender/editors/space_file/space_file.c	2009-02-17 13:11:09 UTC (rev 19005)
@@ -128,35 +128,21 @@
 }
 
 
-/* spacetype; init callback */
+/* spacetype; init callback, area size changes, screen set, etc */
 static void file_init(struct wmWindowManager *wm, ScrArea *sa)
 {
-	SpaceFile *sfile= sa->spacedata.first;	/* XXX get through context? */
-	if (sfile->params) {
-		ED_fileselect_reset_params(sfile);
-	}
-	if (sfile->files) {
-		filelist_free(sfile->files);
-		filelist_freelib(sfile->files);
-		MEM_freeN(sfile->files);
-		sfile->files= NULL;
-	}
 }
 
+
 static SpaceLink *file_duplicate(SpaceLink *sl)
 {
 	SpaceFile *sfileo= (SpaceFile*)sl;
 	SpaceFile *sfilen= MEM_dupallocN(sl);
 	
 	/* clear or remove stuff from old */
-	sfilen->op = NULL; // XXX check if operator can be duplicated
+	sfilen->op = NULL; /* file window doesn't own operators */
 
 	sfilen->params= MEM_dupallocN(sfileo->params);
-	if (!sfilen->params) {
-		sfilen->params= MEM_callocN(sizeof(FileSelectParams), "fileselparams");
-		ED_fileselect_set_params(sfilen, FILE_UNIX, "", "/", 0, 0, 0);
-		sfilen->params->pupmenu = NULL;
-	}
 	
 	sfilen->files = filelist_new();
 	filelist_setdir(sfilen->files, sfilen->params->dir);
@@ -176,6 +162,8 @@
 	/* own keymap */
 	keymap= WM_keymap_listbase(wm, "File", SPACE_FILE, 0);	/* XXX weak? */
 	WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+							   
+
 }
 
 static void file_main_area_draw(const bContext *C, ARegion *ar)
@@ -215,19 +203,26 @@
 	glClearColor(col[0], col[1], col[2], 0.0);
 	glClear(GL_COLOR_BUFFER_BIT);
 	
+	/* Allow dynamically sliders to be set, saves notifiers etc. */
+	if (sfile->params && sfile->params->display)
+		v2d->scroll = V2D_SCROLL_RIGHT;
+	else
+		v2d->scroll = V2D_SCROLL_BOTTOM;
+		/* v2d has initialized flag, so this call will only set the mask correct */
+	UI_view2d_region_reinit(v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
+
 	/* sets tile/border settings in sfile */
 	file_calc_previews(C, ar);
 
+	/* set view */
+	UI_view2d_view_ortho(C, v2d);
+	
 	/* on first read, find active file */
 	if (params->active_file == -1) {
 		wmEvent *event= CTX_wm_window(C)->eventstate;
 		file_hilight_set(sfile, ar, event->x - ar->winrct.xmin, event->y - ar->winrct.ymin);
-		
 	}
 	
-	/* data... */
-	UI_view2d_view_ortho(C, v2d);
-	
 	if (params->display) {
 		file_draw_previews(C, ar);
 	} else {





More information about the Bf-blender-cvs mailing list