//---------------------------------------------------------------------- public NotebookPane(MainMenuManager _manager) : base(_manager) { //------------------------------------------------------------------ var notebook = new NuclearUI.Notebook(Manager.MenuScreen); AddChild(notebook); notebook.HasClosableTabs = true; var homeTab = new NuclearUI.NotebookTab(notebook, "Home", null); homeTab.IsPinned = true; notebook.Tabs.Add(homeTab); var createTab = new NuclearUI.Button(Manager.MenuScreen, "Create tab"); createTab.AnchoredRect = NuclearUI.AnchoredRect.CreateFull(10); int iTabCounter = 0; createTab.ClickHandler = delegate { var tab = new NuclearUI.NotebookTab(notebook, string.Format("Tab {0}", ++iTabCounter), null); notebook.Tabs.Add(tab); }; homeTab.PageGroup.AddChild(createTab); }
//---------------------------------------------------------------------- public clsXWCommandPopup(IMenuManager _manager) : base(_manager) { TitleLabel = new Label(Screen, "", Anchor.Start); TitleLabel.Font = Screen.Style.MediumFont; TitleLabel.AnchoredRect = AnchoredRect.CreateTopAnchored(0, 0, 0, Screen.Style.DefaultButtonHeight); AddChild(TitleLabel); { ContentGroup = new Group(Screen); ContentGroup.AnchoredRect = AnchoredRect.CreateFull(0, 60, 0, 80); AddChild(ContentGroup); MessageLabel = new Label(Screen, "MessageLabel", Anchor.Start); MessageLabel.WrapText = true; MessageLabel.Font = Screen.Style.SmallFont; // Actions mActionsGroup = new BoxGroup(Screen, Orientation.Horizontal, 0, Anchor.End); mActionsGroup.AnchoredRect = AnchoredRect.CreateBottomAnchored(0, 0, 0, Screen.Style.DefaultButtonHeight); AddChild(mActionsGroup); // Close / Cancel mCloseButton = new Button(Screen, NuclearWinter.i18n.Common.Close); mCloseButton.ClickHandler = delegate { Dismiss(); }; mCloseButton.BindPadButton(Buttons.A); //*/ } }
//---------------------------------------------------------------------- public ListView( Screen _screen ) : base(_screen) { Columns = new List<ListViewColumn>(); Rows = new ObservableList<ListViewRow>(); Rows.ListCleared += delegate { SelectedRow = null; HoveredRow = null; FocusedRow = null; mHoveredActionButton = null; mbIsHoveredActionButtonDown = false; }; Rows.ListChanged += delegate( object _source, ObservableList<ListViewRow>.ListChangedEventArgs _args ) { if( ! _args.Added ) { if( _args.Item == SelectedRow ) { SelectedRow = null; } if( _args.Item == HoveredRow ) { UpdateHoveredRow(); } if( _args.Item == FocusedRow ) { FocusedRow = null; IsDragging = false; } } }; SelectedRow = null; FocusedRow = null; HoveredRow = null; TextColor = Screen.Style.DefaultTextColor; Style.ListFrame = Screen.Style.ListFrame; Style.FrameSelected = Screen.Style.GridBoxFrameSelected; Style.FrameSelectedHover = Screen.Style.GridBoxFrameSelectedHover; Style.FrameSelectedFocus = Screen.Style.GridBoxFrameSelectedFocus; Scrollbar = new Scrollbar( _screen ); Scrollbar.Parent = this; ActionButtons = new List<Button>(); UpdateContentSize(); }
//---------------------------------------------------------------------- NuclearUI.Button CreateDemoButton(string _strDemoName, NuclearUI.ManagerPane <MainMenuManager> _demoPane) { var demoPaneButton = new NuclearUI.Button(MenuScreen, _strDemoName); demoPaneButton.ClickHandler = delegate { mDemoPanel.Clear(); mDemoPanel.AddChild(_demoPane); }; return(demoPaneButton); }
//---------------------------------------------------------------------- public BasicDemoPane(MainMenuManager _manager) : base(_manager) { int iRows = 3; var gridGroup = new NuclearUI.GridGroup(Manager.MenuScreen, 2, iRows, false, 0); gridGroup.AnchoredRect = NuclearUI.AnchoredRect.CreateTopLeftAnchored(0, 0, 400, iRows * 50); AddChild(gridGroup); int iRowIndex = 0; //------------------------------------------------------------------ gridGroup.AddChildAt(new NuclearUI.Label(Manager.MenuScreen, "Select Flavor", NuclearUI.Anchor.Start), 0, iRowIndex); { var lItems = new List <NuclearUI.DropDownItem>(); lItems.Add(new NuclearUI.DropDownItem(Manager.MenuScreen, "Chocolate", Flavor.Chocolate)); lItems.Add(new NuclearUI.DropDownItem(Manager.MenuScreen, "Vanilla", Flavor.Vanilla)); lItems.Add(new NuclearUI.DropDownItem(Manager.MenuScreen, "Cheese", Flavor.Cheese)); NuclearUI.DropDownBox dropDownBox = new NuclearUI.DropDownBox(Manager.MenuScreen, lItems, 0); gridGroup.AddChildAt(dropDownBox, 1, iRowIndex); } iRowIndex++; //------------------------------------------------------------------ gridGroup.AddChildAt(new NuclearUI.Label(Manager.MenuScreen, "Choose Cone Size", NuclearUI.Anchor.Start), 0, iRowIndex); { var sizeSlider = new NuclearUI.Slider(Manager.MenuScreen, 1, 5, 1, 1); gridGroup.AddChildAt(sizeSlider, 1, iRowIndex); } iRowIndex++; //------------------------------------------------------------------ gridGroup.AddChildAt(new NuclearUI.Label(Manager.MenuScreen, "Clicky clicky", NuclearUI.Anchor.Start), 0, iRowIndex); { var button = new NuclearUI.Button(Manager.MenuScreen, "Get Ice Cream!"); button.ClickHandler = delegate { Manager.MessagePopup.Setup("Oh noes!", "It melted already. Sorry.", NuclearWinter.i18n.Common.Close, false); Manager.MessagePopup.Open(600, 250); }; gridGroup.AddChildAt(button, 1, iRowIndex); } iRowIndex++; //------------------------------------------------------------------ }
//---------------------------------------------------------------------- public MainMenuManager(Game _game, NuclearUI.Style UIstyle, ContentManager _content) : base(_game, UIstyle, _content) { NuclearUI.Button button = new NuclearUI.Button(MenuScreen, "TestButton"); // Splitter mSplitter = new NuclearUI.Splitter(MenuScreen, NuclearUI.Direction.Up); mSplitter.AnchoredRect = NuclearUI.AnchoredRect.CreateCentered(500, 400);// CreateFull(100, 100, 100, 100); MenuScreen.Root.AddChild(mSplitter); mSplitter.Collapsable = true; mSplitter.FirstPaneMinSize = 100; // Demo list var demosBoxGroup = new NuclearUI.BoxGroup(MenuScreen, NuclearUI.Orientation.Horizontal, 0, NuclearUI.Anchor.Start); mSplitter.FirstPane = demosBoxGroup; mDemoPanel = new NuclearUI.Panel( MenuScreen, Content.Load <Texture2D>("Textures/UI/Panel04"), MenuScreen.Style.PanelCornerSize); var basicDemoPane = new DemoMenus.BasicDemoPane(this); mSplitter.SecondPane = mDemoPanel; mDemoPanel.AddChild(basicDemoPane); // Test button var testButton = new NuclearUI.Button(MenuScreen, "Test"); testButton.ClickHandler = delegate { mDemoPanel.Clear(); }; demosBoxGroup.AddChild(CreateDemoButton("Basic", basicDemoPane), true); demosBoxGroup.AddChild(testButton, true); //demosBoxGroup.AddChild( CreateDemoButton( "Notebook", new Demos.NotebookPane( this ) ), true ); //demosBoxGroup.AddChild( CreateDemoButton( "Text Area", new Demos.TextAreaPane( this ) ), true ); //demosBoxGroup.AddChild( CreateDemoButton( "Custom Viewport", new Demos.CustomViewportPane( this ) ), true ); }
//---------------------------------------------------------------------- public TreeView( Screen _screen ) : base(_screen) { Nodes = new ObservableList<TreeViewNode>(); Nodes.ListCleared += delegate { SelectedNode = null; HoveredNode = null; FocusedNode = null; mHoveredActionButton = null; mbIsHoveredActionButtonDown = false; }; Nodes.ListChanged += delegate( object _source, ObservableList<TreeViewNode>.ListChangedEventArgs _args ) { if( ! _args.Added ) { if( _args.Item == SelectedNode ) { SelectedNode = null; } if( _args.Item == HoveredNode ) { UpdateHoveredNode(); } if( _args.Item == FocusedNode ) { FocusedNode = null; IsDragging = false; } } }; Scrollbar = new UI.Scrollbar( _screen ); Scrollbar.Parent = this; ActionButtons = new List<Button>(); }
internal void UpdateHoveredNode() { TreeViewNode oldHoveredNode = HoveredNode; HoveredNode = null; if( mbIsHovered ) { int iNodeY = ( mHoverPoint.Y - ( LayoutRect.Y + 10 ) + (int)Scrollbar.LerpOffset ); int iOffset = iNodeY % ( NodeHeight + NodeSpacing ); if( iOffset < ( NodeHeight + NodeSpacing ) / 4 ) { InsertMode = NodeInsertMode.Before; } else if( iOffset > ( NodeHeight + NodeSpacing ) * 3 / 4 ) { InsertMode = NodeInsertMode.After; } else { InsertMode = NodeInsertMode.Over; } int iNodeIndex = iNodeY / ( NodeHeight + NodeSpacing ); HoveredNode = FindHoveredNode( Nodes, iNodeIndex, 0 ); if( HoveredNode == null ) { InsertMode = iNodeY < ( NodeHeight + NodeSpacing ) / 4 ? NodeInsertMode.Before : NodeInsertMode.After; } else if( HoverHandler != null && oldHoveredNode != HoveredNode ) { HoverHandler( this ); } if( oldHoveredNode != HoveredNode ) { if( mHoveredActionButton != null ) { if( mbIsHoveredActionButtonDown ) { mHoveredActionButton.ResetPressState(); mbIsHoveredActionButtonDown = false; } mHoveredActionButton = null; } } if( ! IsDragging && HoveredNode != null ) { if( mHoveredActionButton != null ) { if( mHoveredActionButton.HitTest( mHoverPoint ) != null ) { mHoveredActionButton.OnMouseMove( mHoverPoint ); } else { mHoveredActionButton.OnMouseOut( mHoverPoint ); if( mbIsHoveredActionButtonDown ) { mHoveredActionButton.ResetPressState(); mbIsHoveredActionButtonDown = false; } mHoveredActionButton = null; } } if( mHoveredActionButton == null ) { mbIsHoveredActionButtonDown = false; foreach( Button button in ActionButtons ) { if( button.HitTest( mHoverPoint ) != null ) { mHoveredActionButton = button; mHoveredActionButton.OnMouseEnter( mHoverPoint ); break; } } } } else { if( mbIsHoveredActionButtonDown ) { mHoveredActionButton.ResetPressState(); mbIsHoveredActionButtonDown = false; } mHoveredActionButton = null; } } else if( mHoveredActionButton != null ) { if( mbIsHoveredActionButtonDown ) { mHoveredActionButton.ResetPressState(); mbIsHoveredActionButtonDown = false; } mHoveredActionButton = null; } }
void UpdateHoveredRow() { int iRowY = ( mHoverPoint.Y - ( LayoutRect.Y + 10 + ( DisplayColumnHeaders ? RowHeight : 0 ) - (int)Scrollbar.LerpOffset ) ); int iHoveredRowIndex = Math.Max( -1, iRowY / ( RowHeight + RowSpacing ) ); HoveredRow = null; int iOffset = iRowY % ( RowHeight + RowSpacing ); mbInsertAfter = iOffset >= ( RowHeight + RowSpacing ) / 2; if( iHoveredRowIndex >= Rows.Count ) { mbInsertAfter = true; if( mbIsHoveredActionButtonDown ) { mHoveredActionButton.ResetPressState(); mbIsHoveredActionButtonDown = false; } mHoveredActionButton = null; } else if( iHoveredRowIndex >= 0 ) { HoveredRow = Rows[ iHoveredRowIndex ]; if( mHoveredActionButton != null ) { if( mHoveredActionButton.HitTest( mHoverPoint ) != null ) { mHoveredActionButton.OnMouseMove( mHoverPoint ); } else { mHoveredActionButton.OnMouseOut( mHoverPoint ); if( mbIsHoveredActionButtonDown ) { mHoveredActionButton.ResetPressState(); mbIsHoveredActionButtonDown = false; } mHoveredActionButton = null; } } if( mHoveredActionButton == null ) { mbIsHoveredActionButtonDown = false; foreach( Button button in ActionButtons ) { if( button.HitTest( mHoverPoint ) != null ) { mHoveredActionButton = button; mHoveredActionButton.OnMouseEnter( mHoverPoint ); break; } } } } }
//---------------------------------------------------------------------- public override void OnMouseOut( Point _hitPoint ) { HoveredRow = null; if( mHoveredActionButton != null ) { if( mbIsHoveredActionButtonDown ) { mHoveredActionButton.ResetPressState(); mbIsHoveredActionButtonDown = false; } mHoveredActionButton = null; } }
//---------------------------------------------------------------------- public BasicDemoPane(MainMenuManager _manager) : base(_manager) { int iRows = 3; var gridGroup = new NuclearUI.GridGroup(Manager.MenuScreen, 2, iRows, false, 0); gridGroup.AnchoredRect = NuclearUI.AnchoredRect.CreateTopLeftAnchored(0, 0, 400, iRows * 50); var gridGroup2 = new NuclearUI.GridGroup(Manager.MenuScreen, 1, 1, false, 0); gridGroup2.AnchoredRect = NuclearUI.AnchoredRect.CreateBottomAnchored(20, 0, 20, 50); AddChild(gridGroup); AddChild(gridGroup2); int iRowIndex = 0; //------------------------------------------------------------------ gridGroup.AddChildAt(new NuclearUI.Label(Manager.MenuScreen, "Select Flavor", NuclearUI.Anchor.Start), 0, iRowIndex); { var lItems = new List <NuclearUI.DropDownItem>(); lItems.Add(new NuclearUI.DropDownItem(Manager.MenuScreen, "Chocolate", Flavor.Chocolate)); lItems.Add(new NuclearUI.DropDownItem(Manager.MenuScreen, "Vanilla", Flavor.Vanilla)); lItems.Add(new NuclearUI.DropDownItem(Manager.MenuScreen, "Cheese", Flavor.Cheese)); List <NuclearWinter.ScreenMode> modes = NuclearWinter.Resolution.SortedScreenModes; foreach (NuclearWinter.ScreenMode mode in modes) { lItems.Add(new NuclearUI.DropDownItem(Manager.MenuScreen, mode.ToString(), Flavor.Vanilla)); } NuclearUI.DropDownBox dropDownBox = new NuclearUI.DropDownBox(Manager.MenuScreen, lItems, 0); gridGroup.AddChildAt(dropDownBox, 1, iRowIndex); } iRowIndex++; //------------------------------------------------------------------ gridGroup.AddChildAt(new NuclearUI.Label(Manager.MenuScreen, "Draw Distance", NuclearUI.Anchor.Start), 0, iRowIndex); { var sizeSlider = new NuclearUI.Slider(Manager.MenuScreen, 1, 5, 1, 1); gridGroup.AddChildAt(sizeSlider, 1, iRowIndex); } iRowIndex++; //------------------------------------------------------------------ gridGroup.AddChildAt(new NuclearUI.Label(Manager.MenuScreen, "Clicky Clicky", NuclearUI.Anchor.Start), 0, iRowIndex); { var button = new NuclearUI.Button(Manager.MenuScreen, "Go!"); button.ClickHandler = delegate { Manager.MessagePopup.Setup("Oh noes!", "It melted already. Sorry.", NuclearWinter.i18n.Common.Close, false); Manager.MessagePopup.Open(600, 250); }; gridGroup.AddChildAt(button, 1, iRowIndex); } iRowIndex++; //------------------------------------------------------------------ // Add button to second GridGroup { var button = new NuclearUI.Button(Manager.MenuScreen, "Apply Changes"); button.ClickHandler = delegate { Manager.MessagePopup.Setup("Oh noes!", "It melted already. Sorry.", NuclearWinter.i18n.Common.Close, false); Manager.MessagePopup.Open(600, 250); }; gridGroup2.AddChildAt(button, 0, 0); } }
internal void ButtonClicked( Button _button ) { int iSelectedButtonIndex = mlButtons.IndexOf( _button ); if( ClickHandler != null ) { ClickHandler( this, iSelectedButtonIndex ); } SelectedButtonIndex = iSelectedButtonIndex; }
private void imgCommandIcon_ClickHandler(Button sender) { this.Confirm((ICommand)sender.Tag); }
private void entfernen_ClickHandler(Button sender) { int id = ((clsSubUnit)sender.Tag).ID; Program.m_objCampaign.Unit_RemoveSubunit(this.m_objCommandCollection.aktUnit.strOwnerID, this.m_objCommandCollection.aktUnit.Id, id); if (m_objCommandCollection.aktUnit.lisSubUnits.Count == 0) { Program.m_objCampaign.Unit_Remove(this.m_objCommandCollection.aktUnit.strOwnerID, this.m_objCommandCollection.aktUnit.Id); this.Close(); base.raiseUnitWasDestroyd(this.m_objCommandCollection.aktUnit); } Refresh(); }
public void Refresh() { mActionsGroup.Clear(); TitleLabel.Text = m_aktUnit.strBez + " ID " + m_aktUnit.Id; ContentGroup.Clear(); List<clsSubUnit> lisSubUnits = m_aktUnit.lisSubUnits; m_gridSubUnitRooster = new GridGroup(Manager.MenuScreen, 5, lisSubUnits.Count, false, 0); ContentGroup.AddChild(m_gridSubUnitRooster); for (int i = 0; i < lisSubUnits.Count; i++) { Image imgBtn = new Image(Manager.MenuScreen, base.Manager.Content.Load<Texture2D>("Sprites/" + lisSubUnits[i].objUnitType.strIconName)); m_gridSubUnitRooster.AddChildAt(imgBtn, 0, i); Label subLabel = new Label(Manager.MenuScreen); subLabel.Font = Screen.Style.SmallFont; subLabel.Text = lisSubUnits[i].objUnitType.strBez; m_gridSubUnitRooster.AddChildAt(subLabel, 1, i); subLabel = new Label(Manager.MenuScreen); subLabel.Font = Screen.Style.SmallFont; subLabel.Text = "Move: " + lisSubUnits[i].objUnitType.intMovement.ToString(); m_gridSubUnitRooster.AddChildAt(subLabel, 2, i); subLabel = new Label(Manager.MenuScreen); subLabel.Font = Screen.Style.SmallFont; subLabel.Text = "See: " + lisSubUnits[i].objUnitType.intSichtweite.ToString(); m_gridSubUnitRooster.AddChildAt(subLabel, 3, i); BoxGroup testGroup = new BoxGroup(Screen, Orientation.Vertical, 0, Anchor.Center); m_gridSubUnitRooster.AddChildAt(testGroup, 4, i); //add Roosterrow Button mCommandButton = new Button(Screen); mCommandButton.Text = "Destroy " + lisSubUnits[i].ID.ToString(); mCommandButton.Tag = lisSubUnits[i]; mCommandButton.ClickHandler = new Action<Button>(entfernen_ClickHandler); testGroup.AddChild(mCommandButton, false); } mCloseButton.Text = "Schließen"; foreach (ICommand aktCommandType in m_objCommandCollection.listRawCommands) { Button mCommandButton = new Button(Screen); mCommandButton.Text = aktCommandType.strTypeName; mCommandButton.Tag = aktCommandType; mCommandButton.ClickHandler = new Action<Button>(imgCommandIcon_ClickHandler); mActionsGroup.AddChild(mCommandButton); } mActionsGroup.AddChild(mCloseButton); }
//---------------------------------------------------------------------- public NotebookTab( Notebook _notebook, string _strText, Texture2D _iconTex ) : base(_notebook.Screen) { mNotebook = _notebook; Parent = _notebook; mLabel = new Label( Screen, "", Anchor.Start, Screen.Style.DefaultTextColor ); mIcon = new Image( Screen, _iconTex ); mTooltip = new Tooltip( Screen, "" ); mCloseButton = new Button( Screen, new Button.ButtonStyle( 5, null, null, Screen.Style.NotebookTabCloseHover, Screen.Style.NotebookTabCloseDown, null, 0, 0 ), "", Screen.Style.NotebookTabClose, Anchor.Center ); mCloseButton.Parent = this; mCloseButton.Padding = new Box(0); mCloseButton.ClickHandler = delegate { mNotebook.Tabs.Remove( this ); Screen.Focus( mNotebook ); if( mNotebook.TabClosedHandler != null ) { mNotebook.TabClosedHandler( this ); } }; Text = _strText; PageGroup = new Group( Screen ); PageGroup.Parent = this; }