Revision: 52264
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52264
Author:   dail
Date:     2012-11-16 01:12:01 +0000 (Fri, 16 Nov 2012)
Log Message:
-----------
fix [#33180] text editor line height issue

Added small space between lines in the text editor.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_text/text_draw.c
    trunk/blender/source/blender/editors/space_text/text_intern.h
    trunk/blender/source/blender/editors/space_text/text_ops.c

Modified: trunk/blender/source/blender/editors/space_text/text_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_draw.c 2012-11-16 
00:43:28 UTC (rev 52263)
+++ trunk/blender/source/blender/editors/space_text/text_draw.c 2012-11-16 
01:12:01 UTC (rev 52264)
@@ -1494,6 +1494,7 @@
        Text *text = st->text;
        int vcurl, vcurc, vsell, vselc, hidden = 0;
        int x, y, w, i;
+       int lheight = st->lheight + TXT_LINE_SPACING;
 
        /* Draw the selection */
        if (text->curl != text->sell || text->curc != text->selc) {
@@ -1514,11 +1515,11 @@
                y = ar->winy - 2;
 
                if (vcurl == vsell) {
-                       y -= vcurl * st->lheight;
+                       y -= vcurl * lheight;
                        if (vcurc < vselc)
-                               glRecti(x + vcurc * st->cwidth - 1, y, x + 
vselc * st->cwidth, y - st->lheight);
+                               glRecti(x + vcurc * st->cwidth - 1, y, x + 
vselc * st->cwidth, y - lheight + TXT_LINE_SPACING);
                        else
-                               glRecti(x + vselc * st->cwidth - 1, y, x + 
vcurc * st->cwidth, y - st->lheight);
+                               glRecti(x + vselc * st->cwidth - 1, y, x + 
vcurc * st->cwidth, y - lheight + TXT_LINE_SPACING);
                }
                else {
                        int froml, fromc, tol, toc;
@@ -1532,12 +1533,12 @@
                                fromc = vselc; toc = vcurc;
                        }
 
-                       y -= froml * st->lheight;
-                       glRecti(x + fromc * st->cwidth - 1, y, ar->winx, y - 
st->lheight); y -= st->lheight;
+                       y -= froml * lheight;
+                       glRecti(x + fromc * st->cwidth - 1, y, ar->winx, y - 
lheight); y -= lheight;
                        for (i = froml + 1; i < tol; i++)
-                               glRecti(x - 4, y, ar->winx, y - st->lheight),  
y -= st->lheight;
+                               glRecti(x - 4, y, ar->winx, y - lheight),  y -= 
lheight;
 
-                       glRecti(x - 4, y, x + toc * st->cwidth, y - 
st->lheight);  y -= st->lheight;
+                       glRecti(x - 4, y, x + toc * st->cwidth, y - lheight + 
TXT_LINE_SPACING);  y -= lheight;
                }
        }
        else {
@@ -1561,12 +1562,12 @@
 
                        wrap_offset_in_line(st, ar, text->sell, text->selc, 
&offl, &offc);
 
-                       y1 = ar->winy - 2 - (vsell - offl) * st->lheight;
-                       y2 = y1 - st->lheight * visible_lines + 1;
+                       y1 = ar->winy - 2 - (vsell - offl) * lheight;
+                       y2 = y1 - lheight * visible_lines + 1;
                }
                else {
-                       y1 = ar->winy - 2 - vsell * st->lheight;
-                       y2 = y1 - st->lheight + 1;
+                       y1 = ar->winy - 2 - vsell * lheight;
+                       y2 = y1 - lheight + 1;
                }
 
                if (!(y1 < 0 || y2 > ar->winy)) { /* check we need to draw */
@@ -1577,7 +1578,7 @@
                        
                        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
                        glEnable(GL_BLEND);
-                       glRecti(x1 - 4, y1, x2, y2);
+                       glRecti(x1 - 4, y1, x2, y2 + TXT_LINE_SPACING);
                        glDisable(GL_BLEND);
                }
        }
@@ -1586,20 +1587,21 @@
                /* Draw the cursor itself (we draw the sel. cursor as this is 
the leading edge) */
                x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
                x += vselc * st->cwidth;
-               y = ar->winy - 2 - vsell * st->lheight;
+               y = ar->winy - 2 - vsell * lheight;
                
                if (st->overwrite) {
                        char ch = text->sell->line[text->selc];
                        
+                       y += TXT_LINE_SPACING;
                        w = st->cwidth;
                        if (ch == '\t') w *= st->tabnumber - (vselc + st->left) 
% st->tabnumber;
                        
                        UI_ThemeColor(TH_HILITE);
-                       glRecti(x, y - st->lheight - 1, x + w, y - st->lheight 
+ 1);
+                       glRecti(x, y - lheight - 1, x + w, y - lheight + 1);
                }
                else {
                        UI_ThemeColor(TH_HILITE);
-                       glRecti(x - 1, y, x + 1, y - st->lheight);
+                       glRecti(x - 1, y, x + 1, y - lheight + 
TXT_LINE_SPACING);
                }
        }
 }
@@ -1714,8 +1716,8 @@
        if (viewc >= 0) {
                viewl = txt_get_span(text->lines.first, startl) - st->top + 
offl;
 
-               text_font_draw_character(st, x + viewc * st->cwidth, y - viewl 
* st->lheight, ch);
-               text_font_draw_character(st, x + viewc * st->cwidth + 1, y - 
viewl * st->lheight, ch);
+               text_font_draw_character(st, x + viewc * st->cwidth, y - viewl 
* (st->lheight + TXT_LINE_SPACING), ch);
+               text_font_draw_character(st, x + viewc * st->cwidth + 1, y - 
viewl * (st->lheight + TXT_LINE_SPACING), ch);
        }
 
        /* draw closing bracket */
@@ -1726,8 +1728,8 @@
        if (viewc >= 0) {
                viewl = txt_get_span(text->lines.first, endl) - st->top + offl;
 
-               text_font_draw_character(st, x + viewc * st->cwidth, y - viewl 
* st->lheight, ch);
-               text_font_draw_character(st, x + viewc * st->cwidth + 1, y - 
viewl * st->lheight, ch);
+               text_font_draw_character(st, x + viewc * st->cwidth, y - viewl 
* (st->lheight + TXT_LINE_SPACING), ch);
+               text_font_draw_character(st, x + viewc * st->cwidth + 1, y - 
viewl * (st->lheight + TXT_LINE_SPACING), ch);
        }
 }
 
@@ -1743,7 +1745,7 @@
        int wraplinecount = 0, wrap_skip = 0;
        int margin_column_x;
 
-       if (st->lheight) st->viewlines = (int)ar->winy / st->lheight;
+       if (st->lheight) st->viewlines = (int)ar->winy / (st->lheight + 
TXT_LINE_SPACING);
        else st->viewlines = 0;
 
        /* if no text, nothing to do */
@@ -1839,6 +1841,8 @@
                        text_draw(st, tmp->line, st->left, ar->winx / 
st->cwidth, 1, x, y, tmp->format);
                        y -= st->lheight;
                }
+               
+               y-= TXT_LINE_SPACING;
 
                wrap_skip = 0;
        }

Modified: trunk/blender/source/blender/editors/space_text/text_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_intern.h       
2012-11-16 00:43:28 UTC (rev 52263)
+++ trunk/blender/source/blender/editors/space_text/text_intern.h       
2012-11-16 01:12:01 UTC (rev 52264)
@@ -57,6 +57,7 @@
 #define TXT_OFFSET 15
 #define TXT_SCROLL_WIDTH 20
 #define TXT_SCROLL_SPACE 2
+#define TXT_LINE_SPACING 4 /* space between lines */
 
 #define TEXTXLOC               (st->cwidth * st->linenrs_tot)
 

Modified: trunk/blender/source/blender/editors/space_text/text_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_ops.c  2012-11-16 
00:43:28 UTC (rev 52263)
+++ trunk/blender/source/blender/editors/space_text/text_ops.c  2012-11-16 
01:12:01 UTC (rev 52264)
@@ -2202,10 +2202,10 @@
 
        if (!tsc->scrollbar) {
                txtdelta[0] = -tsc->delta[0] / st->cwidth;
-               txtdelta[1] = tsc->delta[1] / st->lheight;
+               txtdelta[1] = tsc->delta[1] / (st->lheight + TXT_LINE_SPACING);
 
                tsc->delta[0] %= st->cwidth;
-               tsc->delta[1] %= st->lheight;
+               tsc->delta[1] %= (st->lheight + TXT_LINE_SPACING);
        }
        else {
                txtdelta[1] = -tsc->delta[1] * st->pix_per_line;
@@ -2599,7 +2599,7 @@
 {
        Text *text = st->text;
        text_update_character_width(st);
-       y = (ar->winy - 2 - y) / st->lheight;
+       y = (ar->winy - 2 - y) / (st->lheight + TXT_LINE_SPACING);
 
        if (st->showlinenrs) x -= TXT_OFFSET + TEXTXLOC;
        else x -= TXT_OFFSET;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to