示例#1
0
void Node2D::edit_set_rect(const Rect2& p_edit_rect) {

	Rect2 r = get_item_rect();

	Vector2 zero_offset;
	if (r.size.x!=0)
		zero_offset.x = -r.pos.x / r.size.x;
	if (r.size.y!=0)
		zero_offset.y = -r.pos.y / r.size.y;

	Size2 new_scale(1,1);

	if (r.size.x!=0)
		new_scale.x = p_edit_rect.size.x / r.size.x;
	if (r.size.y!=0)
		new_scale.y = p_edit_rect.size.y / r.size.y;

	Point2 new_pos = p_edit_rect.pos + p_edit_rect.size*zero_offset;//p_edit_rect.pos - r.pos;

	Matrix32 postxf;
	postxf.set_rotation_and_scale(angle,_scale);
	new_pos = postxf.xform(new_pos);

	pos+=new_pos;
	_scale*=new_scale;

	_update_transform();
	_change_notify("transform/scale");
	_change_notify("transform/pos");

}
示例#2
0
void DiagramWindow::change_zoom(int n) {
  int z = sb_zoom->value() + n;
  
  new_scale((z > 200) 
	    ? 200 
	    : ((z < 30) ? 30 : z));
}
示例#3
0
文件: node_2d.cpp 项目: 93i/godot
void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) {
	ERR_FAIL_COND(!_edit_use_rect());

	Rect2 r = _edit_get_rect();

	Vector2 zero_offset;
	if (r.size.x != 0)
		zero_offset.x = -r.position.x / r.size.x;
	if (r.size.y != 0)
		zero_offset.y = -r.position.y / r.size.y;

	Size2 new_scale(1, 1);

	if (r.size.x != 0)
		new_scale.x = p_edit_rect.size.x / r.size.x;
	if (r.size.y != 0)
		new_scale.y = p_edit_rect.size.y / r.size.y;

	Point2 new_pos = p_edit_rect.position + p_edit_rect.size * zero_offset;

	Transform2D postxf;
	postxf.set_rotation_and_scale(angle, _scale);
	new_pos = postxf.xform(new_pos);

	pos += new_pos;
	_scale *= new_scale;

	_update_transform();
	_change_notify("scale");
	_change_notify("position");
}
示例#4
0
void DiagramWindow::read_session(char * & st) {






  unsigned w = read_unsigned(st);
	
  resize(w, read_unsigned(st));

  new_scale(read_unsigned(st));
  get_view()->read_session(st);
}