void ShaderEditor::_notification(int p_what) { switch(p_what) { case NOTIFICATION_DRAW: { _update_scrollbars(); //VisualServer::get_singleton()->canvas_item_add_rect(get_canvas_item(),Rect2(Point2(),get_size()),Color(0,0,0,1)); for(List<int>::Element *E=order.front();E;E=E->next()) { _draw_node(E->get()); } if (click_type==CLICK_INPUT_SLOT || click_type==CLICK_OUTPUT_SLOT) { VisualServer::get_singleton()->canvas_item_add_line(get_canvas_item(),click_pos,click_motion,Color(0.5,1,0.5,0.8),2); } List<ShaderGraph::Connection> connections = shader_graph.get_connection_list(); for(List<ShaderGraph::Connection>::Element *E=connections.front();E;E=E->next()) { const ShaderGraph::Connection &c=E->get(); Point2 source = _get_slot_pos(c.src_id,false,c.src_slot); Point2 dest = _get_slot_pos(c.dst_id,true,c.dst_slot); bool vec = VisualServer::shader_is_input_vector( shader_graph.node_get_type(c.dst_id), c.dst_slot ); Color col = vec?Color(1,0.5,0.5,0.8):Color(1,1,0.5,0.8); if (click_type==CLICK_NODE && click_node==c.src_id) { source+=click_motion-click_pos; } if (click_type==CLICK_NODE && click_node==c.dst_id) { dest+=click_motion-click_pos; } VisualServer::get_singleton()->canvas_item_add_line(get_canvas_item(),source,dest,col,2); } } break; } }
void ControlEditor::_notification(int p_what) { if (p_what==NOTIFICATION_PROCESS) { for(ControlMap::Element *E=controls.front();E;E=E->next()) { Control *control = E->key(); Rect2 r=control->get_window_rect(); if (r != E->get().last_rect ) { update(); E->get().last_rect=r; } } } if (p_what==NOTIFICATION_CHILDREN_CONFIGURED) { get_scene()->connect("node_removed",this,"_node_removed"); } if (p_what==NOTIFICATION_DRAW) { // TODO fetch the viewport? /* if (!control) { h_scroll->hide(); v_scroll->hide(); return; } */ _update_scrollbars(); if (!current_window) return; for(ControlMap::Element *E=controls.front();E;E=E->next()) { Control *control = E->key(); Rect2 rect=control->get_window_rect(); RID ci=get_canvas_item(); VisualServer::get_singleton()->canvas_item_set_clip(ci,true); Point2 ofs=Point2();//get_global_pos(); Rect2 draw_rect=Rect2(rect.pos-ofs,rect.size); draw_rect.pos = transform.xform(draw_rect.pos); Color light_edit_color=Color(1.0,0.8,0.8); Color dark_edit_color=Color(0.4,0.1,0.1); Size2 handle_size=Size2(handle_len,handle_len); #define DRAW_RECT( m_rect, m_color )\ VisualServer::get_singleton()->canvas_item_add_rect(ci,m_rect,m_color); #define DRAW_EMPTY_RECT( m_rect, m_color )\ DRAW_RECT( Rect2(m_rect.pos,Size2(m_rect.size.width,1)), m_color );\ DRAW_RECT(Rect2(Point2(m_rect.pos.x,m_rect.pos.y+m_rect.size.height-1),Size2(m_rect.size.width,1)), m_color);\ DRAW_RECT(Rect2(m_rect.pos,Size2(1,m_rect.size.height)), m_color);\ DRAW_RECT(Rect2(Point2(m_rect.pos.x+m_rect.size.width-1,m_rect.pos.y),Size2(1,m_rect.size.height)), m_color); #define DRAW_BORDER_RECT( m_rect, m_border_color,m_color )\ DRAW_RECT( m_rect, m_color );\ DRAW_EMPTY_RECT( m_rect, m_border_color ); DRAW_EMPTY_RECT( draw_rect.grow(2), light_edit_color ); DRAW_EMPTY_RECT( draw_rect.grow(1), dark_edit_color ); if (controls.size()==1) { DRAW_BORDER_RECT( Rect2(draw_rect.pos-handle_size,handle_size), light_edit_color,dark_edit_color ); DRAW_BORDER_RECT( Rect2(draw_rect.pos+draw_rect.size,handle_size), light_edit_color,dark_edit_color ); DRAW_BORDER_RECT( Rect2(draw_rect.pos+Point2(draw_rect.size.width,-handle_size.y),handle_size), light_edit_color,dark_edit_color ); DRAW_BORDER_RECT( Rect2(draw_rect.pos+Point2(-handle_size.x,draw_rect.size.height),handle_size), light_edit_color,dark_edit_color ); DRAW_BORDER_RECT( Rect2(draw_rect.pos+Point2(Math::floor((draw_rect.size.width-handle_size.x)/2.0),-handle_size.height),handle_size), light_edit_color,dark_edit_color ); DRAW_BORDER_RECT( Rect2(draw_rect.pos+Point2(-handle_size.width,Math::floor((draw_rect.size.height-handle_size.y)/2.0)),handle_size), light_edit_color,dark_edit_color ); DRAW_BORDER_RECT( Rect2(draw_rect.pos+Point2(Math::floor((draw_rect.size.width-handle_size.x)/2.0),draw_rect.size.height),handle_size), light_edit_color,dark_edit_color ); DRAW_BORDER_RECT( Rect2(draw_rect.pos+Point2(draw_rect.size.width,Math::floor((draw_rect.size.height-handle_size.y)/2.0)),handle_size), light_edit_color,dark_edit_color ); } //DRAW_EMPTY_RECT( Rect2( current_window->get_scroll()-Point2(1,1), get_size()+Size2(2,2)), Color(0.8,0.8,1.0,0.8) ); E->get().last_rect = rect; } } }
void AnimationTreeEditor::_notification(int p_what) { switch(p_what) { case NOTIFICATION_ENTER_TREE: { play_button->set_icon( get_icon("Play","EditorIcons") ); add_menu->set_icon( get_icon("Add","EditorIcons") ); } break; case NOTIFICATION_DRAW: { _update_scrollbars(); //VisualServer::get_singleton()->canvas_item_add_rect(get_canvas_item(),Rect2(Point2(),get_size()),Color(0,0,0,1)); get_stylebox("bg","Tree")->draw(get_canvas_item(),Rect2(Point2(),get_size())); VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(),true); for(List<StringName>::Element *E=order.front();E;E=E->next()) { _draw_node(E->get()); } if (click_type==CLICK_INPUT_SLOT || click_type==CLICK_OUTPUT_SLOT) { _draw_cos_line(click_pos,click_motion,Color(0.5,1,0.5,0.8)); } List<AnimationTreePlayer::Connection> connections; anim_tree->get_connection_list(&connections); for(List<AnimationTreePlayer::Connection>::Element *E=connections.front();E;E=E->next()) { const AnimationTreePlayer::Connection &c=E->get(); Point2 source = _get_slot_pos(c.src_node,false,0); Point2 dest = _get_slot_pos(c.dst_node,true,c.dst_input); Color col = Color(1,1,0.5,0.8); /* if (click_type==CLICK_NODE && click_node==c.src_node) { source+=click_motion-click_pos; } if (click_type==CLICK_NODE && click_node==c.dst_node) { dest+=click_motion-click_pos; }*/ _draw_cos_line(source,dest,col); } switch(anim_tree->get_last_error()) { case AnimationTreePlayer::CONNECT_OK: { Ref<Font> f = get_font("font","Label"); f->draw(get_canvas_item(),Point2(5,25+f->get_ascent()),"Animation Tree is Valid.",Color(0,1,0.6,0.8)); } break; default: { Ref<Font> f = get_font("font","Label"); f->draw(get_canvas_item(),Point2(5,25+f->get_ascent()),"Animation Tree is Invalid.",Color(1,0.6,0.0,0.8)); } break; } } break; } }