示例#1
0
        private void ShowArt()
        {
            m_group ^= ToolbarGroup.Art;

            DisposeControls(~m_group);
            PopulateControls(m_group);
        }
示例#2
0
        private void ShowDesign()
        {
            m_group ^= ToolbarGroup.Design;

            DisposeControls(~m_group);
            PopulateControls(m_group);
        }
示例#3
0
 public AddToToolbarAttribute(string name, string tooltip, ToolbarGroup group = ToolbarGroup.Any, int order = 99)
 {
     m_name    = name;
     m_order   = order;
     m_group   = group;
     m_tooltip = tooltip;
 }
示例#4
0
        private void ShowCode()
        {
            m_group ^= ToolbarGroup.Code;

            DisposeControls(~m_group);
            PopulateControls(m_group);
        }
示例#5
0
        /// <summary>
        /// Initialize the toolbar control.
        /// </summary>
        /// <param name="label">The button label and tooltip.</param>
        /// <param name="order">The order of the toggle in toolbar, 99 by default.</param>
        /// <param name="group">The toolbar group, ToolbarGroup.Any by default.</param>
        public void Init(string path, string name, string tooltip, int order, ToolbarGroup group)
        {
            m_order = order;
            m_group = group;
            m_label = new GUIContent(name, tooltip);

            hideFlags = HideFlags.HideAndDontSave;
        }
示例#6
0
        /// <summary>
        /// Dispose controls and remove them from the list.
        /// </summary>
        private void DisposeControls(ToolbarGroup group)
        {
            for (int i = m_controls.Count - 1; i >= 0; i--)
            {
                ToolbarControl control = m_controls [i];

                if ((group & control.Group) == control.Group)
                {
                    DestroyImmediate(control);
                    m_controls.RemoveAt(i);
                }
            }
        }
示例#7
0
        private void PopulateControls(ToolbarGroup group)
        {
            foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
            {
                AddToToolbarAttribute attribute = Attribute.GetCustomAttribute(type, typeof(AddToToolbarAttribute)) as AddToToolbarAttribute;

                // Skip types without attribute and that don't match category
                if (attribute == null || (group & attribute.Group) != attribute.Group)
                {
                    continue;
                }

                // Skip types that are already in the list or not properly defined
                if (m_controls.Find(x => x.name == "" || x.name == attribute.Name))
                {
                    continue;
                }

                if (type.BaseType == typeof(EditorWindow))
                {
                    ToggleEditorWindow control = CreateInstance <ToggleEditorWindow> ();

                    control.name = attribute.Name;
                    control.Init(m_path, type, attribute.Name, attribute.Tooltip, attribute.Order, attribute.Group);

                    m_controls.Add(control);
                }
                else if (type.BaseType == typeof(SceneWindow))
                {
                    ToggleSceneWindow control = CreateInstance <ToggleSceneWindow> ();

                    control.name = attribute.Name;
                    control.Init(m_path, type, attribute.Name, attribute.Tooltip, attribute.Order, attribute.Group);

                    m_controls.Add(control);
                }
                else
                {
                    ToolbarControl control = (ToolbarControl)CreateInstance(type);

                    control.name = attribute.Name;
                    control.Init(m_path, attribute.Name, attribute.Tooltip, attribute.Order, attribute.Group);

                    m_controls.Add(control);
                }
            }

            // Sort controls by order
            m_controls.Sort((x, y) => (x.Order).CompareTo(y.Order));
        }
            /// <since>5.0</since>
            public ToolbarGroup GetGroup(string name)
            {
                int count = GroupCount;

                for (int i = 0; i < count; i++)
                {
                    ToolbarGroup group = GetGroup(i);
                    if (string.Compare(group.Name, name) == 0)
                    {
                        return(group);
                    }
                }
                return(null);
            }
示例#9
0
        /// <summary>
        /// Initialize the scene window toggle.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="label">The button label and tooltip.</param>
        /// <param name="order">The order of the toggle in toolbar, 99 by default.</param>
        /// <param name="group">The toolbar group, ToolbarGroup.Any by default.</param>
        public void Init(string path, Type type, string name, string tooltip, int order, ToolbarGroup group)
        {
            m_icon = AssetDatabase.LoadAssetAtPath <Texture> (path + "/Editor/Icons/Icon" + name + ".png") as Texture;

            if (m_icon == null)
            {
                m_icon = AssetDatabase.LoadAssetAtPath <Texture> (path + "/Editor/Icons/IconDefault.png") as Texture;
            }

            m_order = order;
            m_group = group;
            m_type  = type.AssemblyQualifiedName;
            m_label = new GUIContent(m_icon, tooltip);

            hideFlags = HideFlags.HideAndDontSave;
        }
示例#10
0
        /// <summary>
        /// Initialize the scene window toggle.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="label">The button label and tooltip.</param>
        /// <param name="order">The order of the toggle in toolbar, 99 by default.</param>
        /// <param name="group">The toolbar group, ToolbarGroup.Any by default.</param>
        public void Init(string path, Type type, string name, string tooltip, int order, ToolbarGroup group)
        {
            m_icon = AssetDatabase.LoadAssetAtPath <Texture> (path + "/Editor/Icons/Icon" + name + ".png") as Texture;

            if (m_icon == null)
            {
                m_icon = AssetDatabase.LoadAssetAtPath <Texture> (path + "/Editor/Icons/IconDefault.png") as Texture;
            }

            m_order = order;
            m_group = group;
            m_label = new GUIContent(m_icon, tooltip);

            hideFlags          = HideFlags.HideAndDontSave;
            m_window           = (SceneWindow)CreateInstance(type);
            m_window.hideFlags = HideFlags.HideAndDontSave;
        }
示例#11
0
 /**
  * Get the background button style for a toolbar group.
  */
 public static GUIStyle GetStyle(ToolbarGroup group, bool isHorizontal)
 {
     if (group == ToolbarGroup.Tool)
     {
         return(GetBackgroundStyle("Tool", isHorizontal));
     }
     else if (group == ToolbarGroup.Selection)
     {
         return(GetBackgroundStyle("Selection", isHorizontal));
     }
     else if (group == ToolbarGroup.Object || group == ToolbarGroup.Entity)
     {
         return(GetBackgroundStyle("Object", isHorizontal));
     }
     else // if( group == pb_ToolbarGroup.Geometry )
     {
         return(GetBackgroundStyle("Geo", isHorizontal));
     }
 }
示例#12
0
        /// <summary>
        /// Enable the toolbar window.
        /// </summary>
        private void OnEnable()
        {
            if (m_controls == null)
            {
                m_group      = ToolbarGroup.All;
                minSize      = new Vector2(30, 30);
                m_controls   = new List <ToolbarControl> ();
                titleContent = new GUIContent("Toolbar", "A custom toolbar container.");

                // Load toolbar group
                if (EditorPrefs.HasKey("ToolbarGroup"))
                {
                    m_group = (ToolbarGroup)EditorPrefs.GetInt("ToolbarGroup");
                }

                m_path = AssetUtility.FindAssetPath("EditorToolbar", "t:Folder");

                PopulateControls(m_group);
            }
        }
示例#13
0
        public static Color GetColor(ToolbarGroup group)
        {
            if (group == ToolbarGroup.Tool)
            {
                return(ToolColor);
            }
            else if (group == ToolbarGroup.Selection)
            {
                return(SelectionColor);
            }
            else if (group == ToolbarGroup.Object || group == ToolbarGroup.Entity)
            {
                return(ObjectColor);
            }
            else if (group == ToolbarGroup.Geometry)
            {
                return(GeometryColor);
            }

            return(Color.white);
        }
示例#14
0
        protected override void OnActivate()
        {
            base.OnActivate();

            Start();
            SearchPane.PropertyChanged += OnSearchPanePropertyChanged;
            ((IActivate)SearchPane).Activate();

            if (_toolbarGroup == null)
            {
                _toolbarGroup = new ToolbarGroup(10)
                {
                    new ToolbarAction(this, "Add", Add),
                    new ToolbarAction(this, "Delete", Delete),
                    new ToolbarAction(this, "Edit", Edit),
                    new ToolbarAction(this, "Save", Save),
                    new ToolbarAction(this, "Cancel", Cancel),
                    new ToolbarAction(this, "Refresh", RefreshData)
                };
            }
            _toolbar.AddGroup(_toolbarGroup);
        }
示例#15
0
        private async void StartAsync()
        {
            var mainGroup = new ToolbarGroup(0);

            _workspaces.OrderBy(w => w.Sequence).ForEach(
                w => mainGroup.Add(new ToolbarAction(this, w.DisplayName, async() => await NavigateToWorkspace(w))));

            var logoutGroup = new ToolbarGroup(100)
            {
                new ToolbarAction(this, "Logout", Logout)
            };

            Toolbar.Clear();
            Toolbar.AddGroup(mainGroup);
            Toolbar.AddGroup(logoutGroup);

            var home = GetHomeScreen();

            if (home != null)
            {
                await NavigateToWorkspace(home);
            }
        }
示例#16
0
 public void RemoveGroup(ToolbarGroup @group)
 {
     _groups.Remove(@group);
     NotifyOfPropertyChange(() => Actions);
     NotifyOfPropertyChange(() => Groups);
 }
示例#17
0
 public void AddGroup(ToolbarGroup @group)
 {
     _groups.Add(@group);
     NotifyOfPropertyChange(() => Actions);
     NotifyOfPropertyChange(() => Groups);
 }
示例#18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="menu"></param>
 private void ShowAll()
 {
     m_group = ToolbarGroup.All;
     PopulateControls(m_group);
 }