From 25f17ef5c86dcd2b2ddbf63ed11c045b0cf10471 Mon Sep 17 00:00:00 2001 From: Alex Lementuev Date: Tue, 20 Dec 2016 10:44:53 -0800 Subject: [PATCH] Refactoring --- .../LunarPlugin/Editor/UI/CAboutWindow.cs | 4 +- .../LunarPlugin/Editor/UI/CAbstractButton.cs | 2 +- Project/Assets/LunarPlugin/Editor/UI/CBox.cs | 2 +- .../LunarPlugin/Editor/UI/CColorRect.cs | 2 +- .../LunarPlugin/Editor/UI/CHyperlink.cs | 2 +- .../Assets/LunarPlugin/Editor/UI/CLabel.cs | 2 +- .../LunarPlugin/Editor/UI/CModalWindow.cs | 4 +- .../LunarPlugin/Editor/UI/CTableView.cs | 12 ++-- .../Editor/UI/CTerminalCompositeView.cs | 4 +- .../LunarPlugin/Editor/UI/CTextField.cs | 6 +- .../Assets/LunarPlugin/Editor/UI/CToggle.cs | 2 +- .../Assets/LunarPlugin/Editor/UI/CToolBar.cs | 10 +-- Project/Assets/LunarPlugin/Editor/UI/CView.cs | 62 +++++++++---------- .../Assets/LunarPlugin/Editor/UI/CWindow.cs | 12 ++-- 14 files changed, 63 insertions(+), 63 deletions(-) mode change 100755 => 100644 Project/Assets/LunarPlugin/Editor/UI/CBox.cs mode change 100755 => 100644 Project/Assets/LunarPlugin/Editor/UI/CModalWindow.cs mode change 100755 => 100644 Project/Assets/LunarPlugin/Editor/UI/CToggle.cs diff --git a/Project/Assets/LunarPlugin/Editor/UI/CAboutWindow.cs b/Project/Assets/LunarPlugin/Editor/UI/CAboutWindow.cs index 92607f5..54eaae2 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CAboutWindow.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CAboutWindow.cs @@ -40,7 +40,7 @@ protected override void CreateUI() { const float indent = 12; - View contentView = new View(this.Width - 2 * indent, this.Height - 2 * indent); + CView contentView = new CView(this.Width - 2 * indent, this.Height - 2 * indent); contentView.X = indent; contentView.Y = indent; AddSubview(contentView); @@ -54,7 +54,7 @@ protected override void CreateUI() copyrightLabel.Height += 20; contentView.AddSubview(copyrightLabel); - View buttonsView = new View(); + 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"); diff --git a/Project/Assets/LunarPlugin/Editor/UI/CAbstractButton.cs b/Project/Assets/LunarPlugin/Editor/UI/CAbstractButton.cs index b50ab57..2c662ff 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CAbstractButton.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CAbstractButton.cs @@ -24,7 +24,7 @@ namespace LunarEditor { - abstract class CAbstractButton : View + abstract class CAbstractButton : CView { public CAbstractButton(string title) { diff --git a/Project/Assets/LunarPlugin/Editor/UI/CBox.cs b/Project/Assets/LunarPlugin/Editor/UI/CBox.cs old mode 100755 new mode 100644 index 5f421c1..ca7235b --- a/Project/Assets/LunarPlugin/Editor/UI/CBox.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CBox.cs @@ -24,7 +24,7 @@ namespace LunarEditor { - class CBox : View + class CBox : CView { public CBox(float width, float height) : this(width, height, GUI.skin.box) diff --git a/Project/Assets/LunarPlugin/Editor/UI/CColorRect.cs b/Project/Assets/LunarPlugin/Editor/UI/CColorRect.cs index 91e16c7..f21c449 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CColorRect.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CColorRect.cs @@ -24,7 +24,7 @@ namespace LunarEditor { - class CColorRect : View + class CColorRect : CView { private Color m_color; private GUIStyle m_style; diff --git a/Project/Assets/LunarPlugin/Editor/UI/CHyperlink.cs b/Project/Assets/LunarPlugin/Editor/UI/CHyperlink.cs index 63f6a93..5334340 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CHyperlink.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CHyperlink.cs @@ -28,7 +28,7 @@ namespace LunarEditor { - class CHyperlink : View + class CHyperlink : CView { private GUIContent m_content; private string m_href; diff --git a/Project/Assets/LunarPlugin/Editor/UI/CLabel.cs b/Project/Assets/LunarPlugin/Editor/UI/CLabel.cs index fe5028d..bd244b7 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CLabel.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CLabel.cs @@ -29,7 +29,7 @@ namespace LunarEditor { - class CLabel : View + class CLabel : CView { private GUIContent m_content; diff --git a/Project/Assets/LunarPlugin/Editor/UI/CModalWindow.cs b/Project/Assets/LunarPlugin/Editor/UI/CModalWindow.cs old mode 100755 new mode 100644 index 73d6a10..b1cac3d --- a/Project/Assets/LunarPlugin/Editor/UI/CModalWindow.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CModalWindow.cs @@ -26,7 +26,7 @@ namespace LunarEditor { class CModalWindow { - private static View m_rootView; + private static CView m_rootView; public CModalWindow() { @@ -69,7 +69,7 @@ public void OnGUI() }, "Test"); } - public static void Show(View rootView) + public static void Show(CView rootView) { if (rootView == null) { diff --git a/Project/Assets/LunarPlugin/Editor/UI/CTableView.cs b/Project/Assets/LunarPlugin/Editor/UI/CTableView.cs index c74d362..bad4d03 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CTableView.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CTableView.cs @@ -56,7 +56,7 @@ enum CTableViewSelectionMode Multiple } - class CTableView : View + class CTableView : CView { private IDictionary m_reusableCellsLists; private CCycleArray m_cellsEntries; @@ -610,7 +610,7 @@ private void OnChangeHeight(float delta) #region Mouse clicks - private bool MouseDownEventHandler(View view, CEvent evt) + private bool MouseDownEventHandler(CView view, CEvent evt) { FocusControl(); @@ -623,7 +623,7 @@ private bool MouseDownEventHandler(View view, CEvent evt) return false; } - private bool MouseDoubleClickHandler(View view, CEvent evt) + private bool MouseDoubleClickHandler(CView view, CEvent evt) { FocusControl(); @@ -682,7 +682,7 @@ protected virtual bool OnMouseDoubleClick(CEvent evt, CTableViewCell cell) return false; } - protected virtual bool KeyDownEventHandler(View view, CEvent evt) + protected virtual bool KeyDownEventHandler(CView view, CEvent evt) { switch (evt.keyCode) { @@ -743,7 +743,7 @@ protected virtual bool KeyDownEventHandler(View view, CEvent evt) return false; } - private bool KeyUpEventHandler(View view, CEvent evt) + private bool KeyUpEventHandler(CView view, CEvent evt) { return false; } @@ -926,7 +926,7 @@ public bool IsSelected } } - class CTableViewCell : View + class CTableViewCell : CView { public CTableViewCell() : this(0, 0) diff --git a/Project/Assets/LunarPlugin/Editor/UI/CTerminalCompositeView.cs b/Project/Assets/LunarPlugin/Editor/UI/CTerminalCompositeView.cs index 9517b90..d80b876 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CTerminalCompositeView.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CTerminalCompositeView.cs @@ -36,7 +36,7 @@ interface ICTerminalCompositeViewDelegate CTerminal Terminal { get; } } - class CTerminalCompositeView : View + class CTerminalCompositeView : CView { private CConsoleView m_consoleView; private CTextField m_commandField; @@ -102,7 +102,7 @@ private void CreateUI() m_commandField = new CTextField(); m_commandField.Width = Width; AddSubview(m_commandField); - m_commandField.AlignX(View.AlignCenter); + m_commandField.AlignX(CView.AlignCenter); m_commandField.AlignBottom(0); m_commandField.AutoresizeMask = ViewAutoresizing.FlexibleTopMargin | ViewAutoresizing.FlexibleWidth; diff --git a/Project/Assets/LunarPlugin/Editor/UI/CTextField.cs b/Project/Assets/LunarPlugin/Editor/UI/CTextField.cs index 79f2a27..6d4ad9e 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CTextField.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CTextField.cs @@ -32,7 +32,7 @@ namespace LunarEditor delegate void CTextFieldDelegate(CTextField field); delegate bool CTextFieldKeyDelegate(CTextField field, KeyCode code, bool pressed); - class CTextField : View + class CTextField : CView { private string m_text; private bool m_firstKeyDown; @@ -58,7 +58,7 @@ public CTextField(float x, float y, float w, float h, string text = "") this.KeyDown = KeyDownHandler; } - private bool KeyDownHandler(View view, CEvent evt) + private bool KeyDownHandler(CView view, CEvent evt) { if (TextKeyDelegate == null) { @@ -101,7 +101,7 @@ private bool KeyDownHandler(View view, CEvent evt) return false; } - private bool KeyUpHandler(View view, CEvent evt) + private bool KeyUpHandler(CView view, CEvent evt) { if (TextKeyDelegate == null) { diff --git a/Project/Assets/LunarPlugin/Editor/UI/CToggle.cs b/Project/Assets/LunarPlugin/Editor/UI/CToggle.cs old mode 100755 new mode 100644 index 44ffc3d..5263212 --- a/Project/Assets/LunarPlugin/Editor/UI/CToggle.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CToggle.cs @@ -26,7 +26,7 @@ namespace LunarEditor { delegate void CToggleChangeDelegate(CToggle toggle); - class CToggle : View + class CToggle : CView { private GUIContent m_content; diff --git a/Project/Assets/LunarPlugin/Editor/UI/CToolBar.cs b/Project/Assets/LunarPlugin/Editor/UI/CToolBar.cs index 3217f69..274e939 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CToolBar.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CToolBar.cs @@ -27,7 +27,7 @@ namespace LunarEditor { - class CToolBar : View + class CToolBar : CView { public CToolBar(float width) : base(width, CUISize.ToolbarHeight) @@ -113,7 +113,7 @@ public override void OnGUI() } } - class CToolBarLabel : View + class CToolBarLabel : CView { private string m_text; @@ -182,7 +182,7 @@ public override void OnGUI() delegate void CToolBarDropListDelegate(CToolBarDropList list); - class CToolBarDropList : View + class CToolBarDropList : CView { private string m_title; private int m_selectedValue; @@ -302,7 +302,7 @@ public CToolBarDropListDelegate Delegate } } - class CToolBarSpace : View + class CToolBarSpace : CView { public CToolBarSpace(float pixels) : base(pixels, 0) @@ -315,7 +315,7 @@ public override void OnGUI() } } - class CToolBarFlexibleSpace : View + class CToolBarFlexibleSpace : CView { public override void OnGUI() { diff --git a/Project/Assets/LunarPlugin/Editor/UI/CView.cs b/Project/Assets/LunarPlugin/Editor/UI/CView.cs index dd63bc4..8e2c96d 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CView.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CView.cs @@ -41,19 +41,19 @@ enum ViewAutoresizing FlexibleBottomMargin = 1 << 5 } - class View : CObjectsPoolEntry, IDisposable + class CView : CObjectsPoolEntry, IDisposable { private static readonly Rect EmptyRect = new Rect(0, 0, 0, 0); - internal delegate bool EventDelegate(View view, CEvent evt); + internal delegate bool EventDelegate(CView view, CEvent evt); public const float AlignMin = 0.0f; public const float AlignCenter = 0.5f; public const float AlignMax = 1.0f; - private static readonly List m_emptyList = new List(0); + private static readonly List m_emptyList = new List(0); - private List m_subviews; + private List m_subviews; private GUIStyle m_style; private Vector2 m_origin; @@ -64,23 +64,23 @@ class View : CObjectsPoolEntry, IDisposable private static int m_nextFocusableViewId; private string m_focusableViewId; - public View(float width, float height) + public CView(float width, float height) : this(0, 0, width, height) { } - public View(float x, float y, float width, float height) + public CView(float x, float y, float width, float height) : this(new Rect(x, y, width, height)) { } - public View(Rect frame) + public CView(Rect frame) : this() { this.Frame = frame; } - public View() + public CView() { m_subviews = m_emptyList; this.IsKeyEventsEnabled = true; @@ -256,11 +256,11 @@ public bool ContainsPoint(float pointX, float pointY) #region Subviews - public View AddSubview(View view) + public CView AddSubview(CView view) { if (m_subviews == m_emptyList) { - m_subviews = new List(1); + m_subviews = new List(1); } m_subviews.Add(view); view.ParentView = this; @@ -268,7 +268,7 @@ public View AddSubview(View view) return view; } - public void RemoveSubview(View view) + public void RemoveSubview(CView view) { if (view.ParentView == this) { @@ -294,7 +294,7 @@ public void RemoveFromParentView() } } - public View FindSubview(object tag) + public CView FindSubview(object tag) { for (int i = 0; i < m_subviews.Count; ++i) { @@ -329,46 +329,46 @@ public void Align(float alignX, float alignY) AlignY(alignY); } - public View AlignTop(float indent = 0.0f) + public CView AlignTop(float indent = 0.0f) { Y = indent; return this; } - public View AlignBottom(float indent = 0.0f) + public CView AlignBottom(float indent = 0.0f) { Y = ParentView.Height - Height - indent; return this; } - public View AlignLeft(float indent = 0.0f) + public CView AlignLeft(float indent = 0.0f) { X = indent; return this; } - public View AlignRight(float indent = 0.0f) + public CView AlignRight(float indent = 0.0f) { X = ParentView.Width - Width - indent; return this; } - public void AttachAbove(View other, float indent = 0.0f) + public void AttachAbove(CView other, float indent = 0.0f) { Y = other.Y - Height - indent; } - public void AttachUnder(View other, float indent = 0.0f) + public void AttachUnder(CView other, float indent = 0.0f) { Y = other.Y + other.Height + indent; } - public void AttachLeft(View other, float indent = 0.0f) + public void AttachLeft(CView other, float indent = 0.0f) { X = other.X - Width - indent; } - public void AttachRight(View other, float indent = 0.0f) + public void AttachRight(CView other, float indent = 0.0f) { X = other.X + other.Width + indent; } @@ -400,7 +400,7 @@ public void ResizeToFitSubviews() for (int i = 0; i < m_subviews.Count; ++i) { - View v = m_subviews[i]; + CView v = m_subviews[i]; newWidth = Mathf.Max(newWidth, v.X + v.Width); newHeight = Mathf.Max(newHeight, v.Y + v.Height); } @@ -412,7 +412,7 @@ public void ResizeToFitSubviews() public void ArrangeVert(float indent = 0.0f) { float nextY = 0; - foreach (View view in Subviews) + foreach (CView view in Subviews) { view.Y = nextY; nextY += view.Height + indent; @@ -422,7 +422,7 @@ public void ArrangeVert(float indent = 0.0f) public void ArrangeHort(float indent = 0.0f) { float nextX = 0; - foreach (View view in Subviews) + foreach (CView view in Subviews) { view.X = nextX; nextX += view.Width + indent; @@ -433,7 +433,7 @@ protected virtual void OnResize(float dx, float dy) { for (int i = 0; i < m_subviews.Count; ++i) { - View subview = m_subviews[i]; + CView subview = m_subviews[i]; ViewAutoresizing mask = subview.AutoresizeMask; if (mask == ViewAutoresizing.None) @@ -504,7 +504,7 @@ protected void DrawChildren() { for (int i = 0; i < m_subviews.Count; ++i) { - View subview = m_subviews[i]; + CView subview = m_subviews[i]; if (!subview.IsEnabled && GUI.enabled) { GUI.enabled = false; @@ -527,7 +527,7 @@ protected void DrawChildren() public virtual void Repaint() { - View rootView = RootView; + CView rootView = RootView; if (rootView != null) { rootView.Repaint(); @@ -579,24 +579,24 @@ protected virtual void OnDispose() public bool IsEnabled { get; set; } - public View ParentView { get; private set; } + public CView ParentView { get; private set; } - public virtual View RootView + public virtual CView RootView { get { return ParentView != null ? ParentView.RootView : null; } } - public List Subviews + public List Subviews { get { return m_subviews; } } - public View FistSubview + public CView FistSubview { get { return m_subviews.Count > 0 ? m_subviews[0] : null; } } - public View LastSubview + public CView LastSubview { get { return m_subviews.Count > 0 ? m_subviews[m_subviews.Count - 1] : null; } } diff --git a/Project/Assets/LunarPlugin/Editor/UI/CWindow.cs b/Project/Assets/LunarPlugin/Editor/UI/CWindow.cs index 8ae84e6..f5fb4e3 100644 --- a/Project/Assets/LunarPlugin/Editor/UI/CWindow.cs +++ b/Project/Assets/LunarPlugin/Editor/UI/CWindow.cs @@ -42,7 +42,7 @@ static class WindowNotifications class Window : EditorWindow { private Vector2 m_oldSize; - private View m_rootView; + private CView m_rootView; private string m_tag; private bool m_dirty; @@ -238,7 +238,7 @@ private static void RemoveWindow(Window window) #region Inheritance - private View CreateRootView() + private CView CreateRootView() { return new WindowRootView(this, Width, Height); } @@ -252,7 +252,7 @@ protected virtual void CreateUI() { } - public void AddSubview(View view) + public void AddSubview(CView view) { m_rootView.AddSubview(view); } @@ -263,7 +263,7 @@ public void AddSubview(View view) #region Properties - public View RootView { get { return m_rootView; } } + public CView RootView { get { return m_rootView; } } public float Width { @@ -296,7 +296,7 @@ public string Tag #endregion } - class WindowRootView : View + class WindowRootView : CView { private Window m_window; @@ -316,7 +316,7 @@ public override bool IsFocused get { return m_window.IsFocused; } } - public override View RootView + public override CView RootView { get { return this; } }