|
|
@@ -6106,20 +6106,39 @@ void OBSBasic::on_actionStretchToScreen_triggered()
|
|
|
&boundsType);
|
|
|
}
|
|
|
|
|
|
-static bool center_to_scene(obs_scene_t *, obs_sceneitem_t *item, void *)
|
|
|
+enum class CenterType {
|
|
|
+ Scene,
|
|
|
+ Vertical,
|
|
|
+ Horizontal
|
|
|
+};
|
|
|
+
|
|
|
+static bool center_to_scene(obs_scene_t *, obs_sceneitem_t *item, void *param)
|
|
|
{
|
|
|
+ CenterType centerType = *reinterpret_cast<CenterType*>(param);
|
|
|
+
|
|
|
vec3 tl, br, itemCenter, screenCenter, offset;
|
|
|
obs_video_info ovi;
|
|
|
+ obs_transform_info oti;
|
|
|
|
|
|
if (obs_sceneitem_is_group(item))
|
|
|
- obs_sceneitem_group_enum_items(item, center_to_scene, nullptr);
|
|
|
+ obs_sceneitem_group_enum_items(item, center_to_scene,
|
|
|
+ ¢erType);
|
|
|
if (!obs_sceneitem_selected(item))
|
|
|
return true;
|
|
|
|
|
|
obs_get_video_info(&ovi);
|
|
|
+ obs_sceneitem_get_info(item, &oti);
|
|
|
+
|
|
|
+ if (centerType == CenterType::Scene)
|
|
|
+ vec3_set(&screenCenter, float(ovi.base_width),
|
|
|
+ float(ovi.base_height), 0.0f);
|
|
|
+ else if (centerType == CenterType::Vertical)
|
|
|
+ vec3_set(&screenCenter, float(oti.bounds.x),
|
|
|
+ float(ovi.base_height), 0.0f);
|
|
|
+ else if (centerType == CenterType::Horizontal)
|
|
|
+ vec3_set(&screenCenter, float(ovi.base_width),
|
|
|
+ float(oti.bounds.y), 0.0f);
|
|
|
|
|
|
- vec3_set(&screenCenter, float(ovi.base_width),
|
|
|
- float(ovi.base_height), 0.0f);
|
|
|
vec3_mulf(&screenCenter, &screenCenter, 0.5f);
|
|
|
|
|
|
GetItemBox(item, tl, br);
|
|
|
@@ -6131,13 +6150,31 @@ static bool center_to_scene(obs_scene_t *, obs_sceneitem_t *item, void *)
|
|
|
vec3_sub(&offset, &screenCenter, &itemCenter);
|
|
|
vec3_add(&tl, &tl, &offset);
|
|
|
|
|
|
+ if (centerType == CenterType::Vertical)
|
|
|
+ tl.x = oti.pos.x;
|
|
|
+ else if (centerType == CenterType::Horizontal)
|
|
|
+ tl.y = oti.pos.y;
|
|
|
+
|
|
|
SetItemTL(item, tl);
|
|
|
return true;
|
|
|
};
|
|
|
|
|
|
void OBSBasic::on_actionCenterToScreen_triggered()
|
|
|
{
|
|
|
- obs_scene_enum_items(GetCurrentScene(), center_to_scene, nullptr);
|
|
|
+ CenterType centerType = CenterType::Scene;
|
|
|
+ obs_scene_enum_items(GetCurrentScene(), center_to_scene, ¢erType);
|
|
|
+}
|
|
|
+
|
|
|
+void OBSBasic::on_actionVerticalCenter_triggered()
|
|
|
+{
|
|
|
+ CenterType centerType = CenterType::Vertical;
|
|
|
+ obs_scene_enum_items(GetCurrentScene(), center_to_scene, ¢erType);
|
|
|
+}
|
|
|
+
|
|
|
+void OBSBasic::on_actionHorizontalCenter_triggered()
|
|
|
+{
|
|
|
+ CenterType centerType = CenterType::Horizontal;
|
|
|
+ obs_scene_enum_items(GetCurrentScene(), center_to_scene, ¢erType);
|
|
|
}
|
|
|
|
|
|
void OBSBasic::EnablePreviewDisplay(bool enable)
|