[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40311] trunk/blender/source/blender/ editors/space_console: Console Scrolling - reset while typing.

Campbell Barton ideasman42 at gmail.com
Sun Sep 18 03:34:55 CEST 2011


Revision: 40311
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40311
Author:   campbellbarton
Date:     2011-09-18 01:34:53 +0000 (Sun, 18 Sep 2011)
Log Message:
-----------
Console Scrolling - reset while typing.
patch from Damir Prebeg with some edits.

Also made it so resizing the console view keeps the lower part of the text in view (could be annoying when you needed to scroll because of a resized view).

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_console/console_ops.c
    trunk/blender/source/blender/editors/space_console/space_console.c

Modified: trunk/blender/source/blender/editors/space_console/console_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/console_ops.c	2011-09-18 01:09:18 UTC (rev 40310)
+++ trunk/blender/source/blender/editors/space_console/console_ops.c	2011-09-18 01:34:53 UTC (rev 40311)
@@ -54,6 +54,14 @@
 
 #include "console_intern.h"
 
+/* so when we type - the view scrolls to the bottom */
+static void console_scroll_bottom(ARegion *ar)
+{
+	View2D *v2d= &ar->v2d;
+	v2d->cur.ymin = 0.0;
+	v2d->cur.ymax =(float)v2d->winy;
+}
+
 static void console_textview_update_rect(SpaceConsole *sc, ARegion *ar)
 {
 	View2D *v2d= &ar->v2d;
@@ -339,9 +347,14 @@
 	}
 	
 	if(done) {
-		ED_area_tag_redraw(CTX_wm_area(C));
+		ScrArea *sa= CTX_wm_area(C);
+		ARegion *ar= CTX_wm_region(C);
+
+		ED_area_tag_redraw(sa);
+		console_scroll_bottom(ar);
 	}
-	
+
+
 	return OPERATOR_FINISHED;
 }
 
@@ -391,7 +404,9 @@
 
 	console_textview_update_rect(sc, ar);
 	ED_area_tag_redraw(CTX_wm_area(C));
-	
+
+	console_scroll_bottom(ar);
+
 	return OPERATOR_FINISHED;
 }
 
@@ -478,6 +493,8 @@
 
 	console_textview_update_rect(sc, ar);
 	ED_area_tag_redraw(CTX_wm_area(C));
+
+	console_scroll_bottom(ar);
 	
 	return OPERATOR_FINISHED;
 }
@@ -589,6 +606,8 @@
 	console_textview_update_rect(sc, ar);
 	ED_area_tag_redraw(CTX_wm_area(C));
 
+	console_scroll_bottom(ar);
+
 	return OPERATOR_FINISHED;
 }
 
@@ -612,6 +631,7 @@
 static int history_append_exec(bContext *C, wmOperator *op)
 {
 	SpaceConsole *sc= CTX_wm_space_console(C);
+	ARegion *ar= CTX_wm_region(C);
 	ScrArea *sa= CTX_wm_area(C);
 	ConsoleLine *ci= console_history_verify(C);
 	char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, dont free */
@@ -637,6 +657,8 @@
 
 	ED_area_tag_redraw(sa);
 
+	console_scroll_bottom(ar);
+
 	return OPERATOR_FINISHED;
 }
 
@@ -825,6 +847,8 @@
 	console_textview_update_rect(sc, ar);
 	ED_area_tag_redraw(CTX_wm_area(C));
 
+	console_scroll_bottom(ar);
+
 	return OPERATOR_FINISHED;
 }
 

Modified: trunk/blender/source/blender/editors/space_console/space_console.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/space_console.c	2011-09-18 01:09:18 UTC (rev 40310)
+++ trunk/blender/source/blender/editors/space_console/space_console.c	2011-09-18 01:34:53 UTC (rev 40311)
@@ -138,8 +138,17 @@
 	wmKeyMap *keymap;
 	ListBase *lb;
 
+	const int prev_y_min= ar->v2d.cur.ymin; /* so resizing keeps the cursor visible */
+
 	UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
 
+	/* always keep the bottom part of the view aligned, less annoying */
+	if(prev_y_min != ar->v2d.cur.ymin) {
+		const float cur_y_range= ar->v2d.cur.ymax - ar->v2d.cur.ymin;
+		ar->v2d.cur.ymin= prev_y_min;
+		ar->v2d.cur.ymax= prev_y_min + cur_y_range;
+	}
+
 	/* own keymap */
 	keymap= WM_keymap_find(wm->defaultconf, "Console", SPACE_CONSOLE, 0);
 	WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);




More information about the Bf-blender-cvs mailing list