void CreateButton() { AddToClassList("unity-enum-field"); m_DropDownButton = new Label(); m_DropDownButton.AddToClassList("unity-enum-field__input"); m_DropDownButton.AddManipulator(new DownClickable(OnClick)); }
public FoldoutWithCheckbox() { m_Toggle.text = string.Empty; m_Toggle.style.flexGrow = 0; m_Checkbox = new Toggle(); m_Checkbox.style.flexGrow = 0; m_Checkbox.AddToClassList(k_CheckboxClassName); m_Checkbox.RegisterValueChangedCallback(e => SetCheckboxValueWithoutNotify(e.newValue)); m_Header.hierarchy.Add(m_Checkbox); m_Label = new Label(); m_Label.AddToClassList(k_LabelClassName); m_Label.AddManipulator(new Clickable(evt => { if ((evt as MouseUpEvent)?.button == (int)MouseButton.LeftMouse) { m_Toggle.value = !m_Toggle.value; } })); m_Header.hierarchy.Add(m_Label); styleSheets.Add(BuilderPackageUtilities.LoadAssetAtPath <StyleSheet>(k_UssPath)); }
public VFXUniformOperatorEdit() { this.AddStyleSheetPathWithSkinVariant("VFXControls"); AddToClassList("VFXUniformOperatorEdit"); m_TypePopup = new Label(); m_TypePopup.AddToClassList("PopupButton"); m_TypePopup.AddManipulator(new DownClickable(() => OnTypeMenu())); Add(m_TypePopup); }
public PreviewSelector() { UIElementsUtils.ApplyStyleSheet("PreviewSelector.uss", this); AddToClassList("previewSelector"); // Target Selection { var selectorContainer = new VisualElement(); selectorContainer.AddToClassList("selectorContainer"); var selectorClick = new Clickable(OnSelectorClicked); selectorContainer.AddManipulator(selectorClick); Label label = new Label { text = "Target" }; var labelClick = new Clickable(OnSelectorClicked); label.AddManipulator(labelClick); m_SelectorDropdown = new Image(); m_SelectorDropdown.AddToClassList("selectorDropdown"); m_SelectorDropdown.RegisterCallback <DragUpdatedEvent>(OnDragUpdate); m_SelectorDropdown.RegisterCallback <DragPerformEvent>(OnDragPerform); selectorContainer.Add(label); selectorContainer.Add(m_SelectorDropdown); Add(selectorContainer); } //Target label { m_TargetContainer = new VisualElement(); m_TargetContainer.AddToClassList("targetContainer"); var containerClick = new Clickable(OnTargetClicked); m_TargetContainer.AddManipulator(containerClick); Image gameObjectIcon = new Image(); gameObjectIcon.AddToClassList("gameObjectIcon"); gameObjectIcon.RegisterCallback <DragUpdatedEvent>(OnDragUpdate); gameObjectIcon.RegisterCallback <DragPerformEvent>(OnDragPerform); m_TargetLabel = new Label { text = k_DefaultLabelText }; m_TargetLabel.AddToClassList("previewLabel"); m_TargetLabel.RegisterCallback <DragUpdatedEvent>(OnDragUpdate); m_TargetLabel.RegisterCallback <DragPerformEvent>(OnDragPerform); m_TargetContainer.Add(gameObjectIcon); m_TargetContainer.Add(m_TargetLabel); Add(m_TargetContainer); } RegisterCallback <DragUpdatedEvent>(OnDragUpdate); RegisterCallback <DragPerformEvent>(OnDragPerform); }
public OperandInfoBase(VFXMultiOperatorEdit <T, U> owner, U op, int index) { this.AddStyleSheetPathWithSkinVariant("VFXControls"); m_Owner = owner; type = new Label(); this.index = index; type.AddToClassList("PopupButton"); type.AddManipulator(new DownClickable(OnTypeMenu)); Add(type); }
static void SetupLabel(string labelName, string text, Manipulator manipulator = null) { Label label = root.Query <Label>(labelName); label.text = text; if (manipulator == null) { return; } label.AddManipulator(manipulator); }
/// <summary> /// Initializes the frontend and backend of a label /// </summary> /// <param name="labelName">The name of the label in the UXML file</param> /// <param name="text">The text the label will display</param> /// <param name="parent">The parent VisualElement of the label</param> /// <param name="manipulator">A Manipulator implementation that defines custom interactions with this label</param> public static void SetupLabel(string labelName, string text, VisualElement parent, Manipulator manipulator = null) { Label label = parent.Query <Label>(labelName); label.text = text; if (manipulator == null) { return; } label.AddManipulator(manipulator); }
void SetupLoadSavedMenu() { //Setup the dropdown menu ContextualMenuManipulator m = new ContextualMenuManipulator(BuildSavedPatternMenu); m.target = _RootElement; Label label = _ControlElement.Query <Label>("Load"); if (label != null) { label.AddManipulator(m); } }
public BreadcrumbElement(string path, string crumbName, Action <string> callback) { Path = path; var xmlAsset = Resources.Load <VisualTreeAsset>("GraphTheory/UIElements/Breadcrumbs/BreadcrumbElement"); xmlAsset.CloneTree(this); Label label = this.Q <Label>(BREADCRUMB_NAME_LABEL); label.text = crumbName; label.AddManipulator(new Clickable(() => { callback?.Invoke(Path); })); }
void SetupSoundBankMenu() { //Setup the dropdown menu ContextualMenuManipulator loadSoundBanksMenu = new ContextualMenuManipulator(BuildSoundBankMenu); loadSoundBanksMenu.target = _RootElement; Label soundBankLabel = _ControlElement.Query <Label>("LoadSoundBank"); if (soundBankLabel != null) { soundBankLabel.AddManipulator(loadSoundBanksMenu); } }
void SetupLabel(string labelName, string text, VisualElement parent = null, Manipulator manipulator = null, bool localize = false) { if (parent == null) { parent = rootVisualElement; } Label label = parent.Query <Label>(labelName); label.text = localize ? Localization.Tr(text) : text; if (manipulator == null) { return; } label.AddManipulator(manipulator); }
void SetupLabel(string labelName, string text, VisualElement parent = null, Manipulator manipulator = null) { if (parent == null) { parent = rootVisualElement; } Label label = parent.Query <Label>(labelName); label.text = text; if (manipulator == null) { return; } label.AddManipulator(manipulator); }
protected override void CreateVisualElements(SerializedProperty property) { _currentNameLabel = new Label("None"); _currentNameLabel.AddToClassList("bb-name-dropdown"); FieldsContainer.Add(_currentNameLabel); UpdateNames(property); var currentName = property.FindPropertyRelative("_name").stringValue; SetNewName(currentName); var manipulator = new ContextualMenuManipulator(PopulateContextMenu); _currentNameLabel.AddManipulator(manipulator); }
void CreateHierarchy() { AddToClassList("unity-enum-field"); m_DropDownButton = new Label(); m_DropDownButton.AddToClassList("unity-enum-field__input"); m_DropDownButton.AddManipulator(new DownClickable(OnClick)); m_ValueText = new TextElement(); m_ValueText.AddToClassList("unity-enum-field__text"); var icon = new VisualElement() { name = "icon" }; icon.AddToClassList("unity-enum-field__arrow"); m_DropDownButton.Add(m_ValueText); m_DropDownButton.Add(icon); }
public NodeTaskProvider(TaskNodeData data) { CurrentType = data?.TaskImplementation?.GetType(); _currentTaskIndex = TaskFactory.GetIndex(CurrentType); var manipulator = new ContextualMenuManipulator(CreateMenu); manipulator.activators.Add(new ManipulatorActivationFilter() { button = MouseButton.LeftMouse, clickCount = 1 }); _label = new Label(); _label.text = ObjectNames.NicifyVariableName(TaskFactory.NamesEditor[_currentTaskIndex]); _label.style.fontSize = 13; _label.AddToClassList("node-task-button"); _label.AddManipulator(manipulator); Add(_label); }
VisualElement MakeItem() { var label = new Label(); label.AddToClassList("toggleItem"); Clickable c = new Clickable(() => { var taggedAnimationClip = label.userData as TaggedAnimationClip; if (taggedAnimationClip != null) { EditorGUIUtility.PingObject(taggedAnimationClip.GetOrLoadClipSync()); } ToggleClip(taggedAnimationClip); Refresh(); }); label.AddManipulator(c); return(label); }
public CollabHistoryDropDown(ICollection <ChangeData> changes, int changesTotal, bool changesTruncated, string revisionId) { m_FilesContainer = new VisualElement(); m_ChangesTotal = changesTotal; m_RevisionId = revisionId; m_ToggleLabel = new Label(ToggleText(false)); m_ToggleLabel.AddManipulator(new Clickable(ToggleDropdown)); Add(m_ToggleLabel); foreach (ChangeData change in changes) { m_FilesContainer.Add(new CollabHistoryDropDownItem(change.path, change.action)); } if (changesTruncated) { m_FilesContainer.Add(new Button(ShowAllClick) { text = "Show all on dashboard" }); } }
public GraphInspectorView(string assetName, PreviewManager previewManager, AbstractMaterialGraph graph) { m_Graph = graph; AddStyleSheetPath("Styles/MaterialGraph"); var topContainer = new VisualElement { name = "top" }; { var headerContainer = new VisualElement { name = "header" }; { var title = new Label(assetName) { name = "title" }; title.AddManipulator(new Clickable(() => { if (onShowInProjectClick != null) { onShowInProjectClick(); } })); headerContainer.Add(title); headerContainer.Add(new Button(() => { if (onUpdateAssetClick != null) { onUpdateAssetClick(); } }) { name = "save", text = "Save" }); } topContainer.Add(headerContainer); var propertiesContainer = new VisualElement { name = "properties" }; { var header = new VisualElement { name = "header" }; { var title = new Label("Properties") { name = "title" }; header.Add(title); var addPropertyButton = new Button(OnAddProperty) { text = "Add", name = "addButton" }; header.Add(addPropertyButton); } propertiesContainer.Add(header); m_PropertyItems = new VisualContainer { name = "items" }; propertiesContainer.Add(m_PropertyItems); } topContainer.Add(propertiesContainer); } Add(topContainer); foreach (var property in m_Graph.properties) { m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property)); } Add(new ResizeBorderFrame(this) { name = "resizeBorderFrame" }); this.AddManipulator(new WindowDraggable()); }
void CreateButton() { m_DropDownButton = new Label(); m_DropDownButton.AddToClassList("PopupButton"); m_DropDownButton.AddManipulator(new DownClickable(OnClick)); }
public void Initialize(AbstractMaterialNode inNode, PreviewManager previewManager, IEdgeConnectorListener connectorListener) { AddToClassList("MaterialNode"); if (inNode == null) { return; } m_ConnectorListener = connectorListener; node = inNode; persistenceKey = node.guid.ToString(); UpdateTitle(); m_ControlsContainer = new VisualElement { name = "controls" }; extensionContainer.Add(m_ControlsContainer); m_ControlsDivider = new VisualElement { name = "divider" }; m_ControlsDivider.AddToClassList("horizontal"); if (node.hasPreview) { m_PreviewContainer = new VisualElement { name = "previewContainer" }; m_PreviewContainer.AddToClassList("expanded"); { m_PreviewTextureView = new PreviewTextureView { name = "preview", pickingMode = PickingMode.Ignore, image = Texture2D.whiteTexture }; m_PreviewRenderData = previewManager.GetPreview(inNode); m_PreviewRenderData.onPreviewChanged += UpdatePreviewTexture; UpdatePreviewTexture(); var collapsePreviewButton = new VisualElement { name = "collapse" }; collapsePreviewButton.Add(new VisualElement { name = "icon" }); collapsePreviewButton.AddManipulator(new Clickable(() => { node.owner.owner.RegisterCompleteObjectUndo("Collapse Preview"); UpdatePreviewExpandedState(false); })); UpdatePreviewExpandedState(node.previewExpanded); m_PreviewTextureView.Add(collapsePreviewButton); var expandPreviewButton = new VisualElement { name = "expand" }; expandPreviewButton.Add(new VisualElement { name = "icon" }); expandPreviewButton.AddManipulator(new Clickable(() => { node.owner.owner.RegisterCompleteObjectUndo("Expand Preview"); UpdatePreviewExpandedState(true); })); m_PreviewContainer.Add(expandPreviewButton); } extensionContainer.Add(m_PreviewContainer); } m_ControlViews = new List <VisualElement>(); foreach (var propertyInfo in node.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { foreach (IControlAttribute attribute in propertyInfo.GetCustomAttributes(typeof(IControlAttribute), false)) { m_ControlViews.Add(attribute.InstantiateControl(node, propertyInfo)); } } m_Attachers = new List <Attacher>(node.GetInputSlots <MaterialSlot>().Count()); AddSlots(node.GetSlots <MaterialSlot>()); UpdateSlotAttachers(); base.expanded = node.drawState.expanded; RefreshExpandedState(); //This should not be needed. GraphView needs to improve the extension api here UpdatePortInputVisibilities(); SetPosition(new Rect(node.drawState.position.x, node.drawState.position.y, 0, 0)); UpdateControls(); if (node is PreviewNode) { var resizeHandle = new Label { name = "resize", text = "" }; resizeHandle.AddManipulator(new Draggable(OnResize)); Add(resizeHandle); UpdateSize(); } }
public GraphInspectorView(string assetName, PreviewManager previewManager, AbstractMaterialGraph graph) { m_Graph = graph; AddStyleSheetPath("Styles/MaterialGraph"); var topContainer = new VisualElement { name = "top" }; { var headerContainer = new VisualElement { name = "header" }; { var title = new Label(assetName) { name = "title" }; title.AddManipulator(new Clickable(() => { if (onShowInProjectClick != null) { onShowInProjectClick(); } })); headerContainer.Add(title); headerContainer.Add(new Button(() => { if (onUpdateAssetClick != null) { onUpdateAssetClick(); } }) { name = "save", text = "Save" }); } topContainer.Add(headerContainer); var propertiesContainer = new VisualElement { name = "properties" }; { var header = new VisualElement { name = "header" }; { var title = new Label("Properties") { name = "title" }; header.Add(title); var addPropertyButton = new Button(OnAddProperty) { text = "Add", name = "addButton" }; header.Add(addPropertyButton); } propertiesContainer.Add(header); m_PropertyItems = new VisualContainer { name = "items" }; propertiesContainer.Add(m_PropertyItems); } topContainer.Add(propertiesContainer); } Add(topContainer); var bottomContainer = new VisualElement { name = "bottom" }; { m_PreviewTextureView = new PreviewTextureView { name = "preview", image = Texture2D.blackTexture }; m_PreviewTextureView.AddManipulator(new Draggable(OnMouseDrag, true)); bottomContainer.Add(m_PreviewTextureView); m_PreviewScrollPosition = new Vector2(0f, 0f); m_PreviewMeshPicker = new ObjectField { objectType = typeof(Mesh) }; m_PreviewMeshPicker.OnValueChanged(OnPreviewMeshChanged); bottomContainer.Add(m_PreviewMeshPicker); } Add(bottomContainer); m_PreviewRenderHandle = previewManager.masterRenderData; m_PreviewRenderHandle.onPreviewChanged += OnPreviewChanged; m_PreviewMeshPicker.SetValueAndNotify(m_Graph.previewData.serializedMesh.mesh); foreach (var property in m_Graph.properties) { m_PropertyItems.Add(new ShaderPropertyView(m_Graph, property)); } Add(new ResizeSideHandle(this, ResizeHandleAnchor.TopLeft, new string[] { "resize", "diagonal", "top-left" })); Add(new ResizeSideHandle(this, ResizeHandleAnchor.Top, new string[] { "resize", "vertical", "top" })); Add(new ResizeSideHandle(this, ResizeHandleAnchor.TopRight, new string[] { "resize", "diagonal", "top-right" })); Add(new ResizeSideHandle(this, ResizeHandleAnchor.Right, new string[] { "resize", "horizontal", "right" })); Add(new ResizeSideHandle(this, ResizeHandleAnchor.BottomRight, new string[] { "resize", "diagonal", "bottom-right" })); Add(new ResizeSideHandle(this, ResizeHandleAnchor.Bottom, new string[] { "resize", "vertical", "bottom" })); Add(new ResizeSideHandle(this, ResizeHandleAnchor.BottomLeft, new string[] { "resize", "diagonal", "bottom-left" })); Add(new ResizeSideHandle(this, ResizeHandleAnchor.Left, new string[] { "resize", "horizontal", "left" })); }