aboutsummaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/base_button.cpp5
-rw-r--r--scene/gui/base_button.h2
-rw-r--r--scene/gui/control.cpp2
-rw-r--r--scene/gui/label.cpp11
-rw-r--r--scene/gui/line_edit.cpp5
-rw-r--r--scene/gui/popup.cpp16
-rw-r--r--scene/gui/popup.h4
-rw-r--r--scene/gui/progress_bar.cpp110
-rw-r--r--scene/gui/progress_bar.h43
-rw-r--r--scene/gui/rich_text_label.cpp7
-rw-r--r--scene/gui/scroll_bar.cpp247
-rw-r--r--scene/gui/scroll_bar.h20
-rw-r--r--scene/gui/scroll_container.cpp2
-rw-r--r--scene/gui/tab_container.cpp6
-rw-r--r--scene/gui/tabs.cpp3
-rw-r--r--scene/gui/text_edit.cpp372
-rw-r--r--scene/gui/text_edit.h32
-rw-r--r--scene/gui/tree.cpp2
-rw-r--r--scene/gui/video_player.cpp14
19 files changed, 761 insertions, 142 deletions
diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp
index 2e0387106..ac2417d53 100644
--- a/scene/gui/base_button.cpp
+++ b/scene/gui/base_button.cpp
@@ -276,6 +276,10 @@ bool BaseButton::is_pressed() const {
return toggle_mode?status.pressed:status.press_attempt;
}
+bool BaseButton::is_hovered() const {
+
+ return status.hovering;
+}
BaseButton::DrawMode BaseButton::get_draw_mode() const {
@@ -337,6 +341,7 @@ void BaseButton::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_input_event"),&BaseButton::_input_event);
ObjectTypeDB::bind_method(_MD("set_pressed","pressed"),&BaseButton::set_pressed);
ObjectTypeDB::bind_method(_MD("is_pressed"),&BaseButton::is_pressed);
+ ObjectTypeDB::bind_method(_MD("is_hovered"),&BaseButton::is_hovered);
ObjectTypeDB::bind_method(_MD("set_toggle_mode","enabled"),&BaseButton::set_toggle_mode);
ObjectTypeDB::bind_method(_MD("is_toggle_mode"),&BaseButton::is_toggle_mode);
ObjectTypeDB::bind_method(_MD("set_disabled","disabled"),&BaseButton::set_disabled);
diff --git a/scene/gui/base_button.h b/scene/gui/base_button.h
index 65563ddc0..a2c640b9c 100644
--- a/scene/gui/base_button.h
+++ b/scene/gui/base_button.h
@@ -83,6 +83,8 @@ public:
bool is_pressed() const; ///< return wether button is pressed (toggled in)
bool is_pressing() const; ///< return wether button is pressed (toggled in)
+ bool is_hovered() const;
+
void set_pressed(bool p_pressed); ///only works in toggle mode
void set_toggle_mode(bool p_on);
bool is_toggle_mode() const;
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index 4b4b4b3c7..687879336 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1002,7 +1002,7 @@ void Control::_window_input_event(InputEvent p_event) {
}
- p_event.mouse_button.global_x = pos.x;
+ p_event.mouse_button.global_x = pos.x;
p_event.mouse_button.global_y = pos.y;
pos = window->focus_inv_xform.xform(pos);
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index a2f837c3c..b7918994d 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -398,12 +398,15 @@ void Label::regenerate_word_cache() {
}
if (current=='\n') {
-
insert_newline=true;
} else {
total_char_cache++;
}
+ if (i<text.length() && text[i] == ' ') {
+ total_char_cache--; // do not count spaces
+ }
+
} else {
@@ -442,7 +445,8 @@ void Label::regenerate_word_cache() {
last_width=line_width;
}
-
+
+ total_char_cache -= line_count + 1; // do not count new lines (including the first one)
if (!autowrap) {
@@ -519,6 +523,7 @@ String Label::get_text() const {
return text;
}
+
void Label::set_visible_characters(int p_amount) {
visible_chars=p_amount;
@@ -582,7 +587,7 @@ void Label::_bind_methods() {
ADD_PROPERTY( PropertyInfo( Variant::INT, "valign", PROPERTY_HINT_ENUM,"Top,Center,Bottom,Fill" ),_SCS("set_valign"),_SCS("get_valign") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "autowrap"),_SCS("set_autowrap"),_SCS("has_autowrap") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "uppercase"),_SCS("set_uppercase"),_SCS("is_uppercase") );
- ADD_PROPERTY( PropertyInfo( Variant::REAL, "percent_visible"),_SCS("set_percent_visible"),_SCS("get_percent_visible") );
+ ADD_PROPERTY( PropertyInfo( Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE,"0,1,0.001"),_SCS("set_percent_visible"),_SCS("get_percent_visible") );
}
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 6c9db7484..e822cfef1 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -323,9 +323,12 @@ bool LineEdit::can_drop_data(const Point2& p_point,const Variant& p_data) const{
void LineEdit::drop_data(const Point2& p_point,const Variant& p_data){
if (p_data.get_type()==Variant::STRING) {
-
set_cursor_at_pixel_pos(p_point.x);
+ int selected = selection.end - selection.begin;
+ text.erase(selection.begin, selected);
append_at_cursor(p_data);
+ selection.begin = cursor_pos-selected;
+ selection.end = cursor_pos;
}
}
diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp
index 0a5b72d2e..65ad02723 100644
--- a/scene/gui/popup.cpp
+++ b/scene/gui/popup.cpp
@@ -38,7 +38,13 @@ void Popup::_input_event(InputEvent p_event) {
void Popup::_notification(int p_what) {
-
+ if (p_what==NOTIFICATION_VISIBILITY_CHANGED) {
+ if (popped_up && !is_visible()) {
+ popped_up=false;
+ notification(NOTIFICATION_POPUP_HIDE);
+ emit_signal("popup_hide");
+ }
+ }
}
void Popup::_fix_size() {
@@ -101,6 +107,7 @@ void Popup::popup_centered_minsize(const Size2& p_minsize) {
popup_centered( total_minsize );
+ popped_up=true;
}
@@ -127,6 +134,7 @@ void Popup::popup_centered(const Size2& p_size) {
_post_popup();
notification(NOTIFICATION_POST_POPUP);
+ popped_up=true;
}
void Popup::popup_centered_ratio(float p_screen_ratio) {
@@ -153,6 +161,7 @@ void Popup::popup_centered_ratio(float p_screen_ratio) {
_post_popup();
notification(NOTIFICATION_POST_POPUP);
+ popped_up=true;
}
@@ -171,6 +180,7 @@ void Popup::popup() {
_post_popup();
notification(NOTIFICATION_POST_POPUP);
+ popped_up=true;
}
void Popup::set_exclusive(bool p_exclusive) {
@@ -193,8 +203,11 @@ void Popup::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_exclusive","enable"),&Popup::set_exclusive);
ObjectTypeDB::bind_method(_MD("is_exclusive"),&Popup::is_exclusive);
ADD_SIGNAL( MethodInfo("about_to_show") );
+ ADD_SIGNAL( MethodInfo("popup_hide") );
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "popup/exclusive"), _SCS("set_exclusive"),_SCS("is_exclusive") );
BIND_CONSTANT(NOTIFICATION_POST_POPUP);
+ BIND_CONSTANT(NOTIFICATION_POPUP_HIDE);
+
}
@@ -202,6 +215,7 @@ Popup::Popup() {
set_as_toplevel(true);
exclusive=false;
+ popped_up=false;
hide();
}
diff --git a/scene/gui/popup.h b/scene/gui/popup.h
index 3744ff283..072b66c2c 100644
--- a/scene/gui/popup.h
+++ b/scene/gui/popup.h
@@ -39,6 +39,7 @@ class Popup : public Control {
OBJ_TYPE( Popup, Control );
bool exclusive;
+ bool popped_up;
protected:
@@ -51,7 +52,8 @@ protected:
public:
enum {
- NOTIFICATION_POST_POPUP=80
+ NOTIFICATION_POST_POPUP=80,
+ NOTIFICATION_POPUP_HIDE=81
};
void set_exclusive(bool p_exclusive);
diff --git a/scene/gui/progress_bar.cpp b/scene/gui/progress_bar.cpp
index 09b960f34..73fa1fbb9 100644
--- a/scene/gui/progress_bar.cpp
+++ b/scene/gui/progress_bar.cpp
@@ -26,47 +26,69 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "progress_bar.h"
-
-
-Size2 ProgressBar::get_minimum_size() const {
-
- Ref<StyleBox> bg = get_stylebox("bg");
- Ref<Font> font = get_font("font");
-
- Size2 ms=bg->get_minimum_size()+bg->get_center_size();
- ms.height=MAX(ms.height,bg->get_minimum_size().height+font->get_height());
- return ms;
-}
-
-
-void ProgressBar::_notification(int p_what) {
-
-
- if (p_what==NOTIFICATION_DRAW) {
-
- Ref<StyleBox> bg = get_stylebox("bg");
- Ref<StyleBox> fg = get_stylebox("fg");
- Ref<Font> font = get_font("font");
- Color font_color=get_color("font_color");
- Color font_color_shadow=get_color("font_color_shadow");
-
- draw_style_box(bg,Rect2(Point2(),get_size()));
- float r = get_unit_value();
- int mp = fg->get_minimum_size().width;
- int p = r*get_size().width-mp;
- if (p>0) {
-
- draw_style_box(fg,Rect2(Point2(),Size2(p+fg->get_minimum_size().width,get_size().height)));
- }
-
- int fh=font->get_height();
- String txt=itos(int(get_unit_value()*100))+"%";
- font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color);
- }
-}
-
-ProgressBar::ProgressBar() {
-
- set_v_size_flags(0);
-}
+#include "progress_bar.h"
+
+
+Size2 ProgressBar::get_minimum_size() const {
+
+ Ref<StyleBox> bg = get_stylebox("bg");
+ Ref<Font> font = get_font("font");
+
+ Size2 ms=bg->get_minimum_size()+bg->get_center_size();
+ ms.height=MAX(ms.height,bg->get_minimum_size().height+font->get_height());
+ return ms;
+}
+
+
+void ProgressBar::_notification(int p_what) {
+
+
+ if (p_what==NOTIFICATION_DRAW) {
+
+ Ref<StyleBox> bg = get_stylebox("bg");
+ Ref<StyleBox> fg = get_stylebox("fg");
+ Ref<Font> font = get_font("font");
+ Color font_color=get_color("font_color");
+ Color font_color_shadow=get_color("font_color_shadow");
+
+ draw_style_box(bg,Rect2(Point2(),get_size()));
+ float r = get_unit_value();
+ int mp = fg->get_minimum_size().width;
+ int p = r*get_size().width-mp;
+ if (p>0) {
+
+ draw_style_box(fg,Rect2(Point2(),Size2(p+fg->get_minimum_size().width,get_size().height)));
+ }
+
+ if (percent_visible) {
+ int fh=font->get_height();
+ String txt=itos(int(get_unit_value()*100))+"%";
+ font->draw_halign(get_canvas_item(),Point2(0,font->get_ascent()+(get_size().height-font->get_height())/2),HALIGN_CENTER,get_size().width,txt,font_color);
+ }
+ }
+}
+
+
+void ProgressBar::set_percent_visible(bool p_visible) {
+
+ percent_visible=p_visible;
+ update();
+}
+
+bool ProgressBar::is_percent_visible() const{
+
+ return percent_visible;
+}
+
+void ProgressBar::_bind_methods() {
+
+ ObjectTypeDB::bind_method(_MD("set_percent_visible","visible"),&ProgressBar::set_percent_visible);
+ ObjectTypeDB::bind_method(_MD("is_percent_visible"),&ProgressBar::is_percent_visible);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL,"percent/visible"),_SCS("set_percent_visible"),_SCS("is_percent_visible"));
+}
+
+ProgressBar::ProgressBar() {
+
+ set_v_size_flags(0);
+ percent_visible=true;
+}
diff --git a/scene/gui/progress_bar.h b/scene/gui/progress_bar.h
index fa334a2ad..fd34c67fa 100644
--- a/scene/gui/progress_bar.h
+++ b/scene/gui/progress_bar.h
@@ -26,22 +26,27 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PROGRESS_BAR_H
-#define PROGRESS_BAR_H
-
-#include "scene/gui/range.h"
-
-class ProgressBar : public Range {
-
- OBJ_TYPE( ProgressBar, Range );
-
-protected:
-
- void _notification(int p_what);
-public:
-
- Size2 get_minimum_size() const;
- ProgressBar();
-};
-
-#endif // PROGRESS_BAR_H
+#ifndef PROGRESS_BAR_H
+#define PROGRESS_BAR_H
+
+#include "scene/gui/range.h"
+
+class ProgressBar : public Range {
+
+ OBJ_TYPE( ProgressBar, Range );
+
+ bool percent_visible;
+protected:
+
+ void _notification(int p_what);
+ static void _bind_methods();
+public:
+
+ void set_percent_visible(bool p_visible);
+ bool is_percent_visible() const;
+
+ Size2 get_minimum_size() const;
+ ProgressBar();
+};
+
+#endif // PROGRESS_BAR_H
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 5ac278a38..94df42fc8 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -1512,6 +1512,10 @@ void RichTextLabel::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_selection_enabled","enabled"),&RichTextLabel::set_selection_enabled);
ObjectTypeDB::bind_method(_MD("is_selection_enabled"),&RichTextLabel::is_selection_enabled);
+ ObjectTypeDB::bind_method(_MD("parse_bbcode", "bbcode"),&RichTextLabel::parse_bbcode);
+ ObjectTypeDB::bind_method(_MD("append_bbcode", "bbcode"),&RichTextLabel::append_bbcode);
+
+
ADD_SIGNAL( MethodInfo("meta_clicked",PropertyInfo(Variant::NIL,"meta")));
BIND_CONSTANT( ALIGN_LEFT );
@@ -1557,8 +1561,9 @@ RichTextLabel::RichTextLabel() {
scroll_active=true;
scroll_w=0;
- vscroll = memnew( VScrollBar );
+ vscroll = memnew( VScrollBar );
add_child(vscroll);
+ vscroll->set_drag_slave(String(".."));
vscroll->set_step(1);
vscroll->set_anchor_and_margin( MARGIN_TOP, ANCHOR_BEGIN, 0);
vscroll->set_anchor_and_margin( MARGIN_BOTTOM, ANCHOR_END, 0);
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index fdd30c5f6..c661a804b 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -29,7 +29,7 @@
#include "scroll_bar.h"
#include "os/keyboard.h"
#include "print_string.h"
-
+#include "os/os.h"
bool ScrollBar::focus_by_default=false;
@@ -293,6 +293,117 @@ void ScrollBar::_notification(int p_what) {
}
+ if (p_what==NOTIFICATION_ENTER_SCENE) {
+
+
+ if (has_node(drag_slave_path)) {
+ Node *n = get_node(drag_slave_path);
+ drag_slave=n->cast_to<Control>();
+ }
+
+ if (drag_slave) {
+ drag_slave->connect("input_event",this,"_drag_slave_input");
+ drag_slave->connect("exit_scene",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
+ }
+
+
+ }
+ if (p_what==NOTIFICATION_EXIT_SCENE) {
+
+ if (drag_slave) {
+ drag_slave->disconnect("input_event",this,"_drag_slave_input");
+ drag_slave->disconnect("exit_scene",this,"_drag_slave_exit");
+ }
+
+ drag_slave=NULL;
+
+ }
+
+ if (p_what==NOTIFICATION_FIXED_PROCESS) {
+
+ if (drag_slave_touching) {
+
+ if (drag_slave_touching_deaccel) {
+
+ Vector2 pos = Vector2(orientation==HORIZONTAL?get_val():0,orientation==VERTICAL?get_val():0);
+ pos+=drag_slave_speed*get_fixed_process_delta_time();
+
+ bool turnoff=false;
+
+ if (orientation==HORIZONTAL) {
+
+ if (pos.x<0) {
+ pos.x=0;
+ turnoff=true;
+ }
+
+ if (pos.x > (get_max()-get_page())) {
+ pos.x=get_max()-get_page();
+ turnoff=true;
+ }
+
+ set_val(pos.x);
+
+ float sgn_x = drag_slave_speed.x<0? -1 : 1;
+ float val_x = Math::abs(drag_slave_speed.x);
+ val_x-=1000*get_fixed_process_delta_time();
+
+ if (val_x<0) {
+ turnoff=true;
+ }
+
+ drag_slave_speed.x=sgn_x*val_x;
+
+ } else {
+
+
+ if (pos.y<0) {
+ pos.y=0;
+ turnoff=true;
+ }
+
+ if (pos.y > (get_max()-get_page())) {
+ pos.y=get_max()-get_page();
+ turnoff=true;
+ }
+
+ set_val(pos.y);
+
+ float sgn_y = drag_slave_speed.y<0? -1 : 1;
+ float val_y = Math::abs(drag_slave_speed.y);
+ val_y-=1000*get_fixed_process_delta_time();
+
+ if (val_y<0) {
+ turnoff=true;
+ }
+ drag_slave_speed.y=sgn_y*val_y;
+ }
+
+
+ if (turnoff) {
+ set_fixed_process(false);
+ drag_slave_touching=false;
+ drag_slave_touching_deaccel=false;
+ }
+
+
+ } else {
+
+
+ if (time_since_motion==0 || time_since_motion>0.1) {
+
+ Vector2 diff = drag_slave_accum - last_drag_slave_accum;
+ last_drag_slave_accum=drag_slave_accum;
+ drag_slave_speed=diff/get_fixed_process_delta_time();
+ }
+
+ time_since_motion+=get_fixed_process_delta_time();
+ }
+ }
+
+
+ }
+
if (p_what==NOTIFICATION_MOUSE_EXIT) {
hilite=HILITE_NONE;
@@ -432,6 +543,131 @@ float ScrollBar::get_custom_step() const {
}
+void ScrollBar::_drag_slave_exit() {
+
+ if (drag_slave) {
+ drag_slave->disconnect("input_event",this,"_drag_slave_input");
+ }
+ drag_slave=NULL;
+}
+
+
+void ScrollBar::_drag_slave_input(const InputEvent& p_input) {
+
+ switch(p_input.type) {
+
+ case InputEvent::MOUSE_BUTTON: {
+
+ const InputEventMouseButton &mb=p_input.mouse_button;
+
+ if (mb.button_index!=1)
+ break;
+
+ if (mb.pressed) {
+
+ if (drag_slave_touching) {
+ set_fixed_process(false);
+ drag_slave_touching_deaccel=false;
+ drag_slave_touching=false;
+ drag_slave_speed=Vector2();
+ drag_slave_accum=Vector2();
+ last_drag_slave_accum=Vector2();
+ drag_slave_from=Vector2();
+ }
+
+ if (true) {
+ drag_slave_speed=Vector2();
+ drag_slave_accum=Vector2();
+ last_drag_slave_accum=Vector2();
+ //drag_slave_from=Vector2(h_scroll->get_val(),v_scroll->get_val());
+ drag_slave_from= Vector2(orientation==HORIZONTAL?get_val():0,orientation==VERTICAL?get_val():0);
+
+ drag_slave_touching=OS::get_singleton()->has_touchscreen_ui_hint();
+ drag_slave_touching_deaccel=false;
+ time_since_motion=0;
+ if (drag_slave_touching) {
+ set_fixed_process(true);
+ time_since_motion=0;
+
+ }
+ }
+
+ } else {
+
+ if (drag_slave_touching) {
+
+ if (drag_slave_speed==Vector2()) {
+ drag_slave_touching_deaccel=false;
+ drag_slave_touching=false;
+ set_fixed_process(false);
+ } else {
+
+ drag_slave_touching_deaccel=true;
+ }
+ }
+ }
+ } break;
+ case InputEvent::MOUSE_MOTION: {
+
+ const InputEventMouseMotion &mm=p_input.mouse_motion;
+
+ if (drag_slave_touching && ! drag_slave_touching_deaccel) {
+
+ Vector2 motion = Vector2(mm.relative_x,mm.relative_y);
+
+ drag_slave_accum-=motion;
+ Vector2 diff = drag_slave_from+drag_slave_accum;
+
+ if (orientation==HORIZONTAL)
+ set_val(diff.x);
+ //else
+ // drag_slave_accum.x=0;
+ if (orientation==VERTICAL)
+ set_val(diff.y);
+ //else
+ // drag_slave_accum.y=0;
+ time_since_motion=0;
+ }
+
+ } break;
+ }
+}
+
+void ScrollBar::set_drag_slave(const NodePath& p_path) {
+
+ if (is_inside_scene()) {
+
+ if (drag_slave) {
+ drag_slave->disconnect("input_event",this,"_drag_slave_input");
+ drag_slave->disconnect("exit_scene",this,"_drag_slave_exit");
+ }
+ }
+
+ drag_slave=NULL;
+ drag_slave_path=p_path;
+
+ if (is_inside_scene()) {
+
+ if (has_node(p_path)) {
+ Node *n = get_node(p_path);
+ drag_slave=n->cast_to<Control>();
+ }
+
+ if (drag_slave) {
+ drag_slave->connect("input_event",this,"_drag_slave_input");
+ drag_slave->connect("exit_scene",this,"_drag_slave_exit",varray(),CONNECT_ONESHOT);
+ }
+ }
+}
+
+NodePath ScrollBar::get_drag_slave() const{
+
+
+ return drag_slave_path;
+}
+
+
+
#if 0
void ScrollBar::mouse_button(const Point2& p_pos, int b.button_index,bool b.pressed,int p_modifier_mask) {
@@ -571,6 +807,8 @@ void ScrollBar::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_input_event"),&ScrollBar::_input_event);
ObjectTypeDB::bind_method(_MD("set_custom_step","step"),&ScrollBar::set_custom_step);
ObjectTypeDB::bind_method(_MD("get_custom_step"),&ScrollBar::get_custom_step);
+ ObjectTypeDB::bind_method(_MD("_drag_slave_input"),&ScrollBar::_drag_slave_input);
+ ObjectTypeDB::bind_method(_MD("_drag_slave_exit"),&ScrollBar::_drag_slave_exit);
ADD_PROPERTY( PropertyInfo(Variant::REAL,"custom_step",PROPERTY_HINT_RANGE,"-1,4096"), _SCS("set_custom_step"),_SCS("get_custom_step"));
@@ -584,9 +822,14 @@ ScrollBar::ScrollBar(Orientation p_orientation)
orientation=p_orientation;
hilite=HILITE_NONE;
custom_step=-1;
+ drag_slave=NULL;
drag.active=false;
-
+
+ drag_slave_speed=Vector2();
+ drag_slave_touching=false;
+ drag_slave_touching_deaccel=false;
+
if (focus_by_default)
set_focus_mode( FOCUS_ALL );
diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h
index 663d3ecd8..ad3d1a7f5 100644
--- a/scene/gui/scroll_bar.h
+++ b/scene/gui/scroll_bar.h
@@ -70,7 +70,22 @@ class ScrollBar : public Range {
double get_grabber_offset() const;
static void set_can_focus_by_default(bool p_can_focus);
-
+
+ Node* drag_slave;
+ NodePath drag_slave_path;
+
+ Vector2 drag_slave_speed;
+ Vector2 drag_slave_accum;
+ Vector2 drag_slave_from;
+ Vector2 last_drag_slave_accum;
+ float last_drag_slave_time;
+ float time_since_motion;
+ bool drag_slave_touching;
+ bool drag_slave_touching_deaccel;
+ bool click_handled;
+
+ void _drag_slave_exit();
+ void _drag_slave_input(const InputEvent& p_input);
void _input_event(InputEvent p_event);
protected:
@@ -83,6 +98,9 @@ public:
void set_custom_step(float p_custom_step);
float get_custom_step() const;
+ void set_drag_slave(const NodePath& p_path);
+ NodePath get_drag_slave() const;
+
virtual Size2 get_minimum_size() const;
ScrollBar(Orientation p_orientation=VERTICAL);
~ScrollBar();
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp
index 817833083..c8f9ed16b 100644
--- a/scene/gui/scroll_container.cpp
+++ b/scene/gui/scroll_container.cpp
@@ -235,7 +235,7 @@ void ScrollContainer::_notification(int p_what) {
}
if (pos.y<0) {
- pos.x=0;
+ pos.y=0;
turnoff_v=true;
}
if (pos.y > (v_scroll->get_max()-v_scroll->get_page())) {
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 3c95b102d..2d6f3cd27 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 b7c857b9c..ae7a4d59a 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 d84e9956b..0b797e7df 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -46,7 +46,6 @@
#define TAB_PIXELS
-
static bool _is_text_char(CharType c) {
return (c>='a' && c<='z') || (c>='A' && c<='Z') || (c>='0' && c<='9') || c=='_';
@@ -57,6 +56,42 @@ static bool _is_symbol(CharType c) {
return c!='_' && ((c>='!' && c<='/') || (c>=':' && c<='@') || (c>='[' && c<='`') || (c>='{' && c<='~') || c=='\t');
}
+static bool _is_pair_right_symbol(CharType c) {
+ return
+ c == '"' ||
+ c == '\'' ||
+ c == ')' ||
+ c == ']' ||
+ c == '}';
+}
+
+static bool _is_pair_left_symbol(CharType c) {
+ return
+ c == '"' ||
+ c == '\'' ||
+ c == '(' ||
+ c == '[' ||
+ c == '{';
+}
+
+static bool _is_pair_symbol(CharType c) {
+ return _is_pair_left_symbol(c) || _is_pair_right_symbol(c);
+}
+
+static CharType _get_right_pair_symbol(CharType c) {
+ if(c == '"')
+ return '"';
+ if(c == '\'')
+ return '\'';
+ if(c == '(')
+ return ')';
+ if(c == '[')
+ return ']';
+ if(c == '{')
+ return '}';
+ return 0;
+}
+
void TextEdit::Text::set_font(const Ref<Font>& p_font) {
font=p_font;
@@ -301,7 +336,7 @@ void TextEdit::_update_scrollbars() {
v_scroll->set_val(cursor.line_ofs);
} else {
-
+ cursor.line_ofs = 0;
v_scroll->hide();
}
@@ -707,6 +742,93 @@ void TextEdit::_notification(int p_what) {
}
}
+void TextEdit::_consume_pair_symbol(CharType ch) {
+
+ int cursor_position_to_move = cursor_get_column() + 1;
+
+ CharType ch_single[2] = {ch, 0};
+ CharType ch_single_pair[2] = {_get_right_pair_symbol(ch), 0};
+ CharType ch_pair[3] = {ch, _get_right_pair_symbol(ch), 0};
+
+ if(is_selection_active()) {
+
+ int new_column,new_line;
+
+ _begin_compex_operation();
+ _insert_text(get_selection_from_line(), get_selection_from_column(),
+ ch_single,
+ &new_line, &new_column);
+
+ int to_col_offset = 0;
+ if(get_selection_from_line() == get_selection_to_line())
+ to_col_offset = 1;
+
+ _insert_text(get_selection_to_line(),
+ get_selection_to_column() + to_col_offset,
+ ch_single_pair,
+ &new_line,&new_column);
+ _end_compex_operation();
+
+ cursor_set_line(get_selection_to_line());
+ cursor_set_column(get_selection_to_column() + to_col_offset);
+
+ deselect();
+ update();
+ return;
+ }
+
+ if( (ch == '\'' || ch == '"') &&
+ cursor_get_column() > 0 &&
+ _is_text_char(text[cursor.line][cursor_get_column() - 1])
+ ) {
+ insert_text_at_cursor(ch_single);
+ cursor_set_column(cursor_position_to_move);
+ return;
+ }
+
+ if(cursor_get_column() < text[cursor.line].length()) {
+ if(_is_text_char(text[cursor.line][cursor_get_column()])) {
+ insert_text_at_cursor(ch_single);
+ cursor_set_column(cursor_position_to_move);
+ return;
+ }
+ if( _is_pair_right_symbol(ch) &&
+ text[cursor.line][cursor_get_column()] == ch
+ ) {
+ cursor_set_column(cursor_position_to_move);
+ return;
+ }
+ }
+
+
+ insert_text_at_cursor(ch_pair);
+ cursor_set_column(cursor_position_to_move);
+ return;
+
+}
+
+void TextEdit::_consume_backspace_for_pair_symbol(int prev_line, int prev_column) {
+
+ bool remove_right_symbol = false;
+
+ if(cursor.column < text[cursor.line].length() && cursor.column > 0) {
+
+ CharType left_char = text[cursor.line][cursor.column - 1];
+ CharType right_char = text[cursor.line][cursor.column];
+
+ if(right_char == _get_right_pair_symbol(left_char)) {
+ remove_right_symbol = true;
+ }
+
+ }
+ if(remove_right_symbol) {
+ _remove_text(prev_line,prev_column,cursor.line,cursor.column + 1);
+ } else {
+ _remove_text(prev_line,prev_column,cursor.line,cursor.column);
+ }
+
+}
+
void TextEdit::backspace_at_cursor() {
if (cursor.column==0 && cursor.line==0)
@@ -714,7 +836,14 @@ void TextEdit::backspace_at_cursor() {
int prev_line = cursor.column?cursor.line:cursor.line-1;
int prev_column = cursor.column?(cursor.column-1):(text[cursor.line-1].length());
- _remove_text(prev_line,prev_column,cursor.line,cursor.column);
+ if(auto_brace_completion_enabled &&
+ cursor.column > 0 &&
+ _is_pair_left_symbol(text[cursor.line][cursor.column - 1])) {
+ _consume_backspace_for_pair_symbol(prev_line, prev_column);
+ } else {
+ _remove_text(prev_line,prev_column,cursor.line,cursor.column);
+ }
+
cursor_set_line(prev_line);
cursor_set_column(prev_column);
@@ -976,7 +1105,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
return;
}
- if (k.scancode==KEY_RETURN) {
+ if (k.scancode==KEY_RETURN || k.scancode==KEY_TAB) {
_confirm_completion();
accept_event();
@@ -1002,11 +1131,17 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (cursor.column<text[cursor.line].length() && text[cursor.line][cursor.column]==k.unicode) {
//same char, move ahead
cursor_set_column(cursor.column+1);
+
} else {
//different char, go back
const CharType chr[2] = {k.unicode, 0};
- _insert_text_at_cursor(chr);
+ if(auto_brace_completion_enabled && _is_pair_symbol(chr[0])) {
+ _consume_pair_symbol(chr[0]);
+ } else {
+ _insert_text_at_cursor(chr);
+ }
}
+
_update_completion_candidates();
accept_event();
@@ -1072,8 +1207,10 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
cursor_set_line(selection.from_line);
cursor_set_column(selection.from_column);
+ _begin_compex_operation();
_remove_text(selection.from_line,selection.from_column,selection.to_line,selection.to_column);
_insert_text_at_cursor(txt);
+ _end_compex_operation();
selection.active=true;
selection.from_column=sel_column;
selection.from_line=sel_line;
@@ -1111,7 +1248,8 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
default:
if (k.unicode>=32 && !k.mod.command && !k.mod.alt && !k.mod.meta)
clear=true;
-
+ if (auto_brace_completion_enabled && _is_pair_left_symbol(k.unicode))
+ clear=false;
}
if (unselect) {
@@ -1216,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);
}
@@ -1256,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);
}
@@ -1431,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: {
@@ -1453,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: {
@@ -1487,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);
@@ -1503,10 +1668,54 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} break;
- default: {
+ 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;}
- scancode_handled=false;
- } 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;
}
@@ -1520,14 +1729,35 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (readonly)
break;
+ accept_event();
+ } else {
+
+ break;
+ }
+ }
+
+ if (!scancode_handled && !k.mod.command && !k.mod.alt) {
+
+ if (k.unicode>=32) {
+
+ if (readonly)
+ break;
+
const CharType chr[2] = {k.unicode, 0};
- _insert_text_at_cursor(chr);
+
+ if(auto_brace_completion_enabled && _is_pair_symbol(chr[0])) {
+ _consume_pair_symbol(chr[0]);
+ } else {
+ _insert_text_at_cursor(chr);
+ }
+
accept_event();
} else {
break;
}
}
+
if (!selection.selecting_test) {
@@ -1569,8 +1799,6 @@ void TextEdit::_post_shift_selection() {
/**** TEXT EDIT CORE API ****/
-
-
void TextEdit::_base_insert_text(int p_line, int p_char,const String& p_text,int &r_end_line,int &r_end_column) {
//save for undo...
@@ -1677,14 +1905,12 @@ void TextEdit::_base_remove_text(int p_from_line, int p_from_column,int p_to_lin
-
void TextEdit::_insert_text(int p_line, int p_char,const String& p_text,int *r_end_line,int *r_end_column) {
if (!setting_text)
idle_detect->start();
if (undo_enabled) {
-
_clear_redo();
}
@@ -1868,7 +2094,6 @@ void TextEdit::adjust_viewport_to_cursor() {
}
-
void TextEdit::cursor_set_column(int p_col) {
if (p_col<0)
@@ -2336,6 +2561,27 @@ String TextEdit::get_selection_text() const {
}
+String TextEdit::get_word_under_cursor() const {
+
+ int prev_cc = cursor.column;
+ while(prev_cc >0) {
+ bool is_char = _is_text_char(text[cursor.line][prev_cc-1]);
+ if (!is_char)
+ break;
+ --prev_cc;
+ }
+
+ int next_cc = cursor.column;
+ while(next_cc<text[cursor.line].length()) {
+ bool is_char = _is_text_char(text[cursor.line][next_cc]);
+ if(!is_char)
+ break;
+ ++ next_cc;
+ }
+ if (prev_cc == cursor.column || next_cc == cursor.column)
+ return "";
+ return text[cursor.line].substr(prev_cc, next_cc-prev_cc);
+}
DVector<int> TextEdit::_search_bind(const String &p_key,uint32_t p_search_flags, int p_from_line,int p_from_column) const {
@@ -2496,7 +2742,7 @@ void TextEdit::_clear_redo() {
void TextEdit::undo() {
-
+
_push_current_op();
if (undo_stack_pos==NULL) {
@@ -2511,8 +2757,13 @@ void TextEdit::undo() {
else
undo_stack_pos=undo_stack_pos->prev();
-
_do_text_op( undo_stack_pos->get(),true);
+ if(undo_stack_pos->get().chain_backward) {
+ do {
+ undo_stack_pos = undo_stack_pos->prev();
+ _do_text_op(undo_stack_pos->get(), true);
+ } while(!undo_stack_pos->get().chain_forward);
+ }
cursor_set_line(undo_stack_pos->get().from_line);
cursor_set_column(undo_stack_pos->get().from_column);
@@ -2526,8 +2777,13 @@ void TextEdit::redo() {
if (undo_stack_pos==NULL)
return; //nothing to do.
-
- _do_text_op( undo_stack_pos->get(),false);
+ _do_text_op(undo_stack_pos->get(), false);
+ if(undo_stack_pos->get().chain_forward) {
+ do {
+ undo_stack_pos=undo_stack_pos->next();
+ _do_text_op(undo_stack_pos->get(), false);
+ } while(!undo_stack_pos->get().chain_backward);
+ }
cursor_set_line(undo_stack_pos->get().from_line);
cursor_set_column(undo_stack_pos->get().from_column);
undo_stack_pos=undo_stack_pos->next();
@@ -2539,20 +2795,43 @@ void TextEdit::clear_undo_history() {
saved_version=0;
current_op.type=TextOperation::TYPE_NONE;
undo_stack_pos=NULL;
- undo_stack.clear();;
+ undo_stack.clear();
}
+void TextEdit::_begin_compex_operation() {
+ _push_current_op();
+ next_operation_is_complex=true;
+}
-void TextEdit::_push_current_op() {
+void TextEdit::_end_compex_operation() {
+
+ _push_current_op();
+ ERR_FAIL_COND(undo_stack.size() == 0);
+
+ if(undo_stack.back()->get().chain_forward) {
+ undo_stack.back()->get().chain_forward=false;
+ return;
+ }
+
+ undo_stack.back()->get().chain_backward=true;
+}
+void TextEdit::_push_current_op() {
+
if (current_op.type==TextOperation::TYPE_NONE)
return; // do nothing
-
+
+ if(next_operation_is_complex) {
+ current_op.chain_forward=true;
+ next_operation_is_complex=false;
+ }
+
undo_stack.push_back(current_op);
current_op.type=TextOperation::TYPE_NONE;
current_op.text="";
-
+ current_op.chain_forward=false;
+
}
void TextEdit::set_draw_tabs(bool p_draw) {
@@ -2693,6 +2972,7 @@ void TextEdit::_update_completion_candidates() {
completion_current=completion_options[completion_index];
+#if 0 // even there's only one option, user still get the chance to choose using it or not
if (completion_options.size()==1) {
//one option to complete, just complete it automagically
_confirm_completion();
@@ -2701,6 +2981,9 @@ void TextEdit::_update_completion_candidates() {
return;
}
+#endif
+ if (completion_options.size()==1 && s==completion_options[0])
+ _cancel_completion();
completion_enabled=true;
@@ -2855,6 +3138,7 @@ void TextEdit::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_selection_to_line"),&TextEdit::get_selection_to_line);
ObjectTypeDB::bind_method(_MD("get_selection_to_column"),&TextEdit::get_selection_to_column);
ObjectTypeDB::bind_method(_MD("get_selection_text"),&TextEdit::get_selection_text);
+ ObjectTypeDB::bind_method(_MD("get_word_under_cursor"),&TextEdit::get_word_under_cursor);
ObjectTypeDB::bind_method(_MD("search","flags","from_line","from_column","to_line","to_column"),&TextEdit::_search_bind);
ObjectTypeDB::bind_method(_MD("undo"),&TextEdit::undo);
@@ -2945,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;
@@ -2957,6 +3241,8 @@ TextEdit::TextEdit() {
completion_line_ofs=0;
tooltip_obj=NULL;
line_numbers=false;
+ next_operation_is_complex=false;
+ auto_brace_completion_enabled=false;
}
TextEdit::~TextEdit(){
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index c3bb5823e..15c289a87 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);
@@ -206,6 +206,9 @@ class TextEdit : public Control {
bool text_changed_dirty;
bool undo_enabled;
bool line_numbers;
+
+ bool auto_brace_completion_enabled;
+ bool cut_copy_line;
uint64_t last_dblclk;
@@ -218,6 +221,8 @@ class TextEdit : public Control {
Object *tooltip_obj;
StringName tooltip_func;
Variant tooltip_ud;
+
+ bool next_operation_is_complex;
int get_visible_rows() const;
@@ -241,11 +246,13 @@ class TextEdit : public Control {
void _update_caches();
void _cursor_changed_emit();
void _text_changed_emit();
-
+
+ void _begin_compex_operation();
+ void _end_compex_operation();
void _push_current_op();
/* super internal api, undo/redo builds on it */
-
+
void _base_insert_text(int p_line, int p_column,const String& p_text,int &r_end_line,int &r_end_column);
String _base_get_text(int p_from_line, int p_from_column,int p_to_line,int p_to_column) const;
void _base_remove_text(int p_from_line, int p_from_column,int p_to_line,int p_to_column);
@@ -262,12 +269,16 @@ class TextEdit : public Control {
protected:
virtual String get_tooltip(const Point2& p_pos) const;
-
+
void _insert_text(int p_line, int p_column,const String& p_text,int *r_end_line=NULL,int *r_end_char=NULL);
void _remove_text(int p_from_line, int p_from_column,int p_to_line,int p_to_column);
void _insert_text_at_cursor(const String& p_text);
void _input_event(const InputEvent& p_input);
void _notification(int p_what);
+
+ void _consume_pair_symbol(CharType ch);
+ void _consume_backspace_for_pair_symbol(int prev_line, int prev_column);
+
static void _bind_methods();
@@ -296,8 +307,11 @@ public:
String get_text();
String get_line(int line) const;
void backspace_at_cursor();
-
-
+
+ inline void set_auto_brace_completion(bool p_enabled) {
+ auto_brace_completion_enabled = p_enabled;
+ }
+
void cursor_set_column(int p_col);
void cursor_set_line(int p_row);
@@ -323,16 +337,18 @@ 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;
+ String get_word_under_cursor() const;
+
bool search(const String &p_key,uint32_t p_search_flags, int p_from_line, int p_from_column,int &r_line,int &r_column) const;
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 fb85f0c6b..25f04379e 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 e3bb50a9a..9a1c07052 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") );