Search in sources :

Example 1 with IBounds

use of de.mossgrabers.framework.graphics.IBounds in project DrivenByMoss by git-moss.

the class OptionsComponent method draw.

/**
 * {@inheritDoc}
 */
@Override
public void draw(final IGraphicsInfo info) {
    final IGraphicsContext gc = info.getContext();
    final IGraphicsDimensions dimensions = info.getDimensions();
    final double menuHeight = 2 * dimensions.getMenuHeight();
    final IGraphicsConfiguration configuration = info.getConfiguration();
    this.header.draw(info.withBounds(0, menuHeight));
    final IBounds bounds = info.getBounds();
    final double left = bounds.left();
    final double height = bounds.height();
    this.footer.draw(info.withBounds(height - menuHeight, menuHeight));
    final boolean hasTopHeader = this.headerTop != null && !this.headerTop.isEmpty();
    final boolean hasBottomHeader = this.headerBottom != null && !this.headerBottom.isEmpty();
    if (!hasTopHeader && !hasBottomHeader)
        return;
    final double headerHeight = (height - 2 * menuHeight) / 2;
    final ColorEx textColor = configuration.getColorText();
    if (hasTopHeader)
        gc.drawTextInHeight(this.headerTop, left, menuHeight, headerHeight, textColor, headerHeight / 2.0);
    if (hasBottomHeader) {
        if (this.isBottomHeaderSelected)
            gc.drawTextInHeight(this.headerBottom, left, menuHeight + headerHeight, headerHeight, ColorEx.calcContrastColor(textColor), textColor, headerHeight / 2.0);
        else
            gc.drawTextInHeight(this.headerBottom, left, menuHeight + headerHeight, headerHeight, textColor, headerHeight / 2.0);
    }
}
Also used : IGraphicsContext(de.mossgrabers.framework.graphics.IGraphicsContext) IGraphicsConfiguration(de.mossgrabers.framework.graphics.IGraphicsConfiguration) IBounds(de.mossgrabers.framework.graphics.IBounds) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IGraphicsDimensions(de.mossgrabers.framework.graphics.IGraphicsDimensions)

Example 2 with IBounds

use of de.mossgrabers.framework.graphics.IBounds in project DrivenByMoss by git-moss.

the class LabelComponent method draw.

/**
 * {@inheritDoc}
 */
@Override
public void draw(final IGraphicsInfo info) {
    if (this.layout == LabelLayout.SEPARATE_COLOR) {
        this.drawSeparateColorLayout(info);
        return;
    }
    final IGraphicsConfiguration configuration = info.getConfiguration();
    final IBounds bounds = info.getBounds();
    final IGraphicsDimensions dimensions = info.getDimensions();
    final double separatorSize = dimensions.getSeparatorSize();
    final double menuHeight = dimensions.getMenuHeight();
    final ColorEx bgColor = this.getBackgroundColor(configuration);
    final ColorEx textColor = ColorEx.calcContrastColor(bgColor);
    if (this.text == null || this.text.length() == 0) {
        if (this.layout == LabelLayout.SMALL_HEADER) {
            // Remove the 2 pixels of the previous menus border line
            info.getContext().fillRectangle(bounds.left() - separatorSize, menuHeight - 2, separatorSize, 1, configuration.getColorBorder());
        }
        return;
    }
    final double left = bounds.left();
    final double top = bounds.top();
    final double width = bounds.width();
    final double height = bounds.height();
    final IGraphicsContext gc = info.getContext();
    if (this.layout == LabelLayout.SMALL_HEADER) {
        gc.fillRectangle(left, top, width, menuHeight - 1.0, bgColor);
        gc.fillRectangle(left, menuHeight - 2.0, width + separatorSize, 1, this.isSelected ? bgColor : textColor);
    } else
        gc.fillRectangle(left, top, width, height, bgColor);
    final double unit = dimensions.getUnit();
    if (this.layout == LabelLayout.SMALL_HEADER)
        gc.drawTextInBounds(this.text, left, 1, width, unit + separatorSize, Align.CENTER, textColor, unit);
    else
        gc.drawTextInBounds(this.text, left, top, width, height, Align.CENTER, textColor, height / 2);
}
Also used : IGraphicsContext(de.mossgrabers.framework.graphics.IGraphicsContext) IGraphicsConfiguration(de.mossgrabers.framework.graphics.IGraphicsConfiguration) IBounds(de.mossgrabers.framework.graphics.IBounds) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IGraphicsDimensions(de.mossgrabers.framework.graphics.IGraphicsDimensions)

Aggregations

ColorEx (de.mossgrabers.framework.controller.color.ColorEx)2 IBounds (de.mossgrabers.framework.graphics.IBounds)2 IGraphicsConfiguration (de.mossgrabers.framework.graphics.IGraphicsConfiguration)2 IGraphicsContext (de.mossgrabers.framework.graphics.IGraphicsContext)2 IGraphicsDimensions (de.mossgrabers.framework.graphics.IGraphicsDimensions)2