This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,194 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.Attributes;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.PlasticSCM.Editor.Views.Attributes
{
internal class ApplyAttributeView : ApplyAttributeDialogOperations.IApplyAttributeDialog
{
internal string SelectedAttributeName => mSelectedAttributeName;
internal string SelectedAttributeValue => mSelectedAttributeValue;
internal ApplyAttributeView(
RepositorySpec repSpec,
IProgressControls progressControls,
AttributeDataDialog parentWindow)
{
mRepSpec = repSpec;
mProgressControls = progressControls;
mParentWindow = parentWindow;
}
void AttributeNameComboBox_Changed(object selectedAttributeName)
{
mSelectedAttributeName = (string)selectedAttributeName;
ApplyAttributeDialogOperations.GetValuesForAttribute(
mRepSpec,
(string)selectedAttributeName,
mProgressControls,
this);
}
internal void SetAttributeToEdit(AttributeRealizationInfo attribute)
{
mAttributeToEdit = attribute;
AddAttribute(new AttributeInfo()
{
Name = attribute.AttributeName,
FIdAcl = attribute.IdAttribute
});
}
void ApplyAttributeDialogOperations.IApplyAttributeDialog.AddAttribute(
AttributeInfo attrInfo)
{
AddAttribute(attrInfo);
}
void ApplyAttributeDialogOperations.IApplyAttributeDialog.FillAttributes(IList attributes)
{
mAttributeNames = new List<string>();
foreach (AttributeInfo attribute in attributes)
mAttributeNames.Add(attribute.Name);
if (attributes.Count > 0)
{
mSelectedAttributeName = ((AttributeInfo)attributes[0]).Name;
ApplyAttributeDialogOperations.GetValuesForAttribute(
mRepSpec, mSelectedAttributeName, mProgressControls, this);
}
}
void ApplyAttributeDialogOperations.IApplyAttributeDialog.FillValues(IList values)
{
mAttributeValues = values.Cast<string>().ToList();
if (mAttributeToEdit != null)
{
mSelectedAttributeValue = mAttributeToEdit.Value;
return;
}
if (values.Count > 0)
mSelectedAttributeValue = (string)values[0];
}
internal void OkButtonAction()
{
ApplyAttributeData applyAttributeData = new ApplyAttributeData(
mSelectedAttributeName,
mSelectedAttributeValue);
ApplyAttributeValidation.Validation(applyAttributeData, mParentWindow, mProgressControls);
}
void NewAttributeButton_Clicked()
{
mParentWindow.ToggleCreateAttributeView(true);
}
void AddAttribute(AttributeInfo attrInfo)
{
mAttributeNames.Add(attrInfo.Name);
mSelectedAttributeName = attrInfo.Name;
ApplyAttributeDialogOperations.GetValuesForAttribute(
mRepSpec, attrInfo.Name, mProgressControls, this);
mParentWindow.ToggleCreateAttributeView(false);
}
internal void OnGUI()
{
using (new EditorGUILayout.HorizontalScope())
{
DoAttributeNamesCombo();
if (mAttributeNames == null && GUILayout.Button(PlasticLocalization.Name.New.GetString(), GUILayout.ExpandWidth(false)))
{
NewAttributeButton_Clicked();
}
}
GUILayout.Space(5);
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.Label(
PlasticLocalization.Name.AttributeValueLabel.GetString(),
GUILayout.Width(LABEL_WIDTH));
Rect valueRect = GUILayoutUtility.GetRect(
GUIContent.none,
EditorStyles.textField,
GUILayout.ExpandWidth(true));
mSelectedAttributeValue = DropDownTextField.DoDropDownTextField(
mSelectedAttributeValue,
DROPDOWN_CONTROL_NAME,
mAttributeValues,
(selectedAttributeValue) =>
{
mSelectedAttributeValue = (string)selectedAttributeValue;
},
valueRect);
}
}
void DoAttributeNamesCombo()
{
GUI.enabled = mAttributeToEdit == null;
GUILayout.Label(
PlasticLocalization.Name.AttributeNameLabel.GetString(),
GUILayout.Width(LABEL_WIDTH));
Rect rect = GUILayoutUtility.GetRect(
new GUIContent(), EditorStyles.popup, GUILayout.ExpandWidth(true));
if (GUI.Button(rect, mSelectedAttributeName, EditorStyles.popup))
{
GenericMenu menu = new GenericMenu();
foreach (string attributeName in mAttributeNames)
{
menu.AddItem(
new GUIContent(UnityMenuItem.EscapedText(attributeName)),
false,
AttributeNameComboBox_Changed,
attributeName);
}
menu.DropDown(rect);
}
GUI.enabled = true;
}
AttributeRealizationInfo mAttributeToEdit;
string mSelectedAttributeName;
List<string> mAttributeNames = new List<string>();
string mSelectedAttributeValue;
List<string> mAttributeValues = new List<string>();
readonly RepositorySpec mRepSpec;
readonly IProgressControls mProgressControls;
readonly AttributeDataDialog mParentWindow;
const float LABEL_WIDTH = 100f;
const string DROPDOWN_CONTROL_NAME = "ApplyAttributeDialog.AttributeValueDropdown";
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: eb8bc19bacda426fb5ae209e56bd32d3
timeCreated: 1769778648
@@ -0,0 +1,156 @@
using UnityEditor;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.Attributes;
using Unity.PlasticSCM.Editor.UI;
namespace Unity.PlasticSCM.Editor.Views.Attributes
{
internal class AttributeDataDialog : PlasticDialog
{
internal static ApplyAttributeData BuildForApplyAttribute(
RepositorySpec repSpec, IWorkspaceWindow workspaceWindow, EditorWindow parentWindow)
{
AttributeDataDialog dialog = Create(null, repSpec, workspaceWindow);
ResponseType dialogResult = dialog.RunModal(parentWindow);
ApplyAttributeData result = new ApplyAttributeData(
dialog.mApplyAttributeView.SelectedAttributeName,
dialog.mApplyAttributeView.SelectedAttributeValue);
result.Result = dialogResult == ResponseType.Ok;
return result;
}
internal static ApplyAttributeData BuildForEditAttributeRealization(
AttributeRealizationInfo attribute,
RepositorySpec repSpec,
IWorkspaceWindow workspaceWindow,
EditorWindow parentWindow)
{
AttributeDataDialog dialog = Create(attribute, repSpec, workspaceWindow);
ResponseType dialogResult = dialog.RunModal(parentWindow);
ApplyAttributeData result = new ApplyAttributeData(
dialog.mApplyAttributeView.SelectedAttributeName,
dialog.mApplyAttributeView.SelectedAttributeValue);
result.Result = dialogResult == ResponseType.Ok;
return result;
}
static AttributeDataDialog Create(
AttributeRealizationInfo attribute,
RepositorySpec repSpec,
IWorkspaceWindow workspaceWindow)
{
var instance = CreateInstance<AttributeDataDialog>();
instance.mRepSpec = repSpec;
instance.mIsEditingAttribute = attribute != null;
instance.mApplyAttributeView = new ApplyAttributeView(
repSpec, instance.mProgressControls, instance);
if (attribute != null)
{
instance.mApplyAttributeView.SetAttributeToEdit(attribute);
return instance;
}
instance.mCreateAttributeView = new CreateAttributeView(
repSpec,
workspaceWindow,
instance.mApplyAttributeView,
instance.mProgressControls,
instance);
ApplyAttributeDialogOperations.LoadAttributes(
repSpec, instance.mProgressControls, instance.mApplyAttributeView);
instance.ToggleCreateAttributeView(false);
return instance;
}
protected override string GetTitle()
{
if (mShowCreateAttributeView)
return PlasticLocalization.Name.CreateAttribute.GetString();
if (mIsEditingAttribute)
return PlasticLocalization.Name.EditAttributeTitle.GetString();
return PlasticLocalization.Name.ApplyAttribute.GetString();
}
protected override string GetExplanation()
{
if (mShowCreateAttributeView)
return PlasticLocalization.Name.CreateAttributeExplanation.GetString(mRepSpec);
return PlasticLocalization.Name.ApplyAttributeExplanation.GetString();
}
internal override void OkButtonAction()
{
if (mShowCreateAttributeView)
{
mCreateAttributeView.OkButtonAction();
return;
}
mApplyAttributeView.OkButtonAction();
}
internal override void CancelButtonAction()
{
if (mShowCreateAttributeView)
{
ToggleCreateAttributeView(false);
return;
}
base.CancelButtonAction();
}
internal void ToggleCreateAttributeView(bool show)
{
mShowCreateAttributeView = show;
mOkButtonText = mShowCreateAttributeView ?
PlasticLocalization.Name.CreateButton.GetString() :
PlasticLocalization.Name.ApplyButton.GetString();
mCancelButtonText = mShowCreateAttributeView ?
PlasticLocalization.Name.BackButton.GetString() :
PlasticLocalization.Name.CancelButton.GetString();
UnityInternals.UnityEditor.EditorGUI.activeEditor?.EndEditing();
}
protected override void DoComponentsArea()
{
// HACK: GetTitle is not called once the dialog is shown
titleContent.text = GetTitle();
if (mShowCreateAttributeView)
{
mCreateAttributeView.OnGUI();
return;
}
mApplyAttributeView.OnGUI();
}
ApplyAttributeView mApplyAttributeView;
CreateAttributeView mCreateAttributeView;
RepositorySpec mRepSpec;
bool mIsEditingAttribute;
bool mShowCreateAttributeView;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a14bb815cfde49609ae0abed939d849b
timeCreated: 1769698643
@@ -0,0 +1,270 @@
using UnityEngine;
using UnityEditor;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.Attributes;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.Views.Properties;
#if !UNITY_6000_3_OR_NEWER
using EditorGUI = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.EditorGUI;
#endif
namespace Unity.PlasticSCM.Editor.Views.Attributes
{
internal class AttributePanel : AttributePanelOperations.IAttributePanel
{
internal interface IAttributesPanel
{
internal void RemovePanel(AttributePanel attributePanel);
}
internal Vector2 DesiredSize => mDesiredSize;
internal AttributePanel(
RepositorySpec repSpec,
AttributeRealizationInfo attribute,
IProgressControls progressControls,
IAttributesPanel attributesPanel,
IWorkspaceWindow workspaceWindow,
EditorWindow window)
{
mRepSpec = repSpec;
mAttribute = attribute;
mProgressControls = progressControls;
mAttributesPanel = attributesPanel;
mWorkspaceWindow = workspaceWindow;
mWindow = window;
Color solidColor = AttributeColor.FromAttributeName(mAttribute.AttributeName);
mNameForegroundColor = solidColor;
mOutlineColor = new Color(solidColor.r, solidColor.g, solidColor.b, 0.5f);;
mFillColor = new Color(solidColor.r, solidColor.g, solidColor.b, 0.1f);
CalculateTextAndDesiredSize();
}
internal void Update()
{
if (!mbEditButtonClicked)
return;
mbEditButtonClicked = false;
EditButton_Click();
}
internal void OnGUI(float availableWidth)
{
GUIStyle labelStyle = UnityStyles.AttributesPanel.AttributeLabel;
GUIStyle editButtonStyle= UnityStyles.AttributesPanel.AttributeLabelButton;
GUIStyle removeButtonStyle= UnityStyles.AttributesPanel.AttributeLabelRightButton;
float buttonsWidth = editButtonStyle.fixedWidth +
removeButtonStyle.fixedWidth +
editButtonStyle.margin.horizontal +
removeButtonStyle.margin.horizontal +
SEPARATOR_WIDTH + 2 * SEPARATOR_MARGIN;
string cutText = CutText(
mPlainText,
mRichText,
labelStyle,
availableWidth - buttonsWidth,
mNameForegroundColor,
out Vector2 textSize);
Rect totalRect = GUILayoutUtility.GetRect(
0,
0,
GUILayout.Width(textSize.x + buttonsWidth + labelStyle.margin.horizontal),
GUILayout.Height(textSize.y + labelStyle.margin.vertical));
Rect boxRect = new Rect(
totalRect.x + labelStyle.margin.left,
totalRect.y + labelStyle.margin.top,
totalRect.width - labelStyle.margin.horizontal,
totalRect.height - labelStyle.margin.vertical);
Rect editButtonRect = new Rect(
boxRect.x + textSize.x,
boxRect.y + (boxRect.height - editButtonStyle.fixedHeight) / 2,
editButtonStyle.fixedWidth,
editButtonStyle.fixedHeight);
Rect separatorRect = new Rect(
editButtonRect.xMax + SEPARATOR_MARGIN,
boxRect.y,
SEPARATOR_WIDTH,
boxRect.height);
Rect removeButtonRect = new Rect(
separatorRect.xMax + SEPARATOR_MARGIN,
boxRect.y + (boxRect.height - removeButtonStyle.fixedHeight) / 2,
removeButtonStyle.fixedWidth,
removeButtonStyle.fixedHeight);
UnityEditor.EditorGUI.DrawRect(boxRect, mFillColor);
EditorGUI.DrawOutline(boxRect, 1, mOutlineColor);
UnityEditor.EditorGUI.DrawRect(separatorRect, mOutlineColor);
GUI.Label(
boxRect,
new GUIContent(cutText, cutText != mRichText ? mRichText : string.Empty),
labelStyle);
if (GUI.Button(
editButtonRect,
Images.GetEditIcon(),
editButtonStyle))
{
mbEditButtonClicked = true;
}
if (GUI.Button(
removeButtonRect,
Images.GetCloseIcon(),
removeButtonStyle))
{
RemoveButton_Click();
}
}
void AttributePanelOperations.IAttributePanel.DisableEditionMode()
{
mAttribute.Value = mEditAttributeValue;
CalculateTextAndDesiredSize();
PropertiesRefreshNotifier.Notify();
}
void AttributePanelOperations.IAttributePanel.Remove()
{
mAttributesPanel.RemovePanel(this);
PropertiesRefreshNotifier.Notify();
}
void EditButton_Click()
{
ApplyAttributeData applyAttributeData = AttributeDataDialog.BuildForEditAttributeRealization(
mAttribute, mRepSpec, mWorkspaceWindow, mWindow);
if (!applyAttributeData.Result)
return;
mEditAttributeValue = applyAttributeData.AttributeValue;
AttributePanelOperations.ChangeAttributeValue(
mRepSpec, mAttribute, applyAttributeData.AttributeValue,
mProgressControls, this);
}
void RemoveButton_Click()
{
AttributePanelOperations.DeleteAttribute(
mRepSpec, mAttribute, mProgressControls, this);
}
void CalculateTextAndDesiredSize()
{
GUIStyle labelStyle = UnityStyles.AttributesPanel.AttributeLabel;
GUIStyle editButtonStyle = UnityStyles.AttributesPanel.AttributeLabelButton;
GUIStyle removeButtonStyle = UnityStyles.AttributesPanel.AttributeLabelRightButton;
mPlainText = string.Format("{0}: {1}", mAttribute.AttributeName, mAttribute.Value);
mRichText = string.Format(
"<b><color={0}>{1}:</color></b> {2}",
GetHexString(mNameForegroundColor),
mAttribute.AttributeName,
mAttribute.Value);
Vector2 desiredTextSize = labelStyle.CalcSize(new GUIContent(mRichText));
mDesiredSize =
desiredTextSize +
new Vector2(
labelStyle.margin.horizontal +
editButtonStyle.fixedWidth +
removeButtonStyle.fixedWidth +
editButtonStyle.margin.horizontal +
removeButtonStyle.margin.horizontal +
SEPARATOR_WIDTH + 2 * SEPARATOR_MARGIN,
labelStyle.margin.vertical);
}
static string CutText(
string plainText,
string richText,
GUIStyle style,
float availableWidth,
Color nameForegroundColor,
out Vector2 usedSize)
{
usedSize = new Vector2();
availableWidth -= style.margin.horizontal;
Vector2 fullTextSize = style.CalcSize(new GUIContent(richText));
if (fullTextSize.x < availableWidth)
{
usedSize = fullTextSize;
return richText;
}
string textResult = string.Format("<b><color={0}>", GetHexString(nameForegroundColor));
bool bReachedAttributeValue = false;
foreach (char c in plainText)
{
Vector2 currentSize = style.CalcSize(
new GUIContent(
textResult + c + ELLIPSIS + (!bReachedAttributeValue ? "</color></b>" : string.Empty)));
if (currentSize.x >= availableWidth)
return textResult + ELLIPSIS + (!bReachedAttributeValue ? "</color></b>" : string.Empty);
usedSize = currentSize;
textResult += c;
if (!bReachedAttributeValue && c == ':')
{
bReachedAttributeValue = true;
textResult += "</color></b>";
}
}
return textResult + ELLIPSIS;
}
static string GetHexString(Color color)
{
return string.Format(
"#{0}{1}{2}{3}",
((int)(color.r * 255)).ToString("X2"),
((int)(color.g * 255)).ToString("X2"),
((int)(color.b * 255)).ToString("X2"),
((int)(color.a * 255)).ToString("X2"));
}
string mRichText;
string mPlainText;
Vector2 mDesiredSize;
string mEditAttributeValue;
bool mbEditButtonClicked;
readonly Color mNameForegroundColor;
readonly Color mOutlineColor;
readonly Color mFillColor;
readonly RepositorySpec mRepSpec;
readonly AttributeRealizationInfo mAttribute;
readonly IProgressControls mProgressControls;
readonly IAttributesPanel mAttributesPanel;
readonly IWorkspaceWindow mWorkspaceWindow;
readonly EditorWindow mWindow;
const string ELLIPSIS = "...";
const float SEPARATOR_WIDTH = 1;
const float SEPARATOR_MARGIN = 4;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7d5374a12bef4020a4e16051c301ba71
timeCreated: 1769602516
@@ -0,0 +1,249 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.Attributes;
using Unity.PlasticSCM.Editor.UI;
using Unity.PlasticSCM.Editor.UI.Progress;
using Unity.PlasticSCM.Editor.Views.Properties;
namespace Unity.PlasticSCM.Editor.Views.Attributes
{
internal class AttributesPanel :
AttributesPanelOperations.IAttributesPanel,
AttributePanel.IAttributesPanel
{
internal AttributesPanel(
Action repaint,
IWorkspaceWindow workspaceWindow,
EditorWindow window)
{
mRepaint = repaint;
mWorkspaceWindow = workspaceWindow;
mWindow = window;
mProgressControls = new ProgressControlsForViews();
}
internal void UpdateRepositorySpec(RepositorySpec repSpec)
{
mRepSpec = repSpec;
}
internal void UpdateInfo(long objId)
{
if (objId == -1)
{
Clear();
return;
}
if (mObjId == objId)
return;
mObjId = objId;
AttributesPanelOperations.Refresh(
mRepSpec, mObjId, mProgressControls, this);
}
internal void Clear()
{
mObjId = -1;
ClearAttributePanels();
}
internal void Refresh()
{
if (mObjId == -1 || mRepSpec == null)
return;
mIsApplyingAttribute = false;
AttributesPanelOperations.Refresh(
mRepSpec, mObjId, mProgressControls, this);
}
internal void Update()
{
foreach (AttributePanel attributePanel in mAttributePanels)
attributePanel.Update();
if (!mbOpenApplyAttributeDialog)
return;
mbOpenApplyAttributeDialog = false;
ApplyAttributesButton_Click();
}
internal void OnGUI()
{
if (mObjId == -1)
return;
using (new GUILayout.HorizontalScope())
{
EditorGUILayout.Space(HORIZONTAL_MARGIN, false);
DrawAttributePanels(mAttributePanels, mLastValidAvailableWidth - 2 * HORIZONTAL_MARGIN);
EditorGUILayout.Space(HORIZONTAL_MARGIN, false);
}
Rect layoutRect = GUILayoutUtility.GetRect(0, 0, GUILayout.ExpandWidth(true));
if (Event.current.type == EventType.Repaint)
{
mLastValidAvailableWidth = layoutRect.width;
}
DrawAddAttributeButton();
}
internal bool IsAvailable()
{
return mObjId != -1;
}
void DrawAttributePanels(List<AttributePanel> attributePanels, float availableWidth)
{
float currentLineWidth = 0f;
bool isNewLine = true;
bool showScrollbar = mLastDesiredHeight > MAX_HEIGHT;
if (showScrollbar)
availableWidth -= UnityConstants.SCROLLBAR_WIDTH;
mScrollPosition = GUILayout.BeginScrollView(
mScrollPosition,
false,
false,
GUIStyle.none,
showScrollbar ? GUI.skin.verticalScrollbar : GUIStyle.none,
GUILayout.Height(showScrollbar ? MAX_HEIGHT : mLastDesiredHeight));
if (Event.current.type == EventType.Repaint)
mLastDesiredHeight = 0;
using (new GUILayout.VerticalScope())
{
foreach (AttributePanel attributePanel in attributePanels)
{
float panelWidth = attributePanel.DesiredSize.x;
if (currentLineWidth + panelWidth >= availableWidth && !isNewLine)
{
GUILayout.EndHorizontal();
isNewLine = true;
currentLineWidth = 0f;
}
if (isNewLine)
{
GUILayout.BeginHorizontal();
isNewLine = false;
if (Event.current.type == EventType.Repaint)
mLastDesiredHeight += attributePanel.DesiredSize.y;
}
attributePanel.OnGUI(availableWidth);
currentLineWidth = currentLineWidth + panelWidth;
}
if (!isNewLine)
GUILayout.EndHorizontal();
}
GUILayout.EndScrollView();
}
void DrawAddAttributeButton()
{
if (GUILayout.Button(
new GUIContent(
PlasticLocalization.Name.AddAttributeButton.GetString(), Images.GetAddIcon()),
UnityStyles.AttributesPanel.AddAttributeButton,
GUILayout.ExpandWidth(false)))
{
mbOpenApplyAttributeDialog = true;
}
}
void ApplyAttributesButton_Click()
{
ApplyAttributeData applyAttributeData = AttributeDataDialog.BuildForApplyAttribute(
mRepSpec, mWorkspaceWindow, mWindow);
mIsApplyingAttribute = true;
AttributesPanelOperations.ApplyAttribute(
mRepSpec, mObjId, applyAttributeData, mProgressControls, this);
}
void AttributesPanelOperations.IAttributesPanel.Fill(
AttributeRealizationInfo[] attributeRealizations)
{
bool shouldNotify = mIsApplyingAttribute;
mIsApplyingAttribute = false;
ClearAttributePanels();
foreach (AttributeRealizationInfo attribute in attributeRealizations)
{
AttributePanel attributePanel = new AttributePanel(
mRepSpec,
attribute,
mProgressControls,
this,
mWorkspaceWindow,
mWindow);
mAttributePanels.Add(attributePanel);
}
if (shouldNotify)
PropertiesRefreshNotifier.Notify();
mRepaint();
}
void AttributesPanelOperations.IAttributesPanel.EnableApplyAttributesButton()
{
}
void AttributesPanelOperations.IAttributesPanel.DisableApplyAttributesButton()
{
}
void AttributePanel.IAttributesPanel.RemovePanel(AttributePanel attributePanel)
{
mAttributePanels.Remove(attributePanel);
}
void ClearAttributePanels()
{
mAttributePanels.Clear();
}
float mLastDesiredHeight;
float mLastValidAvailableWidth;
Vector2 mScrollPosition;
RepositorySpec mRepSpec;
long mObjId;
bool mbOpenApplyAttributeDialog;
bool mIsApplyingAttribute;
readonly IProgressControls mProgressControls;
readonly List<AttributePanel> mAttributePanels = new List<AttributePanel>();
readonly Action mRepaint;
readonly IWorkspaceWindow mWorkspaceWindow;
readonly EditorWindow mWindow;
const int HORIZONTAL_MARGIN = 2;
const float MAX_HEIGHT = 90f;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ed6af67100cc4771885346e6963669f6
timeCreated: 1769601225
@@ -0,0 +1,137 @@
using UnityEditor;
using UnityEngine;
using Codice.CM.Common;
using PlasticGui;
using PlasticGui.WorkspaceWindow.Attributes;
using PlasticGui.WorkspaceWindow.QueryViews.Attributes;
using Unity.PlasticSCM.Editor.UI;
#if !UNITY_6000_3_OR_NEWER
using EditorGUI = Unity.PlasticSCM.Editor.UnityInternals.UnityEditor.EditorGUI;
#endif
namespace Unity.PlasticSCM.Editor.Views.Attributes
{
internal class CreateAttributeView : IPlasticDialogCloser
{
internal CreateAttributeView(
RepositorySpec repSpec,
IWorkspaceWindow workspaceWindow,
ApplyAttributeDialogOperations.IApplyAttributeDialog applyAttributeView,
IProgressControls progressControls,
AttributeDataDialog parentWindow)
{
mRepSpec = repSpec;
mWorkspaceWindow = workspaceWindow;
mApplyAttributeView = applyAttributeView;
mProgressControls = progressControls;
mParentWindow = parentWindow;
}
void IPlasticDialogCloser.CloseDialog()
{
mParentWindow.ToggleCreateAttributeView(false);
ApplyAttributeDialogOperations.CreateAttribute(
BuildCreationData(),
mWorkspaceWindow,
mProgressControls,
mApplyAttributeView);
}
internal void OkButtonAction()
{
AttributeDataValidation.AsyncValidation(
BuildCreationData(),
this,
mProgressControls);
}
AttributeData BuildCreationData()
{
return new AttributeData(
mRepSpec,
null,
mAttributeName,
mComments);
}
internal void OnGUI()
{
using (new EditorGUILayout.VerticalScope())
{
using (new EditorGUILayout.HorizontalScope())
{
GUILayout.Label(
PlasticLocalization.Name.AttributeNameLabel.GetString(),
GUILayout.Width(HORIZONTAL_ALIGNMENT));
Rect nameRect = GUILayoutUtility.GetRect(
new GUIContent(string.Empty),
EditorStyles.textField,
GUILayout.Width(ENTRIES_WIDTH));
GUI.SetNextControlName(NAME_FIELD_CONTROL_NAME);
mAttributeName = UnityEditor.EditorGUI.TextField(nameRect, mAttributeName);
if (!mWasNameFieldFocused)
{
UnityEditor.EditorGUI.FocusTextInControl(NAME_FIELD_CONTROL_NAME);
mWasNameFieldFocused = true;
}
}
GUILayout.Space(5);
using (new EditorGUILayout.HorizontalScope())
{
using (new EditorGUILayout.VerticalScope(GUILayout.Width(HORIZONTAL_ALIGNMENT)))
{
GUILayout.Space(49);
GUILayout.Label(
PlasticLocalization.Name.AttributeCommentLabel.GetString(),
GUILayout.Width(HORIZONTAL_ALIGNMENT));
}
using (new EditorGUILayout.VerticalScope())
{
Rect commentRect = GUILayoutUtility.GetRect(
new GUIContent(string.Empty),
EditorStyles.textArea,
GUILayout.Height(COMMENTS_HEIGHT),
GUILayout.Width(ENTRIES_WIDTH));
mComments = EditorGUI.ScrollableTextAreaInternal(
commentRect,
mComments,
ref mScrollPosition,
EditorStyles.textArea);
GUILayout.Space(5);
GUILayout.Label(
PlasticLocalization.Name.AttributeHelpLabel.GetString(),
UnityStyles.Dialog.MiniLabelText);
}
}
}
}
string mAttributeName = string.Empty;
string mComments = string.Empty;
Vector2 mScrollPosition;
bool mWasNameFieldFocused;
readonly RepositorySpec mRepSpec;
readonly IWorkspaceWindow mWorkspaceWindow;
readonly ApplyAttributeDialogOperations.IApplyAttributeDialog mApplyAttributeView;
readonly IProgressControls mProgressControls;
readonly AttributeDataDialog mParentWindow;
const int HORIZONTAL_ALIGNMENT = 100;
const int COMMENTS_HEIGHT = 200;
const int ENTRIES_WIDTH = 350;
const string NAME_FIELD_CONTROL_NAME = "CreateAttributeNameField";
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 56ea95e3e56f40af895e3479028feb82
timeCreated: 1769784765