Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
weeeBox committed Dec 20, 2016
1 parent 25f17ef commit ca2f661
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
12 changes: 6 additions & 6 deletions Project/Assets/LunarPlugin/Editor/Console/CConsoleView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public CConsoleView(CAbstractConsole console, float width, float height)

protected virtual ICTextMeasure CreateTextMeasure()
{
return new GUIStyleTextMeasure(SharedStyles.consoleTextStyle);
return new CGUIStyleTextMeasure(CSharedStyles.consoleTextStyle);
}

//////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -577,7 +577,7 @@ private void LayoutException(ICTextMeasure measure, CStackTraceLine[] stackLines

if (stackLines[i].sourcePathStart != -1)
{
GUIStyleTextMeasure styleMeasure = measure as GUIStyleTextMeasure;
CGUIStyleTextMeasure styleMeasure = measure as CGUIStyleTextMeasure;
if (styleMeasure != null)
{
ResolveSourceLink(styleMeasure, ref stackLines[i]);
Expand All @@ -592,7 +592,7 @@ private void LayoutException(ICTextMeasure measure, CStackTraceLine[] stackLines
this.height = totalHeight;
}

private static void ResolveSourceLink(GUIStyleTextMeasure measure, ref CStackTraceLine stackLine)
private static void ResolveSourceLink(CGUIStyleTextMeasure measure, ref CStackTraceLine stackLine)
{
Color color = CEditorSkin.GetColor(stackLine.sourcePathExists ? CColorCode.Link : CColorCode.LinkInnactive);

Expand Down Expand Up @@ -661,7 +661,7 @@ class CConsoleTextEntryView : CConsoleViewCell

protected override void DrawGUI()
{
GUIStyle style = SharedStyles.consoleTextStyle;
GUIStyle style = CSharedStyles.consoleTextStyle;
Color oldColor = style.normal.textColor;
style.normal.textColor = this.TextColor;
GUI.Label(Frame, this.Value, style);
Expand Down Expand Up @@ -731,7 +731,7 @@ protected override void DrawGUI()
{
BeginGroup(Frame);
{
GUIStyle style = SharedStyles.consoleTextStyle;
GUIStyle style = CSharedStyles.consoleTextStyle;
Color oldColor = style.normal.textColor;
style.normal.textColor = this.TextColor;

Expand All @@ -753,7 +753,7 @@ private void DrawStackLine(ref CStackTraceLine stackLine, GUIStyle style)
{
if (stackLine.IsClickable)
{
GUIStyle linkStyle = stackLine.sourcePathExists ? SharedStyles.consoleLinkStyle : SharedStyles.consoleLinkInnactiveStyle;
GUIStyle linkStyle = stackLine.sourcePathExists ? CSharedStyles.consoleLinkStyle : CSharedStyles.consoleLinkInnactiveStyle;
CUIHelper.DrawUnderLine(stackLine.sourceFrame, linkStyle);

if (stackLine.sourcePathExists && GUI.Button(stackLine.sourceFrame, GUIContent.none, GUIStyle.none))
Expand Down
2 changes: 1 addition & 1 deletion Project/Assets/LunarPlugin/Editor/UI/CHyperlink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public CHyperlink(string text, string href)

protected override GUIStyle CreateGUIStyle()
{
return SharedStyles.linkTextStyle;
return CSharedStyles.linkTextStyle;
}

protected override void DrawGUI()
Expand Down
4 changes: 2 additions & 2 deletions Project/Assets/LunarPlugin/Editor/UI/CSearchField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected override string CreateTextField(string text)
GUILayout.BeginHorizontal();
{
text = GUILayout.TextField(text, Style);
if (GUILayout.Button(GUIContent.none, SharedStyles.toolbarSearchCancelButton))
if (GUILayout.Button(GUIContent.none, CSharedStyles.toolbarSearchCancelButton))
{
// Remove focus if cleared
text = "";
Expand All @@ -49,7 +49,7 @@ protected override string CreateTextField(string text)

protected override GUIStyle CreateGUIStyle()
{
return SharedStyles.searchField;
return CSharedStyles.searchField;
}
}
}
2 changes: 1 addition & 1 deletion Project/Assets/LunarPlugin/Editor/UI/CTableView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected virtual void DrawVisibleCells()
{
if (IsCellSelected(cell.CellIndex))
{
CUIHelper.DrawRect(cell.Frame, SharedStyles.SelectedCellBackStyle);
CUIHelper.DrawRect(cell.Frame, CSharedStyles.SelectedCellBackStyle);
}
cell.OnGUI();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public CTerminalCompositeView(ICTerminalCompositeViewDelegate del, float width,

private void CreateUI()
{
this.AutoresizeMask = ViewAutoresizing.FlexibleWidth | ViewAutoresizing.FlexibleHeight;
this.AutoresizeMask = CViewAutoresizing.FlexibleWidth | CViewAutoresizing.FlexibleHeight;

CToolBar toolbar = new CToolBar(this.Width);
toolbar.Width = this.Width;
Expand Down Expand Up @@ -104,7 +104,7 @@ private void CreateUI()
AddSubview(m_commandField);
m_commandField.AlignX(CView.AlignCenter);
m_commandField.AlignBottom(0);
m_commandField.AutoresizeMask = ViewAutoresizing.FlexibleTopMargin | ViewAutoresizing.FlexibleWidth;
m_commandField.AutoresizeMask = CViewAutoresizing.FlexibleTopMargin | CViewAutoresizing.FlexibleWidth;

m_commandField.TextKeyDelegate = delegate(CTextField tf, KeyCode code, bool pressed)
{
Expand Down Expand Up @@ -211,7 +211,7 @@ private void CreateUI()
m_consoleView = new CConsoleView(Terminal, m_commandField.Width, this.Height - (toolbar.Height + m_commandField.Height));
m_consoleView.Y = toolbar.Bottom;
m_consoleView.IsScrollLocked = true;
m_consoleView.AutoresizeMask = ViewAutoresizing.FlexibleWidth | ViewAutoresizing.FlexibleHeight;
m_consoleView.AutoresizeMask = CViewAutoresizing.FlexibleWidth | CViewAutoresizing.FlexibleHeight;
AddSubview(m_consoleView);

m_lastUserInput = null;
Expand Down
18 changes: 9 additions & 9 deletions Project/Assets/LunarPlugin/Editor/UI/CToolBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class CToolBar : CView
public CToolBar(float width)
: base(width, CUISize.ToolbarHeight)
{
this.AutoresizeMask = ViewAutoresizing.FlexibleWidth;
this.AutoresizeMask = CViewAutoresizing.FlexibleWidth;
}

public override void OnGUI()
{
GUILayout.BeginHorizontal(SharedStyles.toolbar, GUILayout.Width(this.Width));
GUILayout.BeginHorizontal(CSharedStyles.toolbar, GUILayout.Width(this.Width));
{
DrawChildren();
}
Expand Down Expand Up @@ -100,12 +100,12 @@ class CToolBarButton : CButton
public CToolBarButton(string title, CButtonDelegate buttonDelegate)
: base(title, buttonDelegate)
{
Width = SharedStyles.MeasureWidth(SharedStyles.toolbarButton, title);
Width = CSharedStyles.MeasureWidth(CSharedStyles.toolbarButton, title);
}

public override void OnGUI()
{
if (GUILayout.Button(Title, SharedStyles.toolbarButton, GUILayout.Width(Frame.width)))
if (GUILayout.Button(Title, CSharedStyles.toolbarButton, GUILayout.Width(Frame.width)))
{
if (ButtonDelegate != null)
ButtonDelegate(this);
Expand Down Expand Up @@ -145,13 +145,13 @@ class CToolBarToggle : CToggleButton
public CToolBarToggle(string title, CToggleButtonDelegate buttonDelegate)
: base(title, buttonDelegate)
{
Width = SharedStyles.MeasureWidth(SharedStyles.toolbarButton, title);
Width = CSharedStyles.MeasureWidth(CSharedStyles.toolbarButton, title);
}

public override void OnGUI()
{
bool oldFlag = this.IsOn;
this.IsOn = GUILayout.Toggle(oldFlag, Title, SharedStyles.toolbarButton, GUILayout.Width(Frame.width));
this.IsOn = GUILayout.Toggle(oldFlag, Title, CSharedStyles.toolbarButton, GUILayout.Width(Frame.width));
if (oldFlag ^ this.IsOn)
{
if (ButtonDelegate != null)
Expand All @@ -165,7 +165,7 @@ class CToolBarCheckbox : CToggleButton
public CToolBarCheckbox(string title, CToggleButtonDelegate buttonDelegate)
: base(title, buttonDelegate)
{
Width = SharedStyles.MeasureWidth(GUI.skin.toggle, title);
Width = CSharedStyles.MeasureWidth(GUI.skin.toggle, title);
}

public override void OnGUI()
Expand Down Expand Up @@ -234,7 +234,7 @@ public override void OnGUI()

if (m_titleWith == 0)
{
m_titleWith = SharedStyles.MeasureWidth(style, m_title);
m_titleWith = CSharedStyles.MeasureWidth(style, m_title);
}

GUILayout.Label(m_title, style, GUILayout.Width(m_titleWith));
Expand Down Expand Up @@ -271,7 +271,7 @@ private float CalcPopupWidth(string[] options, GUIStyle style)
float width = 0;
for (int i = 0; i < options.Length; ++i)
{
width = Mathf.Max(width, SharedStyles.MeasureWidth(style, options[i]));
width = Mathf.Max(width, CSharedStyles.MeasureWidth(style, options[i]));
}

return width;
Expand Down
28 changes: 14 additions & 14 deletions Project/Assets/LunarPlugin/Editor/UI/CView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

namespace LunarEditor
{
enum ViewAutoresizing
enum CViewAutoresizing
{
None = 0,
FlexibleLeftMargin = 1 << 0,
Expand Down Expand Up @@ -434,32 +434,32 @@ protected virtual void OnResize(float dx, float dy)
for (int i = 0; i < m_subviews.Count; ++i)
{
CView subview = m_subviews[i];
ViewAutoresizing mask = subview.AutoresizeMask;
CViewAutoresizing mask = subview.AutoresizeMask;

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

float dw = 0;
float dh = 0;

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

if ((mask & ViewAutoresizing.FlexibleHeight) != 0)
if ((mask & CViewAutoresizing.FlexibleHeight) != 0)
{
dh = dy;
subview.Height += dh;
}
else if ((mask & ViewAutoresizing.FlexibleTopMargin) != 0)
else if ((mask & CViewAutoresizing.FlexibleTopMargin) != 0)
{
subview.Y += dy;
}
Expand Down Expand Up @@ -661,7 +661,7 @@ public float Bottom

public object Tag { get; set; }

public ViewAutoresizing AutoresizeMask { get; set; }
public CViewAutoresizing AutoresizeMask { get; set; }

public Color BackColor
{
Expand Down Expand Up @@ -784,7 +784,7 @@ public static void Destroy()
protected abstract void DestroyEvent();
}

class SharedStyles
class CSharedStyles
{
private static GUIContent m_content = new GUIContent();

Expand Down Expand Up @@ -988,11 +988,11 @@ public static float MeasureHeight(GUIStyle style, string text, float width)
}
}

class GUIStyleTextMeasure : ICTextMeasure
class CGUIStyleTextMeasure : ICTextMeasure
{
private GUIStyle m_style;

public GUIStyleTextMeasure(GUIStyle style)
public CGUIStyleTextMeasure(GUIStyle style)
{
if (style == null)
{
Expand All @@ -1004,12 +1004,12 @@ public GUIStyleTextMeasure(GUIStyle style)

public Vector2 CalcSize(string text)
{
return SharedStyles.MeasureText(m_style, text);
return CSharedStyles.MeasureText(m_style, text);
}

public float CalcHeight(string text, float width)
{
return SharedStyles.MeasureHeight(m_style, text, width);
return CSharedStyles.MeasureHeight(m_style, text, width);
}

public float LineHeight
Expand All @@ -1023,7 +1023,7 @@ public GUIStyle Style
}
}

static class SharedGUIContent
static class CSharedGUIContent
{
private static GUIContent m_content = new GUIContent();

Expand Down

0 comments on commit ca2f661

Please sign in to comment.