コード例 #1
0
 protected void DrawChildren()
 {
     if (m_subviews.Count > 0)
     {
         for (int i = 0; i < m_subviews.Count; ++i)
         {
             CView subview = m_subviews[i];
             if (!subview.IsEnabled && GUI.enabled)
             {
                 GUI.enabled = false;
                 try
                 {
                     subview.OnGUI();
                 }
                 finally
                 {
                     GUI.enabled = true;
                 }
             }
             else
             {
                 subview.OnGUI();
             }
         }
     }
 }
コード例 #2
0
        protected virtual bool KeyDownEventHandler(CView view, CEvent evt)
        {
            switch (evt.keyCode)
            {
            case KeyCode.UpArrow:
            {
                if (m_lastSelectedIndex > m_cellsEntries.HeadIndex && !evt.control)
                {
                    int nextSelectedIndex = m_lastSelectedIndex - 1;
                    ScrollUntilRowVisible(nextSelectedIndex);
                    SwitchSelectedCell(nextSelectedIndex);

                    return(true);
                }

                if (FirstVisibleCellIndex > m_cellsEntries.HeadIndex)
                {
                    if (IsCellFullyVisible(FirstVisibleCellIndex))
                    {
                        ScrollUntilRowVisible(FirstVisibleCellIndex - 1);
                    }
                    else
                    {
                        ScrollUntilRowVisible(FirstVisibleCellIndex);
                    }
                    return(true);
                }

                return(false);
            }

            case KeyCode.DownArrow:
            {
                if (m_lastSelectedIndex != -1 && m_lastSelectedIndex < m_cellsEntries.Length - 1 && !evt.control)
                {
                    int nextSelectedIndex = m_lastSelectedIndex + 1;
                    ScrollUntilRowVisible(nextSelectedIndex);
                    SwitchSelectedCell(nextSelectedIndex);
                    return(true);
                }

                if (LastVisibleCellIndex != 1 && LastVisibleCellIndex < m_cellsEntries.Length - 1)
                {
                    if (IsCellFullyVisible(LastVisibleCellIndex))
                    {
                        ScrollUntilRowVisible(LastVisibleCellIndex + 1);
                    }
                    else
                    {
                        ScrollUntilRowVisible(LastVisibleCellIndex);
                    }
                    return(true);
                }

                return(false);
            }
            }

            return(false);
        }
コード例 #3
0
        void OnGUI()
        {
            if (m_rootView == null)
            {
                m_oldSize = new Vector2(this.Width, this.Height);

                m_rootView = CreateRootView();
                if (m_rootView == null)
                {
                    throw new NullReferenceException("Root view should not be null");
                }

                CreateUI();
                RunStart();
            }

            if (m_oldSize.x != this.Width ||
                m_oldSize.y != this.Height)
            {
                m_oldSize = new Vector2(this.Width, this.Height);
                OnSizeChanged();
            }

            m_rootView.OnGUI();
            m_dirty = true;

            CEvent.Destroy();
        }
コード例 #4
0
 public void RemoveSubview(CView view)
 {
     if (view.ParentView == this)
     {
         m_subviews.Remove(view);
         view.ParentView = null;
     }
 }
コード例 #5
0
        protected override void CreateUI()
        {
            const float indent = 12;

            CView contentView = new CView(this.Width - 2 * indent, this.Height - 2 * indent);

            contentView.X = indent;
            contentView.Y = indent;
            AddSubview(contentView);

            GUIStyle titleStyle = new GUIStyle(GUI.skin.label);

            titleStyle.fontSize = 20;
            CLabel titleLabel = new CLabel("Lunar Plugin for Unity", titleStyle);

            contentView.AddSubview(titleLabel);

            CLabel copyrightLabel = new CLabel("(C) 2015  Space Madness", EditorStyles.miniLabel);

            copyrightLabel.Height += 20;
            contentView.AddSubview(copyrightLabel);

            CView buttonsView = new CView();

            CButton twitterButton = new CButton("Follow @LunarPlugin", delegate(CButton button) {
                Application.OpenURL("https://twitter.com/intent/follow?screen_name=LunarPlugin&user_id=2939274198");
            });

            twitterButton.Width = contentView.Width;
            buttonsView.AddSubview(twitterButton);

            CButton facebookButton = new CButton("Facebook Page", delegate(CButton button) {
                Application.OpenURL("https://www.facebook.com/LunarPlugin");
            });

            facebookButton.Width = contentView.Width;
            buttonsView.AddSubview(facebookButton);

            CButton emailButton = new CButton("Send Email", delegate(CButton button) {
                Application.OpenURL("mailto:[email protected]?subject=Lunar%20plugin%20feedback&body=Hey%20Alex%2C%0A%0AI%27ve%20just%20checked%20the%20Lunar%20plugin.%20Nice%20job%2C%20man%21%20Still%2C%20there%27s%20some%20stuff%20I%20don%27t%20really%20like.%20For%20example%2C%20...%0A%0AFix%20it%2C%20you%20son%20of%20a%20bitch%2C%20or%20go%20to%20Hell%21%0A%0ASincerely%2C%0A%0AYour%20Lunar%20Plugin%20User");
            });

            emailButton.Width = contentView.Width;
            buttonsView.AddSubview(emailButton);

            buttonsView.ArrangeVert(5);
            buttonsView.ResizeToFitSubviews();
            buttonsView.Height += 20;

            contentView.AddSubview(buttonsView);

            contentView.ArrangeVert();

            CLabel thanksLabel = new CLabel("Thanks for using Lunar!");

            contentView.AddSubview(thanksLabel);
            thanksLabel.Align(0.5f, 1.0f);
        }
コード例 #6
0
        public static void Show(CView rootView)
        {
            if (rootView == null)
            {
                throw new NullReferenceException("Root view is null");
            }

            m_rootView = rootView;
        }
コード例 #7
0
        public virtual void Repaint()
        {
            CView rootView = RootView;

            if (rootView != null)
            {
                rootView.Repaint();
            }
        }
コード例 #8
0
        //////////////////////////////////////////////////////////////////////////////

        #region Subviews

        public CView AddSubview(CView view)
        {
            if (m_subviews == m_emptyList)
            {
                m_subviews = new List <CView>(1);
            }
            m_subviews.Add(view);
            view.ParentView = this;

            return(view);
        }
コード例 #9
0
        private bool MouseDoubleClickHandler(CView view, CEvent evt)
        {
            FocusControl();

            if (OnMouseDoubleClick(evt))
            {
                Repaint();
                return(true);
            }

            return(false);
        }
コード例 #10
0
        public void ResizeToFitSubviews()
        {
            float newWidth  = 0;
            float newHeight = 0;

            for (int i = 0; i < m_subviews.Count; ++i)
            {
                CView v = m_subviews[i];
                newWidth  = Mathf.Max(newWidth, v.X + v.Width);
                newHeight = Mathf.Max(newHeight, v.Y + v.Height);
            }

            Width  = newWidth;
            Height = newHeight;
        }
コード例 #11
0
        private bool KeyDownHandler(CView view, CEvent evt)
        {
            if (TextKeyDelegate == null)
            {
                return(false);
            }

            if (m_firstKeyDown)
            {
                m_firstKeyDown = false;

                IsCtrlPressed  = evt.control;
                IsShiftPressed = evt.shift;
                IsAltPressed   = evt.alt;
                IsCmdPressed   = evt.command;

                KeyCode key = GetKeyCode(evt);
                if (OnKeyPress(key))
                {
                    return(true);
                }

                try
                {
                    if (TextKeyDelegate(this, key, true))
                    {
                        return(true);
                    }
                }
                catch (Exception e)
                {
                    CLog.error(e);
                }
            }

            if (CEvent.current.keyCode == KeyCode.Tab || CEvent.current.character == '\t')
            {
                CEvent.current.Use();  // disable focus traversal on the tab key
            }

            return(false);
        }
コード例 #12
0
        protected virtual void OnResize(float dx, float dy)
        {
            for (int i = 0; i < m_subviews.Count; ++i)
            {
                CView             subview = m_subviews[i];
                CViewAutoresizing mask    = subview.AutoresizeMask;

                if (mask == CViewAutoresizing.None)
                {
                    continue;
                }

                float dw = 0;
                float dh = 0;

                if ((mask & CViewAutoresizing.FlexibleWidth) != 0)
                {
                    dw             = dx;
                    subview.Width += dw;
                }
                else if ((mask & CViewAutoresizing.FlexibleLeftMargin) != 0)
                {
                    subview.X += dx;
                }

                if ((mask & CViewAutoresizing.FlexibleHeight) != 0)
                {
                    dh              = dy;
                    subview.Height += dh;
                }
                else if ((mask & CViewAutoresizing.FlexibleTopMargin) != 0)
                {
                    subview.Y += dy;
                }

                if (dx != 0 || dy != 0)
                {
                    subview.OnResize(dw, dh);
                }
            }
        }
コード例 #13
0
 protected void DestroyRootView()
 {
     m_rootView = null;
 }
コード例 #14
0
 public void AttachRight(CView other, float indent = 0.0f)
 {
     X = other.X + other.Width + indent;
 }
コード例 #15
0
 public void AttachLeft(CView other, float indent = 0.0f)
 {
     X = other.X - Width - indent;
 }
コード例 #16
0
 public void AttachUnder(CView other, float indent = 0.0f)
 {
     Y = other.Y + other.Height + indent;
 }
コード例 #17
0
 public void AttachAbove(CView other, float indent = 0.0f)
 {
     Y = other.Y - Height - indent;
 }
コード例 #18
0
 public void AddSubview(CView view)
 {
     m_rootView.AddSubview(view);
 }
コード例 #19
0
 private bool KeyUpEventHandler(CView view, CEvent evt)
 {
     return(false);
 }