Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_text/text_draw.c
| Context not available. | |||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "UI_view2d.h" | #include "UI_view2d.h" | ||||
| #include "GPU_draw.h" | |||||
| #include "GPU_immediate.h" | |||||
| #include "text_intern.h" | #include "text_intern.h" | ||||
| #include "text_format.h" | #include "text_format.h" | ||||
| Context not available. | |||||
| case FMT_TYPE_WHITESPACE: | case FMT_TYPE_WHITESPACE: | ||||
| break; | break; | ||||
| case FMT_TYPE_SYMBOL: | case FMT_TYPE_SYMBOL: | ||||
| UI_ThemeColor(TH_SYNTAX_S); | immUniformThemeColor(TH_SYNTAX_S); | ||||
| break; | break; | ||||
| case FMT_TYPE_COMMENT: | case FMT_TYPE_COMMENT: | ||||
| UI_ThemeColor(TH_SYNTAX_C); | immUniformThemeColor(TH_SYNTAX_C); | ||||
| break; | break; | ||||
| case FMT_TYPE_NUMERAL: | case FMT_TYPE_NUMERAL: | ||||
| UI_ThemeColor(TH_SYNTAX_N); | immUniformThemeColor(TH_SYNTAX_N); | ||||
| break; | break; | ||||
| case FMT_TYPE_STRING: | case FMT_TYPE_STRING: | ||||
| UI_ThemeColor(TH_SYNTAX_L); | immUniformThemeColor(TH_SYNTAX_L); | ||||
| break; | break; | ||||
| case FMT_TYPE_DIRECTIVE: | case FMT_TYPE_DIRECTIVE: | ||||
| UI_ThemeColor(TH_SYNTAX_D); | immUniformThemeColor(TH_SYNTAX_D); | ||||
| break; | break; | ||||
| case FMT_TYPE_SPECIAL: | case FMT_TYPE_SPECIAL: | ||||
| UI_ThemeColor(TH_SYNTAX_V); | immUniformThemeColor(TH_SYNTAX_V); | ||||
| break; | break; | ||||
| case FMT_TYPE_RESERVED: | case FMT_TYPE_RESERVED: | ||||
| UI_ThemeColor(TH_SYNTAX_R); | immUniformThemeColor(TH_SYNTAX_R); | ||||
| break; | break; | ||||
| case FMT_TYPE_KEYWORD: | case FMT_TYPE_KEYWORD: | ||||
| UI_ThemeColor(TH_SYNTAX_B); | immUniformThemeColor(TH_SYNTAX_B); | ||||
| break; | break; | ||||
| case FMT_TYPE_DEFAULT: | case FMT_TYPE_DEFAULT: | ||||
| default: | default: | ||||
| UI_ThemeColor(TH_TEXT); | immUniformThemeColor(TH_TEXT); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| float col[4]; | float col[4]; | ||||
| float rad; | float rad; | ||||
| UI_ThemeColor(TH_BACK); | VertexFormat *format = immVertexFormat(); | ||||
| glRecti(back->xmin, back->ymin, back->xmax, back->ymax); | unsigned pos = add_attrib(format, "pos", GL_INT, 2, KEEP_INT ); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| immUniformThemeColor(TH_BACK); | |||||
| immRecti(pos, back->xmin, back->ymin, back->xmax, back->ymax); | |||||
| immUnbindProgram(); | |||||
| UI_draw_widget_scroll(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0); | UI_draw_widget_scroll(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0); | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| Context not available. | |||||
| boxw = DOC_WIDTH * st->cwidth + 20; | boxw = DOC_WIDTH * st->cwidth + 20; | ||||
| boxh = (DOC_HEIGHT + 1) * (st->lheight_dpi + TXT_LINE_SPACING); | boxh = (DOC_HEIGHT + 1) * (st->lheight_dpi + TXT_LINE_SPACING); | ||||
| /* Draw panel */ | |||||
| UI_ThemeColor(TH_BACK); | /* Draw panel */ | ||||
| glRecti(x, y, x + boxw, y - boxh); | VertexFormat* format = immVertexFormat(); | ||||
| UI_ThemeColor(TH_SHADE1); | unsigned pos = add_attrib(format, "pos", GL_INT, 2, KEEP_INT); | ||||
| glBegin(GL_LINE_LOOP); | |||||
| glVertex2i(x, y); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| glVertex2i(x + boxw, y); | |||||
| glVertex2i(x + boxw, y - boxh); | immUniformThemeColor(TH_BACK); | ||||
| glVertex2i(x, y - boxh); | immRecti(pos, x, y, x + boxw, y - boxh); | ||||
| glEnd(); | immUniformThemeColor(TH_BACK); | ||||
| glBegin(GL_LINE_LOOP); | immBegin(GL_LINE_LOOP, 4); | ||||
| glVertex2i(x + boxw - 10, y - 7); | immVertex2i(pos, x, y); | ||||
| glVertex2i(x + boxw - 4, y - 7); | immVertex2i(pos, x + boxw, y); | ||||
| glVertex2i(x + boxw - 7, y - 2); | immVertex2i(pos, x + boxw, y - boxh); | ||||
| glEnd(); | immVertex2i(pos, x, y - boxh); | ||||
| glBegin(GL_LINE_LOOP); | immEnd(); | ||||
| glVertex2i(x + boxw - 10, y - boxh + 7); | immBegin(GL_LINE_LOOP , 3); | ||||
| glVertex2i(x + boxw - 4, y - boxh + 7); | immVertex2i(pos, x + boxw - 10, y - 7); | ||||
| glVertex2i(x + boxw - 7, y - boxh + 2); | immVertex2i(pos, x + boxw - 4, y - 7); | ||||
| glEnd(); | immVertex2i(pos, x + boxw - 7, y - 2); | ||||
| immEnd(); | |||||
| immBegin(GL_LINE_LOOP , 3); | |||||
| immVertex2i(pos, x + boxw - 10, y - boxh + 7); | |||||
| immVertex2i(pos, x + boxw - 4, y - boxh + 7); | |||||
| immVertex2i(pos, x + boxw - 7, y - boxh + 2); | |||||
| immEnd(); | |||||
| immUnbindProgram(); | |||||
| UI_ThemeColor(TH_TEXT); | UI_ThemeColor(TH_TEXT); | ||||
| i = 0; br = DOC_WIDTH; lines = 0; // XXX -doc_scroll; | i = 0; br = DOC_WIDTH; lines = 0; // XXX -doc_scroll; | ||||
| Context not available. | |||||
| /* not needed but stands out nicer */ | /* not needed but stands out nicer */ | ||||
| UI_draw_box_shadow(220, x, y - boxh, x + boxw, y); | UI_draw_box_shadow(220, x, y - boxh, x + boxw, y); | ||||
| UI_ThemeColor(TH_SHADE1); | VertexFormat *format = immVertexFormat(); | ||||
| glRecti(x - 1, y + 1, x + boxw + 1, y - boxh - 1); | unsigned pos = add_attrib(format, "pos", GL_INT, 2, KEEP_INT); | ||||
| UI_ThemeColorShade(TH_BACK, 16); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| glRecti(x, y, x + boxw, y - boxh); | immUniformThemeColor(TH_SHADE1); | ||||
| immRecti(pos, x - 1, y + 1, x + boxw + 1, y - boxh - 1); | |||||
| immUniformThemeColorShade(TH_BACK, 16); | |||||
| immRecti(pos, x, y, x + boxw, y - boxh); | |||||
| immUnbindProgram(); | |||||
| /* Set the top 'item' of the visible list */ | /* Set the top 'item' of the visible list */ | ||||
| for (i = 0, item = first; i < *top && item->next; i++, item = item->next) ; | for (i = 0, item = first; i < *top && item->next; i++, item = item->next) ; | ||||
| Context not available. | |||||
| w = st->cwidth * text_get_char_pos(st, str, len); | w = st->cwidth * text_get_char_pos(st, str, len); | ||||
| if (item == sel) { | if (item == sel) { | ||||
| UI_ThemeColor(TH_SHADE2); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| glRecti(x + margin_x, y - 3, x + margin_x + w, y + lheight - 3); | immUniformThemeColor(TH_SHADE2); | ||||
| } | immRecti(pos, x + margin_x, y - 3, x + margin_x + w, y + lheight - 3); | ||||
| immUnbindProgram(); | |||||
| } | |||||
| format_draw_color(item->type); | format_draw_color(item->type); | ||||
| text_draw(st, tdc, str, 0, 0, x + margin_x, y - 1, NULL); | text_draw(st, tdc, str, 0, 0, x + margin_x, y - 1, NULL); | ||||
| Context not available. | |||||
| int vcurl, vcurc, vsell, vselc, hidden = 0; | int vcurl, vcurc, vsell, vselc, hidden = 0; | ||||
| int x, y, w, i; | int x, y, w, i; | ||||
| const int lheight = st->lheight_dpi + TXT_LINE_SPACING; | const int lheight = st->lheight_dpi + TXT_LINE_SPACING; | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_INT, 2, KEEP_INT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| /* Draw the selection */ | /* Draw the selection */ | ||||
| if (text->curl != text->sell || text->curc != text->selc) { | if (text->curl != text->sell || text->curc != text->selc) { | ||||
| int offl, offc; | int offl, offc; | ||||
| Context not available. | |||||
| hidden = 1; | hidden = 1; | ||||
| } | } | ||||
| UI_ThemeColor(TH_SHADE2); | immUniformThemeColor(TH_SHADE2); | ||||
| x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; | x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; | ||||
| y = ar->winy; | y = ar->winy; | ||||
| if (vcurl == vsell) { | if (vcurl == vsell) { | ||||
| y -= vcurl * lheight; | y -= vcurl * lheight; | ||||
| if (vcurc < vselc) | if (vcurc < vselc) | ||||
| glRecti(x + vcurc * st->cwidth - 1, y, x + vselc * st->cwidth, y - lheight); | immRecti(pos, x + vcurc * st->cwidth - 1, y, x + vselc * st->cwidth, y - lheight); | ||||
| else | else | ||||
| glRecti(x + vselc * st->cwidth - 1, y, x + vcurc * st->cwidth, y - lheight); | immRecti(pos, x + vselc * st->cwidth - 1, y, x + vcurc * st->cwidth, y - lheight); | ||||
| } | } | ||||
| else { | else { | ||||
| int froml, fromc, tol, toc; | int froml, fromc, tol, toc; | ||||
| Context not available. | |||||
| y -= froml * lheight; | y -= froml * lheight; | ||||
| glRecti(x + fromc * st->cwidth - 1, y, ar->winx, y - lheight); | immRecti(pos, x + fromc * st->cwidth - 1, y, ar->winx, y - lheight); | ||||
| y -= lheight; | y -= lheight; | ||||
| for (i = froml + 1; i < tol; i++) { | for (i = froml + 1; i < tol; i++) { | ||||
| glRecti(x - 4, y, ar->winx, y - lheight); | immRecti(pos, x - 4, y, ar->winx, y - lheight); | ||||
| y -= lheight; | y -= lheight; | ||||
| } | } | ||||
| glRecti(x - 4, y, x + toc * st->cwidth, y - lheight); | immRecti(pos, x - 4, y, x + toc * st->cwidth, y - lheight); | ||||
| y -= lheight; | y -= lheight; | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| x1 = 0; // st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; | x1 = 0; // st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; | ||||
| x2 = x1 + ar->winx; | x2 = x1 + ar->winx; | ||||
| glColor4ub(255, 255, 255, 32); | immUniformColor4ub(255, 255, 255, 32); | ||||
| glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| glRecti(x1 - 4, y1, x2, y2); | immRecti(pos, x1 - 4, y1, x2, y2); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||
| w = st->cwidth; | w = st->cwidth; | ||||
| if (ch == '\t') w *= st->tabnumber - (vselc + st->left) % st->tabnumber; | if (ch == '\t') w *= st->tabnumber - (vselc + st->left) % st->tabnumber; | ||||
| UI_ThemeColor(TH_HILITE); | immUniformThemeColor(TH_HILITE); | ||||
| glRecti(x, y - lheight - 1, x + w, y - lheight + 1); | immRecti(pos, x, y - lheight - 1, x + w, y - lheight + 1); | ||||
| } | } | ||||
| else { | else { | ||||
| UI_ThemeColor(TH_HILITE); | immUniformThemeColor(TH_HILITE); | ||||
| glRecti(x - 1, y, x + 1, y - lheight); | immRecti(pos, x - 1, y, x + 1, y - lheight); | ||||
| } | } | ||||
| } | } | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| /******************* draw matching brackets *********************/ | /******************* draw matching brackets *********************/ | ||||
| Context not available. | |||||
| /* draw line numbers background */ | /* draw line numbers background */ | ||||
| if (st->showlinenrs) { | if (st->showlinenrs) { | ||||
| x = TXT_OFFSET + TEXTXLOC; | x = TXT_OFFSET + TEXTXLOC; | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| UI_ThemeColor(TH_GRID); | unsigned pos = add_attrib(format, "pos", GL_INT, 2 , KEEP_INT); | ||||
| glRecti((TXT_OFFSET - 12), 0, (TXT_OFFSET - 5) + TEXTXLOC, ar->winy - 2); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| } | immUniformThemeColor(TH_GRID); | ||||
| immRecti(pos, (TXT_OFFSET - 12), 0, (TXT_OFFSET - 5) + TEXTXLOC, ar->winy - 2); | |||||
| immUnbindProgram(); | |||||
| } | |||||
| else { | else { | ||||
| st->linenrs_tot = 0; /* not used */ | st->linenrs_tot = 0; /* not used */ | ||||
| x = TXT_OFFSET; | x = TXT_OFFSET; | ||||
| Context not available. | |||||
| if (margin_column_x >= x) { | if (margin_column_x >= x) { | ||||
| /* same color as line number background */ | /* same color as line number background */ | ||||
| UI_ThemeColor(TH_GRID); | |||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_INT, 2, KEEP_INT); | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| immUniformThemeColor(TH_GRID); | |||||
| setlinestyle(1); | setlinestyle(1); | ||||
| glBegin(GL_LINES); | immBegin(GL_LINES , 2); | ||||
| glVertex2i(margin_column_x, 0); | immVertex2i(pos, margin_column_x, 0); | ||||
| glVertex2i(margin_column_x, ar->winy - 2); | immVertex2i(pos, margin_column_x, ar->winy - 2); | ||||
| glEnd(); | immEnd(); | ||||
| setlinestyle(0); | setlinestyle(0); | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| } | } | ||||
| Context not available. | |||||