Skip to content

Commit

Permalink
Fix bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ichenpipi committed Aug 10, 2023
1 parent d578981 commit 7d2478b
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [1.0.3] - 2023-08-10

- Fix bugs.

## [1.0.2] - 2023-08-08

- Fix styling issues with Light theme.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private void InitListView()
style =
{
flexBasis = Length.Percent(100),
minWidth = 150,
minWidth = 100,
}
};
m_ContentSplitView.Add(m_AssetList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private void InitContentPreview()
style =
{
flexBasis = Length.Percent(100),
minWidth = 150,
minWidth = 100,
}
};
m_ContentSplitView.Add(m_PreviewPane);
Expand Down
30 changes: 28 additions & 2 deletions Editor/Scripts/Window/ProjectPinBoardWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public static ProjectPinBoardWindow CreateInstance()
text = k_Title,
image = PipiUtility.GetIcon("Favorite"),
};
window.minSize = new Vector2(250f, 200f);
window.minSize = new Vector2(100, 100);
window.SetSize(600, 500);
window.SetCenter();
return window;
Expand Down Expand Up @@ -251,7 +251,33 @@ private void ApplySettings()
m_ToolbarTopFolderToggle.SetValueWithoutNotify(ProjectPinBoardSettings.topFolder);
m_ToolbarPreviewToggle.SetValueWithoutNotify(ProjectPinBoardSettings.enablePreview);
m_ToolbarSyncSelectionToggle.SetValueWithoutNotify(ProjectPinBoardSettings.syncSelection);
m_ContentSplitView.fixedPaneInitialDimension = ProjectPinBoardSettings.dragLinePos;

ApplySettings_DragLine();
}

/// <summary>
/// 应用拖拽线
/// </summary>
private void ApplySettings_DragLine()
{
if (!IsContentInited()) return;

float rootWidth = rootVisualElement.worldBound.width;
float leftPaneMinWidth = m_AssetList.style.minWidth.value.value;
float rightPaneMinWidth = m_PreviewPane.style.minWidth.value.value;
float dragLinePos = ProjectPinBoardSettings.dragLinePos;
if (dragLinePos < leftPaneMinWidth || dragLinePos > rootWidth - rightPaneMinWidth)
{
dragLinePos = leftPaneMinWidth;
}
else
{
if (m_ContentSplitView.fixedPaneIndex == 1)
{
dragLinePos = rootWidth - dragLinePos;
}
}
m_ContentSplitView.fixedPaneInitialDimension = dragLinePos;
}

#endregion
Expand Down
26 changes: 22 additions & 4 deletions Editor/Scripts/Window/ProjectPinBoardWindowContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ public partial class ProjectPinBoardWindow
/// </summary>
private TwoPaneSplitView m_ContentSplitView = null;

/// <summary>
/// 内容分栏拖拽线
/// </summary>
private VisualElement m_ContentDragLine = null;

/// <summary>
/// 初始化内容
/// </summary>
Expand Down Expand Up @@ -95,13 +100,26 @@ void Callback(GeometryChangedEvent evt)

// 拖拽线
{
VisualElement dragLine = m_ContentSplitView.Q<VisualElement>("unity-dragline-anchor");
IStyle dragLineStyle = dragLine.style;
m_ContentDragLine = m_ContentSplitView.Q<VisualElement>("unity-dragline-anchor");
IStyle dragLineStyle = m_ContentDragLine.style;
// 禁止拖拽线在Hover的时候变颜色
Color color = dragLineColor;
dragLine.RegisterCallback<MouseEnterEvent>((evt) => dragLineStyle.backgroundColor = color);
m_ContentDragLine.RegisterCallback<MouseEnterEvent>((evt) => dragLineStyle.backgroundColor = color);
// 拖动拖拽线后保存其位置
dragLine.RegisterCallback<MouseUpEvent>((evt) => ProjectPinBoardSettings.dragLinePos = dragLineStyle.left.value.value);
m_ContentDragLine.RegisterCallback<MouseUpEvent>((evt) =>
{
float rootWidth = rootVisualElement.worldBound.width;
float leftPaneMinWidth = m_AssetList.style.minWidth.value.value;
float rightPaneMinWidth = m_PreviewPane.style.minWidth.value.value;
float dragLinePos = dragLineStyle.left.value.value;
if (dragLinePos < leftPaneMinWidth || dragLinePos > rootWidth - rightPaneMinWidth)
{
dragLinePos = leftPaneMinWidth;
dragLineStyle.left = dragLinePos;
m_ContentSplitView.fixedPaneInitialDimension = dragLinePos;
}
ProjectPinBoardSettings.dragLinePos = dragLinePos;
});
}

// 初始化列表
Expand Down
16 changes: 11 additions & 5 deletions Editor/Scripts/Window/ProjectPinBoardWindowMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public void AddItemsToMenu(GenericMenu menu)
menu.AddItem(new GUIContent("Clear Data ⚠️"), false, Menu_ClearData);
menu.AddItem(new GUIContent("Reset Settings ⚠️"), false, Menu_ResetSettings);
menu.AddSeparator(string.Empty);
menu.AddItem(new GUIContent("About/Home Page (Gitee)"), false, Menu_HomePage1);
menu.AddItem(new GUIContent("About/Home Page (Github)"), false, Menu_HomePage2);
menu.AddItem(new GUIContent("About/陈皮皮 (ichenpipi)"), false, Menu_HomePage);
menu.AddItem(new GUIContent("About/Project Home Page (Github)"), false, Menu_ProjectHomePageGithub);
menu.AddItem(new GUIContent("About/Project Home Page (Gitee)"), false, Menu_ProjectHomePageGitee);
}

private void Menu_Reload()
Expand Down Expand Up @@ -57,16 +58,21 @@ private void Menu_ResetSettings()
ApplySettings();
}

private void Menu_HomePage1()
private void Menu_HomePage()
{
Application.OpenURL("https://gitee.com/ichenpipi/unity-project-pin-board");
Application.OpenURL("https://github.com/ichenpipi");
}

private void Menu_HomePage2()
private void Menu_ProjectHomePageGithub()
{
Application.OpenURL("https://github.com/ichenpipi/unity-project-pin-board");
}

private void Menu_ProjectHomePageGitee()
{
Application.OpenURL("https://gitee.com/ichenpipi/unity-project-pin-board");
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ private void OnPreviewToggleValueChanged(ChangeEvent<bool> evt)
{
ProjectPinBoardSettings.enablePreview = evt.newValue;
TogglePreview(evt.newValue);
// 确保拖拽线位置无异常
if (evt.newValue)
{
ApplySettings_DragLine();
}
}

}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.chenpipi.project-pin-board",
"version": "1.0.2",
"version": "1.0.3",
"unity": "2020.2",
"displayName": "Project Pin Board",
"keywords": [
Expand All @@ -13,13 +13,13 @@
"author": {
"name": "ChenPipi",
"email": "[email protected]",
"url": "https://gitee.com/ichenpipi"
"url": "https://github.com/ichenpipi"
},
"dependencies": {
},
"repository": {
"type": "git",
"url": "https://gitee.com/ichenpipi/unity-project-pin-board.git"
"url": "https://github.com/ichenpipi/unity-project-pin-board.git"
},
"license": "MIT"
}

0 comments on commit 7d2478b

Please sign in to comment.