public void startLayout(ButtonGrid buttonGrid) { this.buttonGrid = buttonGrid; this.canvasSize = buttonGrid.ScrollView.CanvasSize; allowNewlines = false; int totalWidth = ItemWidth + ItemPaddingX; if (!center) { totalWidth -= ItemPaddingX; //Don't need padding on last element if not centered. } int numElements = canvasSize.Width / totalWidth; if (numElements > 0) { int totalElementWidth = numElements * totalWidth; calculatedPadding = (canvasSize.Width - totalElementWidth) / numElements; xStartPosition = center ? calculatedPadding / 2 : 0; } else { calculatedPadding = ItemPaddingX; xStartPosition = 0; } currentPosition = new IntVector2(xStartPosition, 0); }
/// <summary> /// Constructor. /// </summary> /// <param name="name">The name of the group.</param> /// <param name="grid">The grid the group belongs to.</param> public ButtonGridGroup(String name, ButtonGrid grid) { this.grid = grid; this.Name = name; if (grid.ShowGroupCaptions) { caption = grid.CaptionFactory.createCaption(name); toggleCaptionVisibility(); } }
internal ButtonGridItem(ButtonGridGroup group, ButtonGrid list) { this.grid = list; this.Group = group; button = list.ScrollView.createWidgetT("Button", list.ButtonSkin, 0, 0, list.ItemWidth, list.ItemHeight, Align.Top | Align.Left, "") as Button; button.ForwardMouseWheelToParent = true; button.MouseButtonClick += new MyGUIEvent(button_MouseButtonClick); button.MouseButtonDoubleClick += new MyGUIEvent(button_MouseButtonDoubleClick); button.MouseButtonPressed += new MyGUIEvent(button_MouseButtonPressed); button.MouseButtonReleased += new MyGUIEvent(button_MouseButtonReleased); button.MouseDrag += new MyGUIEvent(button_MouseDrag); }
public void startLayout(ButtonGrid buttonGrid) { currentPosition = new IntVector2(0, 0); int totalSize = buttonGrid.Count * (ItemHeight + ItemPaddingY); if (buttonGrid.ShowGroupCaptions) { totalSize += buttonGrid.CaptionHeight * buttonGrid.NonEmptyGroupCount; } //Set the height of the canvas, this allows us to get the width of the client region adjusted for scrollbars canvasSize = buttonGrid.ScrollView.CanvasSize; canvasSize.Height = totalSize; buttonGrid.ScrollView.CanvasSize = canvasSize; //Get the item width from the ViewCoord ItemWidth = buttonGrid.ScrollView.ViewCoord.width; canvasSize.Width = ItemWidth; }
public void startLayout(ButtonGrid buttonGrid) { this.buttonGrid = buttonGrid; currentPosition = new IntVector2(0, 0); this.canvasSize = buttonGrid.ScrollView.CanvasSize; }
/// <summary> /// Set the ButtonGrid for this caption. /// </summary> /// <param name="grid">The grid to set.</param> internal void setButtonGrid(ButtonGrid grid) { this.Grid = grid; gridSet(); }