using System; using System.Collections.Generic; using UnityEditor.Experimental.GraphView; using UnityEditor.Search; using UnityEngine; using UnityEngine.UIElements; namespace UnityEditor.VFX.UI { class VFXStickyNoteController : VFXUIController { public VFXStickyNoteController(VFXViewController viewController, VFXUI ui, int index) : base(viewController, ui, index) { // Happens when the sticky note comes from an older version (different UI) if (colorTheme == 0) { // Slightly increase width to prevent the title from being wrapped because of the space taken by the color swatches position = new Rect(position.x, position.y, position.width + 6, position.height); // Convert old theme to new theme colorTheme = string.Compare(m_UI.stickyNoteInfos[m_Index].theme, nameof(StickyNoteTheme.Black), StringComparison.OrdinalIgnoreCase) == 0 ? 2 : 1; } } public string contents { get { if (m_Index < 0) return ""; return m_UI.stickyNoteInfos[m_Index].contents; } set { if (m_Index < 0) return; m_UI.stickyNoteInfos[m_Index].contents = value; Modified(); } } protected override VFXUI.StickyNoteInfo[] infos => m_UI.stickyNoteInfos; public int colorTheme { get => m_UI.stickyNoteInfos[m_Index].colorTheme; set { if (value != colorTheme) { m_UI.stickyNoteInfos[m_Index].colorTheme = value; Modified(); } } } public string fontSize { get => m_UI.stickyNoteInfos[m_Index].textSize; set { m_UI.stickyNoteInfos[m_Index].textSize = value; Modified(); } } } class VFXStickyNote : StickyNote, IControlledElement, IVFXMovable { const int k_DefaultThemeColor = 1; int m_ColorTheme; VFXStickyNoteController m_Controller; readonly DropdownField m_FontSizeDropdown; public VFXStickyNote() : base(VisualEffectAssetEditorUtility.editorResourcesPath + "/uxml/VFXStickyNote.uxml", Vector2.zero) { this.styleSheets.Add(EditorGUIUtility.Load("StyleSheets/GraphView/Selectable.uss") as StyleSheet); this.styleSheets.Add(EditorGUIUtility.Load("StyleSheets/GraphView/StickyNote.uss") as StyleSheet); this.Q