UTKAccordion 개발 완료. UTKComponentList 완료

This commit is contained in:
logonkhi
2026-01-06 18:51:37 +09:00
parent b7776f3af0
commit ef4e86820c
9 changed files with 532 additions and 233 deletions

View File

@@ -13,7 +13,7 @@ public class UTKComponentListWindowSample : MonoBehaviour
[SerializeField]
public UIDocument uiDocument;
private UTKComponentListWindow listWindow;
private UTKComponentTabListWindow tabListWindow;
@@ -22,7 +22,7 @@ public class UTKComponentListWindowSample : MonoBehaviour
{
uiDocument ??= GetComponent<UIDocument>();
// UTKComponentTabListWindow 사용 (탭 기능 포함)
tabListWindow = new UTKComponentTabListWindow();
tabListWindow.style.marginLeft = 500;
@@ -33,7 +33,7 @@ public class UTKComponentListWindowSample : MonoBehaviour
// 이벤트 핸들러 등록
RegisterTabListEventHandlers();
// UTKComponentListWindow 사용 (기본)
listWindow = new UTKComponentListWindow();
uiDocument.rootVisualElement.Add(listWindow);
@@ -43,24 +43,25 @@ public class UTKComponentListWindowSample : MonoBehaviour
// 이벤트 핸들러 등록
RegisterEventHandlers();
}
/// <summary>
/// 테스트용 계층적 트리 데이터를 생성합니다.
/// 10개의 루트 항목을 생성하고, 각 루트에 5개의 자식,
/// 각 자식에 3개의 손자, 각 손자에 2개의 증손자를 추가합니다.
/// 5개의 카테고리를 생성하고, 각 카테고리에 20개의 항목을 추가합니다.
/// </summary>
private void CreateTestData()
{
var data = new List<UTKComponentListItemData>();
var data = new List<UTKComponentListItemDataBase>();
for (int i = 1; i <= 5; i++)
{
string categoryName = $"Category {i}";
UTKComponentListItemData categoryData = new UTKComponentListItemData { name = categoryName };
// 카테고리 데이터 생성 (UTKComponentListCategoryData 사용)
var categoryData = new UTKComponentListCategoryData { name = categoryName };
for (int j = 1; j <= 20; j++)
{
// 일반 항목 데이터 생성 (UTKComponentListItemData 사용)
var itemData = new UTKComponentListItemData
{
name = $"Item {i}-{j}",
@@ -72,7 +73,7 @@ public class UTKComponentListWindowSample : MonoBehaviour
}
listWindow.SetData(data);
Debug.Log("[UTKComponentListWindowSample] 테스트 데이터 생성 완료: 5개 루트 항목");
Debug.Log("[UTKComponentListWindowSample] 테스트 데이터 생성 완료: 5개 카테고리");
}
/// <summary>
@@ -83,7 +84,7 @@ public class UTKComponentListWindowSample : MonoBehaviour
{
// 항목 선택 이벤트 (다중 선택 지원)
// 사용자가 항목을 클릭하거나 SelectItem() 호출 시 발생
listWindow.OnItemSelected += (List<UTKComponentListItemData> selectedItems) =>
listWindow.OnItemSelected += (List<UTKComponentListItemDataBase> selectedItems) =>
{
foreach (var item in selectedItems)
{
@@ -93,7 +94,7 @@ public class UTKComponentListWindowSample : MonoBehaviour
// 항목 선택 해제 이벤트 (다중 선택 지원)
// 사용자가 다른 항목을 선택하거나 DeselectItem() 호출 시 발생
listWindow.OnItemDeselected += (List<UTKComponentListItemData> deselectedItems) =>
listWindow.OnItemDeselected += (List<UTKComponentListItemDataBase> deselectedItems) =>
{
foreach (var item in deselectedItems)
{
@@ -104,7 +105,7 @@ public class UTKComponentListWindowSample : MonoBehaviour
// 항목 삭제 이벤트
// 사용자가 Delete 또는 Backspace 키를 누를 때 발생
// 실제 삭제는 이 핸들러에서 DeleteItem()을 호출하여 수행
listWindow.OnItemDeleted += (UTKComponentListItemData deletedItem) =>
listWindow.OnItemDeleted += (UTKComponentListItemDataBase deletedItem) =>
{
Debug.Log($"[삭제 요청] {deletedItem.name}");
// 실제로 항목을 삭제하려면 아래 주석을 해제하세요:
@@ -113,21 +114,21 @@ public class UTKComponentListWindowSample : MonoBehaviour
// 항목 더블클릭 이벤트
// 사용자가 항목을 더블클릭하거나 Enter 키를 누를 때 발생
listWindow.OnItemDoubleClicked += (UTKComponentListItemData doubleClickedItem) =>
listWindow.OnItemDoubleClicked += (UTKComponentListItemDataBase doubleClickedItem) =>
{
Debug.Log($"[더블클릭] {doubleClickedItem.name}");
};
// 항목 가시성 변경 이벤트
// 사용자가 눈 아이콘 버튼을 클릭하여 가시성을 토글할 때 발생
listWindow.OnItemVisibilityChanged += (UTKComponentListItemData item, bool isVisible) =>
listWindow.OnItemVisibilityChanged += (UTKComponentListItemDataBase item, bool isVisible) =>
{
Debug.Log($"[가시성 변경] {item.name}, IsVisible: {isVisible}");
};
// 아이콘 클릭 이벤트
// 그룹 항목의 setting-btn 등 아이콘 버튼 클릭 시 발생
listWindow.OnItemIconClicked += (string iconName, UTKComponentListItemData item) =>
listWindow.OnItemIconClicked += (string iconName, UTKComponentListItemDataBase item) =>
{
Debug.Log($"[아이콘 클릭] {iconName}, Item: {item.name}");
};
@@ -141,14 +142,16 @@ public class UTKComponentListWindowSample : MonoBehaviour
/// </summary>
private void CreateTabListTestData()
{
var data = new List<UTKComponentListItemData>();
var data = new List<UTKComponentListItemDataBase>();
for (int i = 1; i <= 5; i++)
{
string categoryName = $"Category {i}";
UTKComponentListItemData categoryData = new UTKComponentListItemData { name = categoryName };
// 카테고리 데이터 생성 (UTKComponentListCategoryData 사용)
var categoryData = new UTKComponentListCategoryData { name = categoryName };
for (int j = 1; j <= 20; j++)
{
// 일반 항목 데이터 생성 (UTKComponentListItemData 사용)
var itemData = new UTKComponentListItemData
{
name = $"Item {i}-{j}",
@@ -169,7 +172,7 @@ public class UTKComponentListWindowSample : MonoBehaviour
private void RegisterTabListEventHandlers()
{
// 항목 선택 이벤트 (다중 선택 지원)
tabListWindow.OnItemSelected += (List<UTKComponentListItemData> selectedItems) =>
tabListWindow.OnItemSelected += (List<UTKComponentListItemDataBase> selectedItems) =>
{
foreach (var item in selectedItems)
{
@@ -178,7 +181,7 @@ public class UTKComponentListWindowSample : MonoBehaviour
};
// 항목 선택 해제 이벤트 (다중 선택 지원)
tabListWindow.OnItemDeselected += (List<UTKComponentListItemData> deselectedItems) =>
tabListWindow.OnItemDeselected += (List<UTKComponentListItemDataBase> deselectedItems) =>
{
foreach (var item in deselectedItems)
{
@@ -187,25 +190,25 @@ public class UTKComponentListWindowSample : MonoBehaviour
};
// 항목 삭제 이벤트
tabListWindow.OnItemDeleted += (UTKComponentListItemData deletedItem) =>
tabListWindow.OnItemDeleted += (UTKComponentListItemDataBase deletedItem) =>
{
Debug.Log($"[TabList 삭제 요청] {deletedItem.name}");
};
// 항목 더블클릭 이벤트
tabListWindow.OnItemDoubleClicked += (UTKComponentListItemData doubleClickedItem) =>
tabListWindow.OnItemDoubleClicked += (UTKComponentListItemDataBase doubleClickedItem) =>
{
Debug.Log($"[TabList 더블클릭] {doubleClickedItem.name}");
};
// 항목 가시성 변경 이벤트
tabListWindow.OnItemVisibilityChanged += (UTKComponentListItemData item, bool isVisible) =>
tabListWindow.OnItemVisibilityChanged += (UTKComponentListItemDataBase item, bool isVisible) =>
{
Debug.Log($"[TabList 가시성 변경] {item.name}, IsVisible: {isVisible}");
};
// 아이콘 클릭 이벤트
tabListWindow.OnItemIconClicked += (string iconName, UTKComponentListItemData item) =>
tabListWindow.OnItemIconClicked += (string iconName, UTKComponentListItemDataBase item) =>
{
Debug.Log($"[TabList 아이콘 클릭] {iconName}, Item: {item.name}");
};