示例#1
0
        public void SwitchTo(FormatMode newMode)
        {
            if (m_currentMode == newMode)
            {
                return;
            }

            BaseViewer preViewer = GetCurrentMode();

            if (preViewer != null)
            {
                preViewer.OnLeave();
            }

            m_currentMode = newMode;

            BaseViewer curViewer = GetCurrentMode();

            if (curViewer != null)
            {
                curViewer.OnEnter();
            }

            EditorPrefs.SetInt(TableConst.CurrentMode, (int)(m_currentMode));
        }
示例#2
0
        public void OnGUI(Rect rect)
        {
            GUILayout.BeginHorizontal(TableStyles.Toolbar);
            GUILayout.Label("Mode: ", GUILayout.MaxWidth(60));
            int selMode = GUILayout.SelectionGrid((int)m_currentMode,
                                                  TableConst.Modes, TableConst.Modes.Length, TableStyles.ToolbarButton);

            if (selMode != (int)m_currentMode)
            {
                SwitchTo((FormatMode)selMode);
            }
            GUILayout.EndHorizontal();

            float      yOffset   = TableConst.TopBarHeight;
            Rect       viewRect  = new Rect(0, yOffset, rect.width, rect.height - yOffset);
            BaseViewer viewTable = GetCurrentMode();

            if (viewTable != null)
            {
                viewTable.Draw(viewRect);
            }
        }