public ProgressView(string name, IGuiSize size, IGuiFrame progressFrame, IGuiPosition progressFramePosition, IGuiStyle progressLabelsStyle, IGuiFrame contextFrame, IGuiPosition contextFramePosition) : base(name, size, null) { if (progressFrame == null) { throw new ArgumentNullException("progressFrame"); } if (progressFramePosition == null) { throw new ArgumentNullException("progressFramePosition"); } if (contextFrame == null) { throw new ArgumentNullException("contextFrame"); } if (contextFramePosition == null) { throw new ArgumentNullException("contextFramePosition"); } mProgressFrame = new Pair <IGuiFrame, IGuiPosition>(progressFrame, progressFramePosition); mContextFrame = new Pair <IGuiFrame, IGuiPosition>(contextFrame, contextFramePosition); mProgressLabelStyle = progressLabelsStyle; mProgressFrame.First.Parent = this; mContextFrame.First.Parent = this; }
public TopLevel(string name, IGuiSize size, IGuiPosition position, IGuiManager manager, KeyValuePair <IGuiFrame, IGuiPosition> mainFrame, IGuiStyle style) : base(name, size, style) { if (manager == null) { throw new ArgumentNullException("manager"); } if (position == null) { throw new ArgumentNullException("position"); } mPosition = position; mWindowId = UnityWindowIdManager.RequestNewWindowId(); mManager = manager; mManager.RegisterTopLevel(this, position); mMainFrame = mainFrame; if (mMainFrame.Value == null) { mMainFrame = new KeyValuePair <IGuiFrame, IGuiPosition>(mainFrame.Key, new MainFrameSizePosition()); } if (mMainFrame.Key != null) { mMainFrame.Key.Parent = this; } }
protected override Window BuildWindow(XmlNode windowNode) { string name = BuildName(windowNode); IGuiSize size = BuildSize(windowNode); IGuiFrame mainFrame = null; IGuiPosition mainFramePosition = null; XmlNode mainFrameNode = windowNode.SelectSingleNode("MainFrame"); if (mainFrameNode != null) { mainFramePosition = BuildPosition(mainFrameNode); mainFrame = BuildFrame(mainFrameNode); if (mainFrame == null) { throw new GuiConstructionException("Found MainFrame node in Window (" + name + "), but was unable to construct it."); } } IGuiStyle style = GetStyle(windowNode, typeof(Window)); return(new DockableEditorTab ( name, size, mManager, new KeyValuePair <IGuiFrame, IGuiPosition> ( mainFrame, mainFramePosition ), style )); }
public Window(string name, IGuiSize size, IGuiPosition position, IGuiManager manager, KeyValuePair <IGuiFrame, IGuiPosition> mainFrame, KeyValuePair <IGuiFrame, IGuiPosition> headerFrame, DragBehavior isDraggable, IGuiStyle style) : base(name, size, position, manager, mainFrame, style) { mLogger = manager.Logger; mDraggable = isDraggable; mHeaderFrame = headerFrame; if (mHeaderFrame.Key != null) { mHeaderFrame.Key.Parent = this; } if (mHeaderFrame.Value == null) { mHeaderFrame = new KeyValuePair <IGuiFrame, IGuiPosition> ( mHeaderFrame.Key, new HeaderFrameSizePosition() ); } }
public void RegisterTopLevel(ITopLevel topLevel, IGuiPosition p) { EditorWindowWrapper wrapper = (EditorWindowWrapper)EditorWindow.GetWindow(typeof(EditorWindowWrapper)); wrapper.Manager = this; wrapper.InnerTopLevel = topLevel; mRegisteredGuiList.Add(wrapper, mDefaultWindowPosition); }
public void SetTopLevelPosition(ITopLevel topLevel, IGuiPosition position) { if (!mRegisteredGuiList.ContainsKey(topLevel)) { throw new ArgumentException("Unable to set position for unknown ITopLevel(" + topLevel.Name + ")", "topLevel"); } mRegisteredGuiList[topLevel] = position; }
public void AddChildWidget(IWidget child, IGuiPosition position) { mWidgets.Add(new KeyValuePair <IWidget, IGuiPosition>(child, position)); child.Parent = this; if (position is IAutoLayout) { mAutoLayoutNeedsUpdate = true; } }
public TabView BuildTabView(XmlNode tabViewNode) { string name = BuildName(tabViewNode); XmlNode buttonsFrameNode = tabViewNode.SelectSingleNode("ButtonsFrame"); if (buttonsFrameNode == null) { throw new GuiConstructionException("Unable to find the ButtonsFrame node that should be a child of TabView (" + name + ")"); } GuiFrame buttonFrame = BuildFrame(buttonsFrameNode); IGuiPosition buttonFramePosition = BuildPosition(buttonsFrameNode); XmlNode contextFrameNode = tabViewNode.SelectSingleNode("ContextFrame"); if (contextFrameNode == null) { throw new GuiConstructionException("Unable to find the ContextFrame node that should be a child of TabView (" + name + ")"); } GuiFrame contextFrame = BuildFrame(contextFrameNode); IGuiPosition contextFramePosition = BuildPosition(contextFrameNode); IGuiSize size = BuildSize(tabViewNode); bool allowEmpty = GetBoolAttributeNothrow(tabViewNode, "allowEmpty", false); return(new TabView ( name, size, buttonFrame, buttonFramePosition, contextFrame, contextFramePosition, allowEmpty )); }
public TabView(string name, IGuiSize size, GuiFrame buttonFrame, IGuiPosition buttonFramePosition, GuiFrame contextFrame, IGuiPosition contextFramePosition, bool allowEmpty) : base(name, size, null) { mAllowEmpty = allowEmpty; if (buttonFrame == null) { throw new ArgumentNullException("buttonFrame"); } mButtonFrame = buttonFrame; mButtonFrame.Parent = this; if (buttonFramePosition == null) { throw new ArgumentNullException("buttonFramePosition"); } mButtonFramePosition = buttonFramePosition; if (contextFrame == null) { throw new ArgumentNullException("contextFrame"); } mContextFrame = contextFrame; mContextFrame.Parent = this; if (contextFramePosition == null) { throw new ArgumentNullException("contextFramePosition"); } mContextFramePosition = contextFramePosition; // Get all the elements of type TabButton in the buttonsFrame and store in mTabs mTabs = new List <TabButton>(); foreach (IGuiElement buttonFrameElement in buttonFrame.SelectElements <IGuiElement>("**/*")) { if (buttonFrameElement is TabButton) { TabButton tabButton = (TabButton)buttonFrameElement; mTabs.Add(tabButton); tabButton.RegisterWithTabView(this); } } if (mTabs.Count < 1) { throw new ArgumentException("Cannot create a TabView without any specified tabs.", "tabs"); } if (!mAllowEmpty) { ActivateTab(mTabs[0]); } }
/// Constructs the appropriate IGuiPosition from the given node public static IGuiPosition BuildPosition(XmlNode node) { IGuiPosition result = null; string positionX = GetStringAttributeNoThrow(node, "positionX"); string positionY = GetStringAttributeNoThrow(node, "positionY"); string position = GetStringAttributeNoThrow(node, "position"); // If there's no position attributes listed, just use the origin as a default if (positionX == null && positionY == null && position == null) { return(new FixedPosition(0.0f, 0.0f)); } // If there's a position attribute, copy it into the positionX and positionY values if (position != null) { // The delimitter for a size attribute with different height and width values is space string[] splitPosition = position.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (splitPosition.Length == 2) { // Space was found (ex. "45 30"), use first value for positionX, second for positionY positionX = splitPosition[0]; positionY = splitPosition[1]; } else if (splitPosition.Length == 1) { // Single value was found, use it for both positionX and positionY positionX = splitPosition[0]; positionY = splitPosition[0]; } else { throw new GuiConstructionException("Unable to parse the position attribute from the node (" + node.Name + "): " + position); } } if (IsFixedPair(positionX, positionY)) { result = BuildFixedPosition(positionX, positionY, node); } else if (IsFillParent(positionX, positionY)) { result = BuildFillParent(positionX, positionY); } else if (IsHorizontalAutoLayout(position)) { result = BuildHorizontalAutoLayout(); } else if (IsMainFrame(positionX, positionY)) { result = BuildMainFrameSizePosition(); } else if (IsHeaderFrame(positionX, positionY)) { result = BuildHeaderFrameSizePosition(positionY); } else if (IsProcedural(position)) { result = new ProceduralPosition(); } else { throw new GuiConstructionException("Unable to create a position from the attributes on node (" + node.Name + "): " + positionX + ", " + positionY); } return(result); }
private ProgressView BuildProgressView(IEnumerable <Pair <IGuiFrame> > progressSteps, IGuiStyle progressLabelStyle) { IGuiFrame mainFrame = mMainWindow.SelectSingleElement <IGuiFrame>("MainFrame"); if (mainFrame == null) { throw new Exception("Cannot find the navigation frame at 'NewRoomDialog/MainFrame'"); } IGuiFrame navigationFrame = mainFrame.SelectSingleElement <IGuiFrame>("NavigationFrame"); if (navigationFrame == null) { throw new Exception("Cannot find the navigation frame at 'NewRoomDialog/MainFrame/NavigationFrame'"); } IGuiFrame viewFrame = mainFrame.SelectSingleElement <IGuiFrame>("ViewFrame"); if (viewFrame == null) { throw new Exception("Cannot find the view frame at 'NewRoomDialog/MainFrame/ViewFrame'"); } IGuiFrame toolFrame = viewFrame.SelectSingleElement <IGuiFrame>("ToolFrame"); if (toolFrame == null) { throw new Exception("Cannot find the tool frame at 'NewRoomDialog/MainFrame/ViewFrame/ToolFrame'"); } IGuiFrame topLetterbox = viewFrame.SelectSingleElement <IGuiFrame>("LetterboxTop"); if (topLetterbox == null) { throw new Exception("Cannot find the tool frame at 'NewRoomDialog/MainFrame/ViewFrame/LetterboxTop'"); } IGuiFrame bottomLetterbox = viewFrame.SelectSingleElement <IGuiFrame>("LetterboxBottom"); if (topLetterbox == null) { throw new Exception("Cannot find the tool frame at 'NewRoomDialog/MainFrame/ViewFrame/LetterboxBottom'"); } if (viewFrame.GuiSize is ProceduralSize) { // The view frame's size covers the screen except for the NavigationFrame's area ((ProceduralSize)viewFrame.GuiSize).SizeFunc = delegate(IGuiElement element) { Vector2 size = element.Parent.Size; size.x -= navigationFrame.Size.x; return(size); }; } if (toolFrame.GuiSize is ProceduralSize) { // The tool frame's size is the largest frame that will fit in the ViewFrame while // still being the same aspect ratio as the screen. ((ProceduralSize)toolFrame.GuiSize).SizeFunc = delegate(IGuiElement element) { float aspectRatio = (float)Screen.width / (float)Screen.height; Vector2 size = viewFrame.Size; size.y = size.x / aspectRatio; return(size); }; } foreach (IGuiElement child in viewFrame.Children) { if ((child is IGuiFrame)) { IGuiFrame frame = (IGuiFrame)child; if (frame.GuiSize is ProceduralSize) { if (frame.Name == "LetterboxTop" || frame.Name == "LetterboxBottom") { // The letterbox sizes are 1/2 of the size difference between the // tool frame and the view frame ((ProceduralSize)frame.GuiSize).SizeFunc = delegate(IGuiElement element) { Vector2 size = viewFrame.Size; size.y = (size.y - toolFrame.Size.y) * 0.5f; return(size); }; } } } } IGuiPosition toolFramePosition = viewFrame.GetChildGuiPosition(toolFrame); if (toolFramePosition is ProceduralPosition) { ((ProceduralPosition)toolFramePosition).PositionFunc = delegate(IGuiElement element) { return(new Vector2(0.0f, topLetterbox.Size.y)); }; } ProgressView result = new ProgressView ( "NewRoomDialogProgressView", new FillParent(), navigationFrame, mainFrame.GetChildGuiPosition(navigationFrame), progressLabelStyle, viewFrame, mainFrame.GetChildGuiPosition(viewFrame) ); mainFrame.ClearChildWidgets(); mainFrame.AddChildWidget(result, new FillParent()); IGuiPosition topLetterboxPosition = viewFrame.GetChildGuiPosition(topLetterbox); IGuiPosition bottomLetterboxPosition = viewFrame.GetChildGuiPosition(bottomLetterbox); foreach (Pair <IGuiFrame> progressStep in progressSteps) { IGuiFrame newContextFrame = new GuiFrame(progressStep.First.Name.Replace("Main", ""), new FillParent()); newContextFrame.AddChildWidget(topLetterbox, topLetterboxPosition); newContextFrame.AddChildWidget(progressStep.First, toolFramePosition); newContextFrame.AddChildWidget(bottomLetterbox, bottomLetterboxPosition); result.AddStep(newContextFrame.Name, newContextFrame, progressStep.Second); } return(result); }
public void RegisterTopLevel(ITopLevel gui, IGuiPosition position) { mRegisteredGuiList.Add(gui, position); }
/// <summary> /// Editor mode TopLevels ignore position (Unity manages them). This function is just a stub /// </summary> public void SetTopLevelPosition(ITopLevel topLevel, IGuiPosition position) { }
protected virtual Window BuildWindow(XmlNode windowNode) { string name = BuildName(windowNode); IGuiSize size = BuildSize(windowNode); IGuiFrame mainFrame = null; IGuiPosition mainFramePosition = null; XmlNode mainFrameNode = windowNode.SelectSingleNode("MainFrame"); if (mainFrameNode != null) { mainFramePosition = BuildPosition(mainFrameNode); mainFrame = BuildFrame(mainFrameNode); if (mainFrame == null) { throw new GuiConstructionException("Found MainFrame node in Window (" + name + "), but was unable to construct it."); } } IGuiFrame headerFrame = null; IGuiPosition headerFramePosition = null; XmlNode headerFrameNode = windowNode.SelectSingleNode("HeaderFrame"); if (headerFrameNode != null) { headerFramePosition = BuildPosition(headerFrameNode); headerFrame = BuildFrame(headerFrameNode); if (headerFrame == null) { throw new GuiConstructionException("Found HeaderFrame node in Window (" + name + "), but was unable to construct it."); } } DragBehavior dragBehavior = BuildDragBehavior(windowNode); IGuiStyle style = GetStyle(windowNode, typeof(Window)); if (windowNode.Attributes["position"] != null) { IGuiPosition position = BuildPosition(windowNode); return(new Window ( name, size, position, mManager, new KeyValuePair <IGuiFrame, IGuiPosition>( mainFrame, mainFramePosition ), new KeyValuePair <IGuiFrame, IGuiPosition>( headerFrame, headerFramePosition ), dragBehavior, style )); } else { return(new Window ( name, size, mManager, new KeyValuePair <IGuiFrame, IGuiPosition> ( mainFrame, mainFramePosition ), new KeyValuePair <IGuiFrame, IGuiPosition> ( headerFrame, headerFramePosition ), dragBehavior, style )); } }