summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/tab_container.cpp6
-rw-r--r--scene/gui/tabs.cpp3
-rw-r--r--scene/gui/text_edit.cpp119
-rw-r--r--scene/gui/text_edit.h7
-rw-r--r--scene/gui/tree.cpp2
-rw-r--r--scene/gui/video_player.cpp14
6 files changed, 108 insertions, 43 deletions
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 3c95b102d7..2d6f3cd27a 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -113,7 +113,7 @@ void TabContainer::_input_event(const InputEvent& p_event) {
break;
}
- String s = c->has_meta("_tab_title")?String(XL_MESSAGE(String(c->get_meta("_tab_title")))):String(c->get_name());
+ String s = c->has_meta("_tab_name")?String(XL_MESSAGE(String(c->get_meta("_tab_name")))):String(c->get_name());
int tab_width=font->get_string_size(s).width;
if (c->has_meta("_tab_icon")) {
@@ -220,7 +220,7 @@ void TabContainer::_notification(int p_what) {
continue;
- String s = c->has_meta("_tab_title")?String(XL_MESSAGE(String(c->get_meta("_tab_title")))):String(c->get_name());
+ String s = c->has_meta("_tab_name")?String(XL_MESSAGE(String(c->get_meta("_tab_name")))):String(c->get_name());
w+=font->get_string_size(s).width;
if (c->has_meta("_tab_icon")) {
Ref<Texture> icon = c->get_meta("_tab_icon");
@@ -284,7 +284,7 @@ void TabContainer::_notification(int p_what) {
continue;
}
- String s = c->has_meta("_tab_title")?String(c->get_meta("_tab_title")):String(c->get_name());
+ String s = c->has_meta("_tab_name")?String(c->get_meta("_tab_name")):String(c->get_name());
int w=font->get_string_size(s).width;
Ref<Texture> icon;
if (c->has_meta("_tab_icon")) {
diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp
index b7c857b9c7..ae7a4d59a7 100644
--- a/scene/gui/tabs.cpp
+++ b/scene/gui/tabs.cpp
@@ -278,7 +278,8 @@ void Tabs::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_tab_title","tab_idx"),&Tabs::get_tab_title);
ObjectTypeDB::bind_method(_MD("set_tab_icon","tab_idx","icon:Texture"),&Tabs::set_tab_icon);
ObjectTypeDB::bind_method(_MD("get_tab_icon:Texture","tab_idx"),&Tabs::get_tab_icon);
- ObjectTypeDB::bind_method(_MD("remove_tab","tab_idx","icon:Texture"),&Tabs::remove_tab);
+ ObjectTypeDB::bind_method(_MD("remove_tab","tab_idx"),&Tabs::remove_tab);
+ ObjectTypeDB::bind_method(_MD("add_tab","title","icon:Texture"),&Tabs::add_tab);
ADD_SIGNAL(MethodInfo("tab_changed",PropertyInfo(Variant::INT,"tab")));
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 3566c1bfc4..0b797e7df3 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1354,13 +1354,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
cursor_set_column(cc);
- } else if (cursor.column==0) {
+ } else if (cursor.column==0) {
if (cursor.line>0) {
cursor_set_line(cursor.line-1);
cursor_set_column(text[cursor.line].length());
}
- } else {
+ } else {
cursor_set_column(cursor_get_column()-1);
}
@@ -1394,13 +1394,13 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
cursor_set_column(cc);
- } else if (cursor.column==text[cursor.line].length()) {
+ } else if (cursor.column==text[cursor.line].length()) {
if (cursor.line<text.size()-1) {
cursor_set_line(cursor.line+1);
cursor_set_column(0);
}
- } else {
+ } else {
cursor_set_column(cursor_get_column()+1);
}
@@ -1569,19 +1569,35 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
break;
}
- if (!selection.active)
- break;
+ if (!selection.active){
- String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- OS::get_singleton()->set_clipboard(clipboard);
+ String clipboard = text[cursor.line];
+ OS::get_singleton()->set_clipboard(clipboard);
+ cursor_set_line(cursor.line);
+ cursor_set_column(0);
+ _remove_text(cursor.line,0,cursor.line,text[cursor.line].length());
- cursor_set_line(selection.from_line);
- cursor_set_column(selection.from_column);
+ backspace_at_cursor();
+ update();
+ cursor_set_line(cursor.line+1);
+ cut_copy_line = true;
- _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- selection.active=false;
- selection.selecting_mode=Selection::MODE_NONE;
- update();
+ }
+ else
+ {
+
+ String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
+ OS::get_singleton()->set_clipboard(clipboard);
+
+ cursor_set_line(selection.from_line);
+ cursor_set_column(selection.from_column);
+
+ _remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
+ selection.active=false;
+ selection.selecting_mode=Selection::MODE_NONE;
+ update();
+ cut_copy_line = false;
+ }
} break;
case KEY_C: {
@@ -1591,11 +1607,16 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
break;
}
- if (!selection.active)
- break;
-
- String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
- OS::get_singleton()->set_clipboard(clipboard);
+ if (!selection.active){
+ String clipboard = _base_get_text(cursor.line,0,cursor.line,text[cursor.line].length());
+ OS::get_singleton()->set_clipboard(clipboard);
+ cut_copy_line = true;
+ }
+ else{
+ String clipboard = _base_get_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
+ OS::get_singleton()->set_clipboard(clipboard);
+ cut_copy_line = false;
+ }
} break;
case KEY_Z: {
@@ -1625,6 +1646,12 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
cursor_set_column(selection.from_column);
}
+ else if (cut_copy_line)
+ {
+ cursor_set_column(0);
+ String ins="\n";
+ clipboard += ins;
+ }
_insert_text_at_cursor(clipboard);
@@ -1641,10 +1668,54 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} break;
- default: {
-
- scancode_handled=false;
- } break;
+ case KEY_K:{
+ if (!k.mod.command || k.mod.shift || k.mod.alt) {
+ scancode_handled=false;
+ break;
+ }
+ else {
+ if (selection.active) {
+ int ini = selection.from_line;
+ int end = selection.to_line;
+ for (int i=ini; i<= end; i++)
+ {
+ _insert_text(i,0,"#");
+ }
+ }
+ else{
+ _insert_text(cursor.line,0,"#");
+ }
+ update();
+ }
+ break;}
+
+ case KEY_U:{
+ if (!k.mod.command || k.mod.shift || k.mod.alt) {
+ scancode_handled=false;
+ break;
+ }
+ else {
+ if (selection.active) {
+ int ini = selection.from_line;
+ int end = selection.to_line;
+ for (int i=ini; i<= end; i++)
+ {
+ if (text[i][0] == '#')
+ _remove_text(i,0,i,1);
+ }
+ }
+ else{
+ if (text[cursor.line][0] == '#')
+ _remove_text(cursor.line,0,cursor.line,1);
+ }
+ update();
+ }
+ break;}
+
+ default: {
+
+ scancode_handled=false;
+ } break;
}
@@ -3158,7 +3229,7 @@ TextEdit::TextEdit() {
current_op.type=TextOperation::TYPE_NONE;
undo_enabled=true;
- undo_stack_pos=NULL;
+ undo_stack_pos=NULL;
setting_text=false;
last_dblclk=0;
current_op.version=0;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 7700bfd4d3..15c289a87e 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -162,7 +162,7 @@ class TextEdit : public Control {
TextOperation current_op;
List<TextOperation> undo_stack;
- List<TextOperation>::Element *undo_stack_pos;
+ List<TextOperation>::Element *undo_stack_pos;
void _clear_redo();
void _do_text_op(const TextOperation& p_op, bool p_reverse);
@@ -208,6 +208,7 @@ class TextEdit : public Control {
bool line_numbers;
bool auto_brace_completion_enabled;
+ bool cut_copy_line;
uint64_t last_dblclk;
@@ -336,7 +337,7 @@ public:
bool is_selection_active() const;
int get_selection_from_line() const;
- int get_selection_from_column() const;
+ int get_selection_from_column() const;
int get_selection_to_line() const;
int get_selection_to_column() const;
String get_selection_text() const;
@@ -347,7 +348,7 @@ public:
void undo();
void redo();
- void clear_undo_history();
+ void clear_undo_history();
void set_draw_tabs(bool p_draw);
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index fb85f0c6b7..25f04379ef 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2787,7 +2787,7 @@ int Tree::get_item_offset(TreeItem *p_item) const {
ofs+=compute_item_height(it)+cache.vseparation;
- if (it->childs) {
+ if (it->childs && !it->collapsed) {
it=it->childs;
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index e3bb50a9af..9a1c070529 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -46,6 +46,7 @@ void VideoPlayer::_notification(int p_notification) {
if (paused)
return;
+ stream->update(get_scene()->get_idle_process_time());
while (stream->get_pending_frame_count()) {
Image img = stream->pop_frame();
@@ -104,10 +105,6 @@ void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) {
stop();
- if (stream_rid.is_valid())
- AudioServer::get_singleton()->free(stream_rid);
- stream_rid=RID();
-
texture = Ref<ImageTexture>(memnew(ImageTexture));
stream=p_stream;
@@ -115,7 +112,6 @@ void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) {
stream->set_loop(loops);
stream->set_paused(paused);
- stream_rid=AudioServer::get_singleton()->audio_stream_create(stream->get_audio_stream());
}
};
@@ -131,8 +127,6 @@ void VideoPlayer::play() {
if (stream.is_null())
return;
stream->play();
- AudioServer::get_singleton()->stream_set_active(stream_rid,true);
- AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
set_process(true);
};
@@ -143,7 +137,6 @@ void VideoPlayer::stop() {
if (stream.is_null())
return;
- AudioServer::get_singleton()->stream_set_active(stream_rid,false);
stream->stop();
set_process(false);
};
@@ -173,8 +166,6 @@ bool VideoPlayer::is_paused() const {
void VideoPlayer::set_volume(float p_vol) {
volume=p_vol;
- if (stream_rid.is_valid())
- AudioServer::get_singleton()->stream_set_volume_scale(stream_rid,volume);
};
float VideoPlayer::get_volume() const {
@@ -213,6 +204,7 @@ float VideoPlayer::get_pos() const {
return stream->get_pos();
};
+
void VideoPlayer::set_autoplay(bool p_enable) {
autoplay=p_enable;
@@ -253,7 +245,7 @@ void VideoPlayer::_bind_methods() {
ObjectTypeDB::bind_method(_MD("has_expand"), &VideoPlayer::has_expand );
- ADD_PROPERTY( PropertyInfo(Variant::OBJECT, "stream/stream", PROPERTY_HINT_RESOURCE_TYPE,"AudioStream"), _SCS("set_stream"), _SCS("get_stream") );
+ 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") );