diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2016-11-09 15:47:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-09 15:47:15 +0100 |
commit | 7d1230a266f4eab3262ebfcbf4a89148dfcb3c48 (patch) | |
tree | 8c2d5368405c7bf1c591dde28dbca3faa3bec3d4 /scene/gui | |
parent | 2ba1b5837496c66ee1b08a290d251112f435e3e5 (diff) | |
parent | 0e2c15e91a4b9b7d4e24a1e4d2e9b791b5bd9a93 (diff) |
Merge pull request #7052 from Paulb23/text_edit_color_uniformation
Made background and symbol color follow the color API
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/text_edit.cpp | 26 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 6 |
2 files changed, 8 insertions, 24 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 9b3b047712..871a3ca68f 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -492,10 +492,10 @@ void TextEdit::_notification(int p_what) { if (syntax_coloring) { - if (custom_bg_color.a>0.01) { + if (cache.background_color.a>0.01) { Point2i ofs = Point2i(cache.style_normal->get_offset())/2.0; - VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),custom_bg_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(ofs, get_size()-cache.style_normal->get_minimum_size()+ofs),cache.background_color); } //compute actual region to start (may be inside say, a comment). //slow in very large documments :( but ok for source! @@ -907,7 +907,7 @@ void TextEdit::_notification(int p_what) { else if (in_function_name) color=cache.function_color; else if (is_symbol) - color=symbol_color; + color=cache.symbol_color; else if (is_number) color=cache.number_color; @@ -3489,6 +3489,8 @@ void TextEdit::_update_caches() { cache.word_highlighted_color=get_color("word_highlighted_color"); cache.search_result_color=get_color("search_result_color"); cache.search_result_border_color=get_color("search_result_border_color"); + cache.symbol_color=get_color("symbol_color"); + cache.background_color=get_color("background_color"); cache.line_spacing=get_constant("line_spacing"); cache.row_height = cache.font->get_height() + cache.line_spacing; cache.tab_icon=get_icon("tab"); @@ -3500,15 +3502,8 @@ void TextEdit::_update_caches() { void TextEdit::clear_colors() { keywords.clear(); - color_regions.clear();; + color_regions.clear(); text.clear_caches(); - custom_bg_color=Color(0,0,0,0); -} - -void TextEdit::set_custom_bg_color(const Color& p_color) { - - custom_bg_color=p_color; - update(); } void TextEdit::add_keyword_color(const String& p_keyword,const Color& p_color) { @@ -3526,12 +3521,6 @@ void TextEdit::add_color_region(const String& p_begin_key,const String& p_end_ke } -void TextEdit::set_symbol_color(const Color& p_color) { - - symbol_color=p_color; - update(); -} - void TextEdit::set_syntax_coloring(bool p_enabled) { syntax_coloring=p_enabled; @@ -4689,8 +4678,6 @@ void TextEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_keyword_color","keyword","color"),&TextEdit::add_keyword_color); ObjectTypeDB::bind_method(_MD("add_color_region","begin_key","end_key","color","line_only"),&TextEdit::add_color_region,DEFVAL(false)); - ObjectTypeDB::bind_method(_MD("set_symbol_color","color"),&TextEdit::set_symbol_color); - ObjectTypeDB::bind_method(_MD("set_custom_bg_color","color"),&TextEdit::set_custom_bg_color); ObjectTypeDB::bind_method(_MD("clear_colors"),&TextEdit::clear_colors); ObjectTypeDB::bind_method(_MD("menu_option"),&TextEdit::menu_option); ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"),&TextEdit::get_menu); @@ -4775,7 +4762,6 @@ TextEdit::TextEdit() { caret_blink_timer->connect("timeout", this,"_toggle_draw_caret"); cursor_set_blink_enabled(false); - custom_bg_color=Color(0,0,0,0); idle_detect = memnew( Timer ); add_child(idle_detect); idle_detect->set_one_shot(true); diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 7820fefdd2..4cf096b7bf 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -95,6 +95,8 @@ class TextEdit : public Control { Color word_highlighted_color; Color search_result_color; Color search_result_border_color; + Color symbol_color; + Color background_color; int row_height; int line_spacing; @@ -187,9 +189,7 @@ class TextEdit : public Control { //syntax coloring - Color symbol_color; HashMap<String,Color> keywords; - Color custom_bg_color; Vector<ColorRegion> color_regions; @@ -471,8 +471,6 @@ public: void add_keyword_color(const String& p_keyword,const Color& p_color); void add_color_region(const String& p_begin_key=String(),const String& p_end_key=String(),const Color &p_color=Color(),bool p_line_only=false); - void set_symbol_color(const Color& p_color); - void set_custom_bg_color(const Color& p_color); void clear_colors(); int get_v_scroll() const; |