コード例 #1
0
        /// <summary>
        /// Constructor of the ComponentTypeVisualElement.
        /// Given an component type, a visual element contains <see cref="CustomToolbarToggle"/>
        /// and an icon representing its access mode will be created.
        /// <para><see cref="ComponentType"/>></para>>
        /// </summary>
        public ComponentToggleWithAccessMode(ComponentType.AccessMode accessMode)
        {
            this.AddToClassList(UssClasses.SystemScheduleWindow.Detail.EachComponentContainer);

            // Access mode.
            var componentAccessModeIcon = new Image()
            {
                tooltip = accessMode.ToString()
            };

            componentAccessModeIcon.AddToClassList(UssClasses.SystemScheduleWindow.Detail.ComponentAccessModeIcon);
            componentAccessModeIcon.AddToClassList(EntityQueryUtility.StyleForAccessMode(accessMode));

            // Component toggle.
            ComponentTypeNameToggle = new CustomToolbarToggle();
            ComponentTypeNameToggle.AddPreIcon(componentAccessModeIcon);
            this.Add(ComponentTypeNameToggle);
        }
コード例 #2
0
        public void AddPreIcon(Image preIcon)
        {
            this.Insert(0, preIcon);
            preIcon.RegisterCallback <MouseDownEvent>(evt =>
            {
                this.value = !this.value;
            });
            preIcon.AddToClassList(UssClasses.DotsEditorCommon.CustomToolbarToggleIcon);

            m_Label = this.Q <Label>();

            m_Label.RemoveFromClassList(UssClasses.DotsEditorCommon.CustomToolbarToggleOnlyLabel);
            m_Label.AddToClassList(UssClasses.DotsEditorCommon.CustomToolbarToggleLabel);
        }