diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/container.cpp | 8 | ||||
-rw-r--r-- | scene/gui/control.cpp | 40 | ||||
-rw-r--r-- | scene/gui/control.h | 4 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 30 | ||||
-rw-r--r-- | scene/gui/graph_edit.h | 2 | ||||
-rw-r--r-- | scene/gui/graph_node.cpp | 51 | ||||
-rw-r--r-- | scene/gui/graph_node.h | 19 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 3 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 4 |
9 files changed, 150 insertions, 11 deletions
diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index 920c6bf1e6..feaf516f42 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -41,6 +41,8 @@ void Container::_child_minsize_changed() { void Container::add_child_notify(Node *p_child) { + Control::add_child_notify(p_child); + Control *control = p_child->cast_to<Control>(); if (!control) return; @@ -50,18 +52,24 @@ void Container::add_child_notify(Node *p_child) { control->connect("visibility_changed",this,"_child_minsize_changed"); queue_sort(); + } void Container::move_child_notify(Node *p_child) { + Control::move_child_notify(p_child); + if (!p_child->cast_to<Control>()) return; queue_sort(); + + } void Container::remove_child_notify(Node *p_child) { + Control::remove_child_notify(p_child); Control *control = p_child->cast_to<Control>(); if (!control) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index c08e10b9ff..71ec508c81 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -422,6 +422,32 @@ void Control::_resize(const Size2& p_size) { _size_changed(); } +//moved theme configuration here, so controls can set up even if still not inside active scene + +void Control::add_child_notify(Node *p_child) { + + Control *child_c=p_child->cast_to<Control>(); + if (!child_c) + return; + + if (child_c->data.theme.is_null() && data.theme_owner) { + child_c->data.theme_owner=data.theme_owner; + child_c->notification(NOTIFICATION_THEME_CHANGED); + } +} + +void Control::remove_child_notify(Node *p_child) { + + Control *child_c=p_child->cast_to<Control>(); + if (!child_c) + return; + + if (child_c->data.theme_owner && child_c->data.theme.is_null()) { + child_c->data.theme_owner=NULL; + //notification(NOTIFICATION_THEME_CHANGED); + } + +} void Control::_notification(int p_notification) { @@ -512,10 +538,10 @@ void Control::_notification(int p_notification) { } - if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) { - data.theme_owner=data.parent->data.theme_owner; - notification(NOTIFICATION_THEME_CHANGED); - } + //if (data.theme.is_null() && data.parent && data.parent->data.theme_owner) { + // data.theme_owner=data.parent->data.theme_owner; + // notification(NOTIFICATION_THEME_CHANGED); + //} } break; case NOTIFICATION_EXIT_CANVAS: { @@ -547,10 +573,10 @@ void Control::_notification(int p_notification) { data.parent=NULL; data.parent_canvas_item=NULL; - if (data.theme_owner && data.theme.is_null()) { - data.theme_owner=NULL; + //if (data.theme_owner && data.theme.is_null()) { + // data.theme_owner=NULL; //notification(NOTIFICATION_THEME_CHANGED); - } + //} } break; case NOTIFICATION_MOVED_IN_PARENT: { diff --git a/scene/gui/control.h b/scene/gui/control.h index 1337cbc4b9..b9ac53067a 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -194,12 +194,16 @@ private: void _font_changed(); + friend class Viewport; void _modal_stack_remove(); void _modal_set_prev_focus_owner(ObjectID p_prev); protected: + virtual void add_child_notify(Node *p_child); + virtual void remove_child_notify(Node *p_child); + //virtual void _window_input_event(InputEvent p_event); bool _set(const StringName& p_name, const Variant& p_value); diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index c488dd0d16..458e51b4fd 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -100,6 +100,15 @@ void GraphEdit::get_connection_list(List<Connection> *r_connections) const { *r_connections=connections; } +void GraphEdit::set_scroll_ofs(const Vector2& p_ofs) { + + setting_scroll_ofs=true; + h_scroll->set_val(p_ofs.x); + v_scroll->set_val(p_ofs.y); + _update_scroll(); + setting_scroll_ofs=false; +} + Vector2 GraphEdit::get_scroll_ofs() const{ return Vector2(h_scroll->get_val(),v_scroll->get_val()); @@ -113,6 +122,10 @@ void GraphEdit::_scroll_moved(double) { //must redraw grid update(); } + + if (!setting_scroll_ofs) {//in godot, signals on change value are avoided as a convention + emit_signal("scroll_offset_changed",get_scroll_ofs()); + } } void GraphEdit::_update_scroll_offset() { @@ -196,6 +209,8 @@ void GraphEdit::_graph_node_moved(Node *p_gn) { void GraphEdit::add_child_notify(Node *p_child) { + Control::add_child_notify(p_child); + top_layer->call_deferred("raise"); //top layer always on top! GraphNode *gn = p_child->cast_to<GraphNode>(); if (gn) { @@ -205,10 +220,14 @@ void GraphEdit::add_child_notify(Node *p_child) { _graph_node_moved(gn); gn->set_stop_mouse(false); } + + } void GraphEdit::remove_child_notify(Node *p_child) { + Control::remove_child_notify(p_child); + top_layer->call_deferred("raise"); //top layer always on top! GraphNode *gn = p_child->cast_to<GraphNode>(); if (gn) { @@ -1036,6 +1055,7 @@ void GraphEdit::_bind_methods() { ObjectTypeDB::bind_method(_MD("disconnect_node","from","from_port","to","to_port"),&GraphEdit::disconnect_node); ObjectTypeDB::bind_method(_MD("get_connection_list"),&GraphEdit::_get_connection_list); ObjectTypeDB::bind_method(_MD("get_scroll_ofs"),&GraphEdit::get_scroll_ofs); + ObjectTypeDB::bind_method(_MD("set_scroll_ofs","ofs"),&GraphEdit::set_scroll_ofs); ObjectTypeDB::bind_method(_MD("set_zoom","p_zoom"),&GraphEdit::set_zoom); ObjectTypeDB::bind_method(_MD("get_zoom"),&GraphEdit::get_zoom); @@ -1073,6 +1093,7 @@ void GraphEdit::_bind_methods() { ADD_SIGNAL(MethodInfo("delete_nodes_request")); ADD_SIGNAL(MethodInfo("_begin_node_move")); ADD_SIGNAL(MethodInfo("_end_node_move")); + ADD_SIGNAL(MethodInfo("scroll_offset_changed",PropertyInfo(Variant::VECTOR2,"ofs"))); } @@ -1103,6 +1124,13 @@ GraphEdit::GraphEdit() { box_selecting = false; dragging = false; + //set large minmax so it can scroll even if not resized yet + h_scroll->set_min(-10000); + h_scroll->set_max(10000); + + v_scroll->set_min(-10000); + v_scroll->set_max(10000); + h_scroll->connect("value_changed", this,"_scroll_moved"); v_scroll->connect("value_changed", this,"_scroll_moved"); @@ -1143,6 +1171,6 @@ GraphEdit::GraphEdit() { snap_amount->connect("value_changed",this,"_snap_value_changed"); zoom_hb->add_child(snap_amount); - + setting_scroll_ofs=false; } diff --git a/scene/gui/graph_edit.h b/scene/gui/graph_edit.h index ad20fbefce..6d35e1518f 100644 --- a/scene/gui/graph_edit.h +++ b/scene/gui/graph_edit.h @@ -107,6 +107,7 @@ private: Rect2 box_selecting_rect; List<GraphNode*> previus_selected; + bool setting_scroll_ofs; bool right_disconnects; bool updating; List<Connection> connections; @@ -188,6 +189,7 @@ public: 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); diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp index 1efc9a1ceb..66d2725ad2 100644 --- a/scene/gui/graph_node.cpp +++ b/scene/gui/graph_node.cpp @@ -189,6 +189,8 @@ void GraphNode::_notification(int p_what) { if (p_what==NOTIFICATION_DRAW) { Ref<StyleBox> sb=get_stylebox(selected ? "selectedframe" : "frame"); + sb=sb->duplicate(); + sb->call("set_modulate",modulate); Ref<Texture> port =get_icon("port"); Ref<Texture> close =get_icon("close"); int close_offset = get_constant("close_offset"); @@ -198,8 +200,25 @@ void GraphNode::_notification(int p_what) { Point2i icofs = -port->get_size()*0.5; int edgeofs=get_constant("port_offset"); icofs.y+=sb->get_margin(MARGIN_TOP); + + + draw_style_box(sb,Rect2(Point2(),get_size())); + switch(overlay) { + case OVERLAY_DISABLED: { + + } break; + case OVERLAY_BREAKPOINT: { + + draw_style_box(get_stylebox("breakpoint"),Rect2(Point2(),get_size())); + } break; + case OVERLAY_POSITION: { + draw_style_box(get_stylebox("position"),Rect2(Point2(),get_size())); + + } break; + } + int w = get_size().width-sb->get_minimum_size().x; if (show_close) @@ -590,6 +609,26 @@ void GraphNode::_input_event(const InputEvent& p_ev) { } +void GraphNode::set_modulate(const Color &p_color) { + + modulate=p_color; + update(); +} + +Color GraphNode::get_modulate() const{ + + return modulate; +} +void GraphNode::set_overlay(Overlay p_overlay) { + + overlay=p_overlay; + update(); +} + +GraphNode::Overlay GraphNode::get_overlay() const{ + + return overlay; +} void GraphNode::_bind_methods() { @@ -620,10 +659,15 @@ void GraphNode::_bind_methods() { 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("set_modulate","color"),&GraphNode::set_modulate); + ObjectTypeDB::bind_method(_MD("get_modulate"),&GraphNode::get_modulate); 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("set_overlay","overlay"),&GraphNode::set_overlay); + ObjectTypeDB::bind_method(_MD("get_overlay"),&GraphNode::get_overlay); + 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")); @@ -631,10 +675,17 @@ void GraphNode::_bind_methods() { ADD_SIGNAL(MethodInfo("dragged",PropertyInfo(Variant::VECTOR2,"from"),PropertyInfo(Variant::VECTOR2,"to"))); ADD_SIGNAL(MethodInfo("raise_request")); ADD_SIGNAL(MethodInfo("close_request")); + + BIND_CONSTANT( OVERLAY_DISABLED ); + BIND_CONSTANT( OVERLAY_BREAKPOINT ); + BIND_CONSTANT( OVERLAY_POSITION ); } GraphNode::GraphNode() { + + overlay=OVERLAY_DISABLED; show_close=false; connpos_dirty=true; set_stop_mouse(false); + modulate=Color(1,1,1,1); } diff --git a/scene/gui/graph_node.h b/scene/gui/graph_node.h index f308f30b81..e87fb15b93 100644 --- a/scene/gui/graph_node.h +++ b/scene/gui/graph_node.h @@ -34,8 +34,14 @@ class GraphNode : public Container { OBJ_TYPE(GraphNode,Container); +public: - + enum Overlay { + OVERLAY_DISABLED, + OVERLAY_BREAKPOINT, + OVERLAY_POSITION + }; +private: struct Slot { bool enable_left; @@ -77,6 +83,10 @@ class GraphNode : public Container { Vector2 drag_from; bool selected; + + Overlay overlay; + + Color modulate; protected: @@ -128,10 +138,17 @@ public: Color get_connection_output_color(int p_idx); + void set_modulate(const Color& p_color); + Color get_modulate() const; + + void set_overlay(Overlay p_overlay); + Overlay get_overlay() const; + virtual Size2 get_minimum_size() const; GraphNode(); }; +VARIANT_ENUM_CAST( GraphNode::Overlay ) #endif // GRAPH_NODE_H diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 0e0339c488..8557500488 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -400,6 +400,7 @@ void TabContainer::_child_renamed_callback() { void TabContainer::add_child_notify(Node *p_child) { + Control::add_child_notify(p_child); Control *c = p_child->cast_to<Control>(); if (!c) @@ -532,6 +533,8 @@ Control* TabContainer::get_current_tab_control() const { void TabContainer::remove_child_notify(Node *p_child) { + Control::remove_child_notify(p_child); + int tc = get_tab_count(); if (current==tc-1) { current--; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index c3bdf7c856..f0301fc250 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -438,7 +438,7 @@ public: bool is_highlight_all_occurrences_enabled() const; bool is_selection_active() const; int get_selection_from_line() const; - int get_selection_from_column() const; + int get_selection_from_column() const; int get_selection_to_line() const; int get_selection_to_column() const; String get_selection_text() const; @@ -496,7 +496,7 @@ public: String get_text_for_completion(); - virtual bool is_text_field() const; + virtual bool is_text_field() const; TextEdit(); ~TextEdit(); }; |