/// <summary> /// {@link #pack() Packs} the dialog and adds it to the stage /// </summary> /// <param name="stage">Stage.</param> public Dialog show(Stage stage) { setPosition(Mathf.round((stage.getWidth() - getWidth()) / 2), Mathf.round((stage.getHeight() - getHeight()) / 2)); pack(); stage.addElement(this); return(this); }
public void show(Stage stage) { if (listBox.isTouchable()) { return; } stage.addElement(this); _screenPosition = _selectBox.localToStageCoordinates(Vector2.Zero); // show the list above or below the select box, limited to a number of items and the available height in the stage. float itemHeight = listBox.getItemHeight(); float height = itemHeight * (maxListCount <= 0 ? _selectBox.getItems().Count : Math.Min(maxListCount, _selectBox.getItems().Count)); var scrollPaneBackground = getStyle().background; if (scrollPaneBackground != null) { height += scrollPaneBackground.topHeight + scrollPaneBackground.bottomHeight; } var listBackground = listBox.getStyle().background; if (listBackground != null) { height += listBackground.topHeight + listBackground.bottomHeight; } float heightAbove = _screenPosition.Y; float heightBelow = Screen.height /*camera.viewportHeight */ - _screenPosition.Y - _selectBox.getHeight(); _isListBelowSelectBox = true; if (height > heightBelow) { if (heightAbove > heightBelow) { _isListBelowSelectBox = false; height = Math.Min(height, heightAbove); } else { height = heightBelow; } } if (!_isListBelowSelectBox) { setY(_screenPosition.Y - height); } else { setY(_screenPosition.Y + _selectBox.getHeight()); } setX(_screenPosition.X); setHeight(height); validate(); var width = Math.Max(preferredWidth, _selectBox.getWidth()); if (preferredHeight > height && !_disableY) { width += getScrollBarWidth(); } setWidth(width); validate(); scrollTo( 0, listBox.getHeight() - _selectBox.getSelectedIndex() * itemHeight - itemHeight / 2, 0, 0, true, true); updateVisualScroll(); _previousScrollFocus = null; listBox.getSelection().set(_selectBox.getSelected()); listBox.setTouchable(Touchable.Enabled); _selectBox.onShow(this, _isListBelowSelectBox); }