From b78067930237ade5a8942b41dc4aea08b827cde2 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Fri, 2 Sep 2016 11:55:12 -0300 Subject: [PATCH] -Added focus to comment node -Make comment node not grab focus on main area --- scene/gui/graph_node.cpp | 31 +++++++++++++++++- scene/gui/graph_node.h | 3 ++ .../resources/default_theme/default_theme.cpp | 2 ++ .../graph_node_comment_focus.png | Bin 0 -> 482 bytes scene/resources/default_theme/theme_data.h | 5 +++ 5 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 scene/resources/default_theme/graph_node_comment_focus.png diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 5ece9709368..da298a795a9 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -183,12 +183,39 @@ void GraphNode::_resort() { } +bool GraphNode::has_point(const Point2& p_point) const { + + if (comment) { + Ref comment = get_stylebox("comment"); + Ref resizer =get_icon("resizer"); + + if (Rect2(get_size()-resizer->get_size(), resizer->get_size()).has_point(p_point)) { + return true; + } + if (Rect2(0,0,get_size().width,comment->get_margin(MARGIN_TOP)).has_point(p_point)) { + return true; + } + + return false; + + } else { + return Control::has_point(p_point); + } +} void GraphNode::_notification(int p_what) { if (p_what==NOTIFICATION_DRAW) { - Ref sb=get_stylebox(comment? "comment": (selected ? "selectedframe" : "frame")); + Ref sb; + + if (comment) { + sb = get_stylebox( selected? "commentfocus" : "comment"); + + } else { + + sb = get_stylebox( selected ? "selectedframe" : "frame"); + } sb=sb->duplicate(); sb->call("set_modulate",modulate); @@ -601,6 +628,8 @@ void GraphNode::_input_event(const InputEvent& p_ev) { ERR_EXPLAIN("GraphNode must be the child of a GraphEdit node."); ERR_FAIL_COND(get_parent_control() == NULL); + print_line("INPUT EVENT BUTTON"); + if(p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) { Vector2 mpos = Vector2(p_ev.mouse_button.x,p_ev.mouse_button.y); diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index 7357ab5a45e..cbfd34f5563 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -93,6 +93,9 @@ private: Overlay overlay; Color modulate; + + bool has_point(const Point2& p_point) const; + protected: diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 8c1233b6340..03f28bef081 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -628,6 +628,7 @@ void fill_default_theme(Ref& t,const Ref & default_font,const Ref graphsb = make_stylebox(graph_node_png,6,24,6,5,16,24,16,5); Ref graphsbcomment = make_stylebox(graph_node_comment_png,6,24,6,5,16,24,16,5); + Ref graphsbcommentselected = make_stylebox(graph_node_comment_focus_png,6,24,6,5,16,24,16,5); Ref graphsbselected = make_stylebox(graph_node_selected_png,6,24,6,5,16,24,16,5); Ref graphsbdefault = make_stylebox(graph_node_default_png,4,4,4,4,6,4,4,4); Ref graphsbdeffocus = make_stylebox(graph_node_default_focus_png,4,4,4,4,6,4,4,4); @@ -641,6 +642,7 @@ void fill_default_theme(Ref& t,const Ref & default_font,const Refset_stylebox("defaultframe", "GraphNode", graphsbdefault ); t->set_stylebox("defaultfocus", "GraphNode", graphsbdeffocus ); t->set_stylebox("comment", "GraphNode", graphsbcomment ); + t->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected ); t->set_stylebox("breakpoint", "GraphNode", graph_bpoint ); t->set_stylebox("position", "GraphNode", graph_position ); t->set_constant("separation","GraphNode", 1 *scale); diff --git a/scene/resources/default_theme/graph_node_comment_focus.png b/scene/resources/default_theme/graph_node_comment_focus.png new file mode 100644 index 0000000000000000000000000000000000000000..a4b7b5a6188c687d52a4c20d8a9c35fc75c354a9 GIT binary patch literal 482 zcmeAS@N?(olHy`uVBq!ia0vp^0zmA*!3HFSYrjteQfx`y?k+$Y2!1;6t_M<_1s;*b z3=G`DAk4@xYmNj^kiEpy*OmPNCljBT(!TeH9s-3VOI#yLobz*YQ}ap~oQqNuOHxx5 z$}>wc6x=<11Hv2m#2FYEy*ynULn02py}sZ3wxi6kkJrruS(v#NDO`H=D8=#4oiz_a z?reIdFCg{7Ur_0Xc*z)kEKmL zRIxg#R*cd0?`jFgxfQC-D;~`CYGCnbsF!;6@fHuC#f|&XwcVMSKR@T~Y6S{I(U0{F zYuw%5RI~qNxM#yubZ5cU_MM_Om5MGmjZJpj`>(IrFzevuzLTXg+`U<;+@JML%#RoD z4Ex`u9Fr0&n8#y09SXW=Uuy6+Z{F{#IGC%VU9J9X~KR3ir^zZ8} R{=lGT@O1TaS?83{1OQ)^!yf