Fix tab indent
This commit is contained in:
parent
bdd12744fe
commit
2a43778793
File diff suppressed because it is too large
Load Diff
@ -8,95 +8,95 @@ class GraphEdit;
|
|||||||
|
|
||||||
class GraphEditFilter : public Control {
|
class GraphEditFilter : public Control {
|
||||||
|
|
||||||
OBJ_TYPE(GraphEditFilter,Control);
|
OBJ_TYPE(GraphEditFilter,Control);
|
||||||
|
|
||||||
friend class GraphEdit;
|
friend class GraphEdit;
|
||||||
GraphEdit *ge;
|
GraphEdit *ge;
|
||||||
virtual bool has_point(const Point2& p_point) const;
|
virtual bool has_point(const Point2& p_point) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
GraphEditFilter(GraphEdit *p_edit);
|
GraphEditFilter(GraphEdit *p_edit);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GraphEdit : public Control {
|
class GraphEdit : public Control {
|
||||||
|
|
||||||
OBJ_TYPE(GraphEdit,Control);
|
OBJ_TYPE(GraphEdit,Control);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct Connection {
|
struct Connection {
|
||||||
StringName from;
|
StringName from;
|
||||||
StringName to;
|
StringName to;
|
||||||
int from_port;
|
int from_port;
|
||||||
int to_port;
|
int to_port;
|
||||||
|
|
||||||
};
|
};
|
||||||
private:
|
private:
|
||||||
|
|
||||||
HScrollBar* h_scroll;
|
HScrollBar* h_scroll;
|
||||||
VScrollBar* v_scroll;
|
VScrollBar* v_scroll;
|
||||||
|
|
||||||
|
|
||||||
bool connecting;
|
bool connecting;
|
||||||
String connecting_from;
|
String connecting_from;
|
||||||
bool connecting_out;
|
bool connecting_out;
|
||||||
int connecting_index;
|
int connecting_index;
|
||||||
int connecting_type;
|
int connecting_type;
|
||||||
Color connecting_color;
|
Color connecting_color;
|
||||||
bool connecting_target;
|
bool connecting_target;
|
||||||
Vector2 connecting_to;
|
Vector2 connecting_to;
|
||||||
String connecting_target_to;
|
String connecting_target_to;
|
||||||
int connecting_target_index;
|
int connecting_target_index;
|
||||||
|
|
||||||
bool dragging;
|
bool dragging;
|
||||||
bool just_selected;
|
bool just_selected;
|
||||||
Vector2 drag_accum;
|
Vector2 drag_accum;
|
||||||
|
|
||||||
bool right_disconnects;
|
bool right_disconnects;
|
||||||
bool updating;
|
bool updating;
|
||||||
List<Connection> connections;
|
List<Connection> connections;
|
||||||
|
|
||||||
void _draw_cos_line(const Vector2& p_from, const Vector2& p_to,const Color& p_color);
|
void _draw_cos_line(const Vector2& p_from, const Vector2& p_to,const Color& p_color);
|
||||||
|
|
||||||
void _graph_node_raised(Node* p_gn);
|
void _graph_node_raised(Node* p_gn);
|
||||||
void _graph_node_moved(Node *p_gn);
|
void _graph_node_moved(Node *p_gn);
|
||||||
|
|
||||||
void _update_scroll();
|
void _update_scroll();
|
||||||
void _scroll_moved(double);
|
void _scroll_moved(double);
|
||||||
void _input_event(const InputEvent& p_ev);
|
void _input_event(const InputEvent& p_ev);
|
||||||
|
|
||||||
GraphEditFilter *top_layer;
|
GraphEditFilter *top_layer;
|
||||||
void _top_layer_input(const InputEvent& p_ev);
|
void _top_layer_input(const InputEvent& p_ev);
|
||||||
void _top_layer_draw();
|
void _top_layer_draw();
|
||||||
void _update_scroll_offset();
|
void _update_scroll_offset();
|
||||||
|
|
||||||
Array _get_connection_list() const;
|
Array _get_connection_list() const;
|
||||||
|
|
||||||
friend class GraphEditFilter;
|
friend class GraphEditFilter;
|
||||||
bool _filter_input(const Point2& p_point);
|
bool _filter_input(const Point2& p_point);
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
virtual void add_child_notify(Node *p_child);
|
virtual void add_child_notify(Node *p_child);
|
||||||
virtual void remove_child_notify(Node *p_child);
|
virtual void remove_child_notify(Node *p_child);
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Error connect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
|
Error connect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
|
||||||
bool is_node_connected(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
|
bool is_node_connected(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
|
||||||
void disconnect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
|
void disconnect_node(const StringName& p_from, int p_from_port,const StringName& p_to,int p_to_port);
|
||||||
void clear_connections();
|
void clear_connections();
|
||||||
|
|
||||||
GraphEditFilter *get_top_layer() const { return top_layer; }
|
GraphEditFilter *get_top_layer() const { return top_layer; }
|
||||||
void get_connection_list(List<Connection> *r_connections) const;
|
void get_connection_list(List<Connection> *r_connections) const;
|
||||||
|
|
||||||
void set_right_disconnects(bool p_enable);
|
void set_right_disconnects(bool p_enable);
|
||||||
bool is_right_disconnects_enabled() const;
|
bool is_right_disconnects_enabled() const;
|
||||||
|
|
||||||
|
|
||||||
GraphEdit();
|
GraphEdit();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GRAPHEdit_H
|
#endif // GRAPHEdit_H
|
||||||
|
@ -4,91 +4,91 @@
|
|||||||
|
|
||||||
bool GraphNode::_set(const StringName& p_name, const Variant& p_value) {
|
bool GraphNode::_set(const StringName& p_name, const Variant& p_value) {
|
||||||
|
|
||||||
if (!p_name.operator String().begins_with("slot/"))
|
if (!p_name.operator String().begins_with("slot/"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int idx=p_name.operator String().get_slice("/",1).to_int();
|
int idx=p_name.operator String().get_slice("/",1).to_int();
|
||||||
String what = p_name.operator String().get_slice("/",2);
|
String what = p_name.operator String().get_slice("/",2);
|
||||||
|
|
||||||
|
|
||||||
Slot si;
|
Slot si;
|
||||||
if (slot_info.has(idx))
|
if (slot_info.has(idx))
|
||||||
si=slot_info[idx];
|
si=slot_info[idx];
|
||||||
|
|
||||||
|
|
||||||
if (what=="left_enabled")
|
if (what=="left_enabled")
|
||||||
si.enable_left=p_value;
|
si.enable_left=p_value;
|
||||||
else if (what=="left_type")
|
else if (what=="left_type")
|
||||||
si.type_left=p_value;
|
si.type_left=p_value;
|
||||||
else if (what=="left_color")
|
else if (what=="left_color")
|
||||||
si.color_left=p_value;
|
si.color_left=p_value;
|
||||||
else if (what=="right_enabled")
|
else if (what=="right_enabled")
|
||||||
si.enable_right=p_value;
|
si.enable_right=p_value;
|
||||||
else if (what=="right_type")
|
else if (what=="right_type")
|
||||||
si.type_right=p_value;
|
si.type_right=p_value;
|
||||||
else if (what=="right_color")
|
else if (what=="right_color")
|
||||||
si.color_right=p_value;
|
si.color_right=p_value;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
set_slot(idx,si.enable_left,si.type_left,si.color_left,si.enable_right,si.type_right,si.color_right);
|
set_slot(idx,si.enable_left,si.type_left,si.color_left,si.enable_right,si.type_right,si.color_right);
|
||||||
update();
|
update();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphNode::_get(const StringName& p_name,Variant &r_ret) const{
|
bool GraphNode::_get(const StringName& p_name,Variant &r_ret) const{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!p_name.operator String().begins_with("slot/")) {
|
if (!p_name.operator String().begins_with("slot/")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int idx=p_name.operator String().get_slice("/",1).to_int();
|
int idx=p_name.operator String().get_slice("/",1).to_int();
|
||||||
String what = p_name.operator String().get_slice("/",2);
|
String what = p_name.operator String().get_slice("/",2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Slot si;
|
Slot si;
|
||||||
if (slot_info.has(idx))
|
if (slot_info.has(idx))
|
||||||
si=slot_info[idx];
|
si=slot_info[idx];
|
||||||
|
|
||||||
if (what=="left_enabled")
|
if (what=="left_enabled")
|
||||||
r_ret=si.enable_left;
|
r_ret=si.enable_left;
|
||||||
else if (what=="left_type")
|
else if (what=="left_type")
|
||||||
r_ret=si.type_left;
|
r_ret=si.type_left;
|
||||||
else if (what=="left_color")
|
else if (what=="left_color")
|
||||||
r_ret=si.color_left;
|
r_ret=si.color_left;
|
||||||
else if (what=="right_enabled")
|
else if (what=="right_enabled")
|
||||||
r_ret=si.enable_right;
|
r_ret=si.enable_right;
|
||||||
else if (what=="right_type")
|
else if (what=="right_type")
|
||||||
r_ret=si.type_right;
|
r_ret=si.type_right;
|
||||||
else if (what=="right_color")
|
else if (what=="right_color")
|
||||||
r_ret=si.color_right;
|
r_ret=si.color_right;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
void GraphNode::_get_property_list( List<PropertyInfo> *p_list) const{
|
void GraphNode::_get_property_list( List<PropertyInfo> *p_list) const{
|
||||||
|
|
||||||
int idx=0;
|
int idx=0;
|
||||||
for(int i=0;i<get_child_count();i++) {
|
for(int i=0;i<get_child_count();i++) {
|
||||||
Control *c=get_child(i)->cast_to<Control>();
|
Control *c=get_child(i)->cast_to<Control>();
|
||||||
if (!c || c->is_set_as_toplevel() )
|
if (!c || c->is_set_as_toplevel() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
String base="slot/"+itos(idx)+"/";
|
String base="slot/"+itos(idx)+"/";
|
||||||
|
|
||||||
p_list->push_back(PropertyInfo(Variant::BOOL,base+"left_enabled"));
|
p_list->push_back(PropertyInfo(Variant::BOOL,base+"left_enabled"));
|
||||||
p_list->push_back(PropertyInfo(Variant::INT,base+"left_type"));
|
p_list->push_back(PropertyInfo(Variant::INT,base+"left_type"));
|
||||||
p_list->push_back(PropertyInfo(Variant::COLOR,base+"left_color"));
|
p_list->push_back(PropertyInfo(Variant::COLOR,base+"left_color"));
|
||||||
p_list->push_back(PropertyInfo(Variant::BOOL,base+"right_enabled"));
|
p_list->push_back(PropertyInfo(Variant::BOOL,base+"right_enabled"));
|
||||||
p_list->push_back(PropertyInfo(Variant::INT,base+"right_type"));
|
p_list->push_back(PropertyInfo(Variant::INT,base+"right_type"));
|
||||||
p_list->push_back(PropertyInfo(Variant::COLOR,base+"right_color"));
|
p_list->push_back(PropertyInfo(Variant::COLOR,base+"right_color"));
|
||||||
|
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,61 +96,61 @@ void GraphNode::_resort() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int sep=get_constant("separation");
|
int sep=get_constant("separation");
|
||||||
Ref<StyleBox> sb=get_stylebox("frame");
|
Ref<StyleBox> sb=get_stylebox("frame");
|
||||||
bool first=true;
|
bool first=true;
|
||||||
|
|
||||||
Size2 minsize;
|
Size2 minsize;
|
||||||
|
|
||||||
for(int i=0;i<get_child_count();i++) {
|
for(int i=0;i<get_child_count();i++) {
|
||||||
Control *c=get_child(i)->cast_to<Control>();
|
Control *c=get_child(i)->cast_to<Control>();
|
||||||
if (!c)
|
if (!c)
|
||||||
continue;
|
continue;
|
||||||
if (c->is_set_as_toplevel())
|
if (c->is_set_as_toplevel())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Size2i size=c->get_combined_minimum_size();
|
Size2i size=c->get_combined_minimum_size();
|
||||||
|
|
||||||
minsize.y+=size.y;
|
minsize.y+=size.y;
|
||||||
minsize.x=MAX(minsize.x,size.x);
|
minsize.x=MAX(minsize.x,size.x);
|
||||||
|
|
||||||
if (first)
|
if (first)
|
||||||
first=false;
|
first=false;
|
||||||
else
|
else
|
||||||
minsize.y+=sep;
|
minsize.y+=sep;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int vofs=0;
|
int vofs=0;
|
||||||
int w = get_size().x - sb->get_minimum_size().x;
|
int w = get_size().x - sb->get_minimum_size().x;
|
||||||
|
|
||||||
|
|
||||||
cache_y.clear();
|
cache_y.clear();
|
||||||
for(int i=0;i<get_child_count();i++) {
|
for(int i=0;i<get_child_count();i++) {
|
||||||
Control *c=get_child(i)->cast_to<Control>();
|
Control *c=get_child(i)->cast_to<Control>();
|
||||||
if (!c)
|
if (!c)
|
||||||
continue;
|
continue;
|
||||||
if (c->is_set_as_toplevel())
|
if (c->is_set_as_toplevel())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Size2i size=c->get_combined_minimum_size();
|
Size2i size=c->get_combined_minimum_size();
|
||||||
|
|
||||||
Rect2 r(sb->get_margin(MARGIN_LEFT),sb->get_margin(MARGIN_TOP)+vofs,w,size.y);
|
Rect2 r(sb->get_margin(MARGIN_LEFT),sb->get_margin(MARGIN_TOP)+vofs,w,size.y);
|
||||||
|
|
||||||
fit_child_in_rect(c,r);
|
fit_child_in_rect(c,r);
|
||||||
cache_y.push_back(vofs+size.y*0.5);
|
cache_y.push_back(vofs+size.y*0.5);
|
||||||
|
|
||||||
if (vofs>0)
|
if (vofs>0)
|
||||||
vofs+=sep;
|
vofs+=sep;
|
||||||
vofs+=size.y;
|
vofs+=size.y;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_change_notify();
|
_change_notify();
|
||||||
update();
|
update();
|
||||||
connpos_dirty=true;
|
connpos_dirty=true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -158,124 +158,124 @@ void GraphNode::_resort() {
|
|||||||
|
|
||||||
void GraphNode::_notification(int p_what) {
|
void GraphNode::_notification(int p_what) {
|
||||||
|
|
||||||
if (p_what==NOTIFICATION_DRAW) {
|
if (p_what==NOTIFICATION_DRAW) {
|
||||||
|
|
||||||
Ref<StyleBox> sb=get_stylebox(selected ? "selectedframe" : "frame");
|
Ref<StyleBox> sb=get_stylebox(selected ? "selectedframe" : "frame");
|
||||||
Ref<Texture> port =get_icon("port");
|
Ref<Texture> port =get_icon("port");
|
||||||
Ref<Texture> close =get_icon("close");
|
Ref<Texture> close =get_icon("close");
|
||||||
int close_offset = get_constant("close_offset");
|
int close_offset = get_constant("close_offset");
|
||||||
Ref<Font> title_font = get_font("title_font");
|
Ref<Font> title_font = get_font("title_font");
|
||||||
int title_offset = get_constant("title_offset");
|
int title_offset = get_constant("title_offset");
|
||||||
Color title_color = get_color("title_color");
|
Color title_color = get_color("title_color");
|
||||||
Point2i icofs = -port->get_size()*0.5;
|
Point2i icofs = -port->get_size()*0.5;
|
||||||
int edgeofs=get_constant("port_offset");
|
int edgeofs=get_constant("port_offset");
|
||||||
icofs.y+=sb->get_margin(MARGIN_TOP);
|
icofs.y+=sb->get_margin(MARGIN_TOP);
|
||||||
draw_style_box(sb,Rect2(Point2(),get_size()));
|
draw_style_box(sb,Rect2(Point2(),get_size()));
|
||||||
|
|
||||||
int w = get_size().width-sb->get_minimum_size().x;
|
int w = get_size().width-sb->get_minimum_size().x;
|
||||||
|
|
||||||
if (show_close)
|
if (show_close)
|
||||||
w-=close->get_width();
|
w-=close->get_width();
|
||||||
|
|
||||||
draw_string(title_font,Point2(sb->get_margin(MARGIN_LEFT),-title_font->get_height()+title_font->get_ascent()+title_offset),title,title_color,w);
|
draw_string(title_font,Point2(sb->get_margin(MARGIN_LEFT),-title_font->get_height()+title_font->get_ascent()+title_offset),title,title_color,w);
|
||||||
if (show_close) {
|
if (show_close) {
|
||||||
Vector2 cpos = Point2(w+sb->get_margin(MARGIN_LEFT),-close->get_height()+close_offset);
|
Vector2 cpos = Point2(w+sb->get_margin(MARGIN_LEFT),-close->get_height()+close_offset);
|
||||||
draw_texture(close,cpos);
|
draw_texture(close,cpos);
|
||||||
close_rect.pos=cpos;
|
close_rect.pos=cpos;
|
||||||
close_rect.size=close->get_size();
|
close_rect.size=close->get_size();
|
||||||
} else {
|
} else {
|
||||||
close_rect=Rect2();
|
close_rect=Rect2();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map<int,Slot>::Element *E=slot_info.front();E;E=E->next()) {
|
for (Map<int,Slot>::Element *E=slot_info.front();E;E=E->next()) {
|
||||||
|
|
||||||
if (E->key() < 0 || E->key()>=cache_y.size())
|
if (E->key() < 0 || E->key()>=cache_y.size())
|
||||||
continue;
|
continue;
|
||||||
if (!slot_info.has(E->key()))
|
if (!slot_info.has(E->key()))
|
||||||
continue;
|
continue;
|
||||||
const Slot &s=slot_info[E->key()];
|
const Slot &s=slot_info[E->key()];
|
||||||
//left
|
//left
|
||||||
if (s.enable_left)
|
if (s.enable_left)
|
||||||
port->draw(get_canvas_item(),icofs+Point2(edgeofs,cache_y[E->key()]),s.color_left);
|
port->draw(get_canvas_item(),icofs+Point2(edgeofs,cache_y[E->key()]),s.color_left);
|
||||||
if (s.enable_right)
|
if (s.enable_right)
|
||||||
port->draw(get_canvas_item(),icofs+Point2(get_size().x-edgeofs,cache_y[E->key()]),s.color_right);
|
port->draw(get_canvas_item(),icofs+Point2(get_size().x-edgeofs,cache_y[E->key()]),s.color_right);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_what==NOTIFICATION_SORT_CHILDREN) {
|
if (p_what==NOTIFICATION_SORT_CHILDREN) {
|
||||||
|
|
||||||
_resort();
|
_resort();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphNode::set_slot(int p_idx,bool p_enable_left,int p_type_left,const Color& p_color_left, bool p_enable_right,int p_type_right,const Color& p_color_right) {
|
void GraphNode::set_slot(int p_idx,bool p_enable_left,int p_type_left,const Color& p_color_left, bool p_enable_right,int p_type_right,const Color& p_color_right) {
|
||||||
|
|
||||||
ERR_FAIL_COND(p_idx<0);
|
ERR_FAIL_COND(p_idx<0);
|
||||||
|
|
||||||
if (!p_enable_left && p_type_left==0 && p_color_left==Color(1,1,1,1) && !p_enable_right && p_type_right==0 && p_color_right==Color(1,1,1,1)) {
|
if (!p_enable_left && p_type_left==0 && p_color_left==Color(1,1,1,1) && !p_enable_right && p_type_right==0 && p_color_right==Color(1,1,1,1)) {
|
||||||
slot_info.erase(p_idx);
|
slot_info.erase(p_idx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Slot s;
|
Slot s;
|
||||||
s.enable_left=p_enable_left;
|
s.enable_left=p_enable_left;
|
||||||
s.type_left=p_type_left;
|
s.type_left=p_type_left;
|
||||||
s.color_left=p_color_left;
|
s.color_left=p_color_left;
|
||||||
s.enable_right=p_enable_right;
|
s.enable_right=p_enable_right;
|
||||||
s.type_right=p_type_right;
|
s.type_right=p_type_right;
|
||||||
s.color_right=p_color_right;
|
s.color_right=p_color_right;
|
||||||
slot_info[p_idx]=s;
|
slot_info[p_idx]=s;
|
||||||
update();
|
update();
|
||||||
connpos_dirty=true;
|
connpos_dirty=true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphNode::clear_slot(int p_idx){
|
void GraphNode::clear_slot(int p_idx){
|
||||||
|
|
||||||
slot_info.erase(p_idx);
|
slot_info.erase(p_idx);
|
||||||
update();
|
update();
|
||||||
connpos_dirty=true;
|
connpos_dirty=true;
|
||||||
|
|
||||||
}
|
}
|
||||||
void GraphNode::clear_all_slots(){
|
void GraphNode::clear_all_slots(){
|
||||||
|
|
||||||
slot_info.clear();
|
slot_info.clear();
|
||||||
update();
|
update();
|
||||||
connpos_dirty=true;
|
connpos_dirty=true;
|
||||||
|
|
||||||
}
|
}
|
||||||
bool GraphNode::is_slot_enabled_left(int p_idx) const{
|
bool GraphNode::is_slot_enabled_left(int p_idx) const{
|
||||||
|
|
||||||
if (!slot_info.has(p_idx))
|
if (!slot_info.has(p_idx))
|
||||||
return false;
|
return false;
|
||||||
return slot_info[p_idx].enable_left;
|
return slot_info[p_idx].enable_left;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GraphNode::get_slot_type_left(int p_idx) const{
|
int GraphNode::get_slot_type_left(int p_idx) const{
|
||||||
|
|
||||||
if (!slot_info.has(p_idx))
|
if (!slot_info.has(p_idx))
|
||||||
return 0;
|
return 0;
|
||||||
return slot_info[p_idx].type_left;
|
return slot_info[p_idx].type_left;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Color GraphNode::get_slot_color_left(int p_idx) const{
|
Color GraphNode::get_slot_color_left(int p_idx) const{
|
||||||
|
|
||||||
if (!slot_info.has(p_idx))
|
if (!slot_info.has(p_idx))
|
||||||
return Color(1,1,1,1);
|
return Color(1,1,1,1);
|
||||||
return slot_info[p_idx].color_left;
|
return slot_info[p_idx].color_left;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphNode::is_slot_enabled_right(int p_idx) const{
|
bool GraphNode::is_slot_enabled_right(int p_idx) const{
|
||||||
|
|
||||||
if (!slot_info.has(p_idx))
|
if (!slot_info.has(p_idx))
|
||||||
return false;
|
return false;
|
||||||
return slot_info[p_idx].enable_right;
|
return slot_info[p_idx].enable_right;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,305 +283,305 @@ bool GraphNode::is_slot_enabled_right(int p_idx) const{
|
|||||||
|
|
||||||
int GraphNode::get_slot_type_right(int p_idx) const{
|
int GraphNode::get_slot_type_right(int p_idx) const{
|
||||||
|
|
||||||
if (!slot_info.has(p_idx))
|
if (!slot_info.has(p_idx))
|
||||||
return 0;
|
return 0;
|
||||||
return slot_info[p_idx].type_right;
|
return slot_info[p_idx].type_right;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Color GraphNode::get_slot_color_right(int p_idx) const{
|
Color GraphNode::get_slot_color_right(int p_idx) const{
|
||||||
|
|
||||||
if (!slot_info.has(p_idx))
|
if (!slot_info.has(p_idx))
|
||||||
return Color(1,1,1,1);
|
return Color(1,1,1,1);
|
||||||
return slot_info[p_idx].color_right;
|
return slot_info[p_idx].color_right;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Size2 GraphNode::get_minimum_size() const {
|
Size2 GraphNode::get_minimum_size() const {
|
||||||
|
|
||||||
Ref<Font> title_font = get_font("title_font");
|
Ref<Font> title_font = get_font("title_font");
|
||||||
|
|
||||||
int sep=get_constant("separation");
|
int sep=get_constant("separation");
|
||||||
Ref<StyleBox> sb=get_stylebox("frame");
|
Ref<StyleBox> sb=get_stylebox("frame");
|
||||||
bool first=true;
|
bool first=true;
|
||||||
|
|
||||||
Size2 minsize;
|
Size2 minsize;
|
||||||
minsize.x=title_font->get_string_size(title).x;
|
minsize.x=title_font->get_string_size(title).x;
|
||||||
if (show_close) {
|
if (show_close) {
|
||||||
Ref<Texture> close =get_icon("close");
|
Ref<Texture> close =get_icon("close");
|
||||||
minsize.x+=sep+close->get_width();
|
minsize.x+=sep+close->get_width();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for(int i=0;i<get_child_count();i++) {
|
for(int i=0;i<get_child_count();i++) {
|
||||||
|
|
||||||
Control *c=get_child(i)->cast_to<Control>();
|
Control *c=get_child(i)->cast_to<Control>();
|
||||||
if (!c)
|
if (!c)
|
||||||
continue;
|
continue;
|
||||||
if (c->is_set_as_toplevel())
|
if (c->is_set_as_toplevel())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Size2i size=c->get_combined_minimum_size();
|
Size2i size=c->get_combined_minimum_size();
|
||||||
|
|
||||||
minsize.y+=size.y;
|
minsize.y+=size.y;
|
||||||
minsize.x=MAX(minsize.x,size.x);
|
minsize.x=MAX(minsize.x,size.x);
|
||||||
|
|
||||||
if (first)
|
if (first)
|
||||||
first=false;
|
first=false;
|
||||||
else
|
else
|
||||||
minsize.y+=sep;
|
minsize.y+=sep;
|
||||||
}
|
}
|
||||||
|
|
||||||
return minsize+sb->get_minimum_size();
|
return minsize+sb->get_minimum_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphNode::set_title(const String& p_title) {
|
void GraphNode::set_title(const String& p_title) {
|
||||||
|
|
||||||
title=p_title;
|
title=p_title;
|
||||||
minimum_size_changed();
|
minimum_size_changed();
|
||||||
update();
|
update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String GraphNode::get_title() const{
|
String GraphNode::get_title() const{
|
||||||
|
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphNode::set_offset(const Vector2& p_offset) {
|
void GraphNode::set_offset(const Vector2& p_offset) {
|
||||||
|
|
||||||
offset=p_offset;
|
offset=p_offset;
|
||||||
emit_signal("offset_changed");
|
emit_signal("offset_changed");
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 GraphNode::get_offset() const {
|
Vector2 GraphNode::get_offset() const {
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphNode::set_selected(bool p_selected)
|
void GraphNode::set_selected(bool p_selected)
|
||||||
{
|
{
|
||||||
selected = p_selected;
|
selected = p_selected;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GraphNode::is_selected()
|
bool GraphNode::is_selected()
|
||||||
{
|
{
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphNode::set_drag(bool p_drag)
|
void GraphNode::set_drag(bool p_drag)
|
||||||
{
|
{
|
||||||
if (p_drag)
|
if (p_drag)
|
||||||
drag_from=get_offset();
|
drag_from=get_offset();
|
||||||
else
|
else
|
||||||
emit_signal("dragged",drag_from,get_offset()); //useful for undo/redo
|
emit_signal("dragged",drag_from,get_offset()); //useful for undo/redo
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 GraphNode::get_drag_from()
|
Vector2 GraphNode::get_drag_from()
|
||||||
{
|
{
|
||||||
return drag_from;
|
return drag_from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphNode::set_show_close_button(bool p_enable){
|
void GraphNode::set_show_close_button(bool p_enable){
|
||||||
|
|
||||||
show_close=p_enable;
|
show_close=p_enable;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
bool GraphNode::is_close_button_visible() const{
|
bool GraphNode::is_close_button_visible() const{
|
||||||
|
|
||||||
return show_close;
|
return show_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphNode::_connpos_update() {
|
void GraphNode::_connpos_update() {
|
||||||
|
|
||||||
|
|
||||||
int edgeofs=get_constant("port_offset");
|
int edgeofs=get_constant("port_offset");
|
||||||
int sep=get_constant("separation");
|
int sep=get_constant("separation");
|
||||||
|
|
||||||
Ref<StyleBox> sb=get_stylebox("frame");
|
Ref<StyleBox> sb=get_stylebox("frame");
|
||||||
conn_input_cache.clear();
|
conn_input_cache.clear();
|
||||||
conn_output_cache.clear();
|
conn_output_cache.clear();
|
||||||
int vofs=0;
|
int vofs=0;
|
||||||
|
|
||||||
int idx=0;
|
int idx=0;
|
||||||
|
|
||||||
for(int i=0;i<get_child_count();i++) {
|
for(int i=0;i<get_child_count();i++) {
|
||||||
Control *c=get_child(i)->cast_to<Control>();
|
Control *c=get_child(i)->cast_to<Control>();
|
||||||
if (!c)
|
if (!c)
|
||||||
continue;
|
continue;
|
||||||
if (c->is_set_as_toplevel())
|
if (c->is_set_as_toplevel())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Size2i size=c->get_combined_minimum_size();
|
Size2i size=c->get_combined_minimum_size();
|
||||||
|
|
||||||
int y = sb->get_margin(MARGIN_TOP)+vofs;
|
int y = sb->get_margin(MARGIN_TOP)+vofs;
|
||||||
int h = size.y;
|
int h = size.y;
|
||||||
|
|
||||||
|
|
||||||
if (slot_info.has(idx)) {
|
if (slot_info.has(idx)) {
|
||||||
|
|
||||||
if (slot_info[idx].enable_left) {
|
if (slot_info[idx].enable_left) {
|
||||||
ConnCache cc;
|
ConnCache cc;
|
||||||
cc.pos=Point2i(edgeofs,y+h/2);
|
cc.pos=Point2i(edgeofs,y+h/2);
|
||||||
cc.type=slot_info[idx].type_left;
|
cc.type=slot_info[idx].type_left;
|
||||||
cc.color=slot_info[idx].color_left;
|
cc.color=slot_info[idx].color_left;
|
||||||
conn_input_cache.push_back(cc);
|
conn_input_cache.push_back(cc);
|
||||||
}
|
}
|
||||||
if (slot_info[idx].enable_right) {
|
if (slot_info[idx].enable_right) {
|
||||||
ConnCache cc;
|
ConnCache cc;
|
||||||
cc.pos=Point2i(get_size().width-edgeofs,y+h/2);
|
cc.pos=Point2i(get_size().width-edgeofs,y+h/2);
|
||||||
cc.type=slot_info[idx].type_right;
|
cc.type=slot_info[idx].type_right;
|
||||||
cc.color=slot_info[idx].color_right;
|
cc.color=slot_info[idx].color_right;
|
||||||
conn_output_cache.push_back(cc);
|
conn_output_cache.push_back(cc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vofs>0)
|
if (vofs>0)
|
||||||
vofs+=sep;
|
vofs+=sep;
|
||||||
vofs+=size.y;
|
vofs+=size.y;
|
||||||
idx++;
|
idx++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
connpos_dirty=false;
|
connpos_dirty=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GraphNode::get_connection_input_count() {
|
int GraphNode::get_connection_input_count() {
|
||||||
|
|
||||||
if (connpos_dirty)
|
if (connpos_dirty)
|
||||||
_connpos_update();
|
_connpos_update();
|
||||||
|
|
||||||
return conn_input_cache.size();
|
return conn_input_cache.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
int GraphNode::get_connection_output_count() {
|
int GraphNode::get_connection_output_count() {
|
||||||
|
|
||||||
if (connpos_dirty)
|
if (connpos_dirty)
|
||||||
_connpos_update();
|
_connpos_update();
|
||||||
|
|
||||||
return conn_output_cache.size();
|
return conn_output_cache.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Vector2 GraphNode::get_connection_input_pos(int p_idx) {
|
Vector2 GraphNode::get_connection_input_pos(int p_idx) {
|
||||||
|
|
||||||
if (connpos_dirty)
|
if (connpos_dirty)
|
||||||
_connpos_update();
|
_connpos_update();
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),Vector2());
|
ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),Vector2());
|
||||||
return conn_input_cache[p_idx].pos;
|
return conn_input_cache[p_idx].pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GraphNode::get_connection_input_type(int p_idx) {
|
int GraphNode::get_connection_input_type(int p_idx) {
|
||||||
|
|
||||||
if (connpos_dirty)
|
if (connpos_dirty)
|
||||||
_connpos_update();
|
_connpos_update();
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),0);
|
ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),0);
|
||||||
return conn_input_cache[p_idx].type;
|
return conn_input_cache[p_idx].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color GraphNode::get_connection_input_color(int p_idx) {
|
Color GraphNode::get_connection_input_color(int p_idx) {
|
||||||
|
|
||||||
if (connpos_dirty)
|
if (connpos_dirty)
|
||||||
_connpos_update();
|
_connpos_update();
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),Color());
|
ERR_FAIL_INDEX_V(p_idx,conn_input_cache.size(),Color());
|
||||||
return conn_input_cache[p_idx].color;
|
return conn_input_cache[p_idx].color;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 GraphNode::get_connection_output_pos(int p_idx){
|
Vector2 GraphNode::get_connection_output_pos(int p_idx){
|
||||||
|
|
||||||
if (connpos_dirty)
|
if (connpos_dirty)
|
||||||
_connpos_update();
|
_connpos_update();
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),Vector2());
|
ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),Vector2());
|
||||||
return conn_output_cache[p_idx].pos;
|
return conn_output_cache[p_idx].pos;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int GraphNode::get_connection_output_type(int p_idx) {
|
int GraphNode::get_connection_output_type(int p_idx) {
|
||||||
|
|
||||||
if (connpos_dirty)
|
if (connpos_dirty)
|
||||||
_connpos_update();
|
_connpos_update();
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),0);
|
ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),0);
|
||||||
return conn_output_cache[p_idx].type;
|
return conn_output_cache[p_idx].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color GraphNode::get_connection_output_color(int p_idx) {
|
Color GraphNode::get_connection_output_color(int p_idx) {
|
||||||
|
|
||||||
if (connpos_dirty)
|
if (connpos_dirty)
|
||||||
_connpos_update();
|
_connpos_update();
|
||||||
|
|
||||||
ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),Color());
|
ERR_FAIL_INDEX_V(p_idx,conn_output_cache.size(),Color());
|
||||||
return conn_output_cache[p_idx].color;
|
return conn_output_cache[p_idx].color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphNode::_input_event(const InputEvent& p_ev) {
|
void GraphNode::_input_event(const InputEvent& p_ev) {
|
||||||
|
|
||||||
if (p_ev.type==InputEvent::MOUSE_BUTTON && p_ev.mouse_button.pressed && p_ev.mouse_button.button_index==BUTTON_LEFT) {
|
if (p_ev.type==InputEvent::MOUSE_BUTTON && 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);
|
Vector2 mpos = Vector2(p_ev.mouse_button.x,p_ev.mouse_button.y);
|
||||||
if (close_rect.size!=Size2() && close_rect.has_point(mpos)) {
|
if (close_rect.size!=Size2() && close_rect.has_point(mpos)) {
|
||||||
emit_signal("close_request");
|
emit_signal("close_request");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
emit_signal("raise_request");
|
emit_signal("raise_request");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GraphNode::_bind_methods() {
|
void GraphNode::_bind_methods() {
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("set_title","title"),&GraphNode::set_title);
|
ObjectTypeDB::bind_method(_MD("set_title","title"),&GraphNode::set_title);
|
||||||
ObjectTypeDB::bind_method(_MD("get_title"),&GraphNode::get_title);
|
ObjectTypeDB::bind_method(_MD("get_title"),&GraphNode::get_title);
|
||||||
ObjectTypeDB::bind_method(_MD("_input_event"),&GraphNode::_input_event);
|
ObjectTypeDB::bind_method(_MD("_input_event"),&GraphNode::_input_event);
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("set_slot","idx","enable_left","type_left","color_left","enable_right","type_right","color_right"),&GraphNode::set_slot);
|
ObjectTypeDB::bind_method(_MD("set_slot","idx","enable_left","type_left","color_left","enable_right","type_right","color_right"),&GraphNode::set_slot);
|
||||||
ObjectTypeDB::bind_method(_MD("clear_slot","idx"),&GraphNode::clear_slot);
|
ObjectTypeDB::bind_method(_MD("clear_slot","idx"),&GraphNode::clear_slot);
|
||||||
ObjectTypeDB::bind_method(_MD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
|
ObjectTypeDB::bind_method(_MD("clear_all_slots","idx"),&GraphNode::clear_all_slots);
|
||||||
ObjectTypeDB::bind_method(_MD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
|
ObjectTypeDB::bind_method(_MD("is_slot_enabled_left","idx"),&GraphNode::is_slot_enabled_left);
|
||||||
ObjectTypeDB::bind_method(_MD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
|
ObjectTypeDB::bind_method(_MD("get_slot_type_left","idx"),&GraphNode::get_slot_type_left);
|
||||||
ObjectTypeDB::bind_method(_MD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
|
ObjectTypeDB::bind_method(_MD("get_slot_color_left","idx"),&GraphNode::get_slot_color_left);
|
||||||
ObjectTypeDB::bind_method(_MD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
|
ObjectTypeDB::bind_method(_MD("is_slot_enabled_right","idx"),&GraphNode::is_slot_enabled_right);
|
||||||
ObjectTypeDB::bind_method(_MD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
|
ObjectTypeDB::bind_method(_MD("get_slot_type_right","idx"),&GraphNode::get_slot_type_right);
|
||||||
ObjectTypeDB::bind_method(_MD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
|
ObjectTypeDB::bind_method(_MD("get_slot_color_right","idx"),&GraphNode::get_slot_color_right);
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("set_offset","offset"),&GraphNode::set_offset);
|
ObjectTypeDB::bind_method(_MD("set_offset","offset"),&GraphNode::set_offset);
|
||||||
ObjectTypeDB::bind_method(_MD("get_offset"),&GraphNode::get_offset);
|
ObjectTypeDB::bind_method(_MD("get_offset"),&GraphNode::get_offset);
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
|
ObjectTypeDB::bind_method(_MD("get_connection_output_count"),&GraphNode::get_connection_output_count);
|
||||||
ObjectTypeDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
|
ObjectTypeDB::bind_method(_MD("get_connection_input_count"),&GraphNode::get_connection_input_count);
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
|
ObjectTypeDB::bind_method(_MD("get_connection_output_pos","idx"),&GraphNode::get_connection_output_pos);
|
||||||
ObjectTypeDB::bind_method(_MD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
|
ObjectTypeDB::bind_method(_MD("get_connection_output_type","idx"),&GraphNode::get_connection_output_type);
|
||||||
ObjectTypeDB::bind_method(_MD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
|
ObjectTypeDB::bind_method(_MD("get_connection_output_color","idx"),&GraphNode::get_connection_output_color);
|
||||||
ObjectTypeDB::bind_method(_MD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
|
ObjectTypeDB::bind_method(_MD("get_connection_input_pos","idx"),&GraphNode::get_connection_input_pos);
|
||||||
ObjectTypeDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
|
ObjectTypeDB::bind_method(_MD("get_connection_input_type","idx"),&GraphNode::get_connection_input_type);
|
||||||
ObjectTypeDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
|
ObjectTypeDB::bind_method(_MD("get_connection_input_color","idx"),&GraphNode::get_connection_input_color);
|
||||||
|
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
|
ObjectTypeDB::bind_method(_MD("set_show_close_button","show"),&GraphNode::set_show_close_button);
|
||||||
ObjectTypeDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
|
ObjectTypeDB::bind_method(_MD("is_close_button_visible"),&GraphNode::is_close_button_visible);
|
||||||
|
|
||||||
ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),_SCS("set_title"),_SCS("get_title"));
|
ADD_PROPERTY( PropertyInfo(Variant::STRING,"title"),_SCS("set_title"),_SCS("get_title"));
|
||||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_close"),_SCS("set_show_close_button"),_SCS("is_close_button_visible"));
|
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"show_close"),_SCS("set_show_close_button"),_SCS("is_close_button_visible"));
|
||||||
|
|
||||||
ADD_SIGNAL(MethodInfo("offset_changed"));
|
ADD_SIGNAL(MethodInfo("offset_changed"));
|
||||||
ADD_SIGNAL(MethodInfo("dragged",PropertyInfo(Variant::VECTOR2,"from"),PropertyInfo(Variant::VECTOR2,"to")));
|
ADD_SIGNAL(MethodInfo("dragged",PropertyInfo(Variant::VECTOR2,"from"),PropertyInfo(Variant::VECTOR2,"to")));
|
||||||
ADD_SIGNAL(MethodInfo("raise_request"));
|
ADD_SIGNAL(MethodInfo("raise_request"));
|
||||||
ADD_SIGNAL(MethodInfo("close_request"));
|
ADD_SIGNAL(MethodInfo("close_request"));
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphNode::GraphNode() {
|
GraphNode::GraphNode() {
|
||||||
show_close=false;
|
show_close=false;
|
||||||
connpos_dirty=true;
|
connpos_dirty=true;
|
||||||
}
|
}
|
||||||
|
@ -5,101 +5,101 @@
|
|||||||
|
|
||||||
class GraphNode : public Container {
|
class GraphNode : public Container {
|
||||||
|
|
||||||
OBJ_TYPE(GraphNode,Container);
|
OBJ_TYPE(GraphNode,Container);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Slot {
|
struct Slot {
|
||||||
bool enable_left;
|
bool enable_left;
|
||||||
int type_left;
|
int type_left;
|
||||||
Color color_left;
|
Color color_left;
|
||||||
bool enable_right;
|
bool enable_right;
|
||||||
int type_right;
|
int type_right;
|
||||||
Color color_right;
|
Color color_right;
|
||||||
|
|
||||||
|
|
||||||
Slot() { enable_left=false; type_left=0; color_left=Color(1,1,1,1); enable_right=false; type_right=0; color_right=Color(1,1,1,1); }
|
Slot() { enable_left=false; type_left=0; color_left=Color(1,1,1,1); enable_right=false; type_right=0; color_right=Color(1,1,1,1); }
|
||||||
};
|
};
|
||||||
|
|
||||||
String title;
|
String title;
|
||||||
bool show_close;
|
bool show_close;
|
||||||
Vector2 offset;
|
Vector2 offset;
|
||||||
|
|
||||||
Rect2 close_rect;
|
Rect2 close_rect;
|
||||||
|
|
||||||
Vector<int> cache_y;
|
Vector<int> cache_y;
|
||||||
|
|
||||||
struct ConnCache {
|
struct ConnCache {
|
||||||
Vector2 pos;
|
Vector2 pos;
|
||||||
int type;
|
int type;
|
||||||
Color color;
|
Color color;
|
||||||
};
|
};
|
||||||
|
|
||||||
Vector<ConnCache> conn_input_cache;
|
Vector<ConnCache> conn_input_cache;
|
||||||
Vector<ConnCache> conn_output_cache;
|
Vector<ConnCache> conn_output_cache;
|
||||||
|
|
||||||
Map<int,Slot> slot_info;
|
Map<int,Slot> slot_info;
|
||||||
|
|
||||||
bool connpos_dirty;
|
bool connpos_dirty;
|
||||||
|
|
||||||
void _connpos_update();
|
void _connpos_update();
|
||||||
void _resort();
|
void _resort();
|
||||||
|
|
||||||
Vector2 drag_from;
|
Vector2 drag_from;
|
||||||
bool selected;
|
bool selected;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void _input_event(const InputEvent& p_ev);
|
void _input_event(const InputEvent& p_ev);
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
bool _set(const StringName& p_name, const Variant& p_value);
|
bool _set(const StringName& p_name, const Variant& p_value);
|
||||||
bool _get(const StringName& p_name,Variant &r_ret) const;
|
bool _get(const StringName& p_name,Variant &r_ret) const;
|
||||||
void _get_property_list( List<PropertyInfo> *p_list) const;
|
void _get_property_list( List<PropertyInfo> *p_list) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void set_slot(int p_idx,bool p_enable_left,int p_type_left,const Color& p_color_left, bool p_enable_right,int p_type_right,const Color& p_color_right);
|
void set_slot(int p_idx,bool p_enable_left,int p_type_left,const Color& p_color_left, bool p_enable_right,int p_type_right,const Color& p_color_right);
|
||||||
void clear_slot(int p_idx);
|
void clear_slot(int p_idx);
|
||||||
void clear_all_slots();
|
void clear_all_slots();
|
||||||
bool is_slot_enabled_left(int p_idx) const;
|
bool is_slot_enabled_left(int p_idx) const;
|
||||||
int get_slot_type_left(int p_idx) const;
|
int get_slot_type_left(int p_idx) const;
|
||||||
Color get_slot_color_left(int p_idx) const;
|
Color get_slot_color_left(int p_idx) const;
|
||||||
bool is_slot_enabled_right(int p_idx) const;
|
bool is_slot_enabled_right(int p_idx) const;
|
||||||
int get_slot_type_right(int p_idx) const;
|
int get_slot_type_right(int p_idx) const;
|
||||||
Color get_slot_color_right(int p_idx) const;
|
Color get_slot_color_right(int p_idx) const;
|
||||||
|
|
||||||
void set_title(const String& p_title);
|
void set_title(const String& p_title);
|
||||||
String get_title() const;
|
String get_title() const;
|
||||||
|
|
||||||
void set_offset(const Vector2& p_offset);
|
void set_offset(const Vector2& p_offset);
|
||||||
Vector2 get_offset() const;
|
Vector2 get_offset() const;
|
||||||
|
|
||||||
void set_selected(bool p_selected);
|
void set_selected(bool p_selected);
|
||||||
bool is_selected();
|
bool is_selected();
|
||||||
|
|
||||||
void set_drag(bool p_drag);
|
void set_drag(bool p_drag);
|
||||||
Vector2 get_drag_from();
|
Vector2 get_drag_from();
|
||||||
|
|
||||||
void set_show_close_button(bool p_enable);
|
void set_show_close_button(bool p_enable);
|
||||||
bool is_close_button_visible() const;
|
bool is_close_button_visible() const;
|
||||||
|
|
||||||
int get_connection_input_count() ;
|
int get_connection_input_count() ;
|
||||||
int get_connection_output_count() ;
|
int get_connection_output_count() ;
|
||||||
Vector2 get_connection_input_pos(int p_idx);
|
Vector2 get_connection_input_pos(int p_idx);
|
||||||
int get_connection_input_type(int p_idx);
|
int get_connection_input_type(int p_idx);
|
||||||
Color get_connection_input_color(int p_idx);
|
Color get_connection_input_color(int p_idx);
|
||||||
Vector2 get_connection_output_pos(int p_idx);
|
Vector2 get_connection_output_pos(int p_idx);
|
||||||
int get_connection_output_type(int p_idx);
|
int get_connection_output_type(int p_idx);
|
||||||
Color get_connection_output_color(int p_idx);
|
Color get_connection_output_color(int p_idx);
|
||||||
|
|
||||||
|
|
||||||
virtual Size2 get_minimum_size() const;
|
virtual Size2 get_minimum_size() const;
|
||||||
|
|
||||||
GraphNode();
|
GraphNode();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ static TexCacheMap *tex_cache;
|
|||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, float p_right, float p_botton,float p_margin_left=-1, float p_margin_top=-1, float p_margin_right=-1, float p_margin_botton=-1, bool p_draw_center=true) {
|
static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, float p_right, float p_botton,float p_margin_left=-1, float p_margin_top=-1, float p_margin_right=-1, float p_margin_botton=-1, bool p_draw_center=true) {
|
||||||
|
|
||||||
Ref<ImageTexture> texture;
|
Ref<ImageTexture> texture;
|
||||||
|
|
||||||
|
|
||||||
@ -56,17 +56,17 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src,float p_left, float p_top, flo
|
|||||||
style->set_default_margin( MARGIN_BOTTOM, p_margin_botton );
|
style->set_default_margin( MARGIN_BOTTOM, p_margin_botton );
|
||||||
style->set_default_margin( MARGIN_TOP, p_margin_top );
|
style->set_default_margin( MARGIN_TOP, p_margin_top );
|
||||||
style->set_draw_center(p_draw_center);
|
style->set_draw_center(p_draw_center);
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
static Ref<Texture> make_icon(T p_src) {
|
static Ref<Texture> make_icon(T p_src) {
|
||||||
|
|
||||||
|
|
||||||
Ref<ImageTexture> texture( memnew( ImageTexture ) );
|
Ref<ImageTexture> texture( memnew( ImageTexture ) );
|
||||||
texture->create_from_image( Image(p_src),ImageTexture::FLAG_FILTER );
|
texture->create_from_image( Image(p_src),ImageTexture::FLAG_FILTER );
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ static Ref<Font> make_font(int p_height,int p_ascent, int p_valign, int p_charco
|
|||||||
|
|
||||||
Ref<Font> font( memnew( Font ) );
|
Ref<Font> font( memnew( Font ) );
|
||||||
font->add_texture( p_texture );
|
font->add_texture( p_texture );
|
||||||
|
|
||||||
for (int i=0;i<p_charcount;i++) {
|
for (int i=0;i<p_charcount;i++) {
|
||||||
|
|
||||||
const int *c = &p_chars[i*8];
|
const int *c = &p_chars[i*8];
|
||||||
@ -91,9 +91,9 @@ static Ref<Font> make_font(int p_height,int p_ascent, int p_valign, int p_charco
|
|||||||
|
|
||||||
|
|
||||||
font->add_char( chr, 0, frect, align,advance );
|
font->add_char( chr, 0, frect, align,advance );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
font->set_height( p_height );
|
font->set_height( p_height );
|
||||||
font->set_ascent( p_ascent );
|
font->set_ascent( p_ascent );
|
||||||
|
|
||||||
@ -152,12 +152,12 @@ static Ref<Font> make_font2(int p_height,int p_ascent, int p_charcount, const in
|
|||||||
static Ref<StyleBox> make_empty_stylebox(float p_margin_left=-1, float p_margin_top=-1, float p_margin_right=-1, float p_margin_botton=-1) {
|
static Ref<StyleBox> make_empty_stylebox(float p_margin_left=-1, float p_margin_top=-1, float p_margin_right=-1, float p_margin_botton=-1) {
|
||||||
|
|
||||||
Ref<StyleBox> style( memnew( StyleBoxEmpty) );
|
Ref<StyleBox> style( memnew( StyleBoxEmpty) );
|
||||||
|
|
||||||
style->set_default_margin( MARGIN_LEFT, p_margin_left );
|
style->set_default_margin( MARGIN_LEFT, p_margin_left );
|
||||||
style->set_default_margin( MARGIN_RIGHT, p_margin_right );
|
style->set_default_margin( MARGIN_RIGHT, p_margin_right );
|
||||||
style->set_default_margin( MARGIN_BOTTOM, p_margin_botton );
|
style->set_default_margin( MARGIN_BOTTOM, p_margin_botton );
|
||||||
style->set_default_margin( MARGIN_TOP, p_margin_top );
|
style->set_default_margin( MARGIN_TOP, p_margin_top );
|
||||||
|
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,49 +300,49 @@ void make_default_theme() {
|
|||||||
|
|
||||||
t->set_constant("hseparation","MenuButton", 0 );
|
t->set_constant("hseparation","MenuButton", 0 );
|
||||||
|
|
||||||
// CheckBox
|
// CheckBox
|
||||||
|
|
||||||
Ref<StyleBox> cbx_empty = memnew( StyleBoxEmpty );
|
Ref<StyleBox> cbx_empty = memnew( StyleBoxEmpty );
|
||||||
cbx_empty->set_default_margin(MARGIN_LEFT,22);
|
cbx_empty->set_default_margin(MARGIN_LEFT,22);
|
||||||
cbx_empty->set_default_margin(MARGIN_RIGHT,4);
|
cbx_empty->set_default_margin(MARGIN_RIGHT,4);
|
||||||
cbx_empty->set_default_margin(MARGIN_TOP,4);
|
cbx_empty->set_default_margin(MARGIN_TOP,4);
|
||||||
cbx_empty->set_default_margin(MARGIN_BOTTOM,5);
|
cbx_empty->set_default_margin(MARGIN_BOTTOM,5);
|
||||||
Ref<StyleBox> cbx_focus = focus;
|
Ref<StyleBox> cbx_focus = focus;
|
||||||
cbx_focus->set_default_margin(MARGIN_LEFT,4);
|
cbx_focus->set_default_margin(MARGIN_LEFT,4);
|
||||||
cbx_focus->set_default_margin(MARGIN_RIGHT,22);
|
cbx_focus->set_default_margin(MARGIN_RIGHT,22);
|
||||||
cbx_focus->set_default_margin(MARGIN_TOP,4);
|
cbx_focus->set_default_margin(MARGIN_TOP,4);
|
||||||
cbx_focus->set_default_margin(MARGIN_BOTTOM,5);
|
cbx_focus->set_default_margin(MARGIN_BOTTOM,5);
|
||||||
|
|
||||||
t->set_stylebox("normal","CheckBox", cbx_empty );
|
t->set_stylebox("normal","CheckBox", cbx_empty );
|
||||||
t->set_stylebox("pressed","CheckBox", cbx_empty );
|
t->set_stylebox("pressed","CheckBox", cbx_empty );
|
||||||
t->set_stylebox("disabled","CheckBox", cbx_empty );
|
t->set_stylebox("disabled","CheckBox", cbx_empty );
|
||||||
t->set_stylebox("hover","CheckBox", cbx_empty );
|
t->set_stylebox("hover","CheckBox", cbx_empty );
|
||||||
t->set_stylebox("focus","CheckBox", cbx_focus );
|
t->set_stylebox("focus","CheckBox", cbx_focus );
|
||||||
|
|
||||||
t->set_icon("checked", "CheckBox", make_icon(checked_png));
|
t->set_icon("checked", "CheckBox", make_icon(checked_png));
|
||||||
t->set_icon("unchecked", "CheckBox", make_icon(unchecked_png));
|
t->set_icon("unchecked", "CheckBox", make_icon(unchecked_png));
|
||||||
t->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png));
|
t->set_icon("radio_checked", "CheckBox", make_icon(radio_checked_png));
|
||||||
t->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png));
|
t->set_icon("radio_unchecked", "CheckBox", make_icon(radio_unchecked_png));
|
||||||
|
|
||||||
t->set_font("font","CheckBox", default_font );
|
t->set_font("font","CheckBox", default_font );
|
||||||
|
|
||||||
t->set_color("font_color","CheckBox", control_font_color );
|
t->set_color("font_color","CheckBox", control_font_color );
|
||||||
t->set_color("font_color_pressed","CheckBox", control_font_color_pressed );
|
t->set_color("font_color_pressed","CheckBox", control_font_color_pressed );
|
||||||
t->set_color("font_color_hover","CheckBox", control_font_color_hover );
|
t->set_color("font_color_hover","CheckBox", control_font_color_hover );
|
||||||
t->set_color("font_color_disabled","CheckBox", control_font_color_disabled );
|
t->set_color("font_color_disabled","CheckBox", control_font_color_disabled );
|
||||||
|
|
||||||
t->set_constant("hseparation","CheckBox",4);
|
t->set_constant("hseparation","CheckBox",4);
|
||||||
t->set_constant("check_vadjust","CheckBox",0);
|
t->set_constant("check_vadjust","CheckBox",0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// CheckButton
|
// CheckButton
|
||||||
|
|
||||||
Ref<StyleBox> cb_empty = memnew( StyleBoxEmpty );
|
Ref<StyleBox> cb_empty = memnew( StyleBoxEmpty );
|
||||||
cb_empty->set_default_margin(MARGIN_LEFT,6);
|
cb_empty->set_default_margin(MARGIN_LEFT,6);
|
||||||
cb_empty->set_default_margin(MARGIN_RIGHT,70);
|
cb_empty->set_default_margin(MARGIN_RIGHT,70);
|
||||||
cb_empty->set_default_margin(MARGIN_TOP,4);
|
cb_empty->set_default_margin(MARGIN_TOP,4);
|
||||||
cb_empty->set_default_margin(MARGIN_BOTTOM,4);
|
cb_empty->set_default_margin(MARGIN_BOTTOM,4);
|
||||||
|
|
||||||
t->set_stylebox("normal","CheckButton", cb_empty );
|
t->set_stylebox("normal","CheckButton", cb_empty );
|
||||||
t->set_stylebox("pressed","CheckButton", cb_empty );
|
t->set_stylebox("pressed","CheckButton", cb_empty );
|
||||||
@ -366,7 +366,7 @@ void make_default_theme() {
|
|||||||
|
|
||||||
|
|
||||||
// Label
|
// Label
|
||||||
|
|
||||||
t->set_font("font","Label", default_font );
|
t->set_font("font","Label", default_font );
|
||||||
|
|
||||||
t->set_color("font_color","Label", Color(1,1,1) );
|
t->set_color("font_color","Label", Color(1,1,1) );
|
||||||
@ -558,11 +558,11 @@ void make_default_theme() {
|
|||||||
// GraphNode
|
// GraphNode
|
||||||
|
|
||||||
Ref<StyleBoxTexture> graphsb = make_stylebox(graph_node_png,6,24,6,5,16,24,16,5);
|
Ref<StyleBoxTexture> graphsb = make_stylebox(graph_node_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> graphsbselected = make_stylebox(graph_node_selected_png,6,24,6,5,16,24,16,5);
|
||||||
//graphsb->set_expand_margin_size(MARGIN_LEFT,10);
|
//graphsb->set_expand_margin_size(MARGIN_LEFT,10);
|
||||||
//graphsb->set_expand_margin_size(MARGIN_RIGHT,10);
|
//graphsb->set_expand_margin_size(MARGIN_RIGHT,10);
|
||||||
t->set_stylebox("frame","GraphNode", graphsb );
|
t->set_stylebox("frame","GraphNode", graphsb );
|
||||||
t->set_stylebox("selectedframe","GraphNode", graphsbselected );
|
t->set_stylebox("selectedframe","GraphNode", graphsbselected );
|
||||||
t->set_constant("separation","GraphNode", 1 );
|
t->set_constant("separation","GraphNode", 1 );
|
||||||
t->set_icon("port","GraphNode", make_icon( graph_port_png ) );
|
t->set_icon("port","GraphNode", make_icon( graph_port_png ) );
|
||||||
t->set_icon("close","GraphNode", make_icon( graph_node_close_png ) );
|
t->set_icon("close","GraphNode", make_icon( graph_node_close_png ) );
|
||||||
@ -713,7 +713,7 @@ void make_default_theme() {
|
|||||||
|
|
||||||
|
|
||||||
// FileDialog
|
// FileDialog
|
||||||
|
|
||||||
t->set_icon("folder","FileDialog",make_icon(icon_folder_png));
|
t->set_icon("folder","FileDialog",make_icon(icon_folder_png));
|
||||||
t->set_color("files_disabled","FileDialog",Color(0,0,0,0.7));
|
t->set_color("files_disabled","FileDialog",Color(0,0,0,0.7));
|
||||||
|
|
||||||
@ -877,10 +877,10 @@ void make_default_theme() {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
void clear_default_theme() {
|
void clear_default_theme() {
|
||||||
|
|
||||||
Theme::set_default( Ref<Theme>() );
|
Theme::set_default( Ref<Theme>() );
|
||||||
Theme::set_default_icon( Ref< Texture >() );
|
Theme::set_default_icon( Ref< Texture >() );
|
||||||
Theme::set_default_style( Ref< StyleBox >() );
|
Theme::set_default_style( Ref< StyleBox >() );
|
||||||
Theme::set_default_font( Ref< Font >() );
|
Theme::set_default_font( Ref< Font >() );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -41,189 +41,189 @@
|
|||||||
#include "tools/editor/property_editor.h"
|
#include "tools/editor/property_editor.h"
|
||||||
#include "scene/resources/shader_graph.h"
|
#include "scene/resources/shader_graph.h"
|
||||||
/**
|
/**
|
||||||
@author Juan Linietsky <reduzio@gmail.com>
|
@author Juan Linietsky <reduzio@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class GraphColorRampEdit : public Control {
|
class GraphColorRampEdit : public Control {
|
||||||
|
|
||||||
OBJ_TYPE(GraphColorRampEdit,Control);
|
OBJ_TYPE(GraphColorRampEdit,Control);
|
||||||
|
|
||||||
|
|
||||||
struct Point {
|
struct Point {
|
||||||
|
|
||||||
float offset;
|
float offset;
|
||||||
Color color;
|
Color color;
|
||||||
bool operator<(const Point& p_ponit) const {
|
bool operator<(const Point& p_ponit) const {
|
||||||
return offset<p_ponit.offset;
|
return offset<p_ponit.offset;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PopupPanel *popup;
|
PopupPanel *popup;
|
||||||
ColorPicker *picker;
|
ColorPicker *picker;
|
||||||
|
|
||||||
|
|
||||||
bool grabbing;
|
bool grabbing;
|
||||||
int grabbed;
|
int grabbed;
|
||||||
float grabbed_at;
|
float grabbed_at;
|
||||||
Vector<Point> points;
|
Vector<Point> points;
|
||||||
|
|
||||||
void _color_changed(const Color& p_color);
|
void _color_changed(const Color& p_color);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _input_event(const InputEvent& p_event);
|
void _input_event(const InputEvent& p_event);
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void set_ramp(const Vector<float>& p_offsets,const Vector<Color>& p_colors);
|
void set_ramp(const Vector<float>& p_offsets,const Vector<Color>& p_colors);
|
||||||
Vector<float> get_offsets() const;
|
Vector<float> get_offsets() const;
|
||||||
Vector<Color> get_colors() const;
|
Vector<Color> get_colors() const;
|
||||||
virtual Size2 get_minimum_size() const;
|
virtual Size2 get_minimum_size() const;
|
||||||
GraphColorRampEdit();
|
GraphColorRampEdit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class GraphCurveMapEdit : public Control {
|
class GraphCurveMapEdit : public Control {
|
||||||
|
|
||||||
OBJ_TYPE(GraphCurveMapEdit,Control);
|
OBJ_TYPE(GraphCurveMapEdit,Control);
|
||||||
|
|
||||||
|
|
||||||
struct Point {
|
struct Point {
|
||||||
|
|
||||||
float offset;
|
float offset;
|
||||||
float height;
|
float height;
|
||||||
bool operator<(const Point& p_ponit) const {
|
bool operator<(const Point& p_ponit) const {
|
||||||
return offset<p_ponit.offset;
|
return offset<p_ponit.offset;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
bool grabbing;
|
bool grabbing;
|
||||||
int grabbed;
|
int grabbed;
|
||||||
Vector<Point> points;
|
Vector<Point> points;
|
||||||
|
|
||||||
void _plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector2& p_c,const Vector2& p_d);
|
void _plot_curve(const Vector2& p_a,const Vector2& p_b,const Vector2& p_c,const Vector2& p_d);
|
||||||
protected:
|
protected:
|
||||||
void _input_event(const InputEvent& p_event);
|
void _input_event(const InputEvent& p_event);
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void set_points(const Vector<Vector2>& p_points);
|
void set_points(const Vector<Vector2>& p_points);
|
||||||
Vector<Vector2> get_points() const;
|
Vector<Vector2> get_points() const;
|
||||||
virtual Size2 get_minimum_size() const;
|
virtual Size2 get_minimum_size() const;
|
||||||
GraphCurveMapEdit();
|
GraphCurveMapEdit();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShaderGraphView : public Node {
|
class ShaderGraphView : public Node {
|
||||||
|
|
||||||
OBJ_TYPE(ShaderGraphView,Node);
|
OBJ_TYPE(ShaderGraphView,Node);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CustomPropertyEditor *ped_popup;
|
CustomPropertyEditor *ped_popup;
|
||||||
bool block_update;
|
bool block_update;
|
||||||
|
|
||||||
Label *status;
|
Label *status;
|
||||||
GraphEdit *graph_edit;
|
GraphEdit *graph_edit;
|
||||||
Ref<ShaderGraph> graph;
|
Ref<ShaderGraph> graph;
|
||||||
int edited_id;
|
int edited_id;
|
||||||
|
|
||||||
ShaderGraph::ShaderType type;
|
ShaderGraph::ShaderType type;
|
||||||
|
|
||||||
void _update_graph();
|
void _update_graph();
|
||||||
void _create_node(int p_id);
|
void _create_node(int p_id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _connection_request(const String& p_from, int p_from_slot,const String& p_to,int p_to_slot);
|
void _connection_request(const String& p_from, int p_from_slot,const String& p_to,int p_to_slot);
|
||||||
void _disconnection_request(const String& p_from, int p_from_slot,const String& p_to,int p_to_slot);
|
void _disconnection_request(const String& p_from, int p_from_slot,const String& p_to,int p_to_slot);
|
||||||
|
|
||||||
void _node_removed(int p_id);
|
void _node_removed(int p_id);
|
||||||
void _begin_node_move();
|
void _begin_node_move();
|
||||||
void _node_moved(const Vector2& p_from, const Vector2& p_to,int p_id);
|
void _node_moved(const Vector2& p_from, const Vector2& p_to,int p_id);
|
||||||
void _end_node_move();
|
void _end_node_move();
|
||||||
void _move_node(int p_id,const Vector2& p_to);
|
void _move_node(int p_id,const Vector2& p_to);
|
||||||
|
|
||||||
void _scalar_const_changed(double p_value,int p_id);
|
void _scalar_const_changed(double p_value,int p_id);
|
||||||
void _vec_const_changed(double p_value, int p_id, Array p_arr);
|
void _vec_const_changed(double p_value, int p_id, Array p_arr);
|
||||||
void _rgb_const_changed(const Color& p_color, int p_id);
|
void _rgb_const_changed(const Color& p_color, int p_id);
|
||||||
void _xform_const_changed(int p_id,Node* p_button);
|
void _xform_const_changed(int p_id,Node* p_button);
|
||||||
void _scalar_op_changed(int p_op, int p_id);
|
void _scalar_op_changed(int p_op, int p_id);
|
||||||
void _vec_op_changed(int p_op, int p_id);
|
void _vec_op_changed(int p_op, int p_id);
|
||||||
void _vec_scalar_op_changed(int p_op, int p_id);
|
void _vec_scalar_op_changed(int p_op, int p_id);
|
||||||
void _rgb_op_changed(int p_op, int p_id);
|
void _rgb_op_changed(int p_op, int p_id);
|
||||||
void _xform_inv_rev_changed(bool p_enabled, int p_id);
|
void _xform_inv_rev_changed(bool p_enabled, int p_id);
|
||||||
void _scalar_func_changed(int p_func, int p_id);
|
void _scalar_func_changed(int p_func, int p_id);
|
||||||
void _vec_func_changed(int p_func, int p_id);
|
void _vec_func_changed(int p_func, int p_id);
|
||||||
void _scalar_input_changed(double p_value,int p_id);
|
void _scalar_input_changed(double p_value,int p_id);
|
||||||
void _vec_input_changed(double p_value, int p_id, Array p_arr);
|
void _vec_input_changed(double p_value, int p_id, Array p_arr);
|
||||||
void _xform_input_changed(int p_id,Node* p_button);
|
void _xform_input_changed(int p_id,Node* p_button);
|
||||||
void _rgb_input_changed(const Color& p_color, int p_id);
|
void _rgb_input_changed(const Color& p_color, int p_id);
|
||||||
void _tex_input_change(int p_id,Node* p_button);
|
void _tex_input_change(int p_id,Node* p_button);
|
||||||
void _cube_input_change(int p_id);
|
void _cube_input_change(int p_id);
|
||||||
void _input_name_changed(const String& p_name,int p_id,Node* p_line_edit);
|
void _input_name_changed(const String& p_name,int p_id,Node* p_line_edit);
|
||||||
void _tex_edited(int p_id,Node* p_button);
|
void _tex_edited(int p_id,Node* p_button);
|
||||||
void _cube_edited(int p_id,Node* p_button);
|
void _cube_edited(int p_id,Node* p_button);
|
||||||
void _variant_edited();
|
void _variant_edited();
|
||||||
void _comment_edited(int p_id,Node* p_button);
|
void _comment_edited(int p_id,Node* p_button);
|
||||||
void _color_ramp_changed(int p_id,Node* p_ramp);
|
void _color_ramp_changed(int p_id,Node* p_ramp);
|
||||||
void _curve_changed(int p_id,Node* p_curve);
|
void _curve_changed(int p_id,Node* p_curve);
|
||||||
void _sg_updated();
|
void _sg_updated();
|
||||||
Map<int,GraphNode*> node_map;
|
Map<int,GraphNode*> node_map;
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void add_node(int p_type, const Vector2 &location);
|
void add_node(int p_type, const Vector2 &location);
|
||||||
GraphEdit *get_graph_edit() { return graph_edit; }
|
GraphEdit *get_graph_edit() { return graph_edit; }
|
||||||
void set_graph(Ref<ShaderGraph> p_graph);
|
void set_graph(Ref<ShaderGraph> p_graph);
|
||||||
|
|
||||||
ShaderGraphView(ShaderGraph::ShaderType p_type=ShaderGraph::SHADER_TYPE_FRAGMENT);
|
ShaderGraphView(ShaderGraph::ShaderType p_type=ShaderGraph::SHADER_TYPE_FRAGMENT);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShaderGraphEditor : public VBoxContainer {
|
class ShaderGraphEditor : public VBoxContainer {
|
||||||
|
|
||||||
OBJ_TYPE(ShaderGraphEditor,VBoxContainer);
|
OBJ_TYPE(ShaderGraphEditor,VBoxContainer);
|
||||||
|
|
||||||
PopupMenu *popup;
|
PopupMenu *popup;
|
||||||
TabContainer *tabs;
|
TabContainer *tabs;
|
||||||
ShaderGraphView *graph_edits[ShaderGraph::SHADER_TYPE_MAX];
|
ShaderGraphView *graph_edits[ShaderGraph::SHADER_TYPE_MAX];
|
||||||
static const char* node_names[ShaderGraph::NODE_TYPE_MAX];
|
static const char* node_names[ShaderGraph::NODE_TYPE_MAX];
|
||||||
Vector2 next_location;
|
Vector2 next_location;
|
||||||
|
|
||||||
bool _2d;
|
bool _2d;
|
||||||
void _add_node(int p_type);
|
void _add_node(int p_type);
|
||||||
void _popup_requested(const Vector2 &p_position);
|
void _popup_requested(const Vector2 &p_position);
|
||||||
protected:
|
protected:
|
||||||
void _notification(int p_what);
|
void _notification(int p_what);
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void edit(Ref<ShaderGraph> p_shader);
|
void edit(Ref<ShaderGraph> p_shader);
|
||||||
ShaderGraphEditor(bool p_2d);
|
ShaderGraphEditor(bool p_2d);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ShaderGraphEditorPlugin : public EditorPlugin {
|
class ShaderGraphEditorPlugin : public EditorPlugin {
|
||||||
|
|
||||||
OBJ_TYPE( ShaderGraphEditorPlugin, EditorPlugin );
|
OBJ_TYPE( ShaderGraphEditorPlugin, EditorPlugin );
|
||||||
|
|
||||||
bool _2d;
|
bool _2d;
|
||||||
ShaderGraphEditor *shader_editor;
|
ShaderGraphEditor *shader_editor;
|
||||||
EditorNode *editor;
|
EditorNode *editor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual String get_name() const { return "ShaderGraph"; }
|
virtual String get_name() const { return "ShaderGraph"; }
|
||||||
bool has_main_screen() const { return false; }
|
bool has_main_screen() const { return false; }
|
||||||
virtual void edit(Object *p_node);
|
virtual void edit(Object *p_node);
|
||||||
virtual bool handles(Object *p_node) const;
|
virtual bool handles(Object *p_node) const;
|
||||||
virtual void make_visible(bool p_visible);
|
virtual void make_visible(bool p_visible);
|
||||||
|
|
||||||
ShaderGraphEditorPlugin(EditorNode *p_node,bool p_2d);
|
ShaderGraphEditorPlugin(EditorNode *p_node,bool p_2d);
|
||||||
~ShaderGraphEditorPlugin();
|
~ShaderGraphEditorPlugin();
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user