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


C++ OBSBasic::devicePixelRatioF方法代码示例

本文整理汇总了C++中OBSBasic::devicePixelRatioF方法的典型用法代码示例。如果您正苦于以下问题:C++ OBSBasic::devicePixelRatioF方法的具体用法?C++ OBSBasic::devicePixelRatioF怎么用?C++ OBSBasic::devicePixelRatioF使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OBSBasic的用法示例。


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

示例1: mousePressEvent

void OBSBasicPreview::mousePressEvent(QMouseEvent *event)
{
	if (scrollMode && IsFixedScaling() &&
	    event->button() == Qt::LeftButton) {
		setCursor(Qt::ClosedHandCursor);
		scrollingFrom.x = event->x();
		scrollingFrom.y = event->y();
		return;
	}

	if (event->button() == Qt::RightButton) {
		scrollMode = false;
		setCursor(Qt::ArrowCursor);
	}

	if (locked) {
		OBSQTDisplay::mousePressEvent(event);
		return;
	}

	OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
#ifdef SUPPORTS_FRACTIONAL_SCALING
	float pixelRatio = main->devicePixelRatioF();
#else
	float pixelRatio = main->devicePixelRatio();
#endif
	float x = float(event->x()) - main->previewX / pixelRatio;
	float y = float(event->y()) - main->previewY / pixelRatio;
	Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers();
	bool altDown = (modifiers & Qt::AltModifier);

	OBSQTDisplay::mousePressEvent(event);

	if (event->button() != Qt::LeftButton &&
	    event->button() != Qt::RightButton)
		return;

	if (event->button() == Qt::LeftButton)
		mouseDown = true;

	if (altDown)
		cropping = true;

	vec2_set(&startPos, x, y);
	GetStretchHandleData(startPos);

	vec2_divf(&startPos, &startPos, main->previewScale / pixelRatio);
	startPos.x = std::round(startPos.x);
	startPos.y = std::round(startPos.y);

	mouseOverItems = SelectedAtPos(startPos);
	vec2_zero(&lastMoveOffset);
}
开发者ID:OsirisNL,项目名称:obs-studio,代码行数:53,代码来源:window-basic-preview.cpp

示例2: GetMouseEventPos

vec2 OBSBasicPreview::GetMouseEventPos(QMouseEvent *event)
{
	OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());
#ifdef SUPPORTS_FRACTIONAL_SCALING
	float pixelRatio = main->devicePixelRatioF();
#else
	float pixelRatio = main->devicePixelRatio();
#endif
	float scale = pixelRatio / main->previewScale;
	vec2 pos;
	vec2_set(&pos,
		(float(event->x()) - main->previewX / pixelRatio) * scale,
		(float(event->y()) - main->previewY / pixelRatio) * scale);

	return pos;
}
开发者ID:OsirisNL,项目名称:obs-studio,代码行数:16,代码来源:window-basic-preview.cpp

示例3: GetStretchHandleData

void OBSBasicPreview::GetStretchHandleData(const vec2 &pos)
{
	OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow());

	OBSScene scene = main->GetCurrentScene();
	if (!scene)
		return;

#ifdef SUPPORTS_FRACTIONAL_SCALING
	float scale = main->previewScale / main->devicePixelRatioF();
#else
	float scale = main->previewScale / main->devicePixelRatio();
#endif
	vec2 scaled_pos = pos;
	vec2_divf(&scaled_pos, &scaled_pos, scale);
	HandleFindData data(scaled_pos, scale);
	obs_scene_enum_items(scene, FindHandleAtPos, &data);

	stretchItem     = std::move(data.item);
	stretchHandle   = data.handle;

	if (stretchHandle != ItemHandle::None) {
		matrix4 boxTransform;
		vec3    itemUL;
		float   itemRot;

		stretchItemSize = GetItemSize(stretchItem);

		obs_sceneitem_get_box_transform(stretchItem, &boxTransform);
		itemRot = obs_sceneitem_get_rot(stretchItem);
		vec3_from_vec4(&itemUL, &boxTransform.t);

		/* build the item space conversion matrices */
		matrix4_identity(&itemToScreen);
		matrix4_rotate_aa4f(&itemToScreen, &itemToScreen,
				0.0f, 0.0f, 1.0f, RAD(itemRot));
		matrix4_translate3f(&itemToScreen, &itemToScreen,
				itemUL.x, itemUL.y, 0.0f);

		matrix4_identity(&screenToItem);
		matrix4_translate3f(&screenToItem, &screenToItem,
				-itemUL.x, -itemUL.y, 0.0f);
		matrix4_rotate_aa4f(&screenToItem, &screenToItem,
				0.0f, 0.0f, 1.0f, RAD(-itemRot));

		obs_sceneitem_get_crop(stretchItem, &startCrop);
		obs_sceneitem_get_pos(stretchItem, &startItemPos);

		obs_source_t *source = obs_sceneitem_get_source(stretchItem);
		cropSize.x = float(obs_source_get_width(source) -
				startCrop.left - startCrop.right);
		cropSize.y = float(obs_source_get_height(source) -
				startCrop.top - startCrop.bottom);

		stretchGroup = obs_sceneitem_get_group(scene, stretchItem);
		if (stretchGroup) {
			obs_sceneitem_get_draw_transform(stretchGroup,
					&invGroupTransform);
			matrix4_inv(&invGroupTransform,
					&invGroupTransform);
			obs_sceneitem_defer_group_resize_begin(stretchGroup);
		}
	}
}
开发者ID:OsirisNL,项目名称:obs-studio,代码行数:64,代码来源:window-basic-preview.cpp


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