-removed stop mouse and ignore mouse from control, which were confusing, replaced by mouse filter

This commit is contained in:
Juan Linietsky 2017-01-08 19:54:19 -03:00
parent 4fd464a4c5
commit 94ee7798ce
20 changed files with 53 additions and 57 deletions

View file

@ -280,7 +280,8 @@ BoxContainer::AlignMode BoxContainer::get_alignment() const {
void BoxContainer::add_spacer(bool p_begin) { void BoxContainer::add_spacer(bool p_begin) {
Control *c = memnew( Control ); Control *c = memnew( Control );
c->set_stop_mouse(false); c->set_mouse_filter(MOUSE_FILTER_PASS);
if (vertical) if (vertical)
c->set_v_size_flags(SIZE_EXPAND_FILL); c->set_v_size_flags(SIZE_EXPAND_FILL);
else else
@ -296,7 +297,7 @@ BoxContainer::BoxContainer(bool p_vertical) {
vertical=p_vertical; vertical=p_vertical;
align = ALIGN_BEGIN; align = ALIGN_BEGIN;
// set_ignore_mouse(true); // set_ignore_mouse(true);
set_stop_mouse(false); set_mouse_filter(MOUSE_FILTER_PASS);
} }
void BoxContainer::_bind_methods() { void BoxContainer::_bind_methods() {

View file

@ -242,7 +242,7 @@ Button::Button(const String &p_text) {
flat=false; flat=false;
clip_text=false; clip_text=false;
set_stop_mouse(true); set_mouse_filter(MOUSE_FILTER_STOP);
set_text(p_text); set_text(p_text);
align=ALIGN_CENTER; align=ALIGN_CENTER;
} }

View file

@ -501,9 +501,9 @@ ColorPicker::ColorPicker() :
uv_edit->set_ignore_mouse(false);
uv_edit->connect("gui_input", this, "_uv_input"); 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)); uv_edit->set_custom_minimum_size(Size2 (256,256));
Vector<Variant> args=Vector<Variant>(); Vector<Variant> args=Vector<Variant>();
args.push_back(0); args.push_back(0);
@ -513,7 +513,7 @@ ColorPicker::ColorPicker() :
add_child(hb_edit); add_child(hb_edit);
w_edit= memnew( Control ); 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->set_custom_minimum_size(Size2(30,256));
w_edit->connect("gui_input", this, "_w_input"); w_edit->connect("gui_input", this, "_w_input");
args.clear(); args.clear();
@ -592,7 +592,7 @@ ColorPicker::ColorPicker() :
preset = memnew( TextureFrame ); preset = memnew( TextureFrame );
bbc->add_child(preset); bbc->add_child(preset);
preset->set_ignore_mouse(false); //preset->set_ignore_mouse(false);
preset->connect("gui_input", this, "_preset_input"); preset->connect("gui_input", this, "_preset_input");
bt_add_preset = memnew ( Button ); bt_add_preset = memnew ( Button );

View file

@ -2161,25 +2161,17 @@ int Control::get_v_size_flags() const{
return data.v_size_flags; 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 { 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("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("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("force_drag","data","preview"),&Control::force_drag);
ClassDB::bind_method(_MD("set_stop_mouse","stop"),&Control::set_stop_mouse); ClassDB::bind_method(_MD("set_mouse_filter","stop"),&Control::set_mouse_filter);
ClassDB::bind_method(_MD("is_stopping_mouse"),&Control::is_stopping_mouse); ClassDB::bind_method(_MD("get_mouse_filter"),&Control::get_mouse_filter);
ClassDB::bind_method(_MD("grab_click_focus"),&Control::grab_click_focus); 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_PROPERTYNZ( PropertyInfo(Variant::STRING,"hint_tooltip", PROPERTY_HINT_MULTILINE_TEXT), _SCS("set_tooltip"),_SCS("_get_tooltip") );
ADD_GROUP("Focus","focus_"); 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_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_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_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_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_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_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") ); 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_FILL );
BIND_CONSTANT( SIZE_EXPAND_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("resized") );
ADD_SIGNAL( MethodInfo("gui_input",PropertyInfo(Variant::INPUT_EVENT,"ev")) ); ADD_SIGNAL( MethodInfo("gui_input",PropertyInfo(Variant::INPUT_EVENT,"ev")) );
ADD_SIGNAL( MethodInfo("mouse_enter") ); ADD_SIGNAL( MethodInfo("mouse_enter") );
@ -2572,9 +2566,7 @@ Control::Control() {
data.parent=NULL; data.parent=NULL;
data.ignore_mouse=false; data.mouse_filter=MOUSE_FILTER_STOP;
data.stop_mouse=true;
data.SI=NULL; data.SI=NULL;
data.MI=NULL; data.MI=NULL;

View file

@ -71,6 +71,12 @@ public:
}; };
enum MouseFilter {
MOUSE_FILTER_STOP,
MOUSE_FILTER_PASS,
MOUSE_FILTER_IGNORE
};
enum CursorShape { enum CursorShape {
CURSOR_ARROW, CURSOR_ARROW,
CURSOR_IBEAM, CURSOR_IBEAM,
@ -124,8 +130,7 @@ private:
bool pending_min_size_update; bool pending_min_size_update;
Point2 custom_minimum_size; Point2 custom_minimum_size;
bool ignore_mouse; MouseFilter mouse_filter;
bool stop_mouse;
bool block_minimum_size_adjust; bool block_minimum_size_adjust;
bool disable_visibility_clip; bool disable_visibility_clip;
@ -337,11 +342,8 @@ public:
Control *get_focus_owner() const; Control *get_focus_owner() const;
void set_ignore_mouse(bool p_ignore); void set_mouse_filter(MouseFilter p_filter);
bool is_ignoring_mouse() const; MouseFilter get_mouse_filter() const;
void set_stop_mouse(bool p_stop);
bool is_stopping_mouse() const;
/* SKINNING */ /* SKINNING */
@ -417,5 +419,6 @@ VARIANT_ENUM_CAST(Control::AnchorType);
VARIANT_ENUM_CAST(Control::FocusMode); VARIANT_ENUM_CAST(Control::FocusMode);
VARIANT_ENUM_CAST(Control::SizeFlags); VARIANT_ENUM_CAST(Control::SizeFlags);
VARIANT_ENUM_CAST(Control::CursorShape); VARIANT_ENUM_CAST(Control::CursorShape);
VARIANT_ENUM_CAST(Control::MouseFilter);
#endif #endif

View file

@ -256,7 +256,7 @@ void GraphEdit::add_child_notify(Node *p_child) {
gn->connect("raise_request",this,"_graph_node_raised",varray(gn)); gn->connect("raise_request",this,"_graph_node_raised",varray(gn));
gn->connect("item_rect_changed",connections_layer,"update"); gn->connect("item_rect_changed",connections_layer,"update");
_graph_node_moved(gn); _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=NULL;
top_layer=memnew(GraphEditFilter(this)); top_layer=memnew(GraphEditFilter(this));
add_child(top_layer); 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->set_area_as_parent_rect();
top_layer->connect("draw",this,"_top_layer_draw"); 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"); top_layer->connect("input_event",this,"_top_layer_input");
connections_layer = memnew( Control ); connections_layer = memnew( Control );

View file

@ -787,7 +787,7 @@ GraphNode::GraphNode() {
overlay=OVERLAY_DISABLED; overlay=OVERLAY_DISABLED;
show_close=false; show_close=false;
connpos_dirty=true; connpos_dirty=true;
set_stop_mouse(false); set_mouse_filter(MOUSE_FILTER_PASS);
modulate=Color(1,1,1,1); modulate=Color(1,1,1,1);
comment=false; comment=false;
resizeable=false; resizeable=false;

View file

@ -230,6 +230,6 @@ Size2 GridContainer::get_minimum_size() const {
GridContainer::GridContainer() { GridContainer::GridContainer() {
set_stop_mouse(false); set_mouse_filter(MOUSE_FILTER_PASS);
columns=1; columns=1;
} }

View file

@ -699,7 +699,7 @@ Label::Label(const String &p_text) {
line_count=0; line_count=0;
set_v_size_flags(0); set_v_size_flags(0);
clip=false; clip=false;
set_ignore_mouse(true); set_mouse_filter(MOUSE_FILTER_IGNORE);
total_char_cache=0; total_char_cache=0;
visible_chars=-1; visible_chars=-1;
percent_visible=1; percent_visible=1;

View file

@ -1341,7 +1341,7 @@ LineEdit::LineEdit() {
set_focus_mode( FOCUS_ALL ); set_focus_mode( FOCUS_ALL );
editable=true; editable=true;
set_default_cursor_shape(CURSOR_IBEAM); set_default_cursor_shape(CURSOR_IBEAM);
set_stop_mouse(true); set_mouse_filter(MOUSE_FILTER_STOP);
draw_caret=true; draw_caret=true;
caret_blink_enabled=false; caret_blink_enabled=false;

View file

@ -41,7 +41,7 @@ void Panel::_notification(int p_what) {
Panel::Panel() { Panel::Panel() {
set_stop_mouse(true); set_mouse_filter(MOUSE_FILTER_STOP);
} }

View file

@ -174,7 +174,7 @@ Patch9Frame::Patch9Frame() {
margin[MARGIN_BOTTOM]=0; margin[MARGIN_BOTTOM]=0;
margin[MARGIN_TOP]=0; margin[MARGIN_TOP]=0;
set_ignore_mouse(true); set_mouse_filter(MOUSE_FILTER_IGNORE);
draw_center=true; draw_center=true;
} }

View file

@ -158,7 +158,7 @@ TextureFrame::TextureFrame() {
expand=false; expand=false;
set_ignore_mouse(true); set_mouse_filter(MOUSE_FILTER_IGNORE);
stretch_mode=STRETCH_SCALE_ON_EXPAND; stretch_mode=STRETCH_SCALE_ON_EXPAND;
} }

View file

@ -3711,7 +3711,7 @@ Tree::Tree() {
blocked=0; blocked=0;
cursor_can_exit_tree=true; cursor_can_exit_tree=true;
set_stop_mouse(true); set_mouse_filter(MOUSE_FILTER_STOP);
drag_speed=0; drag_speed=0;
drag_touching=false; drag_touching=false;

View file

@ -1615,7 +1615,7 @@ void Viewport::_gui_call_input(Control *p_control,const InputEvent& p_input) {
break; break;
if (gui.key_event_accepted) if (gui.key_event_accepted)
break; 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; break;
} }
@ -1724,7 +1724,7 @@ Control* Viewport::_gui_find_control_at_pos(CanvasItem* p_node,const Point2& p_g
matrix.affine_invert(); matrix.affine_invert();
//conditions for considering this as a valid control for return //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; r_inv_xform=matrix;
return c; return c;
} else } else

View file

@ -4090,7 +4090,7 @@ AnimationKeyEditor::AnimationKeyEditor() {
track_pos = memnew( Control ); track_pos = memnew( Control );
track_pos->set_area_as_parent_rect(); track_pos->set_area_as_parent_rect();
track_pos->set_ignore_mouse(true); track_pos->set_mouse_filter(MOUSE_FILTER_IGNORE);
track_editor->add_child(track_pos); track_editor->add_child(track_pos);
track_pos->connect("draw",this,"_track_pos_draw"); track_pos->connect("draw",this,"_track_pos_draw");

View file

@ -157,7 +157,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem() {
set_custom_minimum_size(Size2(250,100)); set_custom_minimum_size(Size2(250,100));
set_h_size_flags(SIZE_EXPAND_FILL); set_h_size_flags(SIZE_EXPAND_FILL);
set_stop_mouse(false); set_mouse_filter(MOUSE_FILTER_PASS);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -1446,7 +1446,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
library_scroll->add_child(library_vb_border); library_scroll->add_child(library_vb_border);
library_vb_border->add_style_override("panel",border2); library_vb_border->add_style_override("panel",border2);
library_vb_border->set_h_size_flags(SIZE_EXPAND_FILL); library_vb_border->set_h_size_flags(SIZE_EXPAND_FILL);
library_vb_border->set_stop_mouse(false); library_vb_border->set_mouse_filter(MOUSE_FILTER_PASS);

View file

@ -5873,7 +5873,7 @@ EditorNode::EditorNode() {
play_cc = memnew( CenterContainer ); play_cc = memnew( CenterContainer );
play_cc->set_ignore_mouse(true); play_cc->set_mouse_filter(Control::MOUSE_FILTER_IGNORE);
gui_base->add_child( play_cc ); gui_base->add_child( play_cc );
play_cc->set_area_as_parent_rect(); play_cc->set_area_as_parent_rect();
play_cc->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,10); play_cc->set_anchor_and_margin(MARGIN_BOTTOM,Control::ANCHOR_BEGIN,10);

View file

@ -710,8 +710,8 @@ EditorProfiler::EditorProfiler()
graph = memnew( TextureFrame ); graph = memnew( TextureFrame );
graph->set_expand(true); graph->set_expand(true);
graph->set_stop_mouse(true); graph->set_mouse_filter(MOUSE_FILTER_STOP);
graph->set_ignore_mouse(false); //graph->set_ignore_mouse(false);
graph->connect("draw",this,"_graph_tex_draw"); graph->connect("draw",this,"_graph_tex_draw");
graph->connect("gui_input",this,"_graph_tex_input"); graph->connect("gui_input",this,"_graph_tex_input");
graph->connect("mouse_exit",this,"_graph_tex_mouse_exit"); graph->connect("mouse_exit",this,"_graph_tex_mouse_exit");

View file

@ -2320,7 +2320,7 @@ void ShaderGraphView::_create_node(int p_id) {
tex->set_custom_minimum_size(Size2(80,80)); tex->set_custom_minimum_size(Size2(80,80));
tex->set_drag_forwarding(this); tex->set_drag_forwarding(this);
gn->add_child(tex); gn->add_child(tex);
tex->set_ignore_mouse(false); tex->set_mouse_filter(MOUSE_FILTER_PASS);
tex->set_texture(graph->texture_input_node_get_value(type,p_id)); tex->set_texture(graph->texture_input_node_get_value(type,p_id));
ToolButton *edit = memnew( ToolButton ); ToolButton *edit = memnew( ToolButton );
edit->set_text("edit.."); edit->set_text("edit..");