summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/item_list.cpp31
-rw-r--r--scene/gui/item_list.h1
-rw-r--r--scene/gui/menu_button.cpp2
-rw-r--r--scene/gui/popup_menu.cpp1
-rw-r--r--scene/gui/rich_text_label.cpp3
-rw-r--r--scene/gui/tabs.cpp33
-rw-r--r--scene/gui/text_edit.cpp113
-rw-r--r--scene/gui/tree.cpp28
-rw-r--r--scene/gui/tree.h8
-rw-r--r--scene/gui/video_player.cpp2
10 files changed, 195 insertions, 27 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 40fade840c..f035cb7722 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -235,6 +235,37 @@ int ItemList::get_current() const {
return current;
}
+void ItemList::move_item(int p_item,int p_to_pos) {
+
+ ERR_FAIL_INDEX(p_item,items.size());
+ ERR_FAIL_INDEX(p_to_pos,items.size()+1);
+
+ Item it=items[p_item];
+ items.remove(p_item);;
+
+ if (p_to_pos>p_item) {
+ p_to_pos--;
+ }
+
+ if (p_to_pos>=items.size()) {
+ items.push_back(it);
+ } else {
+ items.insert(p_to_pos,it);
+ }
+
+ if (current<0) {
+ //do none
+ } if (p_item==current) {
+ current=p_to_pos;
+ } else if (p_to_pos>p_item && current>p_item && current<p_to_pos) {
+ current--;
+ } else if (p_to_pos<p_item && current<p_item && current>p_to_pos) {
+ current++;
+ }
+
+
+ update();
+}
int ItemList::get_item_count() const{
diff --git a/scene/gui/item_list.h b/scene/gui/item_list.h
index 7cf58a6426..bd3cf6484e 100644
--- a/scene/gui/item_list.h
+++ b/scene/gui/item_list.h
@@ -101,6 +101,7 @@ public:
void set_current(int p_current);
int get_current() const;
+ void move_item(int p_item,int p_to_pos);
int get_item_count() const;
void remove_item(int p_idx);
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 13ff7074ea..be7a6b468a 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -54,6 +54,8 @@ void MenuButton::_unhandled_key_input(InputEvent p_event) {
int item = popup->find_item_by_accelerator(code);
+
+
if (item>=0 && ! popup->is_item_disabled(item))
popup->activate_item(item);
/*
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 6c21ea639f..89354322e3 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -774,6 +774,7 @@ void PopupMenu::add_separator() {
void PopupMenu::clear() {
items.clear();
+ mouse_over=-1;
update();
idcount=0;
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index ef6a2ba6aa..b98fec1bde 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -719,7 +719,7 @@ void RichTextLabel::_input_event(InputEvent p_event) {
case InputEvent::KEY: {
const InputEventKey &k=p_event.key;
- if (k.pressed) {
+ if (k.pressed && !k.mod.alt && !k.mod.shift && !k.mod.command && !k.mod.meta) {
bool handled=true;
switch(k.scancode) {
case KEY_PAGEUP: {
@@ -765,6 +765,7 @@ void RichTextLabel::_input_event(InputEvent p_event) {
default: handled=false;
}
+
if (handled)
accept_event();
}
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index 6d84f028b3..8e448dfb2b 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -58,7 +58,7 @@ Size2 Tabs::get_minimum_size() const {
if (tabs[i].right_button.is_valid()) {
Ref<Texture> rb=tabs[i].right_button;
- Size2 bms = rb->get_size()+get_stylebox("button")->get_minimum_size();
+ Size2 bms = rb->get_size();//+get_stylebox("button")->get_minimum_size();
bms.width+=get_constant("hseparation");
ms.width+=bms.width;
@@ -67,9 +67,8 @@ Size2 Tabs::get_minimum_size() const {
if (tabs[i].close_button.is_valid()) {
Ref<Texture> cb=tabs[i].close_button;
- Size2 bms = cb->get_size()+get_stylebox("button")->get_minimum_size();
+ Size2 bms = cb->get_size();//+get_stylebox("button")->get_minimum_size();
bms.width+=get_constant("hseparation");
-
ms.width+=bms.width;
ms.height=MAX(bms.height+tab_bg->get_minimum_size().height,ms.height);
}
@@ -262,9 +261,9 @@ void Tabs::_notification(int p_what) {
Ref<Texture> rb=tabs[i].right_button;
lsize+=get_constant("hseparation");
- lsize+=style->get_margin(MARGIN_LEFT);
+ //lsize+=style->get_margin(MARGIN_LEFT);
lsize+=rb->get_width();
- lsize+=style->get_margin(MARGIN_RIGHT);
+ //lsize+=style->get_margin(MARGIN_RIGHT);
}
@@ -276,9 +275,9 @@ void Tabs::_notification(int p_what) {
Ref<Texture> rb=tabs[i].close_button;
lsize+=get_constant("hseparation");
- lsize+=style->get_margin(MARGIN_LEFT);
+ //lsize+=style->get_margin(MARGIN_LEFT);
lsize+=rb->get_width();
- lsize+=style->get_margin(MARGIN_RIGHT);
+ //lsize+=style->get_margin(MARGIN_RIGHT);
}
} break;
@@ -289,9 +288,9 @@ void Tabs::_notification(int p_what) {
Ref<Texture> rb=tabs[i].close_button;
lsize+=get_constant("hseparation");
- lsize+=style->get_margin(MARGIN_LEFT);
+ //lsize+=style->get_margin(MARGIN_LEFT);
lsize+=rb->get_width();
- lsize+=style->get_margin(MARGIN_RIGHT);
+ //lsize+=style->get_margin(MARGIN_RIGHT);
}
}
@@ -303,9 +302,9 @@ void Tabs::_notification(int p_what) {
Ref<Texture> rb=tabs[i].close_button;
lsize+=get_constant("hseparation");
- lsize+=style->get_margin(MARGIN_LEFT);
+ //lsize+=style->get_margin(MARGIN_LEFT);
lsize+=rb->get_width();
- lsize+=style->get_margin(MARGIN_RIGHT);
+ //lsize+=style->get_margin(MARGIN_RIGHT);
}
}
@@ -404,11 +403,11 @@ void Tabs::_notification(int p_what) {
style->draw(ci,cb_rect);
}
- w+=style->get_margin(MARGIN_LEFT);
+ //w+=style->get_margin(MARGIN_LEFT);
cb->draw(ci,Point2i( w,cb_rect.pos.y+style->get_margin(MARGIN_TOP) ));
w+=cb->get_width();
- w+=style->get_margin(MARGIN_RIGHT);
+ //w+=style->get_margin(MARGIN_RIGHT);
tabs[i].cb_rect=cb_rect;
}
} break;
@@ -432,11 +431,11 @@ void Tabs::_notification(int p_what) {
style->draw(ci,cb_rect);
}
- w+=style->get_margin(MARGIN_LEFT);
+ //w+=style->get_margin(MARGIN_LEFT);
cb->draw(ci,Point2i( w,cb_rect.pos.y+style->get_margin(MARGIN_TOP) ));
w+=cb->get_width();
- w+=style->get_margin(MARGIN_RIGHT);
+ //w+=style->get_margin(MARGIN_RIGHT);
tabs[i].cb_rect=cb_rect;
}
}
@@ -461,11 +460,11 @@ void Tabs::_notification(int p_what) {
style->draw(ci,cb_rect);
}
- w+=style->get_margin(MARGIN_LEFT);
+ //w+=style->get_margin(MARGIN_LEFT);
cb->draw(ci,Point2i( w,cb_rect.pos.y+style->get_margin(MARGIN_TOP) ));
w+=cb->get_width();
- w+=style->get_margin(MARGIN_RIGHT);
+ //w+=style->get_margin(MARGIN_RIGHT);
tabs[i].cb_rect=cb_rect;
}
}
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index be6c0d0a8b..d081e84df4 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1647,8 +1647,60 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
case KEY_BACKSPACE: {
if (readonly)
break;
- backspace_at_cursor();
-
+
+#ifdef APPLE_STYLE_KEYS
+ if (k.mod.alt) {
+#else
+ if (k.mod.alt) {
+ scancode_handled=false;
+ break;
+ } else if (k.mod.command) {
+#endif
+ int line=cursor.line;
+ int column=cursor.column;
+
+ bool prev_char=false;
+ bool only_whitespace=true;
+
+ while (only_whitespace && line > 0) {
+
+ while (column>0) {
+ CharType c=text[line][column-1];
+
+ if (c != '\t' && c != ' ') {
+ only_whitespace=false;
+ break;
+ }
+
+ column--;
+ }
+
+ if (only_whitespace) {
+ line--;
+ column=text[line].length();
+ }
+ }
+
+ while (column>0) {
+ bool ischar=_is_text_char(text[line][column-1]);
+
+ if (prev_char && !ischar)
+ break;
+
+ prev_char=ischar;
+ column--;
+
+ }
+
+ _remove_text(line, column, cursor.line, cursor.column);
+
+ cursor_set_line(line);
+ cursor_set_column(column);
+
+ } else {
+ backspace_at_cursor();
+ }
+
} break;
case KEY_LEFT: {
@@ -1789,10 +1841,63 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (cursor.line==text.size()-1 && cursor.column==curline_len)
break; //nothing to do
- int next_line = cursor.column<curline_len?cursor.line:cursor.line+1;
- int next_column = cursor.column<curline_len?(cursor.column+1):0;
+ int next_line=cursor.column<curline_len?cursor.line:cursor.line+1;
+ int next_column;
+
+#ifdef APPLE_STYLE_KEYS
+ if (k.mod.alt) {
+#else
+ if (k.mod.alt) {
+ scancode_handled=false;
+ break;
+ } else if (k.mod.command) {
+#endif
+ int last_line=text.size()-1;
+
+ int line=cursor.line;
+ int column=cursor.column;
+
+ bool prev_char=false;
+ bool only_whitespace=true;
+
+ while (only_whitespace && line < last_line) {
+
+ while (column<text[line].length()) {
+ CharType c=text[line][column];
+
+ if (c != '\t' && c != ' ') {
+ only_whitespace=false;
+ break;
+ }
+
+ column++;
+ }
+
+ if (only_whitespace) {
+ line++;
+ column=0;
+ }
+ }
+
+ while (column<text[line].length()) {
+
+ bool ischar=_is_text_char(text[line][column]);
+
+ if (prev_char && !ischar)
+ break;
+ prev_char=ischar;
+ column++;
+ }
+
+ next_line=line;
+ next_column=column;
+ } else {
+ next_column=cursor.column<curline_len?(cursor.column+1):0;
+ }
+
_remove_text(cursor.line,cursor.column,next_line,next_column);
update();
+
} break;
#ifdef APPLE_STYLE_KEYS
case KEY_HOME: {
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 5df6f2ced9..a27918cf52 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -962,7 +962,9 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
Point2i guide_space=Point2i( cache.guide_width , height );
- if (p_item->childs) { //has childs, draw the guide box
+
+
+ if (!hide_folding && p_item->childs) { //has childs, draw the guide box
Ref<Texture> arrow;
@@ -986,7 +988,7 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
int font_ascent=font->get_ascent();
- int ofs = p_pos.x + cache.item_margin;
+ int ofs = p_pos.x + (hide_folding?cache.hseparation:cache.item_margin);
for (int i=0;i<columns.size();i++) {
int w = get_column_width(i);
@@ -1062,7 +1064,10 @@ int Tree::draw_item(const Point2i& p_pos,const Point2& p_draw_ofs, const Size2&
if (p_item->cells[i].custom_bg_color) {
- VisualServer::get_singleton()->canvas_item_add_rect(ci,cell_rect,p_item->cells[i].bg_color);
+ Rect2 r=cell_rect;
+ r.pos.x-=cache.hseparation;
+ r.size.x+=cache.hseparation;
+ VisualServer::get_singleton()->canvas_item_add_rect(ci,r,p_item->cells[i].bg_color);
}
Color col=p_item->cells[i].custom_color?p_item->cells[i].color:get_color( p_item->cells[i].selected?"font_color_selected":"font_color");
@@ -1376,7 +1381,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
if (!skip && p_pos.y<item_h) {
// check event!
- if (p_pos.x >=x_ofs && p_pos.x < (x_ofs+cache.item_margin) ) {
+ if (!hide_folding && (p_pos.x >=x_ofs && p_pos.x < (x_ofs+cache.item_margin) )) {
if (p_item->childs)
@@ -3114,6 +3119,16 @@ bool Tree::can_cursor_exit_tree() const {
return cursor_can_exit_tree;
}
+void Tree::set_hide_folding(bool p_hide) {
+ hide_folding=p_hide;
+ update();
+}
+
+bool Tree::is_folding_hidden() const {
+
+ return hide_folding;
+}
+
void Tree::_bind_methods() {
@@ -3155,6 +3170,9 @@ void Tree::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_column_title","column"),&Tree::get_column_title);
ObjectTypeDB::bind_method(_MD("get_scroll"),&Tree::get_scroll);
+ ObjectTypeDB::bind_method(_MD("set_hide_folding","hide"),&Tree::set_hide_folding);
+ ObjectTypeDB::bind_method(_MD("is_folding_hidden"),&Tree::is_folding_hidden);
+
ADD_SIGNAL( MethodInfo("item_selected"));
ADD_SIGNAL( MethodInfo("cell_selected"));
@@ -3242,6 +3260,8 @@ Tree::Tree() {
pressing_for_editor=false;
range_drag_enabled=false;
+ hide_folding=false;
+
}
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 3fbd7c95d9..8fb9b802a1 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -228,6 +228,7 @@ public:
void set_tooltip(int p_column, const String& p_tooltip);
String get_tooltip(int p_column) const;
+
void clear_children();
void move_to_top();
@@ -410,6 +411,8 @@ friend class TreeItem;
bool drag_touching_deaccel;
bool click_handled;
+ bool hide_folding;
+
protected:
static void _bind_methods();
@@ -467,6 +470,11 @@ public:
VScrollBar *get_vscroll_bar() { return v_scroll; }
+ void set_hide_folding(bool p_hide);
+ bool is_folding_hidden() const;
+
+
+
Tree();
~Tree();
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index b4cd437d35..9b9c797ed9 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -384,12 +384,12 @@ void VideoPlayer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_buffering_msec","msec"),&VideoPlayer::set_buffering_msec);
ObjectTypeDB::bind_method(_MD("get_buffering_msec"),&VideoPlayer::get_buffering_msec);
+ ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") );
ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"VideoStream"), _SCS("set_stream"), _SCS("get_stream") );
// ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/loop"), _SCS("set_loop"), _SCS("has_loop") );
ADD_PROPERTY( PropertyInfo(Variant::REAL, "stream/volume_db", PROPERTY_HINT_RANGE,"-80,24,0.01"), _SCS("set_volume_db"), _SCS("get_volume_db") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/autoplay"), _SCS("set_autoplay"), _SCS("has_autoplay") );
ADD_PROPERTY( PropertyInfo(Variant::BOOL, "stream/paused"), _SCS("set_paused"), _SCS("is_paused") );
- ADD_PROPERTY( PropertyInfo(Variant::INT, "stream/audio_track",PROPERTY_HINT_RANGE,"0,128,1"), _SCS("set_audio_track"), _SCS("get_audio_track") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "expand" ), _SCS("set_expand"),_SCS("has_expand") );
}