Implement theme item cache in TextEdit and CodeEdit
This commit is contained in:
parent
91ff34b5b5
commit
db2f99cdc0
4 changed files with 348 additions and 296 deletions
|
@ -36,44 +36,10 @@
|
|||
|
||||
void CodeEdit::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_THEME_CHANGED:
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
style_normal = get_theme_stylebox(SNAME("normal"));
|
||||
|
||||
font = get_theme_font(SNAME("font"));
|
||||
font_size = get_theme_font_size(SNAME("font_size"));
|
||||
|
||||
line_spacing = get_theme_constant(SNAME("line_spacing"));
|
||||
|
||||
case NOTIFICATION_THEME_CHANGED: {
|
||||
set_gutter_width(main_gutter, get_line_height());
|
||||
set_gutter_width(line_number_gutter, (line_number_digits + 1) * font->get_char_size('0', font_size).width);
|
||||
set_gutter_width(line_number_gutter, (line_number_digits + 1) * theme_cache.font->get_char_size('0', theme_cache.font_size).width);
|
||||
set_gutter_width(fold_gutter, get_line_height() / 1.2);
|
||||
|
||||
breakpoint_color = get_theme_color(SNAME("breakpoint_color"));
|
||||
breakpoint_icon = get_theme_icon(SNAME("breakpoint"));
|
||||
|
||||
bookmark_color = get_theme_color(SNAME("bookmark_color"));
|
||||
bookmark_icon = get_theme_icon(SNAME("bookmark"));
|
||||
|
||||
executing_line_color = get_theme_color(SNAME("executing_line_color"));
|
||||
executing_line_icon = get_theme_icon(SNAME("executing_line"));
|
||||
|
||||
line_number_color = get_theme_color(SNAME("line_number_color"));
|
||||
|
||||
folding_color = get_theme_color(SNAME("code_folding_color"));
|
||||
can_fold_icon = get_theme_icon(SNAME("can_fold"));
|
||||
folded_icon = get_theme_icon(SNAME("folded"));
|
||||
|
||||
code_completion_max_width = get_theme_constant(SNAME("completion_max_width"));
|
||||
code_completion_max_lines = get_theme_constant(SNAME("completion_lines"));
|
||||
code_completion_scroll_width = get_theme_constant(SNAME("completion_scroll_width"));
|
||||
code_completion_scroll_color = get_theme_color(SNAME("completion_scroll_color"));
|
||||
code_completion_scroll_hovered_color = get_theme_color(SNAME("completion_scroll_hovered_color"));
|
||||
code_completion_background_color = get_theme_color(SNAME("completion_background_color"));
|
||||
code_completion_selected_color = get_theme_color(SNAME("completion_selected_color"));
|
||||
code_completion_existing_color = get_theme_color(SNAME("completion_existing_color"));
|
||||
|
||||
line_length_guideline_color = get_theme_color(SNAME("line_length_guideline_color"));
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_DRAW: {
|
||||
|
@ -84,14 +50,14 @@ void CodeEdit::_notification(int p_what) {
|
|||
const int row_height = get_line_height();
|
||||
|
||||
if (line_length_guideline_columns.size() > 0) {
|
||||
const int xmargin_beg = style_normal->get_margin(SIDE_LEFT) + get_total_gutter_width();
|
||||
const int xmargin_end = size.width - style_normal->get_margin(SIDE_RIGHT) - (is_drawing_minimap() ? get_minimap_width() : 0);
|
||||
const float char_size = font->get_char_size('0', font_size).width;
|
||||
const int xmargin_beg = theme_cache.style_normal->get_margin(SIDE_LEFT) + get_total_gutter_width();
|
||||
const int xmargin_end = size.width - theme_cache.style_normal->get_margin(SIDE_RIGHT) - (is_drawing_minimap() ? get_minimap_width() : 0);
|
||||
const float char_size = theme_cache.font->get_char_size('0', theme_cache.font_size).width;
|
||||
|
||||
for (int i = 0; i < line_length_guideline_columns.size(); i++) {
|
||||
const int xoffset = xmargin_beg + char_size * (int)line_length_guideline_columns[i] - get_h_scroll();
|
||||
if (xoffset > xmargin_beg && xoffset < xmargin_end) {
|
||||
Color guideline_color = (i == 0) ? line_length_guideline_color : line_length_guideline_color * Color(1, 1, 1, 0.5);
|
||||
Color guideline_color = (i == 0) ? theme_cache.line_length_guideline_color : theme_cache.line_length_guideline_color * Color(1, 1, 1, 0.5);
|
||||
if (rtl) {
|
||||
RenderingServer::get_singleton()->canvas_item_add_line(ci, Point2(size.width - xoffset, 0), Point2(size.width - xoffset, size.height), guideline_color);
|
||||
continue;
|
||||
|
@ -103,45 +69,42 @@ void CodeEdit::_notification(int p_what) {
|
|||
|
||||
bool code_completion_below = false;
|
||||
if (caret_visible && code_completion_active && code_completion_options.size() > 0) {
|
||||
Ref<StyleBox> csb = get_theme_stylebox(SNAME("completion"));
|
||||
|
||||
const int code_completion_options_count = code_completion_options.size();
|
||||
const int lines = MIN(code_completion_options_count, code_completion_max_lines);
|
||||
const int icon_hsep = get_theme_constant(SNAME("h_separation"), SNAME("ItemList"));
|
||||
const int lines = MIN(code_completion_options_count, theme_cache.code_completion_max_lines);
|
||||
const Size2 icon_area_size(row_height, row_height);
|
||||
|
||||
code_completion_rect.size.width = code_completion_longest_line + icon_hsep + icon_area_size.width + 2;
|
||||
code_completion_rect.size.width = code_completion_longest_line + theme_cache.code_completion_icon_separation + icon_area_size.width + 2;
|
||||
code_completion_rect.size.height = lines * row_height;
|
||||
|
||||
const Point2 caret_pos = get_caret_draw_pos();
|
||||
const int total_height = csb->get_minimum_size().y + code_completion_rect.size.height;
|
||||
const int total_height = theme_cache.code_completion_style->get_minimum_size().y + code_completion_rect.size.height;
|
||||
const bool can_fit_completion_above = (caret_pos.y - row_height > total_height);
|
||||
const bool can_fit_completion_below = (caret_pos.y + row_height + total_height <= get_size().height);
|
||||
if (!can_fit_completion_below && can_fit_completion_above) {
|
||||
code_completion_rect.position.y = (caret_pos.y - total_height - row_height) + line_spacing;
|
||||
code_completion_rect.position.y = (caret_pos.y - total_height - row_height) + theme_cache.line_spacing;
|
||||
} else {
|
||||
code_completion_rect.position.y = caret_pos.y + (line_spacing / 2.0f);
|
||||
code_completion_rect.position.y = caret_pos.y + (theme_cache.line_spacing / 2.0f);
|
||||
code_completion_below = true;
|
||||
}
|
||||
|
||||
const int scroll_width = code_completion_options_count > code_completion_max_lines ? code_completion_scroll_width : 0;
|
||||
const int code_completion_base_width = font->get_string_size(code_completion_base, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width;
|
||||
const int scroll_width = code_completion_options_count > theme_cache.code_completion_max_lines ? theme_cache.code_completion_scroll_width : 0;
|
||||
const int code_completion_base_width = theme_cache.font->get_string_size(code_completion_base, HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).width;
|
||||
if (caret_pos.x - code_completion_base_width + code_completion_rect.size.width + scroll_width > get_size().width) {
|
||||
code_completion_rect.position.x = get_size().width - code_completion_rect.size.width - scroll_width;
|
||||
} else {
|
||||
code_completion_rect.position.x = caret_pos.x - code_completion_base_width;
|
||||
}
|
||||
|
||||
draw_style_box(csb, Rect2(code_completion_rect.position - csb->get_offset(), code_completion_rect.size + csb->get_minimum_size() + Size2(scroll_width, 0)));
|
||||
if (code_completion_background_color.a > 0.01) {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(code_completion_rect.position, code_completion_rect.size + Size2(scroll_width, 0)), code_completion_background_color);
|
||||
draw_style_box(theme_cache.code_completion_style, Rect2(code_completion_rect.position - theme_cache.code_completion_style->get_offset(), code_completion_rect.size + theme_cache.code_completion_style->get_minimum_size() + Size2(scroll_width, 0)));
|
||||
if (theme_cache.code_completion_background_color.a > 0.01) {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(code_completion_rect.position, code_completion_rect.size + Size2(scroll_width, 0)), theme_cache.code_completion_background_color);
|
||||
}
|
||||
|
||||
code_completion_scroll_rect.position = code_completion_rect.position + Vector2(code_completion_rect.size.width, 0);
|
||||
code_completion_scroll_rect.size = Vector2(scroll_width, code_completion_rect.size.height);
|
||||
|
||||
code_completion_line_ofs = CLAMP((code_completion_force_item_center < 0 ? code_completion_current_selected : code_completion_force_item_center) - lines / 2, 0, code_completion_options_count - lines);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(code_completion_rect.position.x, code_completion_rect.position.y + (code_completion_current_selected - code_completion_line_ofs) * row_height), Size2(code_completion_rect.size.width, row_height)), code_completion_selected_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(code_completion_rect.position.x, code_completion_rect.position.y + (code_completion_current_selected - code_completion_line_ofs) * row_height), Size2(code_completion_rect.size.width, row_height)), theme_cache.code_completion_selected_color);
|
||||
|
||||
for (int i = 0; i < lines; i++) {
|
||||
int l = code_completion_line_ofs + i;
|
||||
|
@ -149,7 +112,7 @@ void CodeEdit::_notification(int p_what) {
|
|||
|
||||
Ref<TextLine> tl;
|
||||
tl.instantiate();
|
||||
tl->add_string(code_completion_options[l].display, font, font_size);
|
||||
tl->add_string(code_completion_options[l].display, theme_cache.font, theme_cache.font_size);
|
||||
|
||||
int yofs = (row_height - tl->get_size().y) / 2;
|
||||
Point2 title_pos(code_completion_rect.position.x, code_completion_rect.position.y + i * row_height + yofs);
|
||||
|
@ -161,9 +124,9 @@ void CodeEdit::_notification(int p_what) {
|
|||
Size2 icon_size = icon_area.size * 0.7;
|
||||
icon->draw_rect(ci, Rect2(icon_area.position + (icon_area.size - icon_size) / 2, icon_size));
|
||||
}
|
||||
title_pos.x = icon_area.position.x + icon_area.size.width + icon_hsep;
|
||||
title_pos.x = icon_area.position.x + icon_area.size.width + theme_cache.code_completion_icon_separation;
|
||||
|
||||
tl->set_width(code_completion_rect.size.width - (icon_area_size.x + icon_hsep));
|
||||
tl->set_width(code_completion_rect.size.width - (icon_area_size.x + theme_cache.code_completion_icon_separation));
|
||||
if (rtl) {
|
||||
if (code_completion_options[l].default_value.get_type() == Variant::COLOR) {
|
||||
draw_rect(Rect2(Point2(code_completion_rect.position.x, icon_area.position.y), icon_area_size), (Color)code_completion_options[l].default_value);
|
||||
|
@ -176,14 +139,14 @@ void CodeEdit::_notification(int p_what) {
|
|||
tl->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_LEFT);
|
||||
}
|
||||
|
||||
Point2 match_pos = Point2(code_completion_rect.position.x + icon_area_size.x + icon_hsep, code_completion_rect.position.y + i * row_height);
|
||||
Point2 match_pos = Point2(code_completion_rect.position.x + icon_area_size.x + theme_cache.code_completion_icon_separation, code_completion_rect.position.y + i * row_height);
|
||||
|
||||
for (int j = 0; j < code_completion_options[l].matches.size(); j++) {
|
||||
Pair<int, int> match = code_completion_options[l].matches[j];
|
||||
int match_offset = font->get_string_size(code_completion_options[l].display.substr(0, match.first), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width;
|
||||
int match_len = font->get_string_size(code_completion_options[l].display.substr(match.first, match.second), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width;
|
||||
int match_offset = theme_cache.font->get_string_size(code_completion_options[l].display.substr(0, match.first), HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).width;
|
||||
int match_len = theme_cache.font->get_string_size(code_completion_options[l].display.substr(match.first, match.second), HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).width;
|
||||
|
||||
draw_rect(Rect2(match_pos + Point2(match_offset, 0), Size2(match_len, row_height)), code_completion_existing_color);
|
||||
draw_rect(Rect2(match_pos + Point2(match_offset, 0), Size2(match_len, row_height)), theme_cache.code_completion_existing_color);
|
||||
}
|
||||
|
||||
tl->draw(ci, title_pos, code_completion_options[l].font_color);
|
||||
|
@ -191,9 +154,9 @@ void CodeEdit::_notification(int p_what) {
|
|||
|
||||
/* Draw a small scroll rectangle to show a position in the options. */
|
||||
if (scroll_width) {
|
||||
Color scroll_color = is_code_completion_scroll_hovered || is_code_completion_scroll_pressed ? code_completion_scroll_hovered_color : code_completion_scroll_color;
|
||||
Color scroll_color = is_code_completion_scroll_hovered || is_code_completion_scroll_pressed ? theme_cache.code_completion_scroll_hovered_color : theme_cache.code_completion_scroll_color;
|
||||
|
||||
float r = (float)code_completion_max_lines / code_completion_options_count;
|
||||
float r = (float)theme_cache.code_completion_max_lines / code_completion_options_count;
|
||||
float o = (float)code_completion_line_ofs / code_completion_options_count;
|
||||
draw_rect(Rect2(code_completion_rect.position.x + code_completion_rect.size.width, code_completion_rect.position.y + o * code_completion_rect.size.y, scroll_width, code_completion_rect.size.y * r), scroll_color);
|
||||
}
|
||||
|
@ -201,31 +164,29 @@ void CodeEdit::_notification(int p_what) {
|
|||
|
||||
/* Code hint */
|
||||
if (caret_visible && !code_hint.is_empty() && (!code_completion_active || (code_completion_below != code_hint_draw_below))) {
|
||||
const int font_height = font->get_height(font_size);
|
||||
Ref<StyleBox> sb = get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"));
|
||||
Color color = get_theme_color(SNAME("font_color"), SNAME("TooltipLabel"));
|
||||
const int font_height = theme_cache.font->get_height(theme_cache.font_size);
|
||||
|
||||
Vector<String> code_hint_lines = code_hint.split("\n");
|
||||
int line_count = code_hint_lines.size();
|
||||
|
||||
int max_width = 0;
|
||||
for (int i = 0; i < line_count; i++) {
|
||||
max_width = MAX(max_width, font->get_string_size(code_hint_lines[i], HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x);
|
||||
max_width = MAX(max_width, theme_cache.font->get_string_size(code_hint_lines[i], HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).x);
|
||||
}
|
||||
Size2 minsize = sb->get_minimum_size() + Size2(max_width, line_count * font_height + (line_spacing * line_count - 1));
|
||||
Size2 minsize = theme_cache.code_hint_style->get_minimum_size() + Size2(max_width, line_count * font_height + (theme_cache.line_spacing * line_count - 1));
|
||||
|
||||
int offset = font->get_string_size(code_hint_lines[0].substr(0, code_hint_lines[0].find(String::chr(0xFFFF))), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x;
|
||||
int offset = theme_cache.font->get_string_size(code_hint_lines[0].substr(0, code_hint_lines[0].find(String::chr(0xFFFF))), HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).x;
|
||||
if (code_hint_xpos == -0xFFFF) {
|
||||
code_hint_xpos = get_caret_draw_pos().x - offset;
|
||||
}
|
||||
Point2 hint_ofs = Vector2(code_hint_xpos, get_caret_draw_pos().y);
|
||||
if (code_hint_draw_below) {
|
||||
hint_ofs.y += line_spacing / 2.0f;
|
||||
hint_ofs.y += theme_cache.line_spacing / 2.0f;
|
||||
} else {
|
||||
hint_ofs.y -= (minsize.y + row_height) - line_spacing;
|
||||
hint_ofs.y -= (minsize.y + row_height) - theme_cache.line_spacing;
|
||||
}
|
||||
|
||||
draw_style_box(sb, Rect2(hint_ofs, minsize));
|
||||
draw_style_box(theme_cache.code_hint_style, Rect2(hint_ofs, minsize));
|
||||
|
||||
int yofs = 0;
|
||||
for (int i = 0; i < line_count; i++) {
|
||||
|
@ -234,31 +195,80 @@ void CodeEdit::_notification(int p_what) {
|
|||
int begin = 0;
|
||||
int end = 0;
|
||||
if (line.contains(String::chr(0xFFFF))) {
|
||||
begin = font->get_string_size(line.substr(0, line.find(String::chr(0xFFFF))), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x;
|
||||
end = font->get_string_size(line.substr(0, line.rfind(String::chr(0xFFFF))), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x;
|
||||
begin = theme_cache.font->get_string_size(line.substr(0, line.find(String::chr(0xFFFF))), HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).x;
|
||||
end = theme_cache.font->get_string_size(line.substr(0, line.rfind(String::chr(0xFFFF))), HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).x;
|
||||
}
|
||||
|
||||
Point2 round_ofs = hint_ofs + sb->get_offset() + Vector2(0, font->get_ascent(font_size) + font_height * i + yofs);
|
||||
Point2 round_ofs = hint_ofs + theme_cache.code_hint_style->get_offset() + Vector2(0, theme_cache.font->get_ascent(theme_cache.font_size) + font_height * i + yofs);
|
||||
round_ofs = round_ofs.round();
|
||||
draw_string(font, round_ofs, line.replace(String::chr(0xFFFF), ""), HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color);
|
||||
draw_string(theme_cache.font, round_ofs, line.replace(String::chr(0xFFFF), ""), HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size, theme_cache.code_hint_color);
|
||||
if (end > 0) {
|
||||
// Draw an underline for the currently edited function parameter.
|
||||
const Vector2 b = hint_ofs + sb->get_offset() + Vector2(begin, font_height + font_height * i + yofs);
|
||||
draw_line(b, b + Vector2(end - begin, 0), color, 2);
|
||||
const Vector2 b = hint_ofs + theme_cache.code_hint_style->get_offset() + Vector2(begin, font_height + font_height * i + yofs);
|
||||
draw_line(b, b + Vector2(end - begin, 0), theme_cache.code_hint_color, 2);
|
||||
|
||||
// Draw a translucent text highlight as well.
|
||||
const Rect2 highlight_rect = Rect2(
|
||||
b - Vector2(0, font_height),
|
||||
Vector2(end - begin, font_height));
|
||||
draw_rect(highlight_rect, color * Color(1, 1, 1, 0.2));
|
||||
draw_rect(highlight_rect, theme_cache.code_hint_color * Color(1, 1, 1, 0.2));
|
||||
}
|
||||
yofs += line_spacing;
|
||||
yofs += theme_cache.line_spacing;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
void CodeEdit::_update_theme_item_cache() {
|
||||
TextEdit::_update_theme_item_cache();
|
||||
|
||||
/* Gutters */
|
||||
theme_cache.code_folding_color = get_theme_color(SNAME("code_folding_color"));
|
||||
theme_cache.can_fold_icon = get_theme_icon(SNAME("can_fold"));
|
||||
theme_cache.folded_icon = get_theme_icon(SNAME("folded"));
|
||||
theme_cache.folded_eol_icon = get_theme_icon(SNAME("folded_eol_icon"));
|
||||
|
||||
theme_cache.breakpoint_color = get_theme_color(SNAME("breakpoint_color"));
|
||||
theme_cache.breakpoint_icon = get_theme_icon(SNAME("breakpoint"));
|
||||
|
||||
theme_cache.bookmark_color = get_theme_color(SNAME("bookmark_color"));
|
||||
theme_cache.bookmark_icon = get_theme_icon(SNAME("bookmark"));
|
||||
|
||||
theme_cache.executing_line_color = get_theme_color(SNAME("executing_line_color"));
|
||||
theme_cache.executing_line_icon = get_theme_icon(SNAME("executing_line"));
|
||||
|
||||
theme_cache.line_number_color = get_theme_color(SNAME("line_number_color"));
|
||||
|
||||
/* Code Completion */
|
||||
theme_cache.code_completion_style = get_theme_stylebox(SNAME("completion"));
|
||||
theme_cache.code_completion_icon_separation = get_theme_constant(SNAME("h_separation"), SNAME("ItemList"));
|
||||
|
||||
theme_cache.code_completion_max_width = get_theme_constant(SNAME("completion_max_width"));
|
||||
theme_cache.code_completion_max_lines = get_theme_constant(SNAME("completion_lines"));
|
||||
theme_cache.code_completion_scroll_width = get_theme_constant(SNAME("completion_scroll_width"));
|
||||
theme_cache.code_completion_scroll_color = get_theme_color(SNAME("completion_scroll_color"));
|
||||
theme_cache.code_completion_scroll_hovered_color = get_theme_color(SNAME("completion_scroll_hovered_color"));
|
||||
theme_cache.code_completion_background_color = get_theme_color(SNAME("completion_background_color"));
|
||||
theme_cache.code_completion_selected_color = get_theme_color(SNAME("completion_selected_color"));
|
||||
theme_cache.code_completion_existing_color = get_theme_color(SNAME("completion_existing_color"));
|
||||
|
||||
/* Code hint */
|
||||
theme_cache.code_hint_style = get_theme_stylebox(SNAME("panel"), SNAME("TooltipPanel"));
|
||||
theme_cache.code_hint_color = get_theme_color(SNAME("font_color"), SNAME("TooltipLabel"));
|
||||
|
||||
/* Line length guideline */
|
||||
theme_cache.line_length_guideline_color = get_theme_color(SNAME("line_length_guideline_color"));
|
||||
|
||||
/* Other visuals */
|
||||
theme_cache.style_normal = get_theme_stylebox(SNAME("normal"));
|
||||
|
||||
theme_cache.font = get_theme_font(SNAME("font"));
|
||||
theme_cache.font_size = get_theme_font_size(SNAME("font_size"));
|
||||
|
||||
theme_cache.line_spacing = get_theme_constant(SNAME("line_spacing"));
|
||||
}
|
||||
|
||||
void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
|
||||
Ref<InputEventMouseButton> mb = p_gui_input;
|
||||
if (mb.is_valid()) {
|
||||
|
@ -355,7 +365,7 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
|
|||
if (is_line_folded(line)) {
|
||||
int wrap_index = get_line_wrap_index_at_column(line, col);
|
||||
if (wrap_index == get_line_wrap_count(line)) {
|
||||
int eol_icon_width = folded_eol_icon->get_width();
|
||||
int eol_icon_width = theme_cache.folded_eol_icon->get_width();
|
||||
int left_margin = get_total_gutter_width() + eol_icon_width + get_line_width(line, wrap_index) - get_h_scroll();
|
||||
if (mpos.x > left_margin && mpos.x <= left_margin + eol_icon_width + 3) {
|
||||
unfold_line(line);
|
||||
|
@ -499,14 +509,14 @@ void CodeEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
|
|||
return;
|
||||
}
|
||||
if (k->is_action("ui_page_up", true)) {
|
||||
code_completion_current_selected = MAX(0, code_completion_current_selected - code_completion_max_lines);
|
||||
code_completion_current_selected = MAX(0, code_completion_current_selected - theme_cache.code_completion_max_lines);
|
||||
code_completion_force_item_center = -1;
|
||||
queue_redraw();
|
||||
accept_event();
|
||||
return;
|
||||
}
|
||||
if (k->is_action("ui_page_down", true)) {
|
||||
code_completion_current_selected = MIN(code_completion_options.size() - 1, code_completion_current_selected + code_completion_max_lines);
|
||||
code_completion_current_selected = MIN(code_completion_options.size() - 1, code_completion_current_selected + theme_cache.code_completion_max_lines);
|
||||
code_completion_force_item_center = -1;
|
||||
queue_redraw();
|
||||
accept_event();
|
||||
|
@ -635,7 +645,7 @@ Control::CursorShape CodeEdit::get_cursor_shape(const Point2 &p_pos) const {
|
|||
if (line != -1 && is_line_folded(line)) {
|
||||
int wrap_index = get_line_wrap_index_at_column(line, col);
|
||||
if (wrap_index == get_line_wrap_count(line)) {
|
||||
int eol_icon_width = folded_eol_icon->get_width();
|
||||
int eol_icon_width = theme_cache.folded_eol_icon->get_width();
|
||||
int left_margin = get_total_gutter_width() + eol_icon_width + get_line_width(line, wrap_index) - get_h_scroll();
|
||||
if (p_pos.x > left_margin && p_pos.x <= left_margin + eol_icon_width + 3) {
|
||||
return CURSOR_POINTING_HAND;
|
||||
|
@ -1246,7 +1256,7 @@ bool CodeEdit::is_drawing_executing_lines_gutter() const {
|
|||
}
|
||||
|
||||
void CodeEdit::_main_gutter_draw_callback(int p_line, int p_gutter, const Rect2 &p_region) {
|
||||
if (draw_breakpoints && breakpoint_icon.is_valid()) {
|
||||
if (draw_breakpoints && theme_cache.breakpoint_icon.is_valid()) {
|
||||
bool breakpointed = is_line_breakpointed(p_line);
|
||||
bool hovering = p_region.has_point(get_local_mouse_pos());
|
||||
bool shift_pressed = Input::get_singleton()->is_key_pressed(Key::SHIFT);
|
||||
|
@ -1254,18 +1264,18 @@ void CodeEdit::_main_gutter_draw_callback(int p_line, int p_gutter, const Rect2
|
|||
if (breakpointed || (hovering && !is_dragging_cursor() && !shift_pressed)) {
|
||||
int padding = p_region.size.x / 6;
|
||||
|
||||
Color use_color = breakpoint_color;
|
||||
Color use_color = theme_cache.breakpoint_color;
|
||||
if (hovering && !shift_pressed) {
|
||||
use_color = breakpointed ? use_color.lightened(0.3) : use_color.darkened(0.5);
|
||||
}
|
||||
Rect2 icon_region = p_region;
|
||||
icon_region.position += Point2(padding, padding);
|
||||
icon_region.size -= Point2(padding, padding) * 2;
|
||||
breakpoint_icon->draw_rect(get_canvas_item(), icon_region, false, use_color);
|
||||
theme_cache.breakpoint_icon->draw_rect(get_canvas_item(), icon_region, false, use_color);
|
||||
}
|
||||
}
|
||||
|
||||
if (draw_bookmarks && bookmark_icon.is_valid()) {
|
||||
if (draw_bookmarks && theme_cache.bookmark_icon.is_valid()) {
|
||||
bool bookmarked = is_line_bookmarked(p_line);
|
||||
bool hovering = p_region.has_point(get_local_mouse_pos());
|
||||
bool shift_pressed = Input::get_singleton()->is_key_pressed(Key::SHIFT);
|
||||
|
@ -1274,25 +1284,25 @@ void CodeEdit::_main_gutter_draw_callback(int p_line, int p_gutter, const Rect2
|
|||
int horizontal_padding = p_region.size.x / 2;
|
||||
int vertical_padding = p_region.size.y / 4;
|
||||
|
||||
Color use_color = bookmark_color;
|
||||
Color use_color = theme_cache.bookmark_color;
|
||||
if (hovering && shift_pressed) {
|
||||
use_color = bookmarked ? use_color.lightened(0.3) : use_color.darkened(0.5);
|
||||
}
|
||||
Rect2 icon_region = p_region;
|
||||
icon_region.position += Point2(horizontal_padding, 0);
|
||||
icon_region.size -= Point2(horizontal_padding * 1.1, vertical_padding);
|
||||
bookmark_icon->draw_rect(get_canvas_item(), icon_region, false, use_color);
|
||||
theme_cache.bookmark_icon->draw_rect(get_canvas_item(), icon_region, false, use_color);
|
||||
}
|
||||
}
|
||||
|
||||
if (draw_executing_lines && is_line_executing(p_line) && executing_line_icon.is_valid()) {
|
||||
if (draw_executing_lines && is_line_executing(p_line) && theme_cache.executing_line_icon.is_valid()) {
|
||||
int horizontal_padding = p_region.size.x / 10;
|
||||
int vertical_padding = p_region.size.y / 4;
|
||||
|
||||
Rect2 icon_region = p_region;
|
||||
icon_region.position += Point2(horizontal_padding, vertical_padding);
|
||||
icon_region.size -= Point2(horizontal_padding, vertical_padding) * 2;
|
||||
executing_line_icon->draw_rect(get_canvas_item(), icon_region, false, executing_line_color);
|
||||
theme_cache.executing_line_icon->draw_rect(get_canvas_item(), icon_region, false, theme_cache.executing_line_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1416,11 +1426,11 @@ void CodeEdit::_line_number_draw_callback(int p_line, int p_gutter, const Rect2
|
|||
}
|
||||
Ref<TextLine> tl;
|
||||
tl.instantiate();
|
||||
tl->add_string(fc, font, font_size);
|
||||
tl->add_string(fc, theme_cache.font, theme_cache.font_size);
|
||||
int yofs = p_region.position.y + (get_line_height() - tl->get_size().y) / 2;
|
||||
Color number_color = get_line_gutter_item_color(p_line, line_number_gutter);
|
||||
if (number_color == Color(1, 1, 1)) {
|
||||
number_color = line_number_color;
|
||||
number_color = theme_cache.line_number_color;
|
||||
}
|
||||
tl->draw(get_canvas_item(), Point2(p_region.position.x, yofs), number_color);
|
||||
}
|
||||
|
@ -1448,10 +1458,10 @@ void CodeEdit::_fold_gutter_draw_callback(int p_line, int p_gutter, Rect2 p_regi
|
|||
p_region.size -= Point2(horizontal_padding, vertical_padding) * 2;
|
||||
|
||||
if (can_fold_line(p_line)) {
|
||||
can_fold_icon->draw_rect(get_canvas_item(), p_region, false, folding_color);
|
||||
theme_cache.can_fold_icon->draw_rect(get_canvas_item(), p_region, false, theme_cache.code_folding_color);
|
||||
return;
|
||||
}
|
||||
folded_icon->draw_rect(get_canvas_item(), p_region, false, folding_color);
|
||||
theme_cache.folded_icon->draw_rect(get_canvas_item(), p_region, false, theme_cache.code_folding_color);
|
||||
}
|
||||
|
||||
/* Line Folding */
|
||||
|
@ -2866,13 +2876,13 @@ void CodeEdit::_filter_code_completion_candidates_impl() {
|
|||
offset = line_height;
|
||||
}
|
||||
|
||||
if (font.is_valid()) {
|
||||
max_width = MAX(max_width, font->get_string_size(option.display, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width + offset);
|
||||
if (theme_cache.font.is_valid()) {
|
||||
max_width = MAX(max_width, theme_cache.font->get_string_size(option.display, HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).width + offset);
|
||||
}
|
||||
code_completion_options.push_back(option);
|
||||
}
|
||||
|
||||
code_completion_longest_line = MIN(max_width, code_completion_max_width * font_size);
|
||||
code_completion_longest_line = MIN(max_width, theme_cache.code_completion_max_width * theme_cache.font_size);
|
||||
code_completion_current_selected = 0;
|
||||
code_completion_force_item_center = -1;
|
||||
code_completion_active = true;
|
||||
|
@ -2987,8 +2997,8 @@ void CodeEdit::_filter_code_completion_candidates_impl() {
|
|||
|
||||
if (string_to_complete.length() == 0) {
|
||||
code_completion_options.push_back(option);
|
||||
if (font.is_valid()) {
|
||||
max_width = MAX(max_width, font->get_string_size(option.display, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width + offset);
|
||||
if (theme_cache.font.is_valid()) {
|
||||
max_width = MAX(max_width, theme_cache.font->get_string_size(option.display, HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).width + offset);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -3095,8 +3105,8 @@ void CodeEdit::_filter_code_completion_candidates_impl() {
|
|||
option.matches.append_array(ssq_matches);
|
||||
completion_options_subseq.push_back(option);
|
||||
}
|
||||
if (font.is_valid()) {
|
||||
max_width = MAX(max_width, font->get_string_size(option.display, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width + offset);
|
||||
if (theme_cache.font.is_valid()) {
|
||||
max_width = MAX(max_width, theme_cache.font->get_string_size(option.display, HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).width + offset);
|
||||
}
|
||||
} else if (!*ssq_lower) { // Matched the whole subsequence in s_lower.
|
||||
option.matches.clear();
|
||||
|
@ -3114,8 +3124,8 @@ void CodeEdit::_filter_code_completion_candidates_impl() {
|
|||
option.matches.append_array(ssq_lower_matches);
|
||||
completion_options_subseq_casei.push_back(option);
|
||||
}
|
||||
if (font.is_valid()) {
|
||||
max_width = MAX(max_width, font->get_string_size(option.display, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).width + offset);
|
||||
if (theme_cache.font.is_valid()) {
|
||||
max_width = MAX(max_width, theme_cache.font->get_string_size(option.display, HORIZONTAL_ALIGNMENT_LEFT, -1, theme_cache.font_size).width + offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3138,7 +3148,7 @@ void CodeEdit::_filter_code_completion_candidates_impl() {
|
|||
return;
|
||||
}
|
||||
|
||||
code_completion_longest_line = MIN(max_width, code_completion_max_width * font_size);
|
||||
code_completion_longest_line = MIN(max_width, theme_cache.code_completion_max_width * theme_cache.font_size);
|
||||
code_completion_current_selected = 0;
|
||||
code_completion_force_item_center = -1;
|
||||
code_completion_active = true;
|
||||
|
@ -3174,8 +3184,8 @@ void CodeEdit::_text_changed() {
|
|||
line_number_digits++;
|
||||
}
|
||||
|
||||
if (font.is_valid()) {
|
||||
set_gutter_width(line_number_gutter, (line_number_digits + 1) * font->get_char_size('0', font_size).width);
|
||||
if (theme_cache.font.is_valid()) {
|
||||
set_gutter_width(line_number_gutter, (line_number_digits + 1) * theme_cache.font->get_char_size('0', theme_cache.font_size).width);
|
||||
}
|
||||
|
||||
lc = get_line_count();
|
||||
|
|
|
@ -93,32 +93,22 @@ private:
|
|||
// breakpoints
|
||||
HashMap<int, bool> breakpointed_lines;
|
||||
bool draw_breakpoints = false;
|
||||
Color breakpoint_color = Color(1, 1, 1);
|
||||
Ref<Texture2D> breakpoint_icon = Ref<Texture2D>();
|
||||
|
||||
// bookmarks
|
||||
bool draw_bookmarks = false;
|
||||
Color bookmark_color = Color(1, 1, 1);
|
||||
Ref<Texture2D> bookmark_icon = Ref<Texture2D>();
|
||||
|
||||
// executing lines
|
||||
bool draw_executing_lines = false;
|
||||
Color executing_line_color = Color(1, 1, 1);
|
||||
Ref<Texture2D> executing_line_icon = Ref<Texture2D>();
|
||||
|
||||
/* Line numbers */
|
||||
int line_number_gutter = -1;
|
||||
int line_number_digits = 1;
|
||||
String line_number_padding = " ";
|
||||
Color line_number_color = Color(1, 1, 1);
|
||||
void _line_number_draw_callback(int p_line, int p_gutter, const Rect2 &p_region);
|
||||
|
||||
/* Fold Gutter */
|
||||
int fold_gutter = -1;
|
||||
bool draw_fold_gutter = false;
|
||||
Color folding_color = Color(1, 1, 1);
|
||||
Ref<Texture2D> can_fold_icon = Ref<Texture2D>();
|
||||
Ref<Texture2D> folded_icon = Ref<Texture2D>();
|
||||
void _fold_gutter_draw_callback(int p_line, int p_gutter, Rect2 p_region);
|
||||
|
||||
void _gutter_clicked(int p_line, int p_gutter);
|
||||
|
@ -199,15 +189,6 @@ private:
|
|||
bool code_completion_enabled = false;
|
||||
bool code_completion_forced = false;
|
||||
|
||||
int code_completion_max_width = 0;
|
||||
int code_completion_max_lines = 7;
|
||||
int code_completion_scroll_width = 0;
|
||||
Color code_completion_scroll_color = Color(0, 0, 0, 0);
|
||||
Color code_completion_scroll_hovered_color = Color(0, 0, 0, 0);
|
||||
Color code_completion_background_color = Color(0, 0, 0, 0);
|
||||
Color code_completion_selected_color = Color(0, 0, 0, 0);
|
||||
Color code_completion_existing_color = Color(0, 0, 0, 0);
|
||||
|
||||
bool code_completion_active = false;
|
||||
bool is_code_completion_scroll_hovered = false;
|
||||
bool is_code_completion_scroll_pressed = false;
|
||||
|
@ -230,7 +211,6 @@ private:
|
|||
|
||||
/* Line length guidelines */
|
||||
TypedArray<int> line_length_guideline_columns;
|
||||
Color line_length_guideline_color;
|
||||
|
||||
/* Symbol lookup */
|
||||
bool symbol_lookup_on_click_enabled = false;
|
||||
|
@ -240,12 +220,51 @@ private:
|
|||
Point2i symbol_lookup_pos;
|
||||
|
||||
/* Visual */
|
||||
Ref<StyleBox> style_normal;
|
||||
struct ThemeCache {
|
||||
/* Gutters */
|
||||
Color code_folding_color = Color(1, 1, 1);
|
||||
Ref<Texture2D> can_fold_icon;
|
||||
Ref<Texture2D> folded_icon;
|
||||
Ref<Texture2D> folded_eol_icon;
|
||||
|
||||
Ref<Font> font;
|
||||
int font_size = 16;
|
||||
Color breakpoint_color = Color(1, 1, 1);
|
||||
Ref<Texture2D> breakpoint_icon = Ref<Texture2D>();
|
||||
|
||||
int line_spacing = 1;
|
||||
Color bookmark_color = Color(1, 1, 1);
|
||||
Ref<Texture2D> bookmark_icon = Ref<Texture2D>();
|
||||
|
||||
Color executing_line_color = Color(1, 1, 1);
|
||||
Ref<Texture2D> executing_line_icon = Ref<Texture2D>();
|
||||
|
||||
Color line_number_color = Color(1, 1, 1);
|
||||
|
||||
/* Code Completion */
|
||||
Ref<StyleBox> code_completion_style;
|
||||
int code_completion_icon_separation = 0;
|
||||
|
||||
int code_completion_max_width = 0;
|
||||
int code_completion_max_lines = 7;
|
||||
int code_completion_scroll_width = 0;
|
||||
Color code_completion_scroll_color = Color(0, 0, 0, 0);
|
||||
Color code_completion_scroll_hovered_color = Color(0, 0, 0, 0);
|
||||
Color code_completion_background_color = Color(0, 0, 0, 0);
|
||||
Color code_completion_selected_color = Color(0, 0, 0, 0);
|
||||
Color code_completion_existing_color = Color(0, 0, 0, 0);
|
||||
|
||||
/* Code hint */
|
||||
Ref<StyleBox> code_hint_style;
|
||||
Color code_hint_color;
|
||||
|
||||
/* Line length guideline */
|
||||
Color line_length_guideline_color;
|
||||
|
||||
/* Other visuals */
|
||||
Ref<StyleBox> style_normal;
|
||||
|
||||
Ref<Font> font;
|
||||
int font_size = 16;
|
||||
int line_spacing = 1;
|
||||
} theme_cache;
|
||||
|
||||
/* Callbacks */
|
||||
int lines_edited_changed = 0;
|
||||
|
@ -258,9 +277,10 @@ private:
|
|||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
virtual void _update_theme_item_cache() override;
|
||||
|
||||
/* Text manipulation */
|
||||
|
||||
// Overridable actions
|
||||
|
|
|
@ -417,6 +417,10 @@ void TextEdit::Text::move_gutters(int p_from_line, int p_to_line) {
|
|||
|
||||
void TextEdit::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_POSTINITIALIZE: {
|
||||
_update_caches();
|
||||
} break;
|
||||
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
_update_caches();
|
||||
if (caret_pos_dirty) {
|
||||
|
@ -512,28 +516,28 @@ void TextEdit::_notification(int p_what) {
|
|||
|
||||
RID ci = get_canvas_item();
|
||||
RenderingServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
|
||||
int xmargin_beg = style_normal->get_margin(SIDE_LEFT) + gutters_width + gutter_padding;
|
||||
int xmargin_beg = theme_cache.style_normal->get_margin(SIDE_LEFT) + gutters_width + gutter_padding;
|
||||
|
||||
int xmargin_end = size.width - style_normal->get_margin(SIDE_RIGHT);
|
||||
int xmargin_end = size.width - theme_cache.style_normal->get_margin(SIDE_RIGHT);
|
||||
if (draw_minimap) {
|
||||
xmargin_end -= minimap_width;
|
||||
}
|
||||
// Let's do it easy for now.
|
||||
style_normal->draw(ci, Rect2(Point2(), size));
|
||||
theme_cache.style_normal->draw(ci, Rect2(Point2(), size));
|
||||
if (!editable) {
|
||||
style_readonly->draw(ci, Rect2(Point2(), size));
|
||||
theme_cache.style_readonly->draw(ci, Rect2(Point2(), size));
|
||||
draw_caret = false;
|
||||
}
|
||||
if (has_focus()) {
|
||||
style_focus->draw(ci, Rect2(Point2(), size));
|
||||
theme_cache.style_focus->draw(ci, Rect2(Point2(), size));
|
||||
}
|
||||
|
||||
int visible_rows = get_visible_line_count() + 1;
|
||||
|
||||
Color color = !editable ? font_readonly_color : font_color;
|
||||
Color color = !editable ? theme_cache.font_readonly_color : theme_cache.font_color;
|
||||
|
||||
if (background_color.a > 0.01) {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(), get_size()), background_color);
|
||||
if (theme_cache.background_color.a > 0.01) {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(), get_size()), theme_cache.background_color);
|
||||
}
|
||||
|
||||
Vector<BraceMatchingData> brace_matching;
|
||||
|
@ -734,7 +738,7 @@ void TextEdit::_notification(int p_what) {
|
|||
viewport_alpha = 0.1;
|
||||
}
|
||||
|
||||
const Color viewport_color = (background_color.get_v() < 0.5) ? Color(1, 1, 1, viewport_alpha) : Color(0, 0, 0, viewport_alpha);
|
||||
const Color viewport_color = (theme_cache.background_color.get_v() < 0.5) ? Color(1, 1, 1, viewport_alpha) : Color(0, 0, 0, viewport_alpha);
|
||||
if (rtl) {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - (xmargin_end + 2) - minimap_width, viewport_offset_y, minimap_width, viewport_height), viewport_color);
|
||||
} else {
|
||||
|
@ -763,9 +767,9 @@ void TextEdit::_notification(int p_what) {
|
|||
|
||||
Color line_background_color = text.get_line_background_color(minimap_line);
|
||||
line_background_color.a *= 0.6;
|
||||
Color current_color = font_color;
|
||||
Color current_color = theme_cache.font_color;
|
||||
if (!editable) {
|
||||
current_color = font_readonly_color;
|
||||
current_color = theme_cache.font_readonly_color;
|
||||
}
|
||||
|
||||
Vector<String> wrap_rows = get_line_wrapped_text(minimap_line);
|
||||
|
@ -793,9 +797,9 @@ void TextEdit::_notification(int p_what) {
|
|||
|
||||
if (caret_line_wrap_index_map.has(minimap_line) && caret_line_wrap_index_map[minimap_line].has(line_wrap_index) && highlight_current_line) {
|
||||
if (rtl) {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - (xmargin_end + 2) - minimap_width, i * 3, minimap_width, 2), current_line_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - (xmargin_end + 2) - minimap_width, i * 3, minimap_width, 2), theme_cache.current_line_color);
|
||||
} else {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), i * 3, minimap_width, 2), current_line_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2((xmargin_end + 2), i * 3, minimap_width, 2), theme_cache.current_line_color);
|
||||
}
|
||||
} else if (line_background_color != Color(0, 0, 0, 0)) {
|
||||
if (rtl) {
|
||||
|
@ -811,9 +815,9 @@ void TextEdit::_notification(int p_what) {
|
|||
for (int j = 0; j < str.length(); j++) {
|
||||
const Variant *color_data = color_map.getptr(last_wrap_column + j);
|
||||
if (color_data != nullptr) {
|
||||
current_color = (color_data->operator Dictionary()).get("color", font_color);
|
||||
current_color = (color_data->operator Dictionary()).get("color", theme_cache.font_color);
|
||||
if (!editable) {
|
||||
current_color.a = font_readonly_color.a;
|
||||
current_color.a = theme_cache.font_readonly_color.a;
|
||||
}
|
||||
}
|
||||
color = current_color;
|
||||
|
@ -875,16 +879,16 @@ void TextEdit::_notification(int p_what) {
|
|||
int top_limit_y = 0;
|
||||
int bottom_limit_y = get_size().height;
|
||||
if (!editable) {
|
||||
top_limit_y += style_readonly->get_margin(SIDE_TOP);
|
||||
bottom_limit_y -= style_readonly->get_margin(SIDE_BOTTOM);
|
||||
top_limit_y += theme_cache.style_readonly->get_margin(SIDE_TOP);
|
||||
bottom_limit_y -= theme_cache.style_readonly->get_margin(SIDE_BOTTOM);
|
||||
} else {
|
||||
top_limit_y += style_normal->get_margin(SIDE_TOP);
|
||||
bottom_limit_y -= style_normal->get_margin(SIDE_BOTTOM);
|
||||
top_limit_y += theme_cache.style_normal->get_margin(SIDE_TOP);
|
||||
bottom_limit_y -= theme_cache.style_normal->get_margin(SIDE_BOTTOM);
|
||||
}
|
||||
|
||||
// Draw main text.
|
||||
line_drawing_cache.clear();
|
||||
int row_height = draw_placeholder ? placeholder_line_height + line_spacing : get_line_height();
|
||||
int row_height = draw_placeholder ? placeholder_line_height + theme_cache.line_spacing : get_line_height();
|
||||
int line = first_vis_line;
|
||||
for (int i = 0; i < draw_amount; i++) {
|
||||
line++;
|
||||
|
@ -909,9 +913,9 @@ void TextEdit::_notification(int p_what) {
|
|||
Dictionary color_map = _get_line_syntax_highlighting(line);
|
||||
|
||||
// Ensure we at least use the font color.
|
||||
Color current_color = !editable ? font_readonly_color : font_color;
|
||||
Color current_color = !editable ? theme_cache.font_readonly_color : theme_cache.font_color;
|
||||
if (draw_placeholder) {
|
||||
current_color = font_placeholder_color;
|
||||
current_color = theme_cache.font_placeholder_color;
|
||||
}
|
||||
|
||||
const Ref<TextParagraph> ldata = draw_placeholder ? placeholder_data_buf : text.get_line_data(line);
|
||||
|
@ -933,14 +937,14 @@ void TextEdit::_notification(int p_what) {
|
|||
int ofs_x = 0;
|
||||
int ofs_y = 0;
|
||||
if (!editable) {
|
||||
ofs_x = style_readonly->get_offset().x / 2;
|
||||
ofs_x -= style_normal->get_offset().x / 2;
|
||||
ofs_y = style_readonly->get_offset().y / 2;
|
||||
ofs_x = theme_cache.style_readonly->get_offset().x / 2;
|
||||
ofs_x -= theme_cache.style_normal->get_offset().x / 2;
|
||||
ofs_y = theme_cache.style_readonly->get_offset().y / 2;
|
||||
} else {
|
||||
ofs_y = style_normal->get_offset().y / 2;
|
||||
ofs_y = theme_cache.style_normal->get_offset().y / 2;
|
||||
}
|
||||
|
||||
ofs_y += i * row_height + line_spacing / 2;
|
||||
ofs_y += i * row_height + theme_cache.line_spacing / 2;
|
||||
ofs_y -= first_visible_line_wrap_ofs * row_height;
|
||||
ofs_y -= _get_v_scroll_offset() * row_height;
|
||||
|
||||
|
@ -969,20 +973,20 @@ void TextEdit::_notification(int p_what) {
|
|||
// Draw line background if empty as we won't loop at all.
|
||||
if (caret_line_wrap_index_map.has(line) && caret_line_wrap_index_map[line].has(line_wrap_index) && highlight_current_line) {
|
||||
if (rtl) {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - ofs_x - xmargin_end, ofs_y, xmargin_end, row_height), current_line_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - ofs_x - xmargin_end, ofs_y, xmargin_end, row_height), theme_cache.current_line_color);
|
||||
} else {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, row_height), current_line_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, row_height), theme_cache.current_line_color);
|
||||
}
|
||||
}
|
||||
|
||||
// Give visual indication of empty selected line.
|
||||
for (int c = 0; c < carets.size(); c++) {
|
||||
if (has_selection(c) && line >= get_selection_from_line(c) && line <= get_selection_to_line(c) && char_margin >= xmargin_beg) {
|
||||
float char_w = font->get_char_size(' ', font_size).width;
|
||||
float char_w = theme_cache.font->get_char_size(' ', theme_cache.font_size).width;
|
||||
if (rtl) {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - xmargin_beg - ofs_x - char_w, ofs_y, char_w, row_height), selection_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - xmargin_beg - ofs_x - char_w, ofs_y, char_w, row_height), theme_cache.selection_color);
|
||||
} else {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, char_w, row_height), selection_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, char_w, row_height), theme_cache.selection_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -990,9 +994,9 @@ void TextEdit::_notification(int p_what) {
|
|||
// If it has text, then draw current line marker in the margin, as line number etc will draw over it, draw the rest of line marker later.
|
||||
if (caret_line_wrap_index_map.has(line) && caret_line_wrap_index_map[line].has(line_wrap_index) && highlight_current_line) {
|
||||
if (rtl) {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - ofs_x - xmargin_end, ofs_y, xmargin_end, row_height), current_line_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - ofs_x - xmargin_end, ofs_y, xmargin_end, row_height), theme_cache.current_line_color);
|
||||
} else {
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, row_height), current_line_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, row_height), theme_cache.current_line_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1002,7 +1006,7 @@ void TextEdit::_notification(int p_what) {
|
|||
|
||||
cache_entry.y_offset = ofs_y;
|
||||
|
||||
int gutter_offset = style_normal->get_margin(SIDE_LEFT);
|
||||
int gutter_offset = theme_cache.style_normal->get_margin(SIDE_LEFT);
|
||||
for (int g = 0; g < gutters.size(); g++) {
|
||||
const GutterInfo gutter = gutters[g];
|
||||
|
||||
|
@ -1019,11 +1023,11 @@ void TextEdit::_notification(int p_what) {
|
|||
|
||||
Ref<TextLine> tl;
|
||||
tl.instantiate();
|
||||
tl->add_string(txt, font, font_size);
|
||||
tl->add_string(txt, theme_cache.font, theme_cache.font_size);
|
||||
|
||||
int yofs = ofs_y + (row_height - tl->get_size().y) / 2;
|
||||
if (outline_size > 0 && outline_color.a > 0) {
|
||||
tl->draw_outline(ci, Point2(gutter_offset + ofs_x, yofs), outline_size, outline_color);
|
||||
if (theme_cache.outline_size > 0 && theme_cache.outline_color.a > 0) {
|
||||
tl->draw_outline(ci, Point2(gutter_offset + ofs_x, yofs), theme_cache.outline_size, theme_cache.outline_color);
|
||||
}
|
||||
tl->draw(ci, Point2(gutter_offset + ofs_x, yofs), get_line_gutter_item_color(line, g));
|
||||
} break;
|
||||
|
@ -1100,7 +1104,7 @@ void TextEdit::_notification(int p_what) {
|
|||
if (rect.position.x + rect.size.x > xmargin_end) {
|
||||
rect.size.x = xmargin_end - rect.position.x;
|
||||
}
|
||||
draw_rect(rect, selection_color, true);
|
||||
draw_rect(rect, theme_cache.selection_color, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1122,8 +1126,8 @@ void TextEdit::_notification(int p_what) {
|
|||
} else if (rect.position.x + rect.size.x > xmargin_end) {
|
||||
rect.size.x = xmargin_end - rect.position.x;
|
||||
}
|
||||
draw_rect(rect, search_result_color, true);
|
||||
draw_rect(rect, search_result_border_color, false);
|
||||
draw_rect(rect, theme_cache.search_result_color, true);
|
||||
draw_rect(rect, theme_cache.search_result_border_color, false);
|
||||
}
|
||||
|
||||
search_text_col = _get_column_pos_of_word(search_text, str, search_flags, search_text_col + search_text_len);
|
||||
|
@ -1146,7 +1150,7 @@ void TextEdit::_notification(int p_what) {
|
|||
} else if (rect.position.x + rect.size.x > xmargin_end) {
|
||||
rect.size.x = xmargin_end - rect.position.x;
|
||||
}
|
||||
draw_rect(rect, word_highlighted_color);
|
||||
draw_rect(rect, theme_cache.word_highlighted_color);
|
||||
}
|
||||
|
||||
highlighted_text_col = _get_column_pos_of_word(highlighted_text, str, SEARCH_MATCH_CASE | SEARCH_WHOLE_WORDS, highlighted_text_col + highlighted_text_len);
|
||||
|
@ -1160,7 +1164,7 @@ void TextEdit::_notification(int p_what) {
|
|||
while (lookup_symbol_word_col != -1) {
|
||||
Vector<Vector2> sel = TS->shaped_text_get_selection(rid, lookup_symbol_word_col + start, lookup_symbol_word_col + lookup_symbol_word_len + start);
|
||||
for (int j = 0; j < sel.size(); j++) {
|
||||
Rect2 rect = Rect2(sel[j].x + char_margin + ofs_x, ofs_y + (line_spacing / 2), sel[j].y - sel[j].x, row_height);
|
||||
Rect2 rect = Rect2(sel[j].x + char_margin + ofs_x, ofs_y + (theme_cache.line_spacing / 2), sel[j].y - sel[j].x, row_height);
|
||||
if (rect.position.x + rect.size.x <= xmargin_beg || rect.position.x > xmargin_end) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1170,8 +1174,8 @@ void TextEdit::_notification(int p_what) {
|
|||
} else if (rect.position.x + rect.size.x > xmargin_end) {
|
||||
rect.size.x = xmargin_end - rect.position.x;
|
||||
}
|
||||
rect.position.y += ceil(TS->shaped_text_get_ascent(rid)) + ceil(font->get_underline_position(font_size));
|
||||
rect.size.y = MAX(1, font->get_underline_thickness(font_size));
|
||||
rect.position.y += ceil(TS->shaped_text_get_ascent(rid)) + ceil(theme_cache.font->get_underline_position(theme_cache.font_size));
|
||||
rect.size.y = MAX(1, theme_cache.font->get_underline_thickness(theme_cache.font_size));
|
||||
draw_rect(rect, color);
|
||||
}
|
||||
|
||||
|
@ -1191,12 +1195,12 @@ void TextEdit::_notification(int p_what) {
|
|||
int last_visible_char = TS->shaped_text_get_range(rid).x;
|
||||
|
||||
float char_ofs = 0;
|
||||
if (outline_size > 0 && outline_color.a > 0) {
|
||||
if (theme_cache.outline_size > 0 && theme_cache.outline_color.a > 0) {
|
||||
for (int j = 0; j < gl_size; j++) {
|
||||
for (int k = 0; k < glyphs[j].repeat; k++) {
|
||||
if ((char_ofs + char_margin) >= xmargin_beg && (char_ofs + glyphs[j].advance + char_margin) <= xmargin_end) {
|
||||
if (glyphs[j].font_rid != RID()) {
|
||||
TS->font_draw_glyph_outline(glyphs[j].font_rid, ci, glyphs[j].font_size, outline_size, Vector2(char_margin + char_ofs + ofs_x + glyphs[j].x_off, ofs_y + glyphs[j].y_off), glyphs[j].index, outline_color);
|
||||
TS->font_draw_glyph_outline(glyphs[j].font_rid, ci, glyphs[j].font_size, theme_cache.outline_size, Vector2(char_margin + char_ofs + ofs_x + glyphs[j].x_off, ofs_y + glyphs[j].y_off), glyphs[j].index, theme_cache.outline_color);
|
||||
}
|
||||
}
|
||||
char_ofs += glyphs[j].advance;
|
||||
|
@ -1218,9 +1222,9 @@ void TextEdit::_notification(int p_what) {
|
|||
}
|
||||
const Variant *color_data = (color_start >= 0) ? color_map.getptr(color_start) : nullptr;
|
||||
if (color_data != nullptr) {
|
||||
current_color = (color_data->operator Dictionary()).get("color", font_color);
|
||||
if (!editable && current_color.a > font_readonly_color.a) {
|
||||
current_color.a = font_readonly_color.a;
|
||||
current_color = (color_data->operator Dictionary()).get("color", theme_cache.font_color);
|
||||
if (!editable && current_color.a > theme_cache.font_readonly_color.a) {
|
||||
current_color.a = theme_cache.font_readonly_color.a;
|
||||
}
|
||||
}
|
||||
Color gl_color = current_color;
|
||||
|
@ -1231,7 +1235,7 @@ void TextEdit::_notification(int p_what) {
|
|||
int sel_to = (line < get_selection_to_line(c)) ? TS->shaped_text_get_range(rid).y : get_selection_to_column(c);
|
||||
|
||||
if (glyphs[j].start >= sel_from && glyphs[j].end <= sel_to && use_selected_font_color) {
|
||||
gl_color = font_selected_color;
|
||||
gl_color = theme_cache.font_selected_color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1243,30 +1247,30 @@ void TextEdit::_notification(int p_what) {
|
|||
if ((brace_matching[c].open_match_line == line && brace_matching[c].open_match_column == glyphs[j].start) ||
|
||||
(get_caret_column(c) == glyphs[j].start && get_caret_line(c) == line && carets_wrap_index[c] == line_wrap_index && (brace_matching[c].open_matching || brace_matching[c].open_mismatch))) {
|
||||
if (brace_matching[c].open_mismatch) {
|
||||
gl_color = brace_mismatch_color;
|
||||
gl_color = theme_cache.brace_mismatch_color;
|
||||
}
|
||||
Rect2 rect = Rect2(char_pos, ofs_y + font->get_underline_position(font_size), glyphs[j].advance * glyphs[j].repeat, MAX(font->get_underline_thickness(font_size) * get_theme_default_base_scale(), 1));
|
||||
Rect2 rect = Rect2(char_pos, ofs_y + theme_cache.font->get_underline_position(theme_cache.font_size), glyphs[j].advance * glyphs[j].repeat, MAX(theme_cache.font->get_underline_thickness(theme_cache.font_size) * theme_cache.base_scale, 1));
|
||||
draw_rect(rect, gl_color);
|
||||
}
|
||||
|
||||
if ((brace_matching[c].close_match_line == line && brace_matching[c].close_match_column == glyphs[j].start) ||
|
||||
(get_caret_column(c) == glyphs[j].start + 1 && get_caret_line(c) == line && carets_wrap_index[c] == line_wrap_index && (brace_matching[c].close_matching || brace_matching[c].close_mismatch))) {
|
||||
if (brace_matching[c].close_mismatch) {
|
||||
gl_color = brace_mismatch_color;
|
||||
gl_color = theme_cache.brace_mismatch_color;
|
||||
}
|
||||
Rect2 rect = Rect2(char_pos, ofs_y + font->get_underline_position(font_size), glyphs[j].advance * glyphs[j].repeat, MAX(font->get_underline_thickness(font_size) * get_theme_default_base_scale(), 1));
|
||||
Rect2 rect = Rect2(char_pos, ofs_y + theme_cache.font->get_underline_position(theme_cache.font_size), glyphs[j].advance * glyphs[j].repeat, MAX(theme_cache.font->get_underline_thickness(theme_cache.font_size) * theme_cache.base_scale, 1));
|
||||
draw_rect(rect, gl_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (draw_tabs && ((glyphs[j].flags & TextServer::GRAPHEME_IS_TAB) == TextServer::GRAPHEME_IS_TAB)) {
|
||||
int yofs = (text_height - tab_icon->get_height()) / 2 - ldata->get_line_ascent(line_wrap_index);
|
||||
tab_icon->draw(ci, Point2(char_pos, ofs_y + yofs), gl_color);
|
||||
int yofs = (text_height - theme_cache.tab_icon->get_height()) / 2 - ldata->get_line_ascent(line_wrap_index);
|
||||
theme_cache.tab_icon->draw(ci, Point2(char_pos, ofs_y + yofs), gl_color);
|
||||
} else if (draw_spaces && ((glyphs[j].flags & TextServer::GRAPHEME_IS_SPACE) == TextServer::GRAPHEME_IS_SPACE) && ((glyphs[j].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL)) {
|
||||
int yofs = (text_height - space_icon->get_height()) / 2 - ldata->get_line_ascent(line_wrap_index);
|
||||
int xofs = (glyphs[j].advance * glyphs[j].repeat - space_icon->get_width()) / 2;
|
||||
space_icon->draw(ci, Point2(char_pos + xofs, ofs_y + yofs), gl_color);
|
||||
int yofs = (text_height - theme_cache.space_icon->get_height()) / 2 - ldata->get_line_ascent(line_wrap_index);
|
||||
int xofs = (glyphs[j].advance * glyphs[j].repeat - theme_cache.space_icon->get_width()) / 2;
|
||||
theme_cache.space_icon->draw(ci, Point2(char_pos + xofs, ofs_y + yofs), gl_color);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1302,18 +1306,18 @@ void TextEdit::_notification(int p_what) {
|
|||
|
||||
// is_line_folded
|
||||
if (line_wrap_index == line_wrap_amount && line < text.size() - 1 && _is_line_hidden(line + 1)) {
|
||||
int xofs = char_ofs + char_margin + ofs_x + (folded_eol_icon->get_width() / 2);
|
||||
int xofs = char_ofs + char_margin + ofs_x + (theme_cache.folded_eol_icon->get_width() / 2);
|
||||
if (xofs >= xmargin_beg && xofs < xmargin_end) {
|
||||
int yofs = (text_height - folded_eol_icon->get_height()) / 2 - ldata->get_line_ascent(line_wrap_index);
|
||||
Color eol_color = code_folding_color;
|
||||
int yofs = (text_height - theme_cache.folded_eol_icon->get_height()) / 2 - ldata->get_line_ascent(line_wrap_index);
|
||||
Color eol_color = theme_cache.code_folding_color;
|
||||
eol_color.a = 1;
|
||||
folded_eol_icon->draw(ci, Point2(xofs, ofs_y + yofs), eol_color);
|
||||
theme_cache.folded_eol_icon->draw(ci, Point2(xofs, ofs_y + yofs), eol_color);
|
||||
}
|
||||
}
|
||||
|
||||
// Carets.
|
||||
// Prevent carets from disappearing at theme scales below 1.0 (if the caret width is 1).
|
||||
const int caret_width = get_theme_constant(SNAME("caret_width")) * MAX(1, get_theme_default_base_scale());
|
||||
const int caret_width = theme_cache.caret_width * MAX(1, theme_cache.base_scale);
|
||||
|
||||
for (int c = 0; c < carets.size(); c++) {
|
||||
if (!clipped && get_caret_line(c) == line && carets_wrap_index[c] == line_wrap_index) {
|
||||
|
@ -1327,7 +1331,7 @@ void TextEdit::_notification(int p_what) {
|
|||
ts_caret = TS->shaped_text_get_carets(rid, ime_text.is_empty() ? get_caret_column(c) : get_caret_column(c) + ime_selection.x);
|
||||
} else {
|
||||
// No carets, add one at the start.
|
||||
int h = font->get_height(font_size);
|
||||
int h = theme_cache.font->get_height(theme_cache.font_size);
|
||||
if (rtl) {
|
||||
ts_caret.l_dir = TextServer::DIRECTION_RTL;
|
||||
ts_caret.l_caret = Rect2(Vector2(xmargin_end - char_margin + ofs_x, -h / 2), Size2(caret_width * 4, h));
|
||||
|
@ -1348,7 +1352,7 @@ void TextEdit::_notification(int p_what) {
|
|||
if (draw_caret || drag_caret_force_displayed) {
|
||||
if (caret_type == CaretType::CARET_TYPE_BLOCK || overtype_mode) {
|
||||
//Block or underline caret, draw trailing carets at full height.
|
||||
int h = font->get_height(font_size);
|
||||
int h = theme_cache.font->get_height(theme_cache.font_size);
|
||||
|
||||
if (ts_caret.t_caret != Rect2()) {
|
||||
if (overtype_mode) {
|
||||
|
@ -1359,17 +1363,17 @@ void TextEdit::_notification(int p_what) {
|
|||
ts_caret.t_caret.size.y = h;
|
||||
}
|
||||
ts_caret.t_caret.position += Vector2(char_margin + ofs_x, ofs_y);
|
||||
draw_rect(ts_caret.t_caret, caret_color, overtype_mode);
|
||||
draw_rect(ts_caret.t_caret, theme_cache.caret_color, overtype_mode);
|
||||
|
||||
if (ts_caret.l_caret != Rect2() && ts_caret.l_dir != ts_caret.t_dir) {
|
||||
// Draw split caret (leading part).
|
||||
ts_caret.l_caret.position += Vector2(char_margin + ofs_x, ofs_y);
|
||||
ts_caret.l_caret.size.x = caret_width;
|
||||
draw_rect(ts_caret.l_caret, caret_color);
|
||||
draw_rect(ts_caret.l_caret, theme_cache.caret_color);
|
||||
// Draw extra direction marker on top of split caret.
|
||||
float d = (ts_caret.l_dir == TextServer::DIRECTION_LTR) ? 0.5 : -3;
|
||||
Rect2 trect = Rect2(ts_caret.l_caret.position.x + d * caret_width, ts_caret.l_caret.position.y + ts_caret.l_caret.size.y - caret_width, 3 * caret_width, caret_width);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, trect, caret_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, trect, theme_cache.caret_color);
|
||||
}
|
||||
} else { // End of the line.
|
||||
if (gl_size > 0) {
|
||||
|
@ -1386,7 +1390,7 @@ void TextEdit::_notification(int p_what) {
|
|||
ts_caret.l_caret.size.y = caret_width;
|
||||
}
|
||||
if (Math::ceil(ts_caret.l_caret.position.x) >= TS->shaped_text_get_size(rid).x) {
|
||||
ts_caret.l_caret.size.x = font->get_char_size('m', font_size).x;
|
||||
ts_caret.l_caret.size.x = theme_cache.font->get_char_size('m', theme_cache.font_size).x;
|
||||
} else {
|
||||
ts_caret.l_caret.size.x = 3 * caret_width;
|
||||
}
|
||||
|
@ -1394,7 +1398,7 @@ void TextEdit::_notification(int p_what) {
|
|||
if (ts_caret.l_dir == TextServer::DIRECTION_RTL) {
|
||||
ts_caret.l_caret.position.x -= ts_caret.l_caret.size.x;
|
||||
}
|
||||
draw_rect(ts_caret.l_caret, caret_color, overtype_mode);
|
||||
draw_rect(ts_caret.l_caret, theme_cache.caret_color, overtype_mode);
|
||||
}
|
||||
} else {
|
||||
// Normal caret.
|
||||
|
@ -1402,28 +1406,28 @@ void TextEdit::_notification(int p_what) {
|
|||
// Draw extra marker on top of mid caret.
|
||||
Rect2 trect = Rect2(ts_caret.l_caret.position.x - 2.5 * caret_width, ts_caret.l_caret.position.y, 6 * caret_width, caret_width);
|
||||
trect.position += Vector2(char_margin + ofs_x, ofs_y);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, trect, caret_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, trect, theme_cache.caret_color);
|
||||
} else if (ts_caret.l_caret != Rect2() && ts_caret.t_caret != Rect2() && ts_caret.l_dir != ts_caret.t_dir) {
|
||||
// Draw extra direction marker on top of split caret.
|
||||
float d = (ts_caret.l_dir == TextServer::DIRECTION_LTR) ? 0.5 : -3;
|
||||
Rect2 trect = Rect2(ts_caret.l_caret.position.x + d * caret_width, ts_caret.l_caret.position.y + ts_caret.l_caret.size.y - caret_width, 3 * caret_width, caret_width);
|
||||
trect.position += Vector2(char_margin + ofs_x, ofs_y);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, trect, caret_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, trect, theme_cache.caret_color);
|
||||
|
||||
d = (ts_caret.t_dir == TextServer::DIRECTION_LTR) ? 0.5 : -3;
|
||||
trect = Rect2(ts_caret.t_caret.position.x + d * caret_width, ts_caret.t_caret.position.y, 3 * caret_width, caret_width);
|
||||
trect.position += Vector2(char_margin + ofs_x, ofs_y);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, trect, caret_color);
|
||||
RenderingServer::get_singleton()->canvas_item_add_rect(ci, trect, theme_cache.caret_color);
|
||||
}
|
||||
ts_caret.l_caret.position += Vector2(char_margin + ofs_x, ofs_y);
|
||||
ts_caret.l_caret.size.x = caret_width;
|
||||
|
||||
draw_rect(ts_caret.l_caret, caret_color);
|
||||
draw_rect(ts_caret.l_caret, theme_cache.caret_color);
|
||||
|
||||
ts_caret.t_caret.position += Vector2(char_margin + ofs_x, ofs_y);
|
||||
ts_caret.t_caret.size.x = caret_width;
|
||||
|
||||
draw_rect(ts_caret.t_caret, caret_color);
|
||||
draw_rect(ts_caret.t_caret, theme_cache.caret_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1444,7 +1448,7 @@ void TextEdit::_notification(int p_what) {
|
|||
rect.size.x = xmargin_end - rect.position.x;
|
||||
}
|
||||
rect.size.y = caret_width;
|
||||
draw_rect(rect, caret_color);
|
||||
draw_rect(rect, theme_cache.caret_color);
|
||||
carets.write[c].draw_pos.x = rect.position.x;
|
||||
}
|
||||
}
|
||||
|
@ -1463,7 +1467,7 @@ void TextEdit::_notification(int p_what) {
|
|||
rect.size.x = xmargin_end - rect.position.x;
|
||||
}
|
||||
rect.size.y = caret_width * 3;
|
||||
draw_rect(rect, caret_color);
|
||||
draw_rect(rect, theme_cache.caret_color);
|
||||
carets.write[c].draw_pos.x = rect.position.x;
|
||||
}
|
||||
}
|
||||
|
@ -1711,7 +1715,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
|
|||
int row = pos.y;
|
||||
int col = pos.x;
|
||||
|
||||
int left_margin = style_normal->get_margin(SIDE_LEFT);
|
||||
int left_margin = theme_cache.style_normal->get_margin(SIDE_LEFT);
|
||||
for (int i = 0; i < gutters.size(); i++) {
|
||||
if (!gutters[i].draw || gutters[i].width <= 0) {
|
||||
continue;
|
||||
|
@ -1956,7 +1960,7 @@ void TextEdit::gui_input(const Ref<InputEvent> &p_gui_input) {
|
|||
// Check if user is hovering a different gutter, and update if yes.
|
||||
Vector2i current_hovered_gutter = Vector2i(-1, -1);
|
||||
|
||||
int left_margin = style_normal->get_margin(SIDE_LEFT);
|
||||
int left_margin = theme_cache.style_normal->get_margin(SIDE_LEFT);
|
||||
if (mpos.x <= left_margin + gutters_width + gutter_padding) {
|
||||
int hovered_row = get_line_column_at_pos(mpos).y;
|
||||
for (int i = 0; i < gutters.size(); i++) {
|
||||
|
@ -2919,7 +2923,7 @@ void TextEdit::_get_above_below_caret_line_column(int p_old_line, int p_old_wrap
|
|||
}
|
||||
|
||||
void TextEdit::_update_placeholder() {
|
||||
if (font.is_null() || font_size <= 0) {
|
||||
if (theme_cache.font.is_null() || theme_cache.font_size <= 0) {
|
||||
return; // Not in tree?
|
||||
}
|
||||
|
||||
|
@ -2928,7 +2932,7 @@ void TextEdit::_update_placeholder() {
|
|||
placeholder_data_buf->set_width(text.get_width());
|
||||
placeholder_data_buf->set_direction((TextServer::Direction)text_direction);
|
||||
placeholder_data_buf->set_preserve_control(draw_control_chars);
|
||||
placeholder_data_buf->add_string(placeholder_text, font, font_size, language);
|
||||
placeholder_data_buf->add_string(placeholder_text, theme_cache.font, theme_cache.font_size, language);
|
||||
|
||||
placeholder_bidi_override = structured_text_parser(st_parser, st_args, placeholder_text);
|
||||
if (placeholder_bidi_override.is_empty()) {
|
||||
|
@ -2937,13 +2941,13 @@ void TextEdit::_update_placeholder() {
|
|||
|
||||
if (get_tab_size() > 0) {
|
||||
Vector<float> tabs;
|
||||
tabs.push_back(font->get_char_size(' ', font_size).width * get_tab_size());
|
||||
tabs.push_back(theme_cache.font->get_char_size(' ', theme_cache.font_size).width * get_tab_size());
|
||||
placeholder_data_buf->tab_align(tabs);
|
||||
}
|
||||
|
||||
// Update height.
|
||||
const int wrap_amount = placeholder_data_buf->get_line_count() - 1;
|
||||
placeholder_line_height = font->get_height(font_size);
|
||||
placeholder_line_height = theme_cache.font->get_height(theme_cache.font_size);
|
||||
for (int i = 0; i <= wrap_amount; i++) {
|
||||
placeholder_line_height = MAX(placeholder_line_height, placeholder_data_buf->get_line_size(i).y);
|
||||
}
|
||||
|
@ -2959,48 +2963,55 @@ void TextEdit::_update_placeholder() {
|
|||
}
|
||||
}
|
||||
|
||||
void TextEdit::_update_caches() {
|
||||
/* Internal API for CodeEdit. */
|
||||
brace_mismatch_color = get_theme_color(SNAME("brace_mismatch_color"), SNAME("CodeEdit"));
|
||||
code_folding_color = get_theme_color(SNAME("code_folding_color"), SNAME("CodeEdit"));
|
||||
folded_eol_icon = get_theme_icon(SNAME("folded_eol_icon"), SNAME("CodeEdit"));
|
||||
void TextEdit::_update_theme_item_cache() {
|
||||
Control::_update_theme_item_cache();
|
||||
|
||||
theme_cache.base_scale = get_theme_default_base_scale();
|
||||
|
||||
/* Internal API for CodeEdit */
|
||||
theme_cache.brace_mismatch_color = get_theme_color(SNAME("brace_mismatch_color"), SNAME("CodeEdit"));
|
||||
theme_cache.code_folding_color = get_theme_color(SNAME("code_folding_color"), SNAME("CodeEdit"));
|
||||
theme_cache.folded_eol_icon = get_theme_icon(SNAME("folded_eol_icon"), SNAME("CodeEdit"));
|
||||
|
||||
/* Search */
|
||||
search_result_color = get_theme_color(SNAME("search_result_color"));
|
||||
search_result_border_color = get_theme_color(SNAME("search_result_border_color"));
|
||||
theme_cache.search_result_color = get_theme_color(SNAME("search_result_color"));
|
||||
theme_cache.search_result_border_color = get_theme_color(SNAME("search_result_border_color"));
|
||||
|
||||
/* Caret */
|
||||
caret_color = get_theme_color(SNAME("caret_color"));
|
||||
caret_background_color = get_theme_color(SNAME("caret_background_color"));
|
||||
theme_cache.caret_width = get_theme_constant(SNAME("caret_width"));
|
||||
theme_cache.caret_color = get_theme_color(SNAME("caret_color"));
|
||||
theme_cache.caret_background_color = get_theme_color(SNAME("caret_background_color"));
|
||||
|
||||
/* Selection */
|
||||
font_selected_color = get_theme_color(SNAME("font_selected_color"));
|
||||
selection_color = get_theme_color(SNAME("selection_color"));
|
||||
use_selected_font_color = font_selected_color != Color(0, 0, 0, 0);
|
||||
theme_cache.font_selected_color = get_theme_color(SNAME("font_selected_color"));
|
||||
theme_cache.selection_color = get_theme_color(SNAME("selection_color"));
|
||||
use_selected_font_color = theme_cache.font_selected_color != Color(0, 0, 0, 0);
|
||||
|
||||
/* Visual. */
|
||||
style_normal = get_theme_stylebox(SNAME("normal"));
|
||||
style_focus = get_theme_stylebox(SNAME("focus"));
|
||||
style_readonly = get_theme_stylebox(SNAME("read_only"));
|
||||
/* Other visuals */
|
||||
theme_cache.style_normal = get_theme_stylebox(SNAME("normal"));
|
||||
theme_cache.style_focus = get_theme_stylebox(SNAME("focus"));
|
||||
theme_cache.style_readonly = get_theme_stylebox(SNAME("read_only"));
|
||||
|
||||
tab_icon = get_theme_icon(SNAME("tab"));
|
||||
space_icon = get_theme_icon(SNAME("space"));
|
||||
theme_cache.tab_icon = get_theme_icon(SNAME("tab"));
|
||||
theme_cache.space_icon = get_theme_icon(SNAME("space"));
|
||||
|
||||
font = get_theme_font(SNAME("font"));
|
||||
font_size = get_theme_font_size(SNAME("font_size"));
|
||||
font_color = get_theme_color(SNAME("font_color"));
|
||||
font_readonly_color = get_theme_color(SNAME("font_readonly_color"));
|
||||
font_placeholder_color = get_theme_color(SNAME("font_placeholder_color"));
|
||||
theme_cache.font = get_theme_font(SNAME("font"));
|
||||
theme_cache.font_size = get_theme_font_size(SNAME("font_size"));
|
||||
theme_cache.font_color = get_theme_color(SNAME("font_color"));
|
||||
theme_cache.font_readonly_color = get_theme_color(SNAME("font_readonly_color"));
|
||||
theme_cache.font_placeholder_color = get_theme_color(SNAME("font_placeholder_color"));
|
||||
|
||||
outline_size = get_theme_constant(SNAME("outline_size"));
|
||||
outline_color = get_theme_color(SNAME("font_outline_color"));
|
||||
theme_cache.outline_size = get_theme_constant(SNAME("outline_size"));
|
||||
theme_cache.outline_color = get_theme_color(SNAME("font_outline_color"));
|
||||
|
||||
line_spacing = get_theme_constant(SNAME("line_spacing"));
|
||||
theme_cache.line_spacing = get_theme_constant(SNAME("line_spacing"));
|
||||
|
||||
background_color = get_theme_color(SNAME("background_color"));
|
||||
current_line_color = get_theme_color(SNAME("current_line_color"));
|
||||
word_highlighted_color = get_theme_color(SNAME("word_highlighted_color"));
|
||||
theme_cache.background_color = get_theme_color(SNAME("background_color"));
|
||||
theme_cache.current_line_color = get_theme_color(SNAME("current_line_color"));
|
||||
theme_cache.word_highlighted_color = get_theme_color(SNAME("word_highlighted_color"));
|
||||
}
|
||||
|
||||
void TextEdit::_update_caches() {
|
||||
/* Text properties. */
|
||||
TextServer::Direction dir;
|
||||
if (text_direction == Control::TEXT_DIRECTION_INHERITED) {
|
||||
|
@ -3010,8 +3021,8 @@ void TextEdit::_update_caches() {
|
|||
}
|
||||
text.set_direction_and_language(dir, (!language.is_empty()) ? language : TranslationServer::get_singleton()->get_tool_locale());
|
||||
text.set_draw_control_chars(draw_control_chars);
|
||||
text.set_font(font);
|
||||
text.set_font_size(font_size);
|
||||
text.set_font(theme_cache.font);
|
||||
text.set_font_size(theme_cache.font_size);
|
||||
text.invalidate_font();
|
||||
_update_placeholder();
|
||||
|
||||
|
@ -3023,7 +3034,7 @@ void TextEdit::_update_caches() {
|
|||
|
||||
/* General overrides. */
|
||||
Size2 TextEdit::get_minimum_size() const {
|
||||
Size2 size = style_normal->get_minimum_size();
|
||||
Size2 size = theme_cache.style_normal->get_minimum_size();
|
||||
if (fit_content_height) {
|
||||
size.y += content_height_cache;
|
||||
}
|
||||
|
@ -3119,7 +3130,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
|
|||
Point2i pos = get_line_column_at_pos(p_pos);
|
||||
int row = pos.y;
|
||||
|
||||
int left_margin = style_normal->get_margin(SIDE_LEFT);
|
||||
int left_margin = theme_cache.style_normal->get_margin(SIDE_LEFT);
|
||||
int gutter = left_margin + gutters_width;
|
||||
if (p_pos.x < gutter) {
|
||||
for (int i = 0; i < gutters.size(); i++) {
|
||||
|
@ -3137,7 +3148,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
|
|||
return CURSOR_ARROW;
|
||||
}
|
||||
|
||||
int xmargin_end = get_size().width - style_normal->get_margin(SIDE_RIGHT);
|
||||
int xmargin_end = get_size().width - theme_cache.style_normal->get_margin(SIDE_RIGHT);
|
||||
if (draw_minimap && p_pos.x > xmargin_end - minimap_width && p_pos.x <= xmargin_end) {
|
||||
return CURSOR_ARROW;
|
||||
}
|
||||
|
@ -3465,7 +3476,7 @@ int TextEdit::get_line_width(int p_line, int p_wrap_index) const {
|
|||
}
|
||||
|
||||
int TextEdit::get_line_height() const {
|
||||
return text.get_line_height() + line_spacing;
|
||||
return text.get_line_height() + theme_cache.line_spacing;
|
||||
}
|
||||
|
||||
int TextEdit::get_indent_level(int p_line) const {
|
||||
|
@ -4249,7 +4260,7 @@ String TextEdit::get_word_at_pos(const Vector2 &p_pos) const {
|
|||
|
||||
Point2i TextEdit::get_line_column_at_pos(const Point2i &p_pos, bool p_allow_out_of_bounds) const {
|
||||
float rows = p_pos.y;
|
||||
rows -= style_normal->get_margin(SIDE_TOP);
|
||||
rows -= theme_cache.style_normal->get_margin(SIDE_TOP);
|
||||
rows /= get_line_height();
|
||||
rows += _get_v_scroll_offset();
|
||||
int first_vis_line = get_first_visible_line();
|
||||
|
@ -4284,7 +4295,7 @@ Point2i TextEdit::get_line_column_at_pos(const Point2i &p_pos, bool p_allow_out_
|
|||
}
|
||||
|
||||
int col = 0;
|
||||
int colx = p_pos.x - (style_normal->get_margin(SIDE_LEFT) + gutters_width + gutter_padding);
|
||||
int colx = p_pos.x - (theme_cache.style_normal->get_margin(SIDE_LEFT) + gutters_width + gutter_padding);
|
||||
colx += first_visible_col;
|
||||
col = _get_char_pos_for_line(colx, row, wrap_index);
|
||||
if (get_line_wrapping_mode() != LineWrappingMode::LINE_WRAPPING_NONE && wrap_index < get_line_wrap_count(row)) {
|
||||
|
@ -4339,7 +4350,7 @@ Rect2i TextEdit::get_rect_at_line_column(int p_line, int p_column) const {
|
|||
|
||||
Point2i pos, size;
|
||||
pos.y = cache_entry.y_offset + get_line_height() * wrap_index;
|
||||
pos.x = get_total_gutter_width() + style_normal->get_margin(SIDE_LEFT) - get_h_scroll();
|
||||
pos.x = get_total_gutter_width() + theme_cache.style_normal->get_margin(SIDE_LEFT) - get_h_scroll();
|
||||
|
||||
RID text_rid = text.get_line_data(p_line)->get_line_rid(wrap_index);
|
||||
Vector2 col_bounds = TS->shaped_text_get_grapheme_bounds(text_rid, p_column);
|
||||
|
@ -4353,7 +4364,7 @@ Rect2i TextEdit::get_rect_at_line_column(int p_line, int p_column) const {
|
|||
|
||||
int TextEdit::get_minimap_line_at_pos(const Point2i &p_pos) const {
|
||||
float rows = p_pos.y;
|
||||
rows -= style_normal->get_margin(SIDE_TOP);
|
||||
rows -= theme_cache.style_normal->get_margin(SIDE_TOP);
|
||||
rows /= (minimap_char_size.y + minimap_line_spacing);
|
||||
rows += _get_v_scroll_offset();
|
||||
|
||||
|
@ -5519,7 +5530,7 @@ void TextEdit::adjust_viewport_to_caret(int p_caret) {
|
|||
set_line_as_last_visible(cur_line, cur_wrap);
|
||||
}
|
||||
|
||||
int visible_width = get_size().width - style_normal->get_minimum_size().width - gutters_width - gutter_padding;
|
||||
int visible_width = get_size().width - theme_cache.style_normal->get_minimum_size().width - gutters_width - gutter_padding;
|
||||
if (draw_minimap) {
|
||||
visible_width -= minimap_width;
|
||||
}
|
||||
|
@ -5573,7 +5584,7 @@ void TextEdit::center_viewport_to_caret(int p_caret) {
|
|||
minimap_clicked = false;
|
||||
|
||||
set_line_as_center_visible(get_caret_line(p_caret), get_caret_wrap_index(p_caret));
|
||||
int visible_width = get_size().width - style_normal->get_minimum_size().width - gutters_width - gutter_padding;
|
||||
int visible_width = get_size().width - theme_cache.style_normal->get_minimum_size().width - gutters_width - gutter_padding;
|
||||
if (draw_minimap) {
|
||||
visible_width -= minimap_width;
|
||||
}
|
||||
|
@ -7191,7 +7202,7 @@ void TextEdit::_post_shift_selection(int p_caret) {
|
|||
|
||||
/* Line Wrapping */
|
||||
void TextEdit::_update_wrap_at_column(bool p_force) {
|
||||
int new_wrap_at = get_size().width - style_normal->get_minimum_size().width - gutters_width - gutter_padding;
|
||||
int new_wrap_at = get_size().width - theme_cache.style_normal->get_minimum_size().width - gutters_width - gutter_padding;
|
||||
if (draw_minimap) {
|
||||
new_wrap_at -= minimap_width;
|
||||
}
|
||||
|
@ -7228,8 +7239,8 @@ void TextEdit::_update_scrollbars() {
|
|||
Size2 hmin = h_scroll->get_combined_minimum_size();
|
||||
Size2 vmin = v_scroll->get_combined_minimum_size();
|
||||
|
||||
v_scroll->set_begin(Point2(size.width - vmin.width, style_normal->get_margin(SIDE_TOP)));
|
||||
v_scroll->set_end(Point2(size.width, size.height - style_normal->get_margin(SIDE_TOP) - style_normal->get_margin(SIDE_BOTTOM)));
|
||||
v_scroll->set_begin(Point2(size.width - vmin.width, theme_cache.style_normal->get_margin(SIDE_TOP)));
|
||||
v_scroll->set_end(Point2(size.width, size.height - theme_cache.style_normal->get_margin(SIDE_TOP) - theme_cache.style_normal->get_margin(SIDE_BOTTOM)));
|
||||
|
||||
h_scroll->set_begin(Point2(0, size.height - hmin.height));
|
||||
h_scroll->set_end(Point2(size.width - vmin.width, size.height));
|
||||
|
@ -7242,7 +7253,7 @@ void TextEdit::_update_scrollbars() {
|
|||
total_rows += visible_rows - 1;
|
||||
}
|
||||
|
||||
int visible_width = size.width - style_normal->get_minimum_size().width;
|
||||
int visible_width = size.width - theme_cache.style_normal->get_minimum_size().width;
|
||||
int total_width = (draw_placeholder ? placeholder_max_width : text.get_max_width()) + vmin.x + gutters_width + gutter_padding;
|
||||
|
||||
if (draw_minimap) {
|
||||
|
@ -7298,7 +7309,7 @@ void TextEdit::_update_scrollbars() {
|
|||
|
||||
int TextEdit::_get_control_height() const {
|
||||
int control_height = get_size().height;
|
||||
control_height -= style_normal->get_minimum_size().height;
|
||||
control_height -= theme_cache.style_normal->get_minimum_size().height;
|
||||
if (h_scroll->is_visible_in_tree()) {
|
||||
control_height -= h_scroll->get_size().height;
|
||||
}
|
||||
|
@ -7460,7 +7471,7 @@ void TextEdit::_scroll_lines_down() {
|
|||
|
||||
void TextEdit::_update_minimap_hover() {
|
||||
const Point2 mp = get_local_mouse_pos();
|
||||
const int xmargin_end = get_size().width - style_normal->get_margin(SIDE_RIGHT);
|
||||
const int xmargin_end = get_size().width - theme_cache.style_normal->get_margin(SIDE_RIGHT);
|
||||
|
||||
const bool hovering_sidebar = mp.x > xmargin_end - minimap_width && mp.x < xmargin_end;
|
||||
if (!hovering_sidebar) {
|
||||
|
@ -7487,7 +7498,7 @@ void TextEdit::_update_minimap_hover() {
|
|||
void TextEdit::_update_minimap_click() {
|
||||
Point2 mp = get_local_mouse_pos();
|
||||
|
||||
int xmargin_end = get_size().width - style_normal->get_margin(SIDE_RIGHT);
|
||||
int xmargin_end = get_size().width - theme_cache.style_normal->get_margin(SIDE_RIGHT);
|
||||
if (!dragging_minimap && (mp.x < xmargin_end - minimap_width || mp.y > xmargin_end)) {
|
||||
minimap_clicked = false;
|
||||
return;
|
||||
|
@ -7777,7 +7788,6 @@ TextEdit::TextEdit(const String &p_placeholder) {
|
|||
|
||||
clear();
|
||||
set_focus_mode(FOCUS_ALL);
|
||||
_update_caches();
|
||||
set_default_cursor_shape(CURSOR_IBEAM);
|
||||
set_process_unhandled_key_input(true);
|
||||
|
||||
|
|
|
@ -356,9 +356,6 @@ private:
|
|||
void _clear_redo();
|
||||
|
||||
/* Search */
|
||||
Color search_result_color = Color(1, 1, 1);
|
||||
Color search_result_border_color = Color(1, 1, 1);
|
||||
|
||||
String search_text = "";
|
||||
uint32_t search_flags = 0;
|
||||
|
||||
|
@ -413,9 +410,6 @@ private:
|
|||
bool caret_pos_dirty = false;
|
||||
bool caret_index_edit_dirty = true;
|
||||
|
||||
Color caret_color = Color(1, 1, 1);
|
||||
Color caret_background_color = Color(0, 0, 0);
|
||||
|
||||
CaretType caret_type = CaretType::CARET_TYPE_LINE;
|
||||
|
||||
bool draw_caret = true;
|
||||
|
@ -446,8 +440,6 @@ private:
|
|||
bool deselect_on_focus_loss_enabled = true;
|
||||
bool drag_and_drop_selection_enabled = true;
|
||||
|
||||
Color font_selected_color = Color(0, 0, 0, 0);
|
||||
Color selection_color = Color(1, 1, 1);
|
||||
bool use_selected_font_color = false;
|
||||
|
||||
bool selection_drag_attempt = false;
|
||||
|
@ -543,27 +535,50 @@ private:
|
|||
Dictionary _get_line_syntax_highlighting(int p_line);
|
||||
|
||||
/* Visual. */
|
||||
Ref<StyleBox> style_normal;
|
||||
Ref<StyleBox> style_focus;
|
||||
Ref<StyleBox> style_readonly;
|
||||
struct ThemeCache {
|
||||
float base_scale = 1.0;
|
||||
|
||||
Ref<Texture2D> tab_icon;
|
||||
Ref<Texture2D> space_icon;
|
||||
/* Internal API for CodeEdit */
|
||||
Color brace_mismatch_color;
|
||||
Color code_folding_color = Color(1, 1, 1);
|
||||
Ref<Texture2D> folded_eol_icon;
|
||||
|
||||
Ref<Font> font;
|
||||
int font_size = 16;
|
||||
Color font_color = Color(1, 1, 1);
|
||||
Color font_readonly_color = Color(1, 1, 1);
|
||||
Color font_placeholder_color = Color(1, 1, 1, 0.6);
|
||||
/* Search */
|
||||
Color search_result_color = Color(1, 1, 1);
|
||||
Color search_result_border_color = Color(1, 1, 1);
|
||||
|
||||
int outline_size = 0;
|
||||
Color outline_color = Color(1, 1, 1);
|
||||
/* Caret */
|
||||
int caret_width = 1;
|
||||
Color caret_color = Color(1, 1, 1);
|
||||
Color caret_background_color = Color(0, 0, 0);
|
||||
|
||||
int line_spacing = 1;
|
||||
/* Selection */
|
||||
Color font_selected_color = Color(0, 0, 0, 0);
|
||||
Color selection_color = Color(1, 1, 1);
|
||||
|
||||
Color background_color = Color(1, 1, 1);
|
||||
Color current_line_color = Color(1, 1, 1);
|
||||
Color word_highlighted_color = Color(1, 1, 1);
|
||||
/* Other visuals */
|
||||
Ref<StyleBox> style_normal;
|
||||
Ref<StyleBox> style_focus;
|
||||
Ref<StyleBox> style_readonly;
|
||||
|
||||
Ref<Texture2D> tab_icon;
|
||||
Ref<Texture2D> space_icon;
|
||||
|
||||
Ref<Font> font;
|
||||
int font_size = 16;
|
||||
Color font_color = Color(1, 1, 1);
|
||||
Color font_readonly_color = Color(1, 1, 1);
|
||||
Color font_placeholder_color = Color(1, 1, 1, 0.6);
|
||||
|
||||
int outline_size = 0;
|
||||
Color outline_color = Color(1, 1, 1);
|
||||
|
||||
int line_spacing = 1;
|
||||
|
||||
Color background_color = Color(1, 1, 1);
|
||||
Color current_line_color = Color(1, 1, 1);
|
||||
Color word_highlighted_color = Color(1, 1, 1);
|
||||
} theme_cache;
|
||||
|
||||
bool window_has_focus = true;
|
||||
bool first_draw = true;
|
||||
|
@ -607,9 +622,10 @@ private:
|
|||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
virtual void _update_theme_item_cache() override;
|
||||
|
||||
/* Internal API for CodeEdit, pending public API. */
|
||||
// brace matching
|
||||
struct BraceMatchingData {
|
||||
|
@ -624,12 +640,8 @@ protected:
|
|||
};
|
||||
|
||||
bool highlight_matching_braces_enabled = false;
|
||||
Color brace_mismatch_color;
|
||||
|
||||
// Line hiding.
|
||||
Color code_folding_color = Color(1, 1, 1);
|
||||
Ref<Texture2D> folded_eol_icon;
|
||||
|
||||
bool hiding_enabled = false;
|
||||
|
||||
void _set_hiding_enabled(bool p_enabled);
|
||||
|
|
Loading…
Reference in a new issue