Esempio n. 1
0
void _draw_node(node *p, int x1, int x2, int y)
    {
    char content[2];
    if (p != NULL)
	{
	_draw_node(p->left, x1, (x1+x2)/2, y+DY);
	content[0] = *((char*)(p+1));
	content[1] = NULL;
	fillellipse((x1+x2)/2, y,
		    textheight(content)/2+5, textheight(content)/2+5);
	outtextxy((x1+x2)/2, y-3, content);
	_draw_node(p->right, (x1+x2)/2, x2, y+DY);
	}
    else
	fillellipse((x1+x2)/2, y, 3, 3);
    }
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;
	}

}
Esempio n. 3
0
void btv_draw(node *p)
    {
    int gd = DETECT, gm;
    initgraph(&gd, &gm, "c:\\tc\\bgi");
    if (graphresult() != grOk)
	{
	printf("\n Graphic system error !");
	return;
	}
    settextstyle(TRIPLEX_FONT, HORIZ_DIR, 3);
    settextjustify(CENTER_TEXT, CENTER_TEXT);
    setfillstyle(0, BLACK);
    moveto(getmaxx()/2, 10);
    _draw_link(p, 7, getmaxx()-7, 15);
    _draw_node(p, 7, getmaxx()-7, 15);
    setcolor(WHITE);
    wait_hardcopy(LPT1);
    closegraph();
    }
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;
	}

}