浏览代码

UI: Select item that user adds

When a user adds an item (either by adding or copying an item), select
it.  Fixes a bug with copying and pasting sources where the pasted
source will not have the copied transform applied to it.
jp9000 7 年之前
父节点
当前提交
02bdccc6ad
共有 1 个文件被更改,包括 15 次插入0 次删除
  1. 15 0
      UI/window-basic-main.cpp

+ 15 - 0
UI/window-basic-main.cpp

@@ -2388,6 +2388,19 @@ void OBSBasic::RemoveScene(OBSSource source)
 		api->on_event(OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED);
 }
 
+static bool select_one(obs_scene_t *scene, obs_sceneitem_t *item, void *param)
+{
+	obs_sceneitem_t *selectedItem =
+		reinterpret_cast<obs_sceneitem_t*>(param);
+	if (obs_sceneitem_is_group(item))
+		obs_sceneitem_group_enum_items(item, select_one, param);
+
+	obs_sceneitem_select(item, (selectedItem == item));
+
+	UNUSED_PARAMETER(scene);
+	return true;
+}
+
 void OBSBasic::AddSceneItem(OBSSceneItem item)
 {
 	obs_scene_t  *scene  = obs_sceneitem_get_scene(item);
@@ -2404,6 +2417,8 @@ void OBSBasic::AddSceneItem(OBSSceneItem item)
 				obs_source_get_name(itemSource),
 				obs_source_get_id(itemSource),
 				obs_source_get_name(sceneSource));
+		
+		obs_scene_enum_items(scene, select_one, (obs_sceneitem_t*)item);
 	}
 }