diff options
Diffstat (limited to 'scene/gui/graph_edit.h')
| -rw-r--r-- | scene/gui/graph_edit.h | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index 8a7721b9b5..c3276ceacc 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -1,3 +1,31 @@ +/*************************************************************************/ +/* graph_edit.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ #ifndef GRAPH_EDIT_H #define GRAPH_EDIT_H @@ -5,6 +33,7 @@ #include "scene/gui/scroll_bar.h" #include "scene/gui/slider.h" #include "scene/gui/tool_button.h" +#include "scene/gui/spin_box.h" #include "texture_frame.h" class GraphEdit; @@ -42,6 +71,9 @@ private: ToolButton *zoom_reset; ToolButton *zoom_plus; + ToolButton *snap_button; + SpinBox *snap_amount; + void _zoom_minus(); void _zoom_reset(); void _zoom_plus(); @@ -64,6 +96,7 @@ private: bool dragging; bool just_selected; Vector2 drag_accum; + Point2 drag_origin; // Workaround for GH-5907 float zoom; @@ -74,11 +107,14 @@ private: Rect2 box_selecting_rect; List<GraphNode*> previus_selected; + bool setting_scroll_ofs; bool right_disconnects; bool updating; List<Connection> connections; - void _draw_cos_line(const Vector2& p_from, const Vector2& p_to,const Color& p_color); + void _bake_segment2d(CanvasItem* p_where,float p_begin, float p_end, const Vector2& p_a, const Vector2& p_out, const Vector2& p_b, const Vector2& p_in, int p_depth, int p_min_depth, int p_max_depth, float p_tol, const Color& p_color, const Color& p_to_color, int &lines) const; + + void _draw_cos_line(CanvasItem* p_where,const Vector2& p_from, const Vector2& p_to, const Color& p_color, const Color &p_to_color); void _graph_node_raised(Node* p_gn); void _graph_node_moved(Node *p_gn); @@ -94,8 +130,38 @@ private: Array _get_connection_list() const; + bool lines_on_bg; + + + + struct ConnType { + + union { + struct { + uint32_t type_a; + uint32_t type_b; + }; + uint64_t key; + }; + + bool operator<(const ConnType& p_type) const { + return key<p_type.key; + } + + ConnType(uint32_t a=0, uint32_t b=0) { + type_a=a; + type_b=b; + } + }; + + Set<ConnType> valid_connection_types; + Set<int> valid_left_disconnect_types; + Set<int> valid_right_disconnect_types; + friend class GraphEditFilter; bool _filter_input(const Point2& p_point); + void _snap_toggled(); + void _snap_value_changed(double); protected: static void _bind_methods(); @@ -110,6 +176,10 @@ public: void disconnect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port); void clear_connections(); + void add_valid_connection_type(int p_type,int p_with_type); + void remove_valid_connection_type(int p_type,int p_with_type); + bool is_valid_connection_type(int p_type,int p_with_type) const; + void set_zoom(float p_zoom); float get_zoom() const; @@ -119,8 +189,23 @@ public: void set_right_disconnects(bool p_enable); bool is_right_disconnects_enabled() const; + void add_valid_right_disconnect_type(int p_type); + void remove_valid_right_disconnect_type(int p_type); + + void add_valid_left_disconnect_type(int p_type); + void remove_valid_left_disconnect_type(int p_type); + + void set_scroll_ofs(const Vector2& p_ofs); Vector2 get_scroll_ofs() const; + void set_selected(Node* p_child); + + void set_use_snap(bool p_enable); + bool is_using_snap() const; + + int get_snap() const; + void set_snap(int p_snap); + GraphEdit(); }; |