arenos-nexus/Arenos Nexus/Library/PackageCache/com.unity.collab-proxy@ab839cc7d2ad/Editor/Views/PendingChanges/DrawCommentTextArea.cs
Daniel 2e704cae70 init
Init Commit Unity
2025-09-25 22:01:28 +02:00

63 lines
1.8 KiB
C#

using System.Reflection;
using UnityEditor;
using UnityEngine;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.UndoRedo;
namespace Unity.PlasticSCM.Editor.Views.PendingChanges
{
internal static class DrawCommentTextArea
{
internal static void For(
UndoRedoTextArea textArea,
PendingChangesTab pendingChangesTab,
float width,
bool isOperationRunning)
{
using (new GuiEnabled(!isOperationRunning))
{
EditorGUILayout.BeginHorizontal();
Rect textAreaRect = BuildTextAreaRect(
textArea.Text,
width);
EditorGUI.BeginChangeCheck();
textArea.OnGUI(
textAreaRect,
UnityStyles.PendingChangesTab.CommentTextArea,
UnityStyles.PendingChangesTab.CommentPlaceHolder);
if (EditorGUI.EndChangeCheck())
OnTextAreaChanged(pendingChangesTab);
EditorGUILayout.EndHorizontal();
}
}
static void OnTextAreaChanged(PendingChangesTab pendingChangesTab)
{
pendingChangesTab.ClearIsCommentWarningNeeded();
}
static Rect BuildTextAreaRect(string text, float width)
{
GUIStyle commentTextAreaStyle = UnityStyles.PendingChangesTab.CommentTextArea;
commentTextAreaStyle.stretchWidth = false;
Rect result = GUILayoutUtility.GetRect(
width,
UnityConstants.PENDING_CHANGES_COMMENT_HEIGHT);
result.width = width;
result.height = UnityConstants.PENDING_CHANGES_COMMENT_HEIGHT;
result.xMin = 50f;
return result;
}
}
}