• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Point2函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Point2函数的典型用法代码示例。如果您正苦于以下问题:C++ Point2函数的具体用法?C++ Point2怎么用?C++ Point2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Point2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: get_stylebox

void GraphNode::_notification(int p_what) {

	if (p_what==NOTIFICATION_DRAW) {

		Ref<StyleBox> sb;

		if (comment) {
			sb = get_stylebox( selected? "commentfocus" : "comment");

		} else {

			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");
		Ref<Texture> resizer =get_icon("resizer");
		int close_offset = get_constant("close_offset");
		Ref<Font> title_font = get_font("title_font");
		int title_offset = get_constant("title_offset");
		Color title_color = get_color("title_color");
		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)
			w-=close->get_width();

		draw_string(title_font,Point2(sb->get_margin(MARGIN_LEFT),-title_font->get_height()+title_font->get_ascent()+title_offset),title,title_color,w);
		if (show_close) {
			Vector2 cpos = Point2(w+sb->get_margin(MARGIN_LEFT),-close->get_height()+close_offset);
			draw_texture(close,cpos);
			close_rect.pos=cpos;
			close_rect.size=close->get_size();
		} else {
			close_rect=Rect2();
		}

		for (Map<int,Slot>::Element *E=slot_info.front();E;E=E->next()) {

			if (E->key() < 0 || E->key()>=cache_y.size())
				continue;
			if (!slot_info.has(E->key()))
				continue;
			const Slot &s=slot_info[E->key()];
			//left
			if (s.enable_left) {
				Ref<Texture> p = port;
				if (s.custom_slot_left.is_valid()) {
					p=s.custom_slot_left;
				}
				p->draw(get_canvas_item(),icofs+Point2(edgeofs,cache_y[E->key()]),s.color_left);
			}
			if (s.enable_right) {
				Ref<Texture> p = port;
				if (s.custom_slot_right.is_valid()) {
					p=s.custom_slot_right;
				}
				p->draw(get_canvas_item(),icofs+Point2(get_size().x-edgeofs,cache_y[E->key()]),s.color_right);
			}

		}


		if (resizeable) {
			draw_texture(resizer,get_size()-resizer->get_size());
		}
	}

	if (p_what==NOTIFICATION_SORT_CHILDREN) {

		_resort();
	}

}
开发者ID:lordadamson,项目名称:godot,代码行数:97,代码来源:graph_node.cpp


示例2: Point2

Point2 SFAsset::GetPosition() {
  return Point2(bbox->centre->getX(), bbox->centre->getY());
}
开发者ID:Wolfkhan66,项目名称:starship-,代码行数:3,代码来源:SFAsset.cpp


示例3: _get_current_shape_type

void CollisionShape2DEditor::_canvas_draw() {

	if (!node) {
		return;
	}

	if (!node->get_shape().is_valid()) {
		return;
	}

	_get_current_shape_type();

	if (shape_type == -1) {
		return;
	}

	Control *c = canvas_item_editor->get_viewport_control();
	Matrix32 gt = canvas_item_editor->get_canvas_transform() * node->get_global_transform();

	Ref<Texture> h = get_icon("EditorHandle","EditorIcons");
	Vector2 size = h->get_size()*0.5;

	handles.clear();

	switch (shape_type) {
		case CAPSULE_SHAPE: {
			Ref<CapsuleShape2D> shape = node->get_shape();

			handles.resize(2);
			float radius = shape->get_radius();
			float height = shape->get_height()/2;

			handles[0] = Point2(radius, -height);
			handles[1] = Point2(0,-(height + radius));

			c->draw_texture(h, gt.xform(handles[0])-size);
			c->draw_texture(h, gt.xform(handles[1])-size);

		} break;

		case CIRCLE_SHAPE: {
			Ref<CircleShape2D> shape = node->get_shape();

			handles.resize(1);
			handles[0] = Point2(shape->get_radius(),0);

			c->draw_texture(h, gt.xform(handles[0])-size);

		} break;

		case CONCAVE_POLYGON_SHAPE: {

		} break;

		case CONVEX_POLYGON_SHAPE: {

		} break;

		case LINE_SHAPE: {
			Ref<LineShape2D> shape = node->get_shape();
			
			handles.resize(2);
			handles[0] = shape->get_normal() * shape->get_d();
			handles[1] = shape->get_normal() * (shape->get_d() + 30.0);
			
			c->draw_texture(h,gt.xform(handles[0])-size);
			c->draw_texture(h,gt.xform(handles[1])-size);

		} break;

		case RAY_SHAPE: {
			Ref<RayShape2D> shape = node->get_shape();

			handles.resize(1);
			handles[0] = Point2(0,shape->get_length());

			c->draw_texture(h,gt.xform(handles[0])-size);

		} break;

		case RECTANGLE_SHAPE: {
			Ref<RectangleShape2D> shape = node->get_shape();

			handles.resize(2);
			Vector2 ext = shape->get_extents();
			handles[0] = Point2(ext.x,0);
			handles[1] = Point2(0,-ext.y);

			c->draw_texture(h,gt.xform(handles[0])-size);
			c->draw_texture(h,gt.xform(handles[1])-size);

		} break;

		case SEGMENT_SHAPE: {
			Ref<SegmentShape2D> shape = node->get_shape();

			handles.resize(2);
			handles[0] = shape->get_a();
			handles[1] = shape->get_b();

//.........这里部分代码省略.........
开发者ID:AwsomeGameEngine,项目名称:godot,代码行数:101,代码来源:collision_shape_2d_editor_plugin.cpp


示例4: orig_cursor

void FindReplaceDialog::_replace() {

	text_edit->begin_complex_operation();
	if (is_replace_all_mode()) {

		//line as x so it gets priority in comparison, column as y
		Point2i orig_cursor(text_edit->cursor_get_line(), text_edit->cursor_get_column());
		Point2i prev_match = Point2(-1, -1);

		bool selection_enabled = text_edit->is_selection_active();
		Point2i selection_begin, selection_end;
		if (selection_enabled) {
			selection_begin = Point2i(text_edit->get_selection_from_line(), text_edit->get_selection_from_column());
			selection_end = Point2i(text_edit->get_selection_to_line(), text_edit->get_selection_to_column());
		}
		int vsval = text_edit->get_v_scroll();
		//int hsval = text_edit->get_h_scroll();

		text_edit->cursor_set_line(0);
		text_edit->cursor_set_column(0);

		int rc = 0;

		while (_search()) {

			if (!text_edit->is_selection_active()) {
				//search selects
				break;
			}

			//replace area
			Point2i match_from(text_edit->get_selection_from_line(), text_edit->get_selection_from_column());
			Point2i match_to(text_edit->get_selection_to_line(), text_edit->get_selection_to_column());

			if (match_from < prev_match)
				break; //done

			prev_match = match_to;

			if (selection_enabled && is_replace_selection_only()) {

				if (match_from < selection_begin || match_to > selection_end)
					continue;

				//replace but adjust selection bounds

				text_edit->insert_text_at_cursor(get_replace_text());
				if (match_to.x == selection_end.x)
					selection_end.y += get_replace_text().length() - get_search_text().length();
			} else {
				//just replace
				text_edit->insert_text_at_cursor(get_replace_text());
			}
			rc++;
		}
		//restore editor state (selection, cursor, scroll)
		text_edit->cursor_set_line(orig_cursor.x);
		text_edit->cursor_set_column(orig_cursor.y);

		if (selection_enabled && is_replace_selection_only()) {
			//reselect
			text_edit->select(selection_begin.x, selection_begin.y, selection_end.x, selection_end.y);
		} else {
			text_edit->deselect();
		}

		text_edit->set_v_scroll(vsval);
		//text_edit->set_h_scroll(hsval);
		error_label->set_text(vformat(TTR("Replaced %d occurrence(s)."), rc));

		//hide();
	} else {

		if (text_edit->get_selection_text() == get_search_text()) {

			text_edit->insert_text_at_cursor(get_replace_text());
		}

		_search();
	}
	text_edit->end_complex_operation();
}
开发者ID:jejung,项目名称:godot,代码行数:82,代码来源:code_editor.cpp


示例5: pRec

void ParticleTracer::process(const WorkUnit *workUnit, WorkResult *workResult,
		const bool &stop) {
	const RangeWorkUnit *range = static_cast<const RangeWorkUnit *>(workUnit);
	MediumSamplingRecord mRec;
	Intersection its;
	ref<Sensor> sensor    = m_scene->getSensor();
	bool needsTimeSample  = sensor->needsTimeSample();
	PositionSamplingRecord pRec(sensor->getShutterOpen()
		+ 0.5f * sensor->getShutterOpenTime());
	Ray ray;

	m_sampler->generate(Point2i(0));

	for (size_t index = range->getRangeStart(); index <= range->getRangeEnd() && !stop; ++index) {
		m_sampler->setSampleIndex(index);

		/* Sample an emission */
		if (needsTimeSample)
			pRec.time = sensor->sampleTime(m_sampler->next1D());

		const Emitter *emitter = NULL;
		const Medium *medium;

		Spectrum power;
		Ray ray;

		if (m_emissionEvents) {
			/* Sample the position and direction component separately to
			   generate emission events */
			power = m_scene->sampleEmitterPosition(pRec, m_sampler->next2D());
			emitter = static_cast<const Emitter *>(pRec.object);
			medium = emitter->getMedium();

			/* Forward the sampling event to the attached handler */
			handleEmission(pRec, medium, power);

			DirectionSamplingRecord dRec;
			power *= emitter->sampleDirection(dRec, pRec,
					emitter->needsDirectionSample() ? m_sampler->next2D() : Point2(0.5f));
			ray.setTime(pRec.time);
			ray.setOrigin(pRec.p);
			ray.setDirection(dRec.d);
		} else {
			/* Sample both components together, which is potentially
			   faster / uses a better sampling strategy */

			power = m_scene->sampleEmitterRay(ray, emitter,
				m_sampler->next2D(), m_sampler->next2D(), pRec.time);
			medium = emitter->getMedium();
			handleNewParticle();
		}

		int depth = 1, nullInteractions = 0;
		bool delta = false;

		Spectrum throughput(1.0f); // unitless path throughput (used for russian roulette)
		while (!throughput.isZero() && (depth <= m_maxDepth || m_maxDepth < 0)) {
			m_scene->rayIntersectAll(ray, its);

            /* ==================================================================== */
            /*                 Radiative Transfer Equation sampling                 */
            /* ==================================================================== */
			if (medium && medium->sampleDistance(Ray(ray, 0, its.t), mRec, m_sampler)) {
				/* Sample the integral
				  \int_x^y tau(x, x') [ \sigma_s \int_{S^2} \rho(\omega,\omega') L(x,\omega') d\omega' ] dx'
				*/

				throughput *= mRec.sigmaS * mRec.transmittance / mRec.pdfSuccess;

				/* Forward the medium scattering event to the attached handler */
				handleMediumInteraction(depth, nullInteractions,
						delta, mRec, medium, -ray.d, throughput*power);

				PhaseFunctionSamplingRecord pRec(mRec, -ray.d, EImportance);

				throughput *= medium->getPhaseFunction()->sample(pRec, m_sampler);
				delta = false;

				ray = Ray(mRec.p, pRec.wo, ray.time);
				ray.mint = 0;
			} else if (its.t == std::numeric_limits<Float>::infinity()) {
				/* There is no surface in this direction */
				break;
			} else {
				/* Sample
					tau(x, y) (Surface integral). This happens with probability mRec.pdfFailure
					Account for this and multiply by the proper per-color-channel transmittance.
				*/
				if (medium)
					throughput *= mRec.transmittance / mRec.pdfFailure;

				const BSDF *bsdf = its.getBSDF();

				/* Forward the surface scattering event to the attached handler */
				handleSurfaceInteraction(depth, nullInteractions, delta, its, medium, throughput*power);

				BSDFSamplingRecord bRec(its, m_sampler, EImportance);
				Spectrum bsdfWeight = bsdf->sample(bRec, m_sampler->next2D());
				if (bsdfWeight.isZero())
					break;
//.........这里部分代码省略.........
开发者ID:blckshrk,项目名称:IFT6042,代码行数:101,代码来源:particleproc.cpp


示例6: Point2

	Point2 operator-(const Point2 & p, const Vector2 & v)
	{
		return Point2(p.x - v.dx,p.y - v.dy);
	}
开发者ID:pwag42,项目名称:cs4300,代码行数:4,代码来源:pwGeometryOperators.cpp


示例7: benchmark_test_with_internal_configuration

test_report benchmark_test_with_internal_configuration(std::string test_casename, const std::string function_name, int flag, int nVar){
	std::ofstream report_file("tests_report_file.txt", std::ios::app);
	time_t start_time; time (&start_time);

	std::cout << "test case: " << test_casename << " starts with internal configuration" << std::endl;


	general_configuration internal_configuration_old("no_filename",
			10, //1 - diversify
			5, //2 - intensify
			15, //3 - reduce
			0.00, //4 - SS
			0.5, //5 - SSRF
			1, //6 - save step
			3, //7 - sampling
			nVar, //8 - nVar
			2, //9 - nObj
			0, //10 loop limit
			3000, //11 evaluations limit
			0, //12 Improvements limit , number of consecutive improvements
			4, //13 - number of regions
			6, //14 - STM size
			"HV", // 15
			"full", //16
			-0.05, //17 - starting point
			200, //18
			300); //19

	general_configuration internal_configuration("configuration.txt");

	ObjFunction2 test_reference_point=ObjFunction2(2, 22.0);
	ObjFunction2 test_penalty_point=ObjFunction2(2,33333.0);

	Point2 test_lower_bound=Point2(nVar,0.0);
	test_lower_bound[0]=5.0;
	test_lower_bound[1]=1.0;
	test_lower_bound[2]=11.0;

	Point2 test_upper_bound=Point2(nVar,1.0);
	test_upper_bound[0]=11.0;
	test_upper_bound[1]=200.0;
	test_upper_bound[2]=29.0;


	Point2 test_starting_point=Point2(nVar,0.5);
	test_starting_point[0]=7.0;
	test_starting_point[1]=100.0;
	test_starting_point[2]=24.5;

	Point2 test_current_step=Point2(nVar,0.05);
	test_current_step[0]=0.1666666;
	test_current_step[1]=0.050251256;
	test_current_step[2]=0.055555556;

	Overall_Optimisation_Configuration_Settings myConf2(test_casename,
			internal_configuration,
			test_reference_point,
			test_penalty_point,
			test_lower_bound,
			test_upper_bound,
			test_starting_point,
			test_current_step);

	const unsigned int n_of_variables=myConf2.getExternalConfigurationFile().getVar();
	const unsigned int n_of_objectives=myConf2.getExternalConfigurationFile().getObj();

	objective_function_formulae obj_function(n_of_objectives);

	ObjectiveFunctionBasic<double> TS_ObjFunc(myConf2, obj_function);

	Container2 MTM(n_of_variables, n_of_objectives, "MTM","./memories");
	Container2 IM(n_of_variables, n_of_objectives, "IM","./memories");
	Container2 HISTORY(n_of_variables, n_of_objectives, "HISTORY","./memories");

	STM_Container2 STM(myConf2.getExternalConfigurationFile().getStmSize(), n_of_variables, "STM", "./memories");
	LTM_Container2Basic2<double> LTM( n_of_variables ,  myConf2.getExternalConfigurationFile().getRegions(), myConf2.get_lower_bound(), myConf2.get_upper_bound(),"LTM", "./memories");
	std::cout << "Memories done!" << std::endl;

	TabuSearch TS(myConf2, flag, TS_ObjFunc, MTM, IM, HISTORY, STM, LTM);

	double hyper_volume_indicator=TS.search2();

	time_t end; time (&end);
	double dif = difftime (end,start_time);
	std::cout << "end in " << dif<< "seconds" << std::endl;
	report_file << test_casename << "\t" << n_of_variables << "\t" << dif << " seconds " << __DATE__ << "\t" << __TIME__  << std::endl;
	report_file.close();

	return test_report(myConf2.getCaseName(), TS.getDatumPnt(), hyper_volume_indicator) ;
}
开发者ID:christos-tsotskas,项目名称:MOTS2,代码行数:90,代码来源:test_suite.cpp


示例8: Point2

Point2 OSBB10::get_mouse_pos() const {

	return Point2();
}
开发者ID:baekdahl,项目名称:godot,代码行数:4,代码来源:os_bb10.cpp


示例9: screen_event_get_event

void OSBB10::handle_screen_event(bps_event_t *event) {

	screen_event_t screen_event = screen_event_get_event(event);

	int screen_val;
	screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val);

	int pos[2];

	switch (screen_val) {
	case SCREEN_EVENT_MTOUCH_TOUCH:
	case SCREEN_EVENT_MTOUCH_RELEASE: {

		screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_POSITION, pos);

		InputEvent ievent;
		ievent.type = InputEvent::SCREEN_TOUCH;
		ievent.ID = ++last_id;
		ievent.device = 0;
		ievent.screen_touch.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH);
		ievent.screen_touch.x = pos[0];
		ievent.screen_touch.y = pos[1];
		Point2 mpos(ievent.screen_touch.x, ievent.screen_touch.y);

		screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &pos[0]);
		ievent.screen_touch.index = pos[0];

		last_touch_x[pos[0]] = ievent.screen_touch.x;
		last_touch_y[pos[0]] = ievent.screen_touch.y;

		input->parse_input_event( ievent );

		if (ievent.screen_touch.index == 0) {

			InputEvent ievent;
			ievent.type = InputEvent::MOUSE_BUTTON;
			ievent.ID = ++last_id;
			ievent.device = 0;
			ievent.mouse_button.pressed = (screen_val == SCREEN_EVENT_MTOUCH_TOUCH);
			ievent.mouse_button.button_index = BUTTON_LEFT;
			ievent.mouse_button.doubleclick = 0;
			ievent.mouse_button.x = ievent.mouse_button.global_x = mpos.x;
			ievent.mouse_button.y = ievent.mouse_button.global_y = mpos.y;
			input->parse_input_event( ievent );
		};


	} break;
	case SCREEN_EVENT_MTOUCH_MOVE: {

		screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_POSITION, pos);

		InputEvent ievent;
		ievent.type = InputEvent::SCREEN_DRAG;
		ievent.ID = ++last_id;
		ievent.device = 0;
		ievent.screen_drag.x = pos[0];
		ievent.screen_drag.y = pos[1];

		/*
		screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_SOURCE_POSITION, pos);
		ievent.screen_drag.relative_x = ievent.screen_drag.x - pos[0];
		ievent.screen_drag.relative_y = ievent.screen_drag.y - pos[1];
		*/

		screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TOUCH_ID, &pos[0]);
		ievent.screen_drag.index = pos[0];


		ievent.screen_drag.relative_x = ievent.screen_drag.x - last_touch_x[ievent.screen_drag.index];
		ievent.screen_drag.relative_y = ievent.screen_drag.y - last_touch_y[ievent.screen_drag.index];

		last_touch_x[ievent.screen_drag.index] = ievent.screen_drag.x;
		last_touch_y[ievent.screen_drag.index] = ievent.screen_drag.y;

		Point2 mpos(ievent.screen_drag.x, ievent.screen_drag.y);
		Point2 mrel(ievent.screen_drag.relative_x, ievent.screen_drag.relative_y);

		input->parse_input_event( ievent );

		if (ievent.screen_touch.index == 0) {

			InputEvent ievent;
			ievent.type = InputEvent::MOUSE_MOTION;
			ievent.ID = ++last_id;
			ievent.device = 0;
			ievent.mouse_motion.x = ievent.mouse_motion.global_x = mpos.x;
			ievent.mouse_motion.y = ievent.mouse_motion.global_y = mpos.y;
			input->set_mouse_pos(Point2(ievent.mouse_motion.x,ievent.mouse_motion.y));
			ievent.mouse_motion.speed_x=input->get_last_mouse_speed().x;
			ievent.mouse_motion.speed_y=input->get_last_mouse_speed().y;
			ievent.mouse_motion.relative_x = mrel.x;
			ievent.mouse_motion.relative_y = mrel.y;
			ievent.mouse_motion.button_mask = 1; // pressed

			input->parse_input_event( ievent );
		};
	} break;

	case SCREEN_EVENT_KEYBOARD: {
//.........这里部分代码省略.........
开发者ID:baekdahl,项目名称:godot,代码行数:101,代码来源:os_bb10.cpp


示例10: emit_signal


//.........这里部分代码省略.........

		if (b->is_pressed())
			return;

		int button_idx = b->get_button_index();
		switch (button_idx) {

			case BUTTON_WHEEL_DOWN: {

				if (get_global_position().y + get_size().y > get_viewport_rect().size.y) {
					_scroll(-b->get_factor(), b->get_position());
				}
			} break;
			case BUTTON_WHEEL_UP: {

				if (get_global_position().y < 0) {
					_scroll(b->get_factor(), b->get_position());
				}
			} break;
			default: {
				// Allow activating item by releasing the LMB or any that was down when the popup appeared
				if (button_idx == BUTTON_LEFT || (initial_button_mask & (1 << (button_idx - 1)))) {

					bool was_during_grabbed_click = during_grabbed_click;
					during_grabbed_click = false;

					int over = _get_mouse_over(b->get_position());

					if (invalidated_click) {
						invalidated_click = false;
						break;
					}
					if (over < 0) {
						if (!was_during_grabbed_click) {
							hide();
						}
						break; //non-activable
					}

					if (items[over].separator || items[over].disabled)
						break;

					if (items[over].submenu != "") {

						_activate_submenu(over);
						return;
					}
					activate_item(over);
				}
			}
		}

		//update();
	}

	Ref<InputEventMouseMotion> m = p_event;

	if (m.is_valid()) {

		if (invalidated_click) {
			moved += m->get_relative();
			if (moved.length() > 4)
				invalidated_click = false;
		}

		for (List<Rect2>::Element *E = autohide_areas.front(); E; E = E->next()) {

			if (!Rect2(Point2(), get_size()).has_point(m->get_position()) && E->get().has_point(m->get_position())) {
				call_deferred("hide");
				return;
			}
		}

		int over = _get_mouse_over(m->get_position());
		int id = (over < 0 || items[over].separator || items[over].disabled) ? -1 : (items[over].ID >= 0 ? items[over].ID : over);

		if (id < 0) {
			mouse_over = -1;
			update();
			return;
		}

		if (items[over].submenu != "" && submenu_over != over) {
			submenu_over = over;
			submenu_timer->start();
		}

		if (over != mouse_over) {
			mouse_over = over;
			update();
		}
	}

	Ref<InputEventPanGesture> pan_gesture = p_event;
	if (pan_gesture.is_valid()) {
		if (get_global_position().y + get_size().y > get_viewport_rect().size.y || get_global_position().y < 0) {
			_scroll(-pan_gesture->get_delta().y, pan_gesture->get_position());
		}
	}
}
开发者ID:kubecz3k,项目名称:godot,代码行数:101,代码来源:popup_menu.cpp


示例11: switch

void PopupMenu::_notification(int p_what) {

	switch (p_what) {

		case NOTIFICATION_TRANSLATION_CHANGED: {

			for (int i = 0; i < items.size(); i++) {
				items[i].xl_text = tr(items[i].text);
			}

			minimum_size_changed();
			update();

		} break;
		case NOTIFICATION_DRAW: {

			RID ci = get_canvas_item();
			Size2 size = get_size();

			Ref<StyleBox> style = get_stylebox("panel");
			Ref<StyleBox> hover = get_stylebox("hover");
			Ref<Font> font = get_font("font");
			// In Item::checkable_type enum order (less the non-checkable member)
			Ref<Texture> check[] = { get_icon("checked"), get_icon("radio_checked") };
			Ref<Texture> uncheck[] = { get_icon("unchecked"), get_icon("radio_unchecked") };
			Ref<Texture> submenu = get_icon("submenu");
			Ref<StyleBox> separator = get_stylebox("separator");

			style->draw(ci, Rect2(Point2(), get_size()));
			Point2 ofs = style->get_offset();
			int vseparation = get_constant("vseparation");
			int hseparation = get_constant("hseparation");
			Color font_color = get_color("font_color");
			Color font_color_disabled = get_color("font_color_disabled");
			Color font_color_accel = get_color("font_color_accel");
			Color font_color_hover = get_color("font_color_hover");
			float font_h = font->get_height();

			for (int i = 0; i < items.size(); i++) {

				if (i > 0)
					ofs.y += vseparation;
				Point2 item_ofs = ofs;
				float h;
				Size2 icon_size;

				item_ofs.x += items[i].h_ofs;
				if (!items[i].icon.is_null()) {

					icon_size = items[i].icon->get_size();
					h = MAX(icon_size.height, font_h);
				} else {

					h = font_h;
				}

				if (i == mouse_over) {

					hover->draw(ci, Rect2(item_ofs + Point2(-hseparation, -vseparation / 2), Size2(get_size().width - style->get_minimum_size().width + hseparation * 2, h + vseparation)));
				}

				if (items[i].separator) {

					int sep_h = separator->get_center_size().height + separator->get_minimum_size().height;
					separator->draw(ci, Rect2(item_ofs + Point2(0, Math::floor((h - sep_h) / 2.0)), Size2(get_size().width - style->get_minimum_size().width, sep_h)));
				}

				if (items[i].checkable_type) {
					Texture *icon = (items[i].checked ? check[items[i].checkable_type - 1] : uncheck[items[i].checkable_type - 1]).ptr();
					icon->draw(ci, item_ofs + Point2(0, Math::floor((h - icon->get_height()) / 2.0)));
					item_ofs.x += icon->get_width() + hseparation;
				}

				if (!items[i].icon.is_null()) {
					items[i].icon->draw(ci, item_ofs + Point2(0, Math::floor((h - icon_size.height) / 2.0)));
					item_ofs.x += items[i].icon->get_width();
					item_ofs.x += hseparation;
				}

				if (items[i].submenu != "") {
					submenu->draw(ci, Point2(size.width - style->get_margin(MARGIN_RIGHT) - submenu->get_width(), item_ofs.y + Math::floor(h - submenu->get_height()) / 2));
				}

				item_ofs.y += font->get_ascent();
				String text = items[i].shortcut.is_valid() ? String(tr(items[i].shortcut->get_name())) : items[i].xl_text;
				if (!items[i].separator) {

					font->draw(ci, item_ofs + Point2(0, Math::floor((h - font_h) / 2.0)), text, items[i].disabled ? font_color_disabled : (i == mouse_over ? font_color_hover : font_color));
				}

				if (items[i].accel || (items[i].shortcut.is_valid() && items[i].shortcut->is_valid())) {
					//accelerator
					String text = _get_accel_text(i);
					item_ofs.x = size.width - style->get_margin(MARGIN_RIGHT) - font->get_string_size(text).width;
					font->draw(ci, item_ofs + Point2(0, Math::floor((h - font_h) / 2.0)), text, i == mouse_over ? font_color_hover : font_color_accel);
				}

				items[i]._ofs_cache = ofs.y;

				ofs.y += h;
//.........这里部分代码省略.........
开发者ID:kubecz3k,项目名称:godot,代码行数:101,代码来源:popup_menu.cpp


示例12: Texture

Texture2D::Texture2D(Stream *stream, InstanceManager *manager) 
 : Texture(stream, manager) {
	m_uvOffset = Point2(stream);
	m_uvScale = Vector2(stream);
}
开发者ID:aledoronin,项目名称:3D_Hair_Rendering,代码行数:5,代码来源:texture.cpp


示例13: switch


//.........这里部分代码省略.........
                    }

                    emit_signal("pressed");

                } else {

                    status.pressed=!status.pressed;

                    pressed();
                    emit_signal("pressed");

                    toggled(status.pressed);
                    emit_signal("toggled",status.pressed);
                    if (get_script_instance()) {
                        get_script_instance()->call(SceneStringNames::get_singleton()->_toggled,status.pressed);
                    }


                }

            }

            status.press_attempt=false;

        }

        update();
    }
    break;
    case InputEvent::MOUSE_MOTION: {

        if (status.press_attempt && status.pressing_button==0) {
            bool last_press_inside=status.pressing_inside;
            status.pressing_inside=has_point(Point2(p_event.mouse_motion.x,p_event.mouse_motion.y));
            if (last_press_inside!=status.pressing_inside)
                update();
        }
    }
    break;
    case InputEvent::ACTION:
    case InputEvent::JOYSTICK_BUTTON:
    case InputEvent::KEY: {


        if (p_event.is_echo()) {
            break;
        }

        if (status.disabled) {
            break;
        }

        if (status.press_attempt && status.pressing_button==0) {
            break;
        }

        if (p_event.is_action("ui_accept")) {

            if (p_event.is_pressed()) {

                status.pressing_button++;
                status.press_attempt=true;
                status.pressing_inside=true;

            } else if (status.press_attempt) {
开发者ID:Censacrof,项目名称:godot,代码行数:66,代码来源:base_button.cpp


示例14: ARCFAperture

	ARCFAperture(Stream *stream, InstanceManager *manager)
	 : Texture2D(stream, manager) {
		m_color0 = Spectrum(stream);
		m_color1 = Spectrum(stream);
		m_uvBar = Point2(stream);
	}
开发者ID:sidneycadot,项目名称:MitsubaARCF,代码行数:6,代码来源:arcf_aperture.cpp


示例15: _bind_methods

void BitmapFont::_bind_methods() {

	ClassDB::bind_method(_MD("create_from_fnt","path"),&BitmapFont::create_from_fnt);
	ClassDB::bind_method(_MD("set_height","px"),&BitmapFont::set_height);

	ClassDB::bind_method(_MD("set_ascent","px"),&BitmapFont::set_ascent);

	ClassDB::bind_method(_MD("add_kerning_pair","char_a","char_b","kerning"),&BitmapFont::add_kerning_pair);
	ClassDB::bind_method(_MD("get_kerning_pair","char_a","char_b"),&BitmapFont::get_kerning_pair);

	ClassDB::bind_method(_MD("add_texture","texture:Texture"),&BitmapFont::add_texture);
	ClassDB::bind_method(_MD("add_char","character","texture","rect","align","advance"),&BitmapFont::add_char,DEFVAL(Point2()),DEFVAL(-1));


	ClassDB::bind_method(_MD("get_texture_count"),&BitmapFont::get_texture_count);
	ClassDB::bind_method(_MD("get_texture:Texture","idx"),&BitmapFont::get_texture);

	ClassDB::bind_method(_MD("get_char_size","char","next"),&BitmapFont::get_char_size,DEFVAL(0));

	ClassDB::bind_method(_MD("set_distance_field_hint","enable"),&BitmapFont::set_distance_field_hint);

	ClassDB::bind_method(_MD("clear"),&BitmapFont::clear);


	ClassDB::bind_method(_MD("_set_chars"),&BitmapFont::_set_chars);
	ClassDB::bind_method(_MD("_get_chars"),&BitmapFont::_get_chars);

	ClassDB::bind_method(_MD("_set_kernings"),&BitmapFont::_set_kernings);
	ClassDB::bind_method(_MD("_get_kernings"),&BitmapFont::_get_kernings);

	ClassDB::bind_method(_MD("_set_textures"),&BitmapFont::_set_textures);
	ClassDB::bind_method(_MD("_get_textures"),&BitmapFont::_get_textures);

	ClassDB::bind_method(_MD("set_fallback","fallback"),&BitmapFont::set_fallback);
	ClassDB::bind_method(_MD("get_fallback"),&BitmapFont::get_fallback);

	ADD_PROPERTY( PropertyInfo( Variant::ARRAY, "textures", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_textures"), _SCS("_get_textures") );
	ADD_PROPERTY( PropertyInfo( Variant::INT_ARRAY, "chars", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_chars"), _SCS("_get_chars") );
	ADD_PROPERTY( PropertyInfo( Variant::INT_ARRAY, "kernings", PROPERTY_HINT_NONE,"", PROPERTY_USAGE_NOEDITOR ), _SCS("_set_kernings"), _SCS("_get_kernings") );

	ADD_PROPERTY( PropertyInfo( Variant::REAL, "height", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_height"), _SCS("get_height") );
	ADD_PROPERTY( PropertyInfo( Variant::REAL, "ascent", PROPERTY_HINT_RANGE,"-1024,1024,1" ), _SCS("set_ascent"), _SCS("get_ascent") );
	ADD_PROPERTY( PropertyInfo( Variant::BOOL, "distance_field" ), _SCS("set_distance_field_hint"), _SCS("is_distance_field_hint") );
	ADD_PROPERTY( PropertyInfo( Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE,"BitmapFont" ), _SCS("set_fallback"), _SCS("get_fallback") );

}
开发者ID:lonesurvivor,项目名称:godot,代码行数:46,代码来源:font.cpp


示例16: switch

bool Path2DEditor::forward_input_event(const InputEvent& p_event) {

	if (!node)
		return false;

	if (!node->is_visible())
		return false;

	if (!node->get_curve().is_valid())
		return false;

	switch(p_event.type) {

		case InputEvent::MOUSE_BUTTON: {

			const InputEventMouseButton &mb=p_event.mouse_button;

			Matrix32 xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();

			Vector2 gpoint = Point2(mb.x,mb.y);
			Vector2 cpoint = !mb.mod.alt? canvas_item_editor->snap_point(xform.affine_inverse().xform(gpoint))
										: node->get_global_transform().affine_inverse().xform( canvas_item_editor->snap_point(canvas_item_editor->get_canvas_transform().affine_inverse().xform(gpoint)) );

			//first check if a point is to be added (segment split)
			real_t grab_treshold=EDITOR_DEF("poly_editor/point_grab_radius",8);



			// Test move point!!

			if ( mb.pressed && action==ACTION_NONE ) {

				Ref<Curve2D> curve = node->get_curve();

				for(int i=0;i<curve->get_point_count();i++) {

					bool pointunder=false;

					{
						Point2 p = xform.xform( curve->get_point_pos(i) );
						if (gpoint.distance_to(p) < grab_treshold ) {

							if (mb.button_index==BUTTON_LEFT && !mb.mod.shift && mode==MODE_EDIT) {

								action=ACTION_MOVING_POINT;
								action_point=i;
								moving_from=curve->get_point_pos(i);
								moving_screen_from=gpoint;
								return true;
							} else if  ((mb.button_index==BUTTON_RIGHT && mode==MODE_EDIT) || (mb.button_index==BUTTON_LEFT && mode==MODE_DELETE)) {

								undo_redo->create_action(TTR("Remove Point from Curve"));
								undo_redo->add_do_method(curve.ptr(),"remove_point",i);
								undo_redo->add_undo_method(curve.ptr(),"add_point",curve->get_point_pos(i),curve->get_point_in(i),curve->get_point_out(i),i);
								undo_redo->add_do_method(canvas_item_editor->get_viewport_control(),"update");
								undo_redo->add_undo_method(canvas_item_editor->get_viewport_control(),"update");
								undo_redo->commit_action();
								return true;
							} else
								pointunder=true;
						}
					}

					if (mb.button_index==BUTTON_LEFT && i<(curve->get_point_count()-1)) {
						Point2 p = xform.xform( curve->get_point_pos(i)+curve->get_point_out(i) );
						if (gpoint.distance_to(p) < grab_treshold && (mode == MODE_EDIT || mode==MODE_EDIT_CURVE) ) {

							action=ACTION_MOVING_OUT;
							action_point=i;
							moving_from=curve->get_point_out(i);
							moving_screen_from=gpoint;
							return true;
						}
					}

					if (mb.button_index==BUTTON_LEFT && i>0) {
						Point2 p = xform.xform( curve->get_point_pos(i)+curve->get_point_in(i) );
						if (gpoint.distance_to(p) < grab_treshold && (mode == MODE_EDIT || mode==MODE_EDIT_CURVE)) {

							action=ACTION_MOVING_IN;
							action_point=i;
							moving_from=curve->get_point_in(i);
							moving_screen_from=gpoint;
							return true;
						}
					}

					if (pointunder)
						return true;

				}

			}

			// Test add point in empty space!

			if ( mb.pressed && mb.button_index==BUTTON_LEFT && ((mb.mod.command && mode == MODE_EDIT) || mode == MODE_CREATE)) {

				Ref<Curve2D> curve = node->get_curve();

//.........这里部分代码省略.........
开发者ID:03050903,项目名称:godot,代码行数:101,代码来源:path_2d_editor_plugin.cpp


示例17: switch

void PopupMenu::_input_event(const InputEvent &p_event) {

	switch( p_event.type) {

		case InputEvent::KEY: {


			if (!p_event.key.pressed)
				break;

			switch(p_event.key.scancode) {


				case KEY_DOWN: {


					for(int i=mouse_over+1;i<items.size();i++) {

						if (i<0 || i>=items.size())
							continue;

						if (!items[i].separator && !items[i].disabled) {


							mouse_over=i;
							update();
							break;
						}
					}
				} break;
				case KEY_UP: {


					for(int i=mouse_over-1;i>=0;i--) {

						if (i<0 || i>=items.size())
							continue;


						if (!items[i].separator && !items[i].disabled) {


						   mouse_over=i;
						   update();
						   break;
						}
					}
				} break;
				case KEY_RETURN:
				case KEY_ENTER: {

					if (mouse_over>=0 && mouse_over<items.size() && !items[mouse_over].separator) {


						activate_item(mouse_over);

					}
				} break;
			}





		} break;

		case InputEvent::MOUSE_BUTTON: {
	
			
			const InputEventMouseButton &b=p_event.mouse_button;
			if (b.pressed)
				break;			

			switch(b.button_index) {


				case BUTTON_WHEEL_DOWN: {

					if (get_global_pos().y + get_size().y > get_viewport_rect().size.y) {

						int vseparation = get_constant("vseparation");
						Ref<Font> font = get_font("font");

						Point2 pos = get_pos();
						int s = (vseparation+font->get_height())*3;
						pos.y-=s;
						set_pos(pos);

						//update hover
						InputEvent ie;
						ie.type=InputEvent::MOUSE_MOTION;
						ie.mouse_motion.x=b.x;
						ie.mouse_motion.y=b.y+s;
						_input_event(ie);
					}
				} break;
				case BUTTON_WHEEL_UP: {

					if (get_global_pos().y < 0) {

//.........这里部分代码省略.........
开发者ID:Martho42,项目名称:godot,代码行数:101,代码来源:popup_menu.cpp


示例18: set_title

ProjectSettings::ProjectSettings(EditorData *p_data) {


	singleton=this;
	set_title("Project Settings (engine.cfg)");
	undo_redo=&p_data->get_undo_redo();
	data=p_data;


	TabContainer *tab_container = memnew( TabContainer );
	add_child(tab_container);
	set_child_rect(tab_container);

	//tab_container->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 15 );
	//tab_container->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 15 );
	//tab_container->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 15 );
	//tab_container->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );

	Control *props_base = memnew( Control );
	tab_container->add_child(props_base);
	props_base->set_name("General");
	globals_editor = memnew( PropertyEditor );
	props_base->add_child(globals_editor);
	globals_editor->set_area_as_parent_rect();
	globals_editor->hide_top_label();
	globals_editor->set_anchor_and_margin(MARGIN_TOP,ANCHOR_BEGIN, 55 );
	globals_editor->set_anchor_and_margin(MARGIN_BOTTOM,ANCHOR_END, 35 );
	globals_editor->set_anchor_and_margin(MARGIN_LEFT,ANCHOR_BEGIN, 5 );
	globals_editor->set_anchor_and_margin(MARGIN_RIGHT,ANCHOR_END, 5 );
	globals_editor->set_capitalize_paths(false);
	globals_editor->get_tree()->connect("cell_selected",this,"_item_selected");
	globals_editor->connect("property_toggled",this,"_item_checked");
	globals_editor->connect("property_edited",this,"_settings_prop_edited");


	Label *l = memnew( Label );
	props_base->add_child(l);
	l->set_pos(Point2(6,5));
	l->set_text("Category:");


	l = memnew( Label );
	l->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
	props_base->add_child(l);
	l->set_begin(Point2(0.21,5));
	l->set_text("Property:");

	l = memnew( Label );
	l->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
	props_base->add_child(l);
	l->set_begin(Point2(0.51,5));
	l->set_text("Type:");

	category = memnew( LineEdit );
	props_base->add_child(category);
	category->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
	category->set_begin( Point2(5,25) );
	category->set_end( Point2(0.20,26) );
	category->connect("text_entered",this,"_item_adds");

	property = memnew( LineEdit );
	props_base->add_child(property);
	property->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
	property->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
	property->set_begin( Point2(0.21,25) );
	property->set_end( Point2(0.50,26) );
	property->connect("text_entered",this,"_item_adds");


	type = memnew( OptionButton );
	props_base->add_child(type);
	type->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
	type->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
	type->set_begin( Point2(0.51,25) );
	type->set_end( Point2(0.70,26) );
	type->add_item("bool");
	type->add_item("int");
	type->add_item("float");
	type->add_item("string");

	Button *add = memnew( Button );
	props_base->add_child(add);
	add->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
	add->set_anchor(MARGIN_RIGHT,ANCHOR_RATIO);
	add->set_begin( Point2(0.71,25) );
	add->set_end( Point2(0.85,26) );
	add->set_text("Add");
	add->connect("pressed",this,"_item_add");

	Button *del = memnew( Button );
	props_base->add_child(del);
	del->set_anchor(MARGIN_LEFT,ANCHOR_RATIO);
	del->set_anchor(MARGIN_RIGHT,ANCHOR_END);
	del->set_begin( Point2(0.86,25) );
	del->set_end( Point2(5,26) );
	del->set_text("Del");
	del->connect("press 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Point2d函数代码示例发布时间:2022-05-30
下一篇:
C++ PodZero函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap