public override void draw(Graphics graphics, float parentAlpha) { validate(); IDrawable background; if (_isDisabled && style.backgroundDisabled != null) { background = style.backgroundDisabled; } else if (_selectBoxList.hasParent() && style.backgroundOpen != null) { background = style.backgroundOpen; } else if (_isMouseOver && style.backgroundOver != null) { background = style.backgroundOver; } else if (style.background != null) { background = style.background; } else { background = null; } var font = style.font; var fontColor = _isDisabled ? style.disabledFontColor : style.fontColor; var color = getColor(); color = new Color(color, color.A * parentAlpha); float x = getX(); float y = getY(); float width = getWidth(); float height = getHeight(); if (background != null) { background.draw(graphics, x, y, width, height, color); } var selected = _selection.first(); if (selected != null) { var str = selected.ToString(); if (background != null) { width -= background.leftWidth + background.rightWidth; height -= background.bottomHeight + background.topHeight; x += background.leftWidth; y += (int)(height / 2 + background.bottomHeight - font.lineHeight / 2); } else { y += (int)(height / 2 + font.lineHeight / 2); } fontColor = new Color(fontColor, fontColor.A * parentAlpha); graphics.batcher.drawString(font, str, new Vector2(x, y), fontColor); } }
/// <summary> /// Returns the first selected item, or null /// </summary> /// <returns>The selected.</returns> public T getSelected() { return(_selection.first()); }