summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/label.cpp4
-rw-r--r--scene/gui/line_edit.cpp3
-rw-r--r--scene/gui/rich_text_label.cpp30
-rw-r--r--scene/gui/rich_text_label.h1
-rw-r--r--scene/gui/text_edit.cpp28
-rw-r--r--scene/gui/text_edit.h3
-rw-r--r--scene/gui/tree.cpp10
-rw-r--r--scene/gui/tree.h2
8 files changed, 66 insertions, 15 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 778d24cc35..0431d824fa 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -535,7 +535,9 @@ void Label::set_text(const String& p_string) {
if (percent_visible<1)
visible_chars=get_total_character_count()*percent_visible;
update();
- minimum_size_changed();
+ if (!autowrap) {
+ minimum_size_changed();
+ }
}
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index d6c018ae8e..6c47072b33 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -31,6 +31,7 @@
#include "os/os.h"
#include "print_string.h"
#include "label.h"
+#include "translation.h"
#ifdef TOOLS_ENABLED
#include "tools/editor/editor_settings.h"
#endif
@@ -947,7 +948,7 @@ String LineEdit::get_text() const {
void LineEdit::set_placeholder(String p_text) {
- placeholder = p_text;
+ placeholder = XL_MESSAGE(p_text);
update();
}
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 31cef85aa0..b4fa463cde 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -662,8 +662,7 @@ void RichTextLabel::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
- if (use_bbcode)
- parse_bbcode(bbcode);
+ set_bbcode(bbcode);
main->first_invalid_line=0; //invalidate ALL
update();
@@ -1440,7 +1439,6 @@ bool RichTextLabel::is_scroll_following() const {
Error RichTextLabel::parse_bbcode(const String& p_bbcode) {
-
clear();
return append_bbcode(p_bbcode);
}
@@ -1858,6 +1856,10 @@ void RichTextLabel::set_bbcode(const String& p_bbcode) {
bbcode=p_bbcode;
if (is_inside_tree() && use_bbcode)
parse_bbcode(p_bbcode);
+ else { // raw text
+ clear();
+ add_text(p_bbcode);
+ }
}
String RichTextLabel::get_bbcode() const {
@@ -1869,19 +1871,37 @@ void RichTextLabel::set_use_bbcode(bool p_enable) {
if (use_bbcode==p_enable)
return;
use_bbcode=p_enable;
- if (is_inside_tree() && use_bbcode)
- parse_bbcode(bbcode);
+ set_bbcode(bbcode);
}
bool RichTextLabel::is_using_bbcode() const {
return use_bbcode;
}
+
+String RichTextLabel::get_text() {
+ String text = "";
+ Item *it = main;
+ while (it) {
+ if (it->type == ITEM_TEXT) {
+ ItemText *t = static_cast<ItemText*>(it);
+ text += t->text;
+ } else if (it->type == ITEM_NEWLINE) {
+ text += "\n";
+ } else if (it->type == ITEM_INDENT) {
+ text += "\t";
+ }
+ it=_get_next_item(it,true);
+ }
+ return text;
+}
+
void RichTextLabel::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_input_event"),&RichTextLabel::_input_event);
ObjectTypeDB::bind_method(_MD("_scroll_changed"),&RichTextLabel::_scroll_changed);
+ ObjectTypeDB::bind_method(_MD("get_text"),&RichTextLabel::get_text);
ObjectTypeDB::bind_method(_MD("add_text","text"),&RichTextLabel::add_text);
ObjectTypeDB::bind_method(_MD("add_image","image:Texture"),&RichTextLabel::add_image);
ObjectTypeDB::bind_method(_MD("newline"),&RichTextLabel::add_newline);
diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h
index 635fe87ad4..5147905a0e 100644
--- a/scene/gui/rich_text_label.h
+++ b/scene/gui/rich_text_label.h
@@ -280,6 +280,7 @@ protected:
public:
+ String get_text();
void add_text(const String& p_text);
void add_image(const Ref<Texture>& p_image);
void add_newline();
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 55e1a2cc52..a680d5d873 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -965,6 +965,12 @@ void TextEdit::_notification(int p_what) {
}
bool in_highlighted_word = (j >= highlighted_text_col && j < highlighted_text_col+highlighted_text.length());
+
+ /* if this is the original highlighted text we don't want to highlight it again */
+ if (cursor.line==line && (cursor.column >= highlighted_text_col && cursor.column <= highlighted_text_col+highlighted_text.length())) {
+ in_highlighted_word = false;
+ }
+
if (in_highlighted_word) {
VisualServer::get_singleton()->canvas_item_add_rect(ci,Rect2(Point2i( char_ofs+char_margin, ofs_y ), Size2i(char_w, get_row_height())),cache.word_highlighted_color);
}
@@ -1105,7 +1111,7 @@ void TextEdit::_notification(int p_what) {
int l = line_from + i;
ERR_CONTINUE( l < 0 || l>= completion_options.size());
- Color text_color = cache.font_color;
+ Color text_color = cache.completion_font_color;
for(int j=0;j<color_regions.size();j++) {
if (completion_options[l].begins_with(color_regions[j].begin_key)) {
text_color=color_regions[j].color;
@@ -3306,6 +3312,7 @@ void TextEdit::_update_caches() {
cache.completion_background_color=get_color("completion_background_color");
cache.completion_selected_color=get_color("completion_selected_color");
cache.completion_existing_color=get_color("completion_existing_color");
+ cache.completion_font_color=get_color("completion_font_color");
cache.font=get_font("font");
cache.caret_color=get_color("caret_color");
cache.line_number_color=get_color("line_number_color");
@@ -3603,6 +3610,10 @@ void TextEdit::set_highlight_all_occurrences(const bool p_enabled) {
update();
}
+bool TextEdit::is_highlight_all_occurrences_enabled() const {
+ return highlight_all_occurrences;
+}
+
int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_search, uint32_t p_search_flags, int p_from_column) {
int col = -1;
@@ -4312,6 +4323,10 @@ void TextEdit::set_show_line_numbers(bool p_show) {
update();
}
+bool TextEdit::is_show_line_numbers_enabled() const {
+ return line_numbers;
+}
+
void TextEdit::set_draw_breakpoint_gutter(bool p_draw) {
draw_breakpoint_gutter = p_draw;
update();
@@ -4426,6 +4441,12 @@ void TextEdit::_bind_methods() {
ObjectTypeDB::bind_method(_MD("redo"),&TextEdit::redo);
ObjectTypeDB::bind_method(_MD("clear_undo_history"),&TextEdit::clear_undo_history);
+ ObjectTypeDB::bind_method(_MD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers);
+ ObjectTypeDB::bind_method(_MD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled);
+
+ ObjectTypeDB::bind_method(_MD("set_highlight_all_occurrences", "enable"), &TextEdit::set_highlight_all_occurrences);
+ ObjectTypeDB::bind_method(_MD("is_highlight_all_occurrences_enabled"), &TextEdit::is_highlight_all_occurrences_enabled);
+
ObjectTypeDB::bind_method(_MD("set_syntax_coloring","enable"),&TextEdit::set_syntax_coloring);
ObjectTypeDB::bind_method(_MD("is_syntax_coloring_enabled"),&TextEdit::is_syntax_coloring_enabled);
@@ -4438,7 +4459,10 @@ void TextEdit::_bind_methods() {
ObjectTypeDB::bind_method(_MD("menu_option"),&TextEdit::menu_option);
ObjectTypeDB::bind_method(_MD("get_menu:PopupMenu"),&TextEdit::get_menu);
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));;
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), _SCS("set_show_line_numbers"), _SCS("is_show_line_numbers_enabled"));
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), _SCS("set_highlight_all_occurrences"), _SCS("is_highlight_all_occurrences_enabled"));
+
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret/caret_blink"), _SCS("cursor_set_blink_enabled"), _SCS("cursor_get_blink_enabled"));
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret/caret_blink_speed",PROPERTY_HINT_RANGE,"0.1,10,0.1"), _SCS("cursor_set_blink_speed"),_SCS("cursor_get_blink_speed") );
ADD_SIGNAL(MethodInfo("cursor_changed"));
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index acac687b59..270a1723b1 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -77,6 +77,7 @@ class TextEdit : public Control {
Color completion_background_color;
Color completion_selected_color;
Color completion_existing_color;
+ Color completion_font_color;
Color caret_color;
Color line_number_color;
Color font_color;
@@ -427,6 +428,7 @@ public:
void set_current_search_result(int line, int col);
void set_highlight_all_occurrences(const bool p_enabled);
+ bool is_highlight_all_occurrences_enabled() const;
bool is_selection_active() const;
int get_selection_from_line() const;
int get_selection_from_column() const;
@@ -468,6 +470,7 @@ public:
void menu_option(int p_option);
void set_show_line_numbers(bool p_show);
+ bool is_show_line_numbers_enabled() const;
void set_draw_breakpoint_gutter(bool p_draw);
bool is_drawing_breakpoint_gutter() const;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index f30b1979ef..305a3920da 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1030,7 +1030,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
Point2i o = Point2i( ofs+w-s.width, p_pos.y )-cache.offset+p_draw_ofs;
- if (cache.click_type==Cache::CLICK_BUTTON && cache.click_item==p_item && cache.click_column==i && !p_item->cells[i].buttons[j].disabled) {
+ if (cache.click_type==Cache::CLICK_BUTTON && cache.click_item==p_item && cache.click_column==i && cache.click_index==j && !p_item->cells[i].buttons[j].disabled) {
//being pressed
cache.button_pressed->draw(get_canvas_item(),Rect2(o,s));
}
@@ -1335,7 +1335,7 @@ int Tree::_count_selected_items(TreeItem* p_from) const {
return count;
}
-void Tree::select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col,TreeItem *p_prev,bool *r_in_range) {
+void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_col, TreeItem *p_prev, bool *r_in_range, bool p_force_deselect) {
TreeItem::Cell &selected_cell=p_selected->cells[p_col];
@@ -1409,7 +1409,7 @@ void Tree::select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col
} else {
- if (r_in_range && *r_in_range) {
+ if (r_in_range && *r_in_range && !p_force_deselect) {
if (!c.selected && c.selectable) {
@@ -1417,7 +1417,7 @@ void Tree::select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col
emit_signal("multi_selected",p_current,i,true);
}
- } else if (!r_in_range){
+ } else if (!r_in_range || p_force_deselect){
if (select_mode==SELECT_MULTI && c.selected)
emit_signal("multi_selected",p_current,i,false);
c.selected=false;
@@ -1436,7 +1436,7 @@ void Tree::select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col
while (c) {
- select_single_item(p_selected,c,p_col,p_prev,r_in_range);
+ select_single_item(p_selected,c,p_col,p_prev,r_in_range,p_current->is_collapsed() || p_force_deselect);
c=c->next;
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 0172546c1d..f5100ab5b6 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -331,7 +331,7 @@ friend class TreeItem;
// void draw_item_text(String p_text,const Ref<Texture>& p_icon,int p_icon_max_w,bool p_tool,Rect2i p_rect,const Color& p_color);
void draw_item_rect(const TreeItem::Cell& p_cell,const Rect2i& p_rect,const Color& p_color);
int draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2& p_draw_size,TreeItem *p_item);
- void select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col,TreeItem *p_prev=NULL,bool *r_in_range=NULL);
+ void select_single_item(TreeItem *p_selected,TreeItem *p_current,int p_col,TreeItem *p_prev=NULL,bool *r_in_range=NULL,bool p_force_deselect=false);
int propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_doubleclick,TreeItem *p_item,int p_button,const InputModifierState& p_mod);
void text_editor_enter(String p_text);
void _text_editor_modal_close();