aboutsummaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/container.cpp2
-rw-r--r--scene/gui/control.cpp54
-rw-r--r--scene/gui/control.h16
-rw-r--r--scene/gui/option_button.cpp9
-rw-r--r--scene/gui/popup_menu.cpp20
-rw-r--r--scene/gui/popup_menu.h1
-rw-r--r--scene/gui/spin_box.cpp31
-rw-r--r--scene/gui/spin_box.h4
-rw-r--r--scene/gui/text_edit.cpp41
-rw-r--r--scene/gui/text_edit.h2
-rw-r--r--scene/gui/texture_button.cpp10
-rw-r--r--scene/gui/texture_button.h4
-rw-r--r--scene/gui/tree.cpp62
-rw-r--r--scene/gui/tree.h7
-rw-r--r--scene/gui/video_player.cpp9
-rw-r--r--scene/gui/video_player.h6
16 files changed, 245 insertions, 33 deletions
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp
index 8cdf4dd03..2ff51d22c 100644
--- a/scene/gui/container.cpp
+++ b/scene/gui/container.cpp
@@ -105,6 +105,8 @@ void Container::fit_child_in_rect(Control *p_child,const Rect2& p_rect) {
p_child->set_pos(r.pos);
p_child->set_size(r.size);
+ p_child->set_rotation(0);
+ p_child->set_scale(Vector2(1,1));
}
void Container::queue_sort() {
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index bd6b8078f..ec4886a6a 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -580,8 +580,8 @@ void Control::_notification(int p_notification) {
} break;
case NOTIFICATION_DRAW: {
- Matrix32 xform;
- xform.set_origin(get_pos());
+ Matrix32 xform=Matrix32(data.rotation,get_pos());
+ xform.scale_basis(data.scale);
VisualServer::get_singleton()->canvas_item_set_transform(get_canvas_item(),xform);
VisualServer::get_singleton()->canvas_item_set_custom_rect( get_canvas_item(),true, Rect2(Point2(),get_size()));
//emit_signal(SceneStringNames::get_singleton()->draw);
@@ -1927,6 +1927,7 @@ void Control::set_size(const Size2& p_size) {
data.margin[3] = _s2a( y+h, data.anchor[3], ph );
_size_changed();
+
}
@@ -2412,9 +2413,9 @@ Control::CursorShape Control::get_cursor_shape(const Point2& p_pos) const {
Matrix32 Control::get_transform() const {
- Matrix32 xf;
- xf.set_origin(get_pos());
- return xf;
+ Matrix32 xform=Matrix32(data.rotation,get_pos());
+ xform.scale_basis(data.scale);
+ return xform;
}
String Control::_get_tooltip() const {
@@ -2728,6 +2729,39 @@ bool Control::is_text_field() const {
return false;
}
+
+void Control::_set_rotation_deg(float p_rot) {
+ set_rotation(Math::deg2rad(p_rot));
+}
+
+float Control::_get_rotation_deg() const {
+ return Math::rad2deg(get_rotation());
+}
+
+void Control::set_rotation(float p_rotation) {
+
+ data.rotation=p_rotation;
+ update();
+ _notify_transform();
+}
+
+float Control::get_rotation() const{
+
+ return data.rotation;
+}
+
+void Control::set_scale(const Vector2& p_scale){
+
+ data.scale=p_scale;
+ update();
+ _notify_transform();
+}
+Vector2 Control::get_scale() const{
+
+ return data.scale;
+}
+
+
void Control::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_window_input_event"),&Control::_window_input_event);
@@ -2756,15 +2790,21 @@ void Control::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_size","size"),&Control::set_size);
ObjectTypeDB::bind_method(_MD("set_custom_minimum_size","size"),&Control::set_custom_minimum_size);
ObjectTypeDB::bind_method(_MD("set_global_pos","pos"),&Control::set_global_pos);
+ ObjectTypeDB::bind_method(_MD("set_rotation","rotation"),&Control::set_rotation);
+ ObjectTypeDB::bind_method(_MD("_set_rotation_deg","rotation"),&Control::_set_rotation_deg);
+ ObjectTypeDB::bind_method(_MD("set_scale","scale"),&Control::set_scale);
ObjectTypeDB::bind_method(_MD("get_margin","margin"),&Control::get_margin);
ObjectTypeDB::bind_method(_MD("get_begin"),&Control::get_begin);
ObjectTypeDB::bind_method(_MD("get_end"),&Control::get_end);
ObjectTypeDB::bind_method(_MD("get_pos"),&Control::get_pos);
ObjectTypeDB::bind_method(_MD("get_size"),&Control::get_size);
+ ObjectTypeDB::bind_method(_MD("get_rotation"),&Control::get_rotation);
+ ObjectTypeDB::bind_method(_MD("get_scale"),&Control::get_scale);
ObjectTypeDB::bind_method(_MD("get_custom_minimum_size"),&Control::get_custom_minimum_size);
ObjectTypeDB::bind_method(_MD("get_parent_area_size"),&Control::get_size);
ObjectTypeDB::bind_method(_MD("get_global_pos"),&Control::get_global_pos);
ObjectTypeDB::bind_method(_MD("get_rect"),&Control::get_rect);
+ ObjectTypeDB::bind_method(_MD("_get_rotation_deg"),&Control::_get_rotation_deg);
ObjectTypeDB::bind_method(_MD("get_global_rect"),&Control::get_global_rect);
ObjectTypeDB::bind_method(_MD("set_area_as_parent_rect","margin"),&Control::set_area_as_parent_rect,DEFVAL(0));
ObjectTypeDB::bind_method(_MD("show_modal","exclusive"),&Control::show_modal,DEFVAL(false));
@@ -2846,6 +2886,8 @@ void Control::_bind_methods() {
ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/pos", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_pos"),_SCS("get_pos") );
ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/size", PROPERTY_HINT_NONE, "",PROPERTY_USAGE_EDITOR), _SCS("set_size"),_SCS("get_size") );
ADD_PROPERTYNZ( PropertyInfo(Variant::VECTOR2,"rect/min_size"), _SCS("set_custom_minimum_size"),_SCS("get_custom_minimum_size") );
+ ADD_PROPERTYNZ( PropertyInfo(Variant::REAL,"rect/rotation",PROPERTY_HINT_RANGE,"-1080,1080,0.01"), _SCS("_set_rotation_deg"),_SCS("_get_rotation_deg") );
+ ADD_PROPERTYNO( PropertyInfo(Variant::VECTOR2,"rect/scale"), _SCS("set_scale"),_SCS("get_scale") );
ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint/tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") );
ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/left" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_LEFT );
ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour/top" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_TOP );
@@ -2928,6 +2970,8 @@ Control::Control() {
data.v_size_flags=SIZE_FILL;
data.expand=1;
data.pending_min_size_update=false;
+ data.rotation=0;
+ data.scale=Vector2(1,1);
for (int i=0;i<4;i++) {
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 4311b299c..09a4b48e6 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -107,7 +107,10 @@ private:
float margin[4];
AnchorType anchor[4];
- FocusMode focus_mode;
+ FocusMode focus_mode;
+
+ float rotation;
+ Vector2 scale;
bool pending_resize;
@@ -211,6 +214,8 @@ private:
void _size_changed();
String _get_tooltip() const;
+ void _set_rotation_deg(float p_rot);
+ float _get_rotation_deg() const;
protected:
bool window_has_modal_stack() const;
@@ -299,6 +304,13 @@ public:
Rect2 get_rect() const;
Rect2 get_global_rect() const;
Rect2 get_window_rect() const; ///< use with care, as it blocks waiting for the visual server
+
+ void set_rotation(float p_rotation);
+ float get_rotation() const;
+
+ void set_scale(const Vector2& p_scale);
+ Vector2 get_scale() const;
+
void set_area_as_parent_rect(int p_margin=0);
@@ -382,7 +394,7 @@ public:
void warp_mouse(const Point2& p_to_pos);
- virtual bool is_text_field() const;
+ virtual bool is_text_field() const;
Control();
~Control();
diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp
index ff94a37be..3cc5acc1a 100644
--- a/scene/gui/option_button.cpp
+++ b/scene/gui/option_button.cpp
@@ -77,9 +77,14 @@ void OptionButton::_selected(int p_which) {
}
}
- ERR_FAIL_COND(selid==-1);
+ if (selid==-1 && p_which>=0 && p_which<popup->get_item_count()) {
+ _select(p_which,true);
+ } else {
- _select(selid,true);
+ ERR_FAIL_COND(selid==-1);
+
+ _select(selid,true);
+ }
}
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 20f28ecf1..9dc03272b 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -370,7 +370,7 @@ void PopupMenu::_input_event(const InputEvent &p_event) {
}
int over=_get_mouse_over(Point2(m.x,m.y));
- int id = (over<0 || items[over].separator || items[over].disabled)?-1:items[over].ID;
+ int id = (over<0 || items[over].separator || items[over].disabled)?-1:(items[over].ID>=0?items[over].ID:over);
if (id<0) {
mouse_over=-1;
@@ -524,7 +524,7 @@ void PopupMenu::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,i
item.icon=p_icon;
item.text=p_label;
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
items.push_back(item);
update();
}
@@ -533,7 +533,7 @@ void PopupMenu::add_item(const String& p_label,int p_ID,uint32_t p_accel) {
Item item;
item.text=XL_MESSAGE(p_label);
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
items.push_back(item);
update();
}
@@ -542,7 +542,7 @@ void PopupMenu::add_submenu_item(const String& p_label, const String& p_submenu,
Item item;
item.text=XL_MESSAGE(p_label);
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
item.submenu=p_submenu;
items.push_back(item);
update();
@@ -554,7 +554,7 @@ void PopupMenu::add_icon_check_item(const Ref<Texture>& p_icon,const String& p_l
item.icon=p_icon;
item.text=XL_MESSAGE(p_label);
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
item.checkable=true;
items.push_back(item);
update();
@@ -564,7 +564,7 @@ void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel)
Item item;
item.text=XL_MESSAGE(p_label);
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
item.checkable=true;
items.push_back(item);
update();
@@ -753,9 +753,11 @@ int PopupMenu::find_item_by_accelerator(uint32_t p_accel) const {
void PopupMenu::activate_item(int p_item) {
+
ERR_FAIL_INDEX(p_item,items.size());
ERR_FAIL_COND(items[p_item].separator);
- emit_signal("item_pressed",items[p_item].ID);
+ int id = items[p_item].ID>=0?items[p_item].ID:p_item;
+ emit_signal("item_pressed",id);
//hide all parent PopupMenue's
Node *next = get_parent();
@@ -789,7 +791,7 @@ void PopupMenu::clear() {
items.clear();
mouse_over=-1;
update();
- idcount=0;
+
}
@@ -937,7 +939,7 @@ void PopupMenu::set_invalidate_click_until_motion() {
PopupMenu::PopupMenu() {
- idcount=0;
+
mouse_over=-1;
set_focus_mode(FOCUS_ALL);
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index ed78fe673..30223469a 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -59,7 +59,6 @@ class PopupMenu : public Popup {
Timer *submenu_timer;
List<Rect2> autohide_areas;
Vector<Item> items;
- int idcount;
int mouse_over;
int submenu_over;
Rect2 parent_rect;
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index a48136f54..051a8dd01 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -68,6 +68,25 @@ void SpinBox::_line_edit_input(const InputEvent& p_event) {
}
+void SpinBox::_range_click_timeout() {
+
+ if (!drag.enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+
+ int pos_y = Input::get_singleton()->get_mouse_pos().y-get_global_pos().y;
+ bool up = pos_y < (get_size().height/2);
+ set_val( get_val() + (up?get_step():-get_step()));
+
+ if (range_click_timer->is_one_shot()) {
+ range_click_timer->set_wait_time(0.075);
+ range_click_timer->set_one_shot(false);
+ range_click_timer->start();
+ }
+
+ } else {
+ range_click_timer->stop();
+ }
+}
+
void SpinBox::_input_event(const InputEvent& p_event) {
@@ -85,6 +104,10 @@ void SpinBox::_input_event(const InputEvent& p_event) {
set_val( get_val() + (up?get_step():-get_step()));
+ range_click_timer->set_wait_time(0.6);
+ range_click_timer->set_one_shot(true);
+ range_click_timer->start();
+
} break;
case BUTTON_RIGHT: {
@@ -112,6 +135,8 @@ void SpinBox::_input_event(const InputEvent& p_event) {
if (p_event.type==InputEvent::MOUSE_BUTTON && !p_event.mouse_button.pressed && p_event.mouse_button.button_index==1) {
//set_default_cursor_shape(CURSOR_ARROW);
+ range_click_timer->stop();
+
if (drag.enabled) {
drag.enabled=false;
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_VISIBLE);
@@ -167,6 +192,7 @@ void SpinBox::_notification(int p_what) {
Size2i size = get_size();
updown->draw(ci,Point2i(size.width-updown->get_width(),(size.height-updown->get_height())/2));
+
} else if (p_what==NOTIFICATION_FOCUS_EXIT) {
@@ -227,6 +253,7 @@ void SpinBox::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_line_edit_focus_exit"),&SpinBox::_line_edit_focus_exit);
ObjectTypeDB::bind_method(_MD("get_line_edit"),&SpinBox::get_line_edit);
ObjectTypeDB::bind_method(_MD("_line_edit_input"),&SpinBox::_line_edit_input);
+ ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&SpinBox::_range_click_timeout);
ADD_PROPERTY(PropertyInfo(Variant::BOOL,"editable"),_SCS("set_editable"),_SCS("is_editable"));
@@ -248,4 +275,8 @@ SpinBox::SpinBox() {
line_edit->connect("focus_exit",this,"_line_edit_focus_exit",Vector<Variant>(),CONNECT_DEFERRED);
line_edit->connect("input_event",this,"_line_edit_input");
drag.enabled=false;
+
+ range_click_timer = memnew( Timer );
+ range_click_timer->connect("timeout",this,"_range_click_timeout");
+ add_child(range_click_timer);
}
diff --git a/scene/gui/spin_box.h b/scene/gui/spin_box.h
index 4c8cb8432..1b3bc6d81 100644
--- a/scene/gui/spin_box.h
+++ b/scene/gui/spin_box.h
@@ -31,6 +31,7 @@
#include "scene/gui/line_edit.h"
#include "scene/gui/range.h"
+#include "scene/main/timer.h"
class SpinBox : public Range {
@@ -39,6 +40,9 @@ class SpinBox : public Range {
LineEdit *line_edit;
int last_w;
+ Timer *range_click_timer;
+ void _range_click_timeout();
+
void _text_entered(const String& p_string);
virtual void _value_changed(double);
String prefix;
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 78792dc78..29969b65e 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -29,6 +29,7 @@
#include "text_edit.h"
#include "os/keyboard.h"
+#include "os/input.h"
#include "os/os.h"
#include "globals.h"
@@ -349,6 +350,29 @@ void TextEdit::_update_scrollbars() {
updating_scrolls=false;
}
+void TextEdit::_click_selection_held() {
+
+ if (Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT) && selection.selecting_mode!=Selection::MODE_NONE) {
+
+ Point2 mp = Input::get_singleton()->get_mouse_pos()-get_global_pos();
+
+ int row,col;
+ _get_mouse_pos(Point2i(mp.x,mp.y), row,col);
+
+ select(selection.selecting_line,selection.selecting_column,row,col);
+
+ cursor_set_line( row );
+ cursor_set_column( col );
+ update();
+
+ click_select_held->start();
+
+ } else {
+
+ click_select_held->stop();
+ }
+}
+
void TextEdit::_notification(int p_what) {
@@ -1292,6 +1316,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
update();
}
} else {
+
+ if (mb.button_index==BUTTON_LEFT)
+ click_select_held->stop();
// notify to show soft keyboard
notification(NOTIFICATION_FOCUS_ENTER);
@@ -1304,16 +1331,18 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
if (mm.button_mask&BUTTON_MASK_LEFT) {
- int row,col;
- _get_mouse_pos(Point2i(mm.x,mm.y), row,col);
-
if (selection.selecting_mode!=Selection::MODE_NONE) {
+
+ int row,col;
+ _get_mouse_pos(Point2i(mm.x,mm.y), row,col);
select(selection.selecting_line,selection.selecting_column,row,col);
cursor_set_line( row );
cursor_set_column( col );
update();
+
+ click_select_held->start();
}
@@ -3697,6 +3726,7 @@ void TextEdit::_bind_methods() {
ObjectTypeDB::bind_method(_MD("_cursor_changed_emit"),&TextEdit::_cursor_changed_emit);
ObjectTypeDB::bind_method(_MD("_text_changed_emit"),&TextEdit::_text_changed_emit);
ObjectTypeDB::bind_method(_MD("_push_current_op"),&TextEdit::_push_current_op);
+ ObjectTypeDB::bind_method(_MD("_click_selection_held"),&TextEdit::_click_selection_held);
BIND_CONSTANT( SEARCH_MATCH_CASE );
BIND_CONSTANT( SEARCH_WHOLE_WORDS );
@@ -3811,6 +3841,11 @@ TextEdit::TextEdit() {
idle_detect->set_one_shot(true);
idle_detect->set_wait_time(GLOBAL_DEF("display/text_edit_idle_detect_sec",3));
idle_detect->connect("timeout", this,"_push_current_op");
+
+ click_select_held = memnew( Timer );
+ add_child(click_select_held);
+ click_select_held->set_wait_time(0.05);
+ click_select_held->connect("timeout", this,"_click_selection_held");
#if 0
syntax_coloring=true;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 91369309c..f8e8ef3b9 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -219,6 +219,7 @@ class TextEdit : public Control {
uint64_t last_dblclk;
Timer *idle_detect;
+ Timer *click_select_held;
HScrollBar *h_scroll;
VScrollBar *v_scroll;
bool updating_scrolls;
@@ -240,6 +241,7 @@ class TextEdit : public Control {
void adjust_viewport_to_cursor();
void _scroll_moved(double);
void _update_scrollbars();
+ void _click_selection_held();
void _pre_shift_selection();
void _post_shift_selection();
diff --git a/scene/gui/texture_button.cpp b/scene/gui/texture_button.cpp
index 5b2caecb5..7e6bf2cbd 100644
--- a/scene/gui/texture_button.cpp
+++ b/scene/gui/texture_button.cpp
@@ -145,7 +145,7 @@ void TextureButton::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_disabled_texture","texture:Texture"),&TextureButton::set_disabled_texture);
ObjectTypeDB::bind_method(_MD("set_focused_texture","texture:Texture"),&TextureButton::set_focused_texture);
ObjectTypeDB::bind_method(_MD("set_click_mask","mask:BitMap"),&TextureButton::set_click_mask);
- ObjectTypeDB::bind_method(_MD("set_scale","scale"),&TextureButton::set_scale);
+ ObjectTypeDB::bind_method(_MD("set_texture_scale","scale"),&TextureButton::set_texture_scale);
ObjectTypeDB::bind_method(_MD("set_modulate","color"),&TextureButton::set_modulate);
ObjectTypeDB::bind_method(_MD("get_normal_texture:Texture"),&TextureButton::get_normal_texture);
@@ -154,7 +154,7 @@ void TextureButton::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_disabled_texture:Texture"),&TextureButton::get_disabled_texture);
ObjectTypeDB::bind_method(_MD("get_focused_texture:Texture"),&TextureButton::get_focused_texture);
ObjectTypeDB::bind_method(_MD("get_click_mask:BitMap"),&TextureButton::get_click_mask);
- ObjectTypeDB::bind_method(_MD("get_scale"),&TextureButton::get_scale);
+ ObjectTypeDB::bind_method(_MD("get_texture_scale"),&TextureButton::get_texture_scale);
ObjectTypeDB::bind_method(_MD("get_modulate"),&TextureButton::get_modulate);
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/normal",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_normal_texture"), _SCS("get_normal_texture"));
@@ -163,7 +163,7 @@ void TextureButton::_bind_methods() {
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/disabled",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_disabled_texture"), _SCS("get_disabled_texture"));
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/focused",PROPERTY_HINT_RESOURCE_TYPE,"Texture"), _SCS("set_focused_texture"), _SCS("get_focused_texture"));
ADD_PROPERTYNZ(PropertyInfo(Variant::OBJECT,"textures/click_mask",PROPERTY_HINT_RESOURCE_TYPE,"BitMap"), _SCS("set_click_mask"), _SCS("get_click_mask")) ;
- ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_scale"), _SCS("get_scale"));
+ ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2,"params/scale",PROPERTY_HINT_RANGE,"0.01,1024,0.01"), _SCS("set_texture_scale"), _SCS("get_texture_scale"));
ADD_PROPERTYNO(PropertyInfo(Variant::COLOR,"params/modulate"), _SCS("set_modulate"), _SCS("get_modulate"));
}
@@ -232,14 +232,14 @@ void TextureButton::set_focused_texture(const Ref<Texture>& p_focused) {
focused = p_focused;
};
-void TextureButton::set_scale(Size2 p_scale) {
+void TextureButton::set_texture_scale(Size2 p_scale) {
scale=p_scale;
minimum_size_changed();
update();
}
-Size2 TextureButton::get_scale() const{
+Size2 TextureButton::get_texture_scale() const{
return scale;
}
diff --git a/scene/gui/texture_button.h b/scene/gui/texture_button.h
index 01924c1c1..49687986c 100644
--- a/scene/gui/texture_button.h
+++ b/scene/gui/texture_button.h
@@ -68,8 +68,8 @@ public:
Ref<Texture> get_focused_texture() const;
Ref<BitMap> get_click_mask() const;
- void set_scale(Size2 p_scale);
- Size2 get_scale() const;
+ void set_texture_scale(Size2 p_scale);
+ Size2 get_texture_scale() const;
void set_modulate(const Color& p_modulate);
Color get_modulate() const;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 16a12fe40..ee7c0724e 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1369,7 +1369,40 @@ Rect2 Tree::search_item_rect(TreeItem *p_from, TreeItem *p_item) {
}
+void Tree::_range_click_timeout() {
+ if (range_item_last && !range_drag_enabled && Input::get_singleton()->is_mouse_button_pressed(BUTTON_LEFT)) {
+
+ Point2 pos = (Input::get_singleton()->get_mouse_pos()-get_global_pos())-cache.bg->get_offset();
+ if (show_column_titles) {
+ pos.y-=_get_title_button_height();
+
+ if (pos.y<0) {
+ range_click_timer->stop();
+ return;
+ }
+ }
+
+ click_handled=false;
+ InputModifierState mod = {}; // should be irrelevant..
+
+ blocked++;
+ propagate_mouse_event(pos+cache.offset, 0, 0, false, root, BUTTON_LEFT, mod);
+ blocked--;
+
+ if (range_click_timer->is_one_shot()) {
+ range_click_timer->set_wait_time(0.05);
+ range_click_timer->set_one_shot(false);
+ range_click_timer->start();
+ }
+
+ if (!click_handled)
+ range_click_timer->stop();
+
+ } else {
+ range_click_timer->stop();
+ }
+}
int Tree::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) {
@@ -1564,9 +1597,25 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_
bool up=p_pos.y < (item_h /2);
if (p_button==BUTTON_LEFT) {
+
+ if (range_click_timer->get_time_left() == 0) {
+
+ range_item_last=p_item;
+ range_up_last=up;
+
+ range_click_timer->set_wait_time(0.6);
+ range_click_timer->set_one_shot(true);
+ range_click_timer->start();
+
+ } else if (up != range_up_last) {
+
+ return -1; // break. avoid changing direction on mouse held
+ }
+
p_item->set_range( col, c.val + (up?1.0:-1.0) * c.step );
item_edited(col,p_item);
+
} else if (p_button==BUTTON_RIGHT) {
p_item->set_range( col, (up?c.max:c.min) );
@@ -2024,6 +2073,8 @@ void Tree::_input_event(InputEvent p_event) {
update_cache();
const InputEventMouseMotion& b=p_event.mouse_motion;
+ range_click_timer->stop();
+
Ref<StyleBox> bg = cache.bg;
Point2 pos = Point2(b.x,b.y) - bg->get_offset();
@@ -2031,7 +2082,6 @@ void Tree::_input_event(InputEvent p_event) {
Cache::ClickType old_hover = cache.hover_type;
int old_index = cache.hover_index;
-
cache.hover_type=Cache::CLICK_NONE;
cache.hover_index=0;
if (show_column_titles) {
@@ -2108,6 +2158,8 @@ void Tree::_input_event(InputEvent p_event) {
if (b.button_index==BUTTON_LEFT) {
+ range_click_timer->stop();
+
if (pressing_for_editor) {
if (range_drag_enabled) {
@@ -2228,10 +2280,13 @@ void Tree::_input_event(InputEvent p_event) {
} break;
case BUTTON_WHEEL_UP: {
+
+ range_click_timer->stop();
v_scroll->set_val( v_scroll->get_val()-v_scroll->get_page()/8 );
} break;
case BUTTON_WHEEL_DOWN: {
+ range_click_timer->stop();
v_scroll->set_val( v_scroll->get_val()+v_scroll->get_page()/8 );
} break;
}
@@ -3135,6 +3190,7 @@ bool Tree::is_folding_hidden() const {
void Tree::_bind_methods() {
+ ObjectTypeDB::bind_method(_MD("_range_click_timeout"),&Tree::_range_click_timeout);
ObjectTypeDB::bind_method(_MD("_input_event"),&Tree::_input_event);
ObjectTypeDB::bind_method(_MD("_popup_select"),&Tree::popup_select);
ObjectTypeDB::bind_method(_MD("_text_editor_enter"),&Tree::text_editor_enter);
@@ -3229,6 +3285,10 @@ Tree::Tree() {
add_child(h_scroll);
add_child(v_scroll);
+ range_click_timer = memnew( Timer );
+ range_click_timer->connect("timeout",this,"_range_click_timeout");
+ add_child(range_click_timer);
+
h_scroll->connect("value_changed", this,"_scroll_moved");
v_scroll->connect("value_changed", this,"_scroll_moved");
text_editor->connect("text_entered", this,"_text_editor_enter");
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 8fb9b802a..55ccc16d0 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -127,7 +127,7 @@ friend class Tree;
- TreeItem(Tree *p_tree);
+ TreeItem(Tree *p_tree);
void _changed_notify(int p_cell);
@@ -301,6 +301,11 @@ friend class TreeItem;
Vector<ColumnInfo> columns;
+ Timer *range_click_timer;
+ TreeItem *range_item_last;
+ bool range_up_last;
+ void _range_click_timeout();
+
int compute_item_height(TreeItem *p_item) const;
int get_item_height(TreeItem *p_item) const;
// 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);
diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp
index d99da5e90..22b19f50b 100644
--- a/scene/gui/video_player.cpp
+++ b/scene/gui/video_player.cpp
@@ -338,6 +338,13 @@ float VideoPlayer::get_stream_pos() const {
return playback->get_pos();
};
+Ref<Texture> VideoPlayer::get_video_texture() {
+
+ if (playback.is_valid())
+ return playback->get_texture();
+
+ return Ref<Texture> ();
+}
void VideoPlayer::set_autoplay(bool p_enable) {
@@ -384,6 +391,8 @@ 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);
+ ObjectTypeDB::bind_method(_MD("get_video_texutre:Texture"), &VideoPlayer::get_video_texture );
+
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") );
diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h
index c485e3d6b..b14d3936b 100644
--- a/scene/gui/video_player.h
+++ b/scene/gui/video_player.h
@@ -88,6 +88,8 @@ public:
bool has_expand() const;
+ Ref<Texture> get_video_texture();
+
void set_stream(const Ref<VideoStream> &p_stream);
Ref<VideoStream> get_stream() const;
@@ -110,8 +112,8 @@ public:
void set_autoplay(bool p_vol);
bool has_autoplay() const;
- void set_audio_track(int p_track);
- int get_audio_track() const;
+ void set_audio_track(int p_track);
+ int get_audio_track() const;
void set_buffering_msec(int p_msec);
int get_buffering_msec() const;