Exemplo n.º 1
0
        private void DrawChapterContent(int position)
        {
            bool isActiveChapter = (activeChapter == position);

            GUILayout.BeginHorizontal();
            {
                GUILayout.Space(TabSpace);
                if (isActiveChapter)
                {
                    GUILayout.Space(ChapterPadding);
                }

                EditorColorUtils.SetTransparency(isActiveChapter ? 0.8f : 0.25f);
                GUILayout.Label(folderIcon.Texture, GUILayout.Width(ButtonSize), GUILayout.Height(ButtonSize));
                EditorColorUtils.ResetColor();

                GUIStyle style = new GUIStyle(GUI.skin.label);
                style.alignment = TextAnchor.MiddleLeft;
                GUILayout.Label(Course.Data.Chapters[position].Data.Name, style, GUILayout.Width(160f), GUILayout.Height(20f));
                Rect labelPosition = GUILayoutUtility.GetLastRect();

                GUILayout.FlexibleSpace();
                AddMoveUpButton(position);
                AddMoveDownButton(position);
                AddRemoveButton(position, Course.Data.Chapters.Count == 1);
                AddRenameButton(position, labelPosition);
            }
            GUILayout.EndHorizontal();
        }
Exemplo n.º 2
0
        private static bool FlatIconButton(Texture icon)
        {
            EditorColorUtils.SetTransparency(0.25f);
            bool isTriggered = GUILayout.Button(icon, EditorStyles.label, GUILayout.Width(ButtonSize), GUILayout.Height(ButtonSize));
            // Creating a highlight effect if the mouse is currently hovering the button.
            Rect buttonRect = GUILayoutUtility.GetLastRect();

            if (buttonRect.Contains(Event.current.mousePosition))
            {
                EditorColorUtils.SetTransparency(0.5f);
                GUI.Label(buttonRect, icon);
            }

            EditorColorUtils.ResetColor();
            return(isTriggered);
        }
Exemplo n.º 3
0
        private void DrawChapter(int position)
        {
            EditorColorUtils.ResetBackgroundColor();
            if (position != activeChapter)
            {
                if (EditorGUIUtility.isProSkin)
                {
                    EditorColorUtils.SetBackgroundColor(Color.gray);
                }
            }
            else if (EditorGUIUtility.isProSkin == false)
            {
                EditorColorUtils.SetBackgroundColor(new Color(0.8f, 0.8f, 0.8f));
            }

            GUILayout.BeginHorizontal("box");
            {
                EditorColorUtils.ResetBackgroundColor();
                GUILayout.BeginVertical();
                {
                    GUILayout.Space(ChapterPadding);
                    DrawChapterContent(position);
                    GUILayout.Space(ChapterPadding);
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();

            Rect rect = GUILayoutUtility.GetLastRect();

            if (rect.Contains(Event.current.mousePosition))
            {
                if (Event.current.GetTypeForControl(GUIUtility.GetControlID(FocusType.Passive)) == EventType.MouseDown)
                {
                    activeChapter = position;
                    EmitChapterChanged();

                    Event.current.Use();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Draws the training menu.
        /// </summary>
        public void Draw()
        {
            IsExtended = isExtended;
            GUILayout.BeginArea(new Rect(0f, 0f, IsExtended ? ExtendedMenuWidth : MinimizedMenuWidth, ParentWindow.position.size.y));
            {
                if (EditorGUIUtility.isProSkin)
                {
                    EditorColorUtils.SetBackgroundColor(Color.black);
                }

                GUILayout.BeginVertical("box");
                {
                    DrawExtendToggle();

                    EditorColorUtils.ResetBackgroundColor();

                    Vector2 deltaPosition = GUILayout.BeginScrollView(scrollPosition);
                    {
                        if (IsExtended)
                        {
                            DrawHeader();
                            DrawChapterList();
                            AddChapterButton();
                        }
                    }
                    GUILayout.EndScrollView();

                    if (changeNamePopup == null || changeNamePopup.IsClosed)
                    {
                        scrollPosition = deltaPosition;
                    }
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndArea();
        }