diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/box_container.cpp | 5 | ||||
-rw-r--r-- | scene/gui/button.cpp | 2 | ||||
-rw-r--r-- | scene/gui/color_picker.cpp | 8 | ||||
-rw-r--r-- | scene/gui/control.cpp | 38 | ||||
-rw-r--r-- | scene/gui/control.h | 17 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 6 | ||||
-rw-r--r-- | scene/gui/graph_node.cpp | 2 | ||||
-rw-r--r-- | scene/gui/grid_container.cpp | 2 | ||||
-rw-r--r-- | scene/gui/label.cpp | 2 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 2 | ||||
-rw-r--r-- | scene/gui/panel.cpp | 2 | ||||
-rw-r--r-- | scene/gui/patch_9_frame.cpp | 2 | ||||
-rw-r--r-- | scene/gui/texture_frame.cpp | 2 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 2 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 4 |
15 files changed, 46 insertions, 50 deletions
diff --git a/scene/gui/box_container.cpp b/scene/gui/box_container.cpp index 531c3b0a00..95e796ab56 100644 --- a/scene/gui/box_container.cpp +++ b/scene/gui/box_container.cpp @@ -280,7 +280,8 @@ BoxContainer::AlignMode BoxContainer::get_alignment() const { void BoxContainer::add_spacer(bool p_begin) { Control *c = memnew( Control ); - c->set_stop_mouse(false); + c->set_mouse_filter(MOUSE_FILTER_PASS); + if (vertical) c->set_v_size_flags(SIZE_EXPAND_FILL); else @@ -296,7 +297,7 @@ BoxContainer::BoxContainer(bool p_vertical) { vertical=p_vertical; align = ALIGN_BEGIN; // set_ignore_mouse(true); - set_stop_mouse(false); + set_mouse_filter(MOUSE_FILTER_PASS); } void BoxContainer::_bind_methods() { diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp index 9c96adcbf2..a7e08f9f7e 100644 --- a/scene/gui/button.cpp +++ b/scene/gui/button.cpp @@ -242,7 +242,7 @@ Button::Button(const String &p_text) { flat=false; clip_text=false; - set_stop_mouse(true); + set_mouse_filter(MOUSE_FILTER_STOP); set_text(p_text); align=ALIGN_CENTER; } diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 9083bdc128..9c30b333b0 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -501,9 +501,9 @@ ColorPicker::ColorPicker() : - uv_edit->set_ignore_mouse(false); + uv_edit->connect("gui_input", this, "_uv_input"); - uv_edit->set_stop_mouse(false); + uv_edit->set_mouse_filter(MOUSE_FILTER_PASS); uv_edit->set_custom_minimum_size(Size2 (256,256)); Vector<Variant> args=Vector<Variant>(); args.push_back(0); @@ -513,7 +513,7 @@ ColorPicker::ColorPicker() : add_child(hb_edit); w_edit= memnew( Control ); - w_edit->set_ignore_mouse(false); + //w_edit->set_ignore_mouse(false); w_edit->set_custom_minimum_size(Size2(30,256)); w_edit->connect("gui_input", this, "_w_input"); args.clear(); @@ -592,7 +592,7 @@ ColorPicker::ColorPicker() : preset = memnew( TextureFrame ); bbc->add_child(preset); - preset->set_ignore_mouse(false); + //preset->set_ignore_mouse(false); preset->connect("gui_input", this, "_preset_input"); bt_add_preset = memnew ( Button ); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 1f5f6e10f6..7507ab0952 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2161,25 +2161,17 @@ int Control::get_v_size_flags() const{ return data.v_size_flags; } -void Control::set_ignore_mouse(bool p_ignore) { +void Control::set_mouse_filter(MouseFilter p_filter) { - data.ignore_mouse=p_ignore; + ERR_FAIL_INDEX(p_filter,3); + data.mouse_filter=p_filter; } -bool Control::is_ignoring_mouse() const { +Control::MouseFilter Control::get_mouse_filter() const{ - return data.ignore_mouse; + return data.mouse_filter; } -void Control::set_stop_mouse(bool p_stop) { - - data.stop_mouse=p_stop; -} - -bool Control::is_stopping_mouse() const { - - return data.stop_mouse; -} Control *Control::get_focus_owner() const { @@ -2450,13 +2442,10 @@ void Control::_bind_methods() { ClassDB::bind_method(_MD("set_focus_neighbour","margin","neighbour"),&Control::set_focus_neighbour); ClassDB::bind_method(_MD("get_focus_neighbour","margin"),&Control::get_focus_neighbour); - ClassDB::bind_method(_MD("set_ignore_mouse","ignore"),&Control::set_ignore_mouse); - ClassDB::bind_method(_MD("is_ignoring_mouse"),&Control::is_ignoring_mouse); - ClassDB::bind_method(_MD("force_drag","data","preview"),&Control::force_drag); - ClassDB::bind_method(_MD("set_stop_mouse","stop"),&Control::set_stop_mouse); - ClassDB::bind_method(_MD("is_stopping_mouse"),&Control::is_stopping_mouse); + ClassDB::bind_method(_MD("set_mouse_filter","stop"),&Control::set_mouse_filter); + ClassDB::bind_method(_MD("get_mouse_filter"),&Control::get_mouse_filter); ClassDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus); @@ -2503,13 +2492,14 @@ void Control::_bind_methods() { ADD_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint_tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") ); ADD_GROUP("Focus","focus_"); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus_ignore_mouse"), _SCS("set_ignore_mouse"),_SCS("is_ignoring_mouse") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"focus_stop_mouse"), _SCS("set_stop_mouse"),_SCS("is_stopping_mouse") ); 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 ); ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_right" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_RIGHT ); ADD_PROPERTYINZ( PropertyInfo(Variant::NODE_PATH,"focus_neighbour_bottom" ), _SCS("set_focus_neighbour"),_SCS("get_focus_neighbour"),MARGIN_BOTTOM ); + ADD_GROUP("Mouse","mouse_"); + ADD_PROPERTY( PropertyInfo(Variant::INT,"mouse_filter",PROPERTY_HINT_ENUM,"Stop,Pass,Ignore"), _SCS("set_mouse_filter"),_SCS("get_mouse_filter") ); + ADD_GROUP("Size Flags","size_flags_"); ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags_horizontal", PROPERTY_HINT_FLAGS, "Fill,Expand"), _SCS("set_h_size_flags"),_SCS("get_h_size_flags") ); ADD_PROPERTYNO( PropertyInfo(Variant::INT,"size_flags_vertical", PROPERTY_HINT_FLAGS, "Fill,Expand"), _SCS("set_v_size_flags"),_SCS("get_v_size_flags") ); @@ -2556,6 +2546,10 @@ void Control::_bind_methods() { BIND_CONSTANT( SIZE_FILL ); BIND_CONSTANT( SIZE_EXPAND_FILL ); + BIND_CONSTANT( MOUSE_FILTER_STOP ); + BIND_CONSTANT( MOUSE_FILTER_PASS ); + BIND_CONSTANT( MOUSE_FILTER_IGNORE ); + ADD_SIGNAL( MethodInfo("resized") ); ADD_SIGNAL( MethodInfo("gui_input",PropertyInfo(Variant::INPUT_EVENT,"ev")) ); ADD_SIGNAL( MethodInfo("mouse_enter") ); @@ -2572,9 +2566,7 @@ Control::Control() { data.parent=NULL; - data.ignore_mouse=false; - data.stop_mouse=true; - + data.mouse_filter=MOUSE_FILTER_STOP; data.SI=NULL; data.MI=NULL; diff --git a/scene/gui/control.h b/scene/gui/control.h index fa8e5f22e3..b67e5980c5 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -71,6 +71,12 @@ public: }; + enum MouseFilter { + MOUSE_FILTER_STOP, + MOUSE_FILTER_PASS, + MOUSE_FILTER_IGNORE + }; + enum CursorShape { CURSOR_ARROW, CURSOR_IBEAM, @@ -124,8 +130,7 @@ private: bool pending_min_size_update; Point2 custom_minimum_size; - bool ignore_mouse; - bool stop_mouse; + MouseFilter mouse_filter; bool block_minimum_size_adjust; bool disable_visibility_clip; @@ -337,11 +342,8 @@ public: Control *get_focus_owner() const; - void set_ignore_mouse(bool p_ignore); - bool is_ignoring_mouse() const; - - void set_stop_mouse(bool p_stop); - bool is_stopping_mouse() const; + void set_mouse_filter(MouseFilter p_filter); + MouseFilter get_mouse_filter() const; /* SKINNING */ @@ -417,5 +419,6 @@ VARIANT_ENUM_CAST(Control::AnchorType); VARIANT_ENUM_CAST(Control::FocusMode); VARIANT_ENUM_CAST(Control::SizeFlags); VARIANT_ENUM_CAST(Control::CursorShape); +VARIANT_ENUM_CAST(Control::MouseFilter); #endif diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index 25260ec608..d3f2ad7e13 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -256,7 +256,7 @@ void GraphEdit::add_child_notify(Node *p_child) { gn->connect("raise_request",this,"_graph_node_raised",varray(gn)); gn->connect("item_rect_changed",connections_layer,"update"); _graph_node_moved(gn); - gn->set_stop_mouse(false); + gn->set_mouse_filter(MOUSE_FILTER_PASS); } @@ -1262,10 +1262,10 @@ GraphEdit::GraphEdit() { top_layer=NULL; top_layer=memnew(GraphEditFilter(this)); add_child(top_layer); - top_layer->set_stop_mouse(false); + top_layer->set_mouse_filter(MOUSE_FILTER_PASS); top_layer->set_area_as_parent_rect(); top_layer->connect("draw",this,"_top_layer_draw"); - top_layer->set_stop_mouse(false); + top_layer->set_mouse_filter(MOUSE_FILTER_PASS); top_layer->connect("input_event",this,"_top_layer_input"); connections_layer = memnew( Control ); diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 4d658deab4..8b7b84910d 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -787,7 +787,7 @@ GraphNode::GraphNode() { overlay=OVERLAY_DISABLED; show_close=false; connpos_dirty=true; - set_stop_mouse(false); + set_mouse_filter(MOUSE_FILTER_PASS); modulate=Color(1,1,1,1); comment=false; resizeable=false; diff --git a/scene/gui/grid_container.cpp b/scene/gui/grid_container.cpp index 13cb972a19..7dffaa2fd5 100644 --- a/scene/gui/grid_container.cpp +++ b/scene/gui/grid_container.cpp @@ -230,6 +230,6 @@ Size2 GridContainer::get_minimum_size() const { GridContainer::GridContainer() { - set_stop_mouse(false); + set_mouse_filter(MOUSE_FILTER_PASS); columns=1; } diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp index 03a0219e98..3d350b2230 100644 --- a/scene/gui/label.cpp +++ b/scene/gui/label.cpp @@ -699,7 +699,7 @@ Label::Label(const String &p_text) { line_count=0; set_v_size_flags(0); clip=false; - set_ignore_mouse(true); + set_mouse_filter(MOUSE_FILTER_IGNORE); total_char_cache=0; visible_chars=-1; percent_visible=1; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 30c04608ef..e75785b1ff 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1341,7 +1341,7 @@ LineEdit::LineEdit() { set_focus_mode( FOCUS_ALL ); editable=true; set_default_cursor_shape(CURSOR_IBEAM); - set_stop_mouse(true); + set_mouse_filter(MOUSE_FILTER_STOP); draw_caret=true; caret_blink_enabled=false; diff --git a/scene/gui/panel.cpp b/scene/gui/panel.cpp index 68d01ccb6e..c4b7199c3e 100644 --- a/scene/gui/panel.cpp +++ b/scene/gui/panel.cpp @@ -41,7 +41,7 @@ void Panel::_notification(int p_what) { Panel::Panel() { - set_stop_mouse(true); + set_mouse_filter(MOUSE_FILTER_STOP); } diff --git a/scene/gui/patch_9_frame.cpp b/scene/gui/patch_9_frame.cpp index 5bcc6eb3e9..e32f60a222 100644 --- a/scene/gui/patch_9_frame.cpp +++ b/scene/gui/patch_9_frame.cpp @@ -174,7 +174,7 @@ Patch9Frame::Patch9Frame() { margin[MARGIN_BOTTOM]=0; margin[MARGIN_TOP]=0; - set_ignore_mouse(true); + set_mouse_filter(MOUSE_FILTER_IGNORE); draw_center=true; } diff --git a/scene/gui/texture_frame.cpp b/scene/gui/texture_frame.cpp index b0940df1f6..bfa72ef067 100644 --- a/scene/gui/texture_frame.cpp +++ b/scene/gui/texture_frame.cpp @@ -158,7 +158,7 @@ TextureFrame::TextureFrame() { expand=false; - set_ignore_mouse(true); + set_mouse_filter(MOUSE_FILTER_IGNORE); stretch_mode=STRETCH_SCALE_ON_EXPAND; } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index ba22320a22..16175e9f4b 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -3711,7 +3711,7 @@ Tree::Tree() { blocked=0; cursor_can_exit_tree=true; - set_stop_mouse(true); + set_mouse_filter(MOUSE_FILTER_STOP); drag_speed=0; drag_touching=false; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 4c7114d093..8d8e41812b 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1615,7 +1615,7 @@ void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) { break; if (gui.key_event_accepted) break; - if (!cant_stop_me_now && control->data.stop_mouse && (ev.type==InputEvent::MOUSE_BUTTON || ev.type==InputEvent::MOUSE_MOTION)) + if (!cant_stop_me_now && control->data.mouse_filter==Control::MOUSE_FILTER_STOP && (ev.type==InputEvent::MOUSE_BUTTON || ev.type==InputEvent::MOUSE_MOTION)) break; } @@ -1724,7 +1724,7 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g matrix.affine_invert(); //conditions for considering this as a valid control for return - if (!c->data.ignore_mouse && c->has_point(matrix.xform(p_global)) && (!gui.drag_preview || (c!=gui.drag_preview && !gui.drag_preview->is_a_parent_of(c)))) { + if (c->data.mouse_filter!=Control::MOUSE_FILTER_IGNORE && c->has_point(matrix.xform(p_global)) && (!gui.drag_preview || (c!=gui.drag_preview && !gui.drag_preview->is_a_parent_of(c)))) { r_inv_xform=matrix; return c; } else |