/// <summary> /// Updates the GUI Item /// </summary> /// <param name="mouseState">Mouse state.</param> public override void Update(vxEngine vxEngine) { SetLengths(); //Position_Requested = Position_Original; Position_Original = this.xTabCntrl.Position - new Vector2(this.xTabCntrl.TabHeight - Padding, 0); if (HasFocus == true) { ForceSelect = false; } //First Set Position based off of Selection Status if (IsSelected || ForceSelect) { Position_Requested = Position_Original + OffsetVector; } else if (HasFocus == false) { Position_Requested = Position_Original; } Position = vxMathHelper.Smooth(Position, Position_Requested, 6); //Then Set Tab Position TabPosition = this.Position + TabPositionOffset; TabTextPosition = this.Position + TabTextPositionOffset; Rec_Tab = new Rectangle((int)(TabPosition.X), (int)(TabPosition.Y), tabHeight, tabWidth); //vxConsole.WriteToInGameDebug(TabPosition); BoundingRectangle = Rec_Tab; base.Update(vxEngine); if (HasFocus == false) { Rec_Back = new Rectangle((int)(Position.X), (int)(Position.Y), this.Width, this.Height); BoundingRectangle = Rec_Back; base.Update(vxEngine); } //First Set Position for (int i = 0; i < Items.Count; i++) { vxGUIBaseItem bsGuiItm = Items [i]; bsGuiItm.Position = this.Position + ChildElementOffset + bsGuiItm.OriginalPosition; bsGuiItm.Update(vxEngine); if (bsGuiItm.HasFocus == true) { HasFocus = true; } //Re-eable all child items if (Math.Abs(Vector2.Subtract(Position, Position_Requested).Length()) < 10) { bsGuiItm.Enabled = true; bsGuiItm.HoverAlphaReq = 1; } else { bsGuiItm.Enabled = false; bsGuiItm.HoverAlphaReq = 0; } } }
/// <summary> /// Add an Item to the Scroll Panel /// </summary> /// <param name="guiItem">GUI item.</param> public void AddItem(vxGUIBaseItem guiItem) { //vxConsole.WriteLine ("Adding Item: " + guiItem.GetType ().ToString ()); if (guiItem.GetType() == typeof(vxFileDialogItem) || guiItem.GetBaseGuiType() == typeof(vxScrollPanelItem)) { Padding = 5; } //int temp_height = 0; //First, Check that the Width of the item is not wider than the panel it's self; /****************************************************************************************************/ if (guiItem.Width > this.BoundingRectangle.Width) { guiItem.Width = this.BoundingRectangle.Width - this.Padding * 3 - this.ScrollBarWidth; } //First set position relative too last item /****************************************************************************************************/ if (Items.Count > 0) { //If there's more than one item in teh scroll panel, get it. vxGUIBaseItem LastGuiItem = Items[Items.Count - 1]; //Now Set the Position of the new item relative too the previous one. guiItem.Position = LastGuiItem.Position + new Vector2(LastGuiItem.BoundingRectangle.Width + Padding, 0); } else { //If this is the first item, stick it in the top left corner. guiItem.Position = new Vector2(Padding); } //Check if it is inside the bounding rectangle, if not, move it down one row. /****************************************************************************************************/ //if (guiItem.Position.X + guiItem.BoundingRectangle.Width > this.Position.X + BoundingRectangle.Width - Padding * 2 - ScrollBarWidth || if (guiItem.Position.X + guiItem.BoundingRectangle.Width > BoundingRectangle.Width - Padding * 2 - ScrollBarWidth || guiItem.GetType() == typeof(vxFileDialogItem) || guiItem.GetBaseGuiType() == typeof(vxScrollPanelItem)) { if (Items.Count > 0) { vxGUIBaseItem LastGuiItem = Items[Items.Count - 1]; guiItem.Position = new Vector2(Padding, LastGuiItem.Position.Y + LastGuiItem.BoundingRectangle.Height + Padding); } //There's a chance that This item is the width of the scroll panel, so it //should be set as the minimum between it's width, and the scroll panels width //guiItem.Width = Math.Min(guiItem.Width, BoundingRectangle.Width - Padding * 2 - ScrollBarWidth); } //Reset the Original Position guiItem.OriginalPosition = guiItem.Position; //scrollBar.ViewHeight = (int)((float)(BoundingRectangle.Height - 2*Padding) * Math.Min(1,((float)BoundingRectangle.Height / (float)temp_height))); //TODO: Put Item Spefic code in the items classes them selves, not here. if (guiItem.GetType() == typeof(vxFileDialogItem)) { ((vxFileDialogItem)guiItem).ButtonWidth = BoundingRectangle.Width - Padding * 4 - ScrollBarWidth; } if (guiItem.GetBaseGuiType() == typeof(vxScrollPanelItem)) { ((vxScrollPanelItem)guiItem).ButtonWidth = BoundingRectangle.Width - Padding * 4 - ScrollBarWidth; } //Finally Add the newly Positioned and Sized Item. Items.Add(guiItem); //Finally, set the Scrollbar scroll length. /****************************************************************************************************/ float totalHeight = this.Height; float tempPos_min = this.Height - 1; float tempPos_max = this.Height; //Get The Max and Min Positions of Items to get the overall Height foreach (vxGUIBaseItem bsGuiItm in Items) { tempPos_min = Math.Min(bsGuiItm.Position.Y, tempPos_min); tempPos_max = Math.Max(bsGuiItm.Position.Y + bsGuiItm.BoundingRectangle.Height, tempPos_max); } scrollBar.ScrollLength = (int)((tempPos_max - tempPos_min)); }
/// <summary> /// Adds the item. /// </summary> /// <param name="guiItem">GUI item.</param> public void AddItem(vxGUIBaseItem guiItem) { Items.Add(guiItem); }
/// <summary> /// Constructor. /// </summary> public vxGuiItemClickEventArgs(vxGUIBaseItem vxbaseGuiItem) { this.vxbaseGuiItem = vxbaseGuiItem; }