mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-07 03:53:38 +00:00
UI: Add ability to copy-paste scene item transforms
This commit adds the ability to copy a scene item's transform and crop settings and paste those settings onto another scene item in any scene or scene collection. It also changes the menu shortcut key for the Transform action "Center to screen" from "C" to "n" because "C" is the standard shortcut key for "Copy" in most other applications. Closes jp9000/obs-studio#719
This commit is contained in:
parent
ee019c7761
commit
42a646f28e
|
@ -342,6 +342,8 @@ Basic.MainMenu.Edit.Scale.Canvas="Canvas (%1x%2)"
|
|||
Basic.MainMenu.Edit.Scale.Output="Output (%1x%2)"
|
||||
Basic.MainMenu.Edit.Transform="&Transform"
|
||||
Basic.MainMenu.Edit.Transform.EditTransform="&Edit Transform..."
|
||||
Basic.MainMenu.Edit.Transform.CopyTransform="Copy Transform"
|
||||
Basic.MainMenu.Edit.Transform.PasteTransform="Paste Transform"
|
||||
Basic.MainMenu.Edit.Transform.ResetTransform="&Reset Transform"
|
||||
Basic.MainMenu.Edit.Transform.Rotate90CW="Rotate 90 degrees CW"
|
||||
Basic.MainMenu.Edit.Transform.Rotate90CCW="Rotate 90 degrees CCW"
|
||||
|
|
|
@ -850,6 +850,8 @@
|
|||
<string>Basic.MainMenu.Edit.Transform</string>
|
||||
</property>
|
||||
<addaction name="actionEditTransform"/>
|
||||
<addaction name="actionCopyTransform"/>
|
||||
<addaction name="actionPasteTransform"/>
|
||||
<addaction name="actionResetTransform"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionRotate90CW"/>
|
||||
|
@ -1129,6 +1131,19 @@
|
|||
<string>Basic.MainMenu.Edit.Transform.EditTransform</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCopyTransform">
|
||||
<property name="text">
|
||||
<string>Basic.MainMenu.Edit.Transform.CopyTransform</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPasteTransform">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Basic.MainMenu.Edit.Transform.PasteTransform</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRotate90CW">
|
||||
<property name="text">
|
||||
<string>Basic.MainMenu.Edit.Transform.Rotate90CW</string>
|
||||
|
|
|
@ -4387,6 +4387,50 @@ void OBSBasic::on_actionEditTransform_triggered()
|
|||
transformWindow->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
}
|
||||
|
||||
static obs_transform_info copiedTransformInfo;
|
||||
static obs_sceneitem_crop copiedCropInfo;
|
||||
|
||||
void OBSBasic::on_actionCopyTransform_triggered()
|
||||
{
|
||||
auto func = [](obs_scene_t *scene, obs_sceneitem_t *item, void *param)
|
||||
{
|
||||
if (!obs_sceneitem_selected(item))
|
||||
return true;
|
||||
|
||||
obs_sceneitem_defer_update_begin(item);
|
||||
obs_sceneitem_get_info(item, &copiedTransformInfo);
|
||||
obs_sceneitem_get_crop(item, &copiedCropInfo);
|
||||
obs_sceneitem_defer_update_end(item);
|
||||
|
||||
UNUSED_PARAMETER(scene);
|
||||
UNUSED_PARAMETER(param);
|
||||
return true;
|
||||
};
|
||||
|
||||
obs_scene_enum_items(GetCurrentScene(), func, nullptr);
|
||||
ui->actionPasteTransform->setEnabled(true);
|
||||
}
|
||||
|
||||
void OBSBasic::on_actionPasteTransform_triggered()
|
||||
{
|
||||
auto func = [](obs_scene_t *scene, obs_sceneitem_t *item, void *param)
|
||||
{
|
||||
if (!obs_sceneitem_selected(item))
|
||||
return true;
|
||||
|
||||
obs_sceneitem_defer_update_begin(item);
|
||||
obs_sceneitem_set_info(item, &copiedTransformInfo);
|
||||
obs_sceneitem_set_crop(item, &copiedCropInfo);
|
||||
obs_sceneitem_defer_update_end(item);
|
||||
|
||||
UNUSED_PARAMETER(scene);
|
||||
UNUSED_PARAMETER(param);
|
||||
return true;
|
||||
};
|
||||
|
||||
obs_scene_enum_items(GetCurrentScene(), func, nullptr);
|
||||
}
|
||||
|
||||
void OBSBasic::on_actionResetTransform_triggered()
|
||||
{
|
||||
auto func = [] (obs_scene_t *scene, obs_sceneitem_t *item, void *param)
|
||||
|
|
|
@ -498,6 +498,8 @@ private slots:
|
|||
void on_actionCheckForUpdates_triggered();
|
||||
|
||||
void on_actionEditTransform_triggered();
|
||||
void on_actionCopyTransform_triggered();
|
||||
void on_actionPasteTransform_triggered();
|
||||
void on_actionRotate90CW_triggered();
|
||||
void on_actionRotate90CCW_triggered();
|
||||
void on_actionRotate180_triggered();
|
||||
|
|
Loading…
Reference in a new issue