GraphEdit::GraphEdit() { set_focus_mode(FOCUS_ALL); top_layer=NULL; top_layer=memnew(GraphEditFilter(this)); add_child(top_layer); top_layer->set_stop_mouse(false); top_layer->set_area_as_parent_rect(); top_layer->connect("draw",this,"_top_layer_draw"); top_layer->set_stop_mouse(false); top_layer->connect("input_event",this,"_top_layer_input"); h_scroll = memnew(HScrollBar); h_scroll->set_name("_h_scroll"); top_layer->add_child(h_scroll); v_scroll = memnew(VScrollBar); v_scroll->set_name("_v_scroll"); top_layer->add_child(v_scroll); updating=false; connecting=false; right_disconnects=false; box_selecting = false; dragging = false; h_scroll->connect("value_changed", this,"_scroll_moved"); v_scroll->connect("value_changed", this,"_scroll_moved"); }
GraphEdit::GraphEdit() { set_focus_mode(FOCUS_ALL); awaiting_scroll_offset_update = false; top_layer = NULL; top_layer = memnew(GraphEditFilter(this)); add_child(top_layer); top_layer->set_mouse_filter(MOUSE_FILTER_PASS); top_layer->set_anchors_and_margins_preset(Control::PRESET_WIDE); top_layer->connect("draw", this, "_top_layer_draw"); top_layer->set_mouse_filter(MOUSE_FILTER_PASS); top_layer->connect("gui_input", this, "_top_layer_input"); connections_layer = memnew(Control); add_child(connections_layer); connections_layer->connect("draw", this, "_connections_layer_draw"); connections_layer->set_name("CLAYER"); connections_layer->set_disable_visibility_clip(true); // so it can draw freely and be offset connections_layer->set_mouse_filter(MOUSE_FILTER_IGNORE); h_scroll = memnew(HScrollBar); h_scroll->set_name("_h_scroll"); top_layer->add_child(h_scroll); v_scroll = memnew(VScrollBar); v_scroll->set_name("_v_scroll"); top_layer->add_child(v_scroll); updating = false; connecting = false; right_disconnects = false; 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"); zoom = 1; zoom_hb = memnew(HBoxContainer); top_layer->add_child(zoom_hb); zoom_hb->set_position(Vector2(10, 10)); zoom_minus = memnew(ToolButton); zoom_hb->add_child(zoom_minus); zoom_minus->set_tooltip(RTR("Zoom Out")); zoom_minus->connect("pressed", this, "_zoom_minus"); zoom_minus->set_focus_mode(FOCUS_NONE); zoom_reset = memnew(ToolButton); zoom_hb->add_child(zoom_reset); zoom_reset->set_tooltip(RTR("Zoom Reset")); zoom_reset->connect("pressed", this, "_zoom_reset"); zoom_reset->set_focus_mode(FOCUS_NONE); zoom_plus = memnew(ToolButton); zoom_hb->add_child(zoom_plus); zoom_plus->set_tooltip(RTR("Zoom In")); zoom_plus->connect("pressed", this, "_zoom_plus"); zoom_plus->set_focus_mode(FOCUS_NONE); snap_button = memnew(ToolButton); snap_button->set_toggle_mode(true); snap_button->set_tooltip(RTR("Enable snap and show grid.")); snap_button->connect("pressed", this, "_snap_toggled"); snap_button->set_pressed(true); snap_button->set_focus_mode(FOCUS_NONE); zoom_hb->add_child(snap_button); snap_amount = memnew(SpinBox); snap_amount->set_min(5); snap_amount->set_max(100); snap_amount->set_step(1); snap_amount->set_value(20); snap_amount->connect("value_changed", this, "_snap_value_changed"); zoom_hb->add_child(snap_amount); setting_scroll_ofs = false; just_disconnected = false; set_clip_contents(true); }