Revision: 56101
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56101
Author:   campbellbarton
Date:     2013-04-17 04:53:23 +0000 (Wed, 17 Apr 2013)
Log Message:
-----------
text editor reload no-longer resets scroll & cursor - annoying when making 
tweaks to UI scripts.
also restrict freestyle hack to WITH_FREESTYLE define.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/depsgraph.c
    trunk/blender/source/blender/editors/space_text/text_ops.c

Modified: trunk/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/depsgraph.c  2013-04-17 
01:16:23 UTC (rev 56100)
+++ trunk/blender/source/blender/blenkernel/intern/depsgraph.c  2013-04-17 
04:53:23 UTC (rev 56101)
@@ -2341,8 +2341,13 @@
 
                /* we tag based on first ID type character to avoid 
                 * looping over all ID's in case there are no tags */
-               /* XXX very weak... added check for '27' to ignore freestyle 
added objects */
-               if (id && id->name[2] > 27 && 
bmain->id_tag_update[id->name[0]]) {
+               if (id &&
+#ifdef WITH_FREESTYLE
+                   /* XXX very weak... added check for '27' to ignore 
freestyle added objects */
+                   id->name[2] > 27 &&
+#endif
+                   bmain->id_tag_update[id->name[0]])
+               {
                        updated = 1;
                        break;
                }

Modified: trunk/blender/source/blender/editors/space_text/text_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_ops.c  2013-04-17 
01:16:23 UTC (rev 56100)
+++ trunk/blender/source/blender/editors/space_text/text_ops.c  2013-04-17 
04:53:23 UTC (rev 56101)
@@ -69,6 +69,8 @@
 #include "text_intern.h"
 #include "text_format.h"
 
+static void txt_screen_clamp(SpaceText *st, ARegion *ar);
+
 /************************ poll ***************************/
 
 
@@ -319,8 +321,15 @@
 
 static int text_reload_exec(bContext *C, wmOperator *op)
 {
+       SpaceText *st = CTX_wm_space_text(C);
        Text *text = CTX_data_edit_text(C);
+       ARegion *ar = CTX_wm_region(C);
 
+       /* store view & cursor state */
+       const int orig_top = st->top;
+       const int orig_curl = BLI_findindex(&text->lines, text->curl);
+       const int orig_curc = text->curc;
+
        if (!BKE_text_reload(text)) {
                BKE_report(op->reports, RPT_ERROR, "Could not reopen file");
                return OPERATOR_CANCELLED;
@@ -336,6 +345,12 @@
        text_drawcache_tag_update(CTX_wm_space_text(C), 1);
        WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text);
 
+       /* return to scroll position */
+       st->top = orig_top;
+       txt_screen_clamp(st, ar);
+       /* return cursor */
+       txt_move_to(text, orig_curl, orig_curc, false);
+
        return OPERATOR_FINISHED;
 }
 
@@ -2053,20 +2068,21 @@
 
 /******************* scroll operator **********************/
 
-/* Moves the view vertically by the specified number of lines */
-static void txt_screen_skip(SpaceText *st, ARegion *ar, int lines)
+static void txt_screen_clamp(SpaceText *st, ARegion *ar)
 {
        int last;
-
-       st->top += lines;
-
        last = text_get_total_lines(st, ar);
        last = last - (st->viewlines / 2);
-       
-       if (st->top > last) st->top = last;
-       if (st->top < 0) st->top = 0;
+       CLAMP(st->top, 0, last);
 }
 
+/* Moves the view vertically by the specified number of lines */
+static void txt_screen_skip(SpaceText *st, ARegion *ar, int lines)
+{
+       st->top += lines;
+       txt_screen_clamp(st, ar);
+}
+
 /* quick enum for tsc->zone (scroller handles) */
 enum {
        SCROLLHANDLE_BAR,
@@ -2179,15 +2195,8 @@
                case RIGHTMOUSE:
                case MIDDLEMOUSE:
                        if (ELEM(tsc->zone, SCROLLHANDLE_MIN_OUTSIDE, 
SCROLLHANDLE_MAX_OUTSIDE)) {
-                               int last;
+                               txt_screen_skip(st, ar, st->viewlines * 
(tsc->zone == SCROLLHANDLE_MIN_OUTSIDE ? 1 : -1));
 
-                               st->top += st->viewlines * (tsc->zone == 
SCROLLHANDLE_MIN_OUTSIDE ? 1 : -1);
-
-                               last = text_get_total_lines(st, ar);
-                               last = last - (st->viewlines / 2);
-
-                               CLAMP(st->top, 0, last);
-
                                ED_area_tag_redraw(CTX_wm_area(C));
                        }
                        scroll_exit(C, op);

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to