[Bf-blender-cvs] [8c6ce742391] master: UI: Text Editor Visual Changes

Harley Acheson noreply at git.blender.org
Wed Nov 20 22:01:27 CET 2019


Commit: 8c6ce742391b2b8798143a4a2c2224ebbeb7f1ec
Author: Harley Acheson
Date:   Wed Nov 20 12:59:19 2019 -0800
Branches: master
https://developer.blender.org/rB8c6ce742391b2b8798143a4a2c2224ebbeb7f1ec

UI: Text Editor Visual Changes

Various small changes to Text Editor, mostly to do with scaling, alignment, and theme support.

Differential Revision: https://developer.blender.org/D6268

Reviewed by Campbell Barton

===================================================================

M	release/datafiles/locale
M	release/datafiles/userdef/userdef_default_theme.c
M	release/scripts/addons
M	release/scripts/addons_contrib
M	source/blender/blenloader/intern/versioning_userdef.c
M	source/blender/editors/include/UI_resources.h
M	source/blender/editors/interface/resources.c
M	source/blender/editors/space_text/text_autocomplete.c
M	source/blender/editors/space_text/text_draw.c
M	source/blender/editors/space_text/text_intern.h
M	source/blender/editors/space_text/text_ops.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 8a05b618f03..5402eec9637 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 8a05b618f031582c006c6f62b9e60619ab3eef8b
+Subproject commit 5402eec9637b5c360e35bdd936d9e7a076d5df7f
diff --git a/release/datafiles/userdef/userdef_default_theme.c b/release/datafiles/userdef/userdef_default_theme.c
index 8fb2237c9aa..6d0107de2fe 100644
--- a/release/datafiles/userdef/userdef_default_theme.c
+++ b/release/datafiles/userdef/userdef_default_theme.c
@@ -726,6 +726,7 @@ const bTheme U_theme_default = {
     .syntaxc = RGBA(0x939393ff),
     .syntaxd = RGBA(0xad80ffff),
     .syntaxr = RGBA(0xc4753bff),
+    .line_numbers = RGBA(0xd0d0d0ff),
   },
   .space_outliner = {
     .back = RGBA(0x28282800),
diff --git a/release/scripts/addons b/release/scripts/addons
index 67f1fbca148..249288e02af 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 67f1fbca1482d9d9362a4001332e785c3fd5d230
+Subproject commit 249288e02afdcd024a64480ec29fa61be53dc5ec
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index ef6ef414d22..f3beaf24199 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit ef6ef414d22c2578fad99327743b925ab640a99c
+Subproject commit f3beaf241996d17feec0dee5f0888b0e9f55b4e3
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index e8783f68bcb..838bb9bb9c8 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -161,6 +161,7 @@ static void do_versions_theme(const UserDef *userdef, bTheme *btheme)
    */
   {
     FROM_DEFAULT_V4_UCHAR(space_sequencer.anim_preview_range);
+    FROM_DEFAULT_V4_UCHAR(space_text.line_numbers);
   }
 
 #undef FROM_DEFAULT_V4_UCHAR
diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h
index 89579b88d24..c909c9b8d58 100644
--- a/source/blender/editors/include/UI_resources.h
+++ b/source/blender/editors/include/UI_resources.h
@@ -136,6 +136,7 @@ typedef enum ThemeColorID {
   TH_SYNTAX_D,
   TH_SYNTAX_N,
   TH_SYNTAX_S,
+  TH_LINENUMBERS,
 
   TH_BONE_SOLID,
   TH_BONE_POSE,
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c
index 99594cf0803..a405069efd8 100644
--- a/source/blender/editors/interface/resources.c
+++ b/source/blender/editors/interface/resources.c
@@ -567,6 +567,9 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
         case TH_SYNTAX_S:
           cp = ts->syntaxs;
           break;
+        case TH_LINENUMBERS:
+          cp = ts->line_numbers;
+          break;
 
         case TH_NODE:
           cp = ts->syntaxl;
diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c
index b6c660ae5b2..a4531284e1a 100644
--- a/source/blender/editors/space_text/text_autocomplete.c
+++ b/source/blender/editors/space_text/text_autocomplete.c
@@ -82,12 +82,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *ar)
 
   text_update_character_width(st);
 
-  if (st->showlinenrs) {
-    x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET + TEXTXLOC - 4;
-  }
-  else {
-    x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET - 4;
-  }
+  x = TXT_BODY_LEFT(st) + (st->cwidth * (st->text->curc - st->left));
   y = ar->winy - st->lheight_dpi * l - 2;
 
   w = SUGG_LIST_WIDTH * st->cwidth + U.widget_unit;
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index e99bf680077..b2366cbe182 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -192,7 +192,7 @@ int wrap_width(const SpaceText *st, ARegion *ar)
   int winx = ar->winx - TXT_SCROLL_WIDTH;
   int x, max;
 
-  x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
+  x = TXT_BODY_LEFT(st);
   max = st->cwidth ? (winx - x) / st->cwidth : 0;
   return max > 8 ? max : 8;
 }
@@ -472,7 +472,7 @@ static int text_draw_wrapped(const SpaceText *st,
         x += text_font_draw_character_utf8(tdc, x, y, str + ma);
         fpos++;
       }
-      y -= st->lheight_dpi + TXT_LINE_SPACING;
+      y -= TXT_LINE_HEIGHT(st);
       x = basex;
       lines++;
       fstart = fpos;
@@ -1052,19 +1052,14 @@ static void draw_documentation(const SpaceText *st, ARegion *ar)
     return;
   }
 
-  if (st->showlinenrs) {
-    x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET + TEXTXLOC - 4;
-  }
-  else {
-    x = st->cwidth * (st->text->curc - st->left) + TXT_OFFSET - 4;
-  }
+  x = TXT_BODY_LEFT(st) + (st->cwidth * (st->text->curc - st->left));
   if (texttool_suggest_first()) {
     x += SUGG_LIST_WIDTH * st->cwidth + 50;
   }
 
   /* top = */ /* UNUSED */ y = ar->winy - st->lheight_dpi * l - 2;
   boxw = DOC_WIDTH * st->cwidth + 20;
-  boxh = (DOC_HEIGHT + 1) * (st->lheight_dpi + TXT_LINE_SPACING);
+  boxh = (DOC_HEIGHT + 1) * TXT_LINE_HEIGHT(st);
 
   /* Draw panel */
   uint pos = GPU_vertformat_attr_add(
@@ -1142,7 +1137,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
   char str[SUGG_LIST_WIDTH * BLI_UTF8_MAX + 1];
   int offl, offc, vcurl, vcurc;
   int w, boxw = 0, boxh, i, x, y, *top;
-  const int lheight = st->lheight_dpi + TXT_LINE_SPACING;
+  const int lheight = TXT_LINE_HEIGHT(st);
   const int margin_x = 2;
 
   if (!st->text) {
@@ -1167,8 +1162,7 @@ static void draw_suggestion_list(const SpaceText *st, const TextDrawContext *tdc
   vcurl = txt_get_span(st->text->lines.first, st->text->curl) - st->top + offl;
   vcurc = text_get_char_pos(st, st->text->curl->line, st->text->curc) - st->left + offc;
 
-  x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
-  x += vcurc * st->cwidth - 4;
+  x = TXT_BODY_LEFT(st) + (vcurc * st->cwidth);
   y = ar->winy - (vcurl + 1) * lheight - 2;
 
   /* offset back so the start of the text lines up with the suggestions,
@@ -1239,7 +1233,7 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
   int vcurl, vcurc, vsell, vselc, hidden = 0;
   int x, y, w, i;
   int offl, offc;
-  const int lheight = st->lheight_dpi + TXT_LINE_SPACING;
+  const int lheight = TXT_LINE_HEIGHT(st);
 
   /* Convert to view space character coordinates to determine if cursor is hidden */
   wrap_offset(st, ar, text->sell, text->selc, &offl, &offc);
@@ -1273,17 +1267,17 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
 
     immUniformThemeColor(TH_SHADE2);
 
-    x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
+    x = TXT_BODY_LEFT(st);
     y = ar->winy;
 
     if (vcurl == vsell) {
       y -= vcurl * lheight;
 
       if (vcurc < vselc) {
-        immRecti(pos, x + vcurc * st->cwidth - 1, y, x + vselc * st->cwidth, y - lheight);
+        immRecti(pos, x + vcurc * st->cwidth, y, x + vselc * st->cwidth, y - lheight);
       }
       else {
-        immRecti(pos, x + vselc * st->cwidth - 1, y, x + vcurc * st->cwidth, y - lheight);
+        immRecti(pos, x + vselc * st->cwidth, y, x + vcurc * st->cwidth, y - lheight);
       }
     }
     else {
@@ -1304,15 +1298,17 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
 
       y -= froml * lheight;
 
-      immRecti(pos, x + fromc * st->cwidth - 1, y, ar->winx, y - lheight);
+      immRecti(pos, x + fromc * st->cwidth - U.pixelsize, y, ar->winx, y - lheight);
       y -= lheight;
 
       for (i = froml + 1; i < tol; i++) {
-        immRecti(pos, x - 4, y, ar->winx, y - lheight);
+        immRecti(pos, x - U.pixelsize, y, ar->winx, y - lheight);
         y -= lheight;
       }
 
-      immRecti(pos, x - 4, y, x + toc * st->cwidth, y - lheight);
+      if (x + toc * st->cwidth > x) {
+        immRecti(pos, x - U.pixelsize, y, x + toc * st->cwidth, y - lheight);
+      }
       y -= lheight;
     }
   }
@@ -1334,22 +1330,22 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
     }
 
     if (!(y1 < 0 || y2 > ar->winy)) { /* check we need to draw */
-      x1 = 0;                         // st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
-      x2 = x1 + ar->winx;
-
-      immUniformColor4ub(255, 255, 255, 32);
-
+      float highlight_color[4];
+      UI_GetThemeColor4fv(TH_TEXT, highlight_color);
+      highlight_color[3] = 0.1f;
+      immUniformColor4fv(highlight_color);
       GPU_blend_set_func_separate(
           GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
       GPU_blend(true);
-      immRecti(pos, x1 - 4, y1, x2, y2);
+      immRecti(
+          pos, 0, y1, ar->winx, y2);
       GPU_blend(false);
     }
   }
 
   if (!hidden) {
     /* Draw the cursor itself (we draw the sel. cursor as this is the leading edge) */
-    x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
+    x = TXT_BODY_LEFT(st);
     x += vselc * st->cwidth;
     y = ar->winy - vsell * lheight;
 
@@ -1358,16 +1354,20 @@ static void draw_text_decoration(SpaceText *st, ARegion *ar)
     if (st->overwrite) {
       char ch = text->sell->line[text->selc];
 
-      y += TXT_LINE_SPACING;
+      y += TXT_LINE_SPACING(st);
       w = st->cwidth;
       if (ch == '\t') {
         w *= st->tabnumber - (vselc + st->left) % st->tabnumber;
       }
 
-      immRecti(pos, x, y - lheight - 1, x + w, y - lheight + 1);
+      immRecti(pos,
+               x,
+               y - lheight - U.pixelsize,
+               x + w + U.pixelsize,
+               y - lheight - (3 * U.pixelsize));
     }
     else {
-      immRecti(pos, x - 1, y, x + 1, y - lheight);
+      immRecti(pos, x - U.pixelsize, y, x + U.pixelsize, y - lheight);
     }
   }
 
@@ -1500,7 +1500,7 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
   }
 
   UI_FontThemeColor(tdc->font_id, TH_HILITE);
-  x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
+  x = TXT_BODY_LEFT(st);
   y = ar->winy - st->lheight_dpi;
 
   /* draw opening bracket */
@@ -1511,10 +1511,9 @@ static void draw_brackets(const SpaceText *st, 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list