Browse Source

-Added focus to comment node
-Make comment node not grab focus on main area

Juan Linietsky 9 years ago
parent
commit
b780679302

+ 30 - 1
scene/gui/graph_node.cpp

@@ -183,12 +183,39 @@ void GraphNode::_resort() {
 
 }
 
+bool GraphNode::has_point(const Point2& p_point) const {
+
+	if (comment) {
+		Ref<StyleBox> comment = get_stylebox("comment");
+		Ref<Texture> 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<StyleBox> sb=get_stylebox(comment? "comment": (selected ? "selectedframe" : "frame"));
+		Ref<StyleBox> 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);

+ 3 - 0
scene/gui/graph_node.h

@@ -93,6 +93,9 @@ private:
 	Overlay overlay;
 
 	Color modulate;
+
+	bool has_point(const Point2& p_point) const;
+
 protected:
 
 

+ 2 - 0
scene/resources/default_theme/default_theme.cpp

@@ -628,6 +628,7 @@ void fill_default_theme(Ref<Theme>& t,const Ref<Font> & default_font,const Ref<F
 
 	Ref<StyleBoxTexture> graphsb = make_stylebox(graph_node_png,6,24,6,5,16,24,16,5);
 	Ref<StyleBoxTexture> graphsbcomment = make_stylebox(graph_node_comment_png,6,24,6,5,16,24,16,5);
+	Ref<StyleBoxTexture> graphsbcommentselected = make_stylebox(graph_node_comment_focus_png,6,24,6,5,16,24,16,5);
 	Ref<StyleBoxTexture> graphsbselected = make_stylebox(graph_node_selected_png,6,24,6,5,16,24,16,5);
 	Ref<StyleBoxTexture> graphsbdefault = make_stylebox(graph_node_default_png,4,4,4,4,6,4,4,4);
 	Ref<StyleBoxTexture> 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<Theme>& t,const Ref<Font> & default_font,const Ref<F
 	t->set_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);

BIN
scene/resources/default_theme/graph_node_comment_focus.png


File diff suppressed because it is too large
+ 1 - 0
scene/resources/default_theme/theme_data.h


Some files were not shown because too many files changed in this diff