当前位置: 首页>>代码示例>>C++>>正文


C++ Point2函数代码示例

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


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


注:本文中的Point2函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。