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
This commit is contained in:
parent
0418e28944
commit
8c6ce74239
|
@ -1 +1 @@
|
|||
Subproject commit 8a05b618f031582c006c6f62b9e60619ab3eef8b
|
||||
Subproject commit 5402eec9637b5c360e35bdd936d9e7a076d5df7f
|
|
@ -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),
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 67f1fbca1482d9d9362a4001332e785c3fd5d230
|
||||
Subproject commit 249288e02afdcd024a64480ec29fa61be53dc5ec
|
|
@ -1 +1 @@
|
|||
Subproject commit ef6ef414d22c2578fad99327743b925ab640a99c
|
||||
Subproject commit f3beaf241996d17feec0dee5f0888b0e9f55b4e3
|
|
@ -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
|
||||
|
|
|
@ -136,6 +136,7 @@ typedef enum ThemeColorID {
|
|||
TH_SYNTAX_D,
|
||||
TH_SYNTAX_N,
|
||||
TH_SYNTAX_S,
|
||||
TH_LINENUMBERS,
|
||||
|
||||
TH_BONE_SOLID,
|
||||
TH_BONE_POSE,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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, const TextDrawContext *tdc, ARegi
|
|||
if (viewc >= 0) {
|
||||
viewl = txt_get_span(text->lines.first, startl) - st->top + offl;
|
||||
|
||||
text_font_draw_character(tdc, x + viewc * st->cwidth, y - viewl * TXT_LINE_HEIGHT(st), ch);
|
||||
text_font_draw_character(
|
||||
tdc, x + viewc * st->cwidth, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch);
|
||||
text_font_draw_character(
|
||||
tdc, x + viewc * st->cwidth + 1, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch);
|
||||
tdc, x + viewc * st->cwidth + 1, y - viewl * TXT_LINE_HEIGHT(st), ch);
|
||||
}
|
||||
|
||||
/* draw closing bracket */
|
||||
|
@ -1525,10 +1524,9 @@ static void draw_brackets(const SpaceText *st, const TextDrawContext *tdc, ARegi
|
|||
if (viewc >= 0) {
|
||||
viewl = txt_get_span(text->lines.first, endl) - st->top + offl;
|
||||
|
||||
text_font_draw_character(tdc, x + viewc * st->cwidth, y - viewl * TXT_LINE_HEIGHT(st), ch);
|
||||
text_font_draw_character(
|
||||
tdc, x + viewc * st->cwidth, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch);
|
||||
text_font_draw_character(
|
||||
tdc, x + viewc * st->cwidth + 1, y - viewl * (st->lheight_dpi + TXT_LINE_SPACING), ch);
|
||||
tdc, x + viewc * st->cwidth + 1, y - viewl * TXT_LINE_HEIGHT(st), ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1557,9 +1555,7 @@ void draw_text_main(SpaceText *st, ARegion *ar)
|
|||
/* don't draw lines below this */
|
||||
const int clip_min_y = -(int)(st->lheight_dpi - 1);
|
||||
|
||||
st->viewlines = (st->lheight_dpi) ?
|
||||
(int)(ar->winy - clip_min_y) / (st->lheight_dpi + TXT_LINE_SPACING) :
|
||||
0;
|
||||
st->viewlines = (st->lheight_dpi) ? (int)(ar->winy - clip_min_y) / TXT_LINE_HEIGHT(st) : 0;
|
||||
|
||||
text_draw_context_init(st, &tdc);
|
||||
|
||||
|
@ -1610,19 +1606,18 @@ void draw_text_main(SpaceText *st, ARegion *ar)
|
|||
|
||||
/* draw line numbers background */
|
||||
if (st->showlinenrs) {
|
||||
x = TXT_OFFSET + TEXTXLOC;
|
||||
|
||||
uint pos = GPU_vertformat_attr_add(
|
||||
immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
immUniformThemeColor(TH_GRID);
|
||||
immRecti(pos, (TXT_OFFSET - 12), 0, (TXT_OFFSET - 5) + TEXTXLOC, ar->winy - 2);
|
||||
immRecti(pos, 0, 0, TXT_NUMCOL_WIDTH(st), ar->winy);
|
||||
immUnbindProgram();
|
||||
}
|
||||
else {
|
||||
st->linenrs_tot = 0; /* not used */
|
||||
x = TXT_OFFSET;
|
||||
}
|
||||
|
||||
x = TXT_BODY_LEFT(st);
|
||||
y = ar->winy - st->lheight_dpi;
|
||||
winx = ar->winx - TXT_SCROLL_WIDTH;
|
||||
|
||||
|
@ -1643,12 +1638,12 @@ void draw_text_main(SpaceText *st, ARegion *ar)
|
|||
UI_FontThemeColor(tdc.font_id, TH_HILITE);
|
||||
}
|
||||
else {
|
||||
UI_FontThemeColor(tdc.font_id, TH_TEXT);
|
||||
UI_FontThemeColor(tdc.font_id, TH_LINENUMBERS);
|
||||
}
|
||||
|
||||
BLI_snprintf(linenr, sizeof(linenr), "%*d", st->linenrs_tot, i + linecount + 1);
|
||||
/* itoa(i + linecount + 1, linenr, 10); */ /* not ansi-c :/ */
|
||||
text_font_draw(&tdc, TXT_OFFSET - 7, y, linenr);
|
||||
text_font_draw(&tdc, TXT_NUMCOL_PAD * st->cwidth, y, linenr);
|
||||
|
||||
if (tmp == text->curl) {
|
||||
UI_FontThemeColor(tdc.font_id, TH_TEXT);
|
||||
|
@ -1658,12 +1653,12 @@ void draw_text_main(SpaceText *st, ARegion *ar)
|
|||
if (st->wordwrap) {
|
||||
/* draw word wrapped text */
|
||||
int lines = text_draw_wrapped(st, &tdc, tmp->line, x, y, winx - x, tmp->format, wrap_skip);
|
||||
y -= lines * (st->lheight_dpi + TXT_LINE_SPACING);
|
||||
y -= lines * TXT_LINE_HEIGHT(st);
|
||||
}
|
||||
else {
|
||||
/* draw unwrapped text */
|
||||
text_draw(st, &tdc, tmp->line, st->left, ar->winx / st->cwidth, x, y, tmp->format);
|
||||
y -= st->lheight_dpi + TXT_LINE_SPACING;
|
||||
y -= TXT_LINE_HEIGHT(st);
|
||||
}
|
||||
|
||||
wrap_skip = 0;
|
||||
|
@ -1671,28 +1666,17 @@ void draw_text_main(SpaceText *st, ARegion *ar)
|
|||
|
||||
if (st->flags & ST_SHOW_MARGIN) {
|
||||
margin_column_x = x + st->cwidth * (st->margin_column - st->left);
|
||||
|
||||
if (margin_column_x >= x) {
|
||||
const uint shdr_pos = GPU_vertformat_attr_add(
|
||||
uint pos = GPU_vertformat_attr_add(
|
||||
immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT);
|
||||
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR);
|
||||
|
||||
GPU_line_width(2.0f);
|
||||
|
||||
float viewport_size[4];
|
||||
GPU_viewport_size_get_f(viewport_size);
|
||||
immUniform2f("viewport_size", viewport_size[2] / UI_DPI_FAC, viewport_size[3] / UI_DPI_FAC);
|
||||
|
||||
immUniform1i("colors_len", 0); /* "simple" mode */
|
||||
immUniformThemeColor3(TH_GRID); /* same color as line number background */
|
||||
immUniform1f("dash_width", 2.0f);
|
||||
immUniform1f("dash_factor", 0.5f);
|
||||
|
||||
immBegin(GPU_PRIM_LINES, 2);
|
||||
immVertex2i(shdr_pos, margin_column_x, 0);
|
||||
immVertex2i(shdr_pos, margin_column_x, ar->winy - 2);
|
||||
immEnd();
|
||||
immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
|
||||
float margin_color[4];
|
||||
UI_GetThemeColor4fv(TH_TEXT, margin_color);
|
||||
margin_color[3] = 0.2f;
|
||||
immUniformColor4fv(margin_color);
|
||||
GPU_blend(true);
|
||||
immRecti(pos, margin_column_x, 0, margin_column_x + U.pixelsize, ar->winy);
|
||||
GPU_blend(false);
|
||||
immUnbindProgram();
|
||||
}
|
||||
}
|
||||
|
@ -1761,7 +1745,7 @@ void text_scroll_to_cursor(SpaceText *st, ARegion *ar, const bool center)
|
|||
}
|
||||
else {
|
||||
x = st->cwidth * (text_get_char_pos(st, text->sell->line, text->selc) - st->left);
|
||||
winx -= TXT_OFFSET + (st->showlinenrs ? TEXTXLOC : 0) + TXT_SCROLL_WIDTH;
|
||||
winx -= TXT_BODY_LEFT(st) + TXT_SCROLL_WIDTH;
|
||||
|
||||
if (center) {
|
||||
if (x <= 0 || x > winx) {
|
||||
|
@ -1833,14 +1817,14 @@ bool ED_text_region_location_from_cursor(SpaceText *st,
|
|||
}
|
||||
else {
|
||||
int offl, offc;
|
||||
int linenr_offset = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET;
|
||||
int linenr_offset = TXT_BODY_LEFT(st);
|
||||
/* handle tabs as well! */
|
||||
int char_pos = text_get_char_pos(st, line->line, cursor_co[1]);
|
||||
|
||||
wrap_offset(st, ar, line, cursor_co[1], &offl, &offc);
|
||||
r_pixel_co[0] = (char_pos + offc - st->left) * st->cwidth + linenr_offset;
|
||||
r_pixel_co[1] = (cursor_co[0] + offl - st->top) * (st->lheight_dpi + TXT_LINE_SPACING);
|
||||
r_pixel_co[1] = (ar->winy - (r_pixel_co[1] + TXT_OFFSET)) - st->lheight_dpi;
|
||||
r_pixel_co[1] = (cursor_co[0] + offl - st->top) * TXT_LINE_HEIGHT(st);
|
||||
r_pixel_co[1] = (ar->winy - (r_pixel_co[1] + (TXT_BODY_LPAD * st->cwidth))) - st->lheight_dpi;
|
||||
}
|
||||
return true;
|
||||
|
||||
|
|
|
@ -44,11 +44,25 @@ void text_scroll_to_cursor(struct SpaceText *st, struct ARegion *ar, const bool
|
|||
void text_scroll_to_cursor__area(struct SpaceText *st, struct ScrArea *sa, const bool center);
|
||||
void text_update_cursor_moved(struct bContext *C);
|
||||
|
||||
#define TXT_OFFSET ((int)(0.5f * U.widget_unit))
|
||||
/* Padding around line numbers in character widths. */
|
||||
#define TXT_NUMCOL_PAD 1.0f
|
||||
/* Total width of the optional line numbers column. */
|
||||
#define TXT_NUMCOL_WIDTH(st) (st->cwidth * (st->linenrs_tot + (2 * TXT_NUMCOL_PAD)))
|
||||
|
||||
/* Padding on left of body text in character units. */
|
||||
#define TXT_BODY_LPAD 1.0f
|
||||
/* Left position of body text. */
|
||||
#define TXT_BODY_LEFT(st) (st->showlinenrs ? TXT_NUMCOL_WIDTH(st) : 0) + (TXT_BODY_LPAD * st->cwidth)
|
||||
|
||||
#define TXT_SCROLL_WIDTH U.widget_unit
|
||||
#define TXT_SCROLL_SPACE ((int)(0.1f * U.widget_unit))
|
||||
#define TXT_LINE_SPACING ((int)(0.3f * st->lheight_dpi)) /* space between lines */
|
||||
#define TEXTXLOC (st->cwidth * st->linenrs_tot)
|
||||
|
||||
/* Space between lines, in relation to letter height. */
|
||||
#define TXT_LINE_VPAD 0.3f
|
||||
/* Space between lines. */
|
||||
#define TXT_LINE_SPACING(st) ((int)(TXT_LINE_VPAD * st->lheight_dpi))
|
||||
/* Total height of each line. */
|
||||
#define TXT_LINE_HEIGHT(st) ((int)((1.0f + TXT_LINE_VPAD) * st->lheight_dpi))
|
||||
|
||||
#define SUGG_LIST_SIZE 7
|
||||
#define SUGG_LIST_WIDTH 20
|
||||
|
|
|
@ -2544,7 +2544,7 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event)
|
|||
* line offset but taken together should still scroll */
|
||||
if (!tsc->scrollbar) {
|
||||
st->scroll_accum[0] += -tsc->delta[0] / (float)st->cwidth;
|
||||
st->scroll_accum[1] += tsc->delta[1] / (float)(st->lheight_dpi + TXT_LINE_SPACING);
|
||||
st->scroll_accum[1] += tsc->delta[1] / (float)(TXT_LINE_HEIGHT(st));
|
||||
}
|
||||
else {
|
||||
st->scroll_accum[1] += -tsc->delta[1] * st->pix_per_line;
|
||||
|
@ -2982,15 +2982,9 @@ static void text_cursor_set_to_pos(SpaceText *st, ARegion *ar, int x, int y, con
|
|||
{
|
||||
Text *text = st->text;
|
||||
text_update_character_width(st);
|
||||
y = (ar->winy - 2 - y) / (st->lheight_dpi + TXT_LINE_SPACING);
|
||||
|
||||
if (st->showlinenrs) {
|
||||
x -= TXT_OFFSET + TEXTXLOC;
|
||||
}
|
||||
else {
|
||||
x -= TXT_OFFSET;
|
||||
}
|
||||
y = (ar->winy - 2 - y) / TXT_LINE_HEIGHT(st);
|
||||
|
||||
x -= TXT_BODY_LEFT(st);
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
|
@ -3261,7 +3255,8 @@ static int text_line_number_invoke(bContext *C, wmOperator *UNUSED(op), const wm
|
|||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
if (!(mval[0] > 2 && mval[0] < (TXT_OFFSET + TEXTXLOC) && mval[1] > 2 &&
|
||||
if (!(mval[0] > 2 && mval[0] < (TXT_NUMCOL_WIDTH(st) + (TXT_BODY_LPAD * st->cwidth)) &&
|
||||
mval[1] > 2 &&
|
||||
mval[1] < ar->winy - 2)) {
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
|
|
@ -320,6 +320,9 @@ typedef struct ThemeSpace {
|
|||
unsigned char syntaxv[4], syntaxc[4]; // in nodespace used for converter group
|
||||
unsigned char syntaxd[4], syntaxr[4]; // in nodespace used for distort
|
||||
|
||||
unsigned char line_numbers[4];
|
||||
char _pad6[4];
|
||||
|
||||
unsigned char nodeclass_output[4], nodeclass_filter[4];
|
||||
unsigned char nodeclass_vector[4], nodeclass_texture[4];
|
||||
unsigned char nodeclass_shader[4], nodeclass_script[4];
|
||||
|
|
|
@ -2560,6 +2560,12 @@ static void rna_def_userdef_theme_space_text(BlenderRNA *brna)
|
|||
|
||||
rna_def_userdef_theme_spaces_main(srna);
|
||||
|
||||
prop = RNA_def_property(srna, "line_numbers", PROP_FLOAT, PROP_COLOR_GAMMA);
|
||||
RNA_def_property_float_sdna(prop, NULL, "line_numbers");
|
||||
RNA_def_property_array(prop, 3);
|
||||
RNA_def_property_ui_text(prop, "Line Numbers", "");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_theme_update");
|
||||
|
||||
prop = RNA_def_property(srna, "line_numbers_background", PROP_FLOAT, PROP_COLOR_GAMMA);
|
||||
RNA_def_property_float_sdna(prop, NULL, "grid");
|
||||
RNA_def_property_array(prop, 3);
|
||||
|
|
Loading…
Reference in New Issue