Example usage for com.badlogic.gdx.scenes.scene2d.ui WidgetGroup getPrefHeight

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui WidgetGroup getPrefHeight

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui WidgetGroup getPrefHeight.

Prototype

public float getPrefHeight() 

Source Link

Usage

From source file:es.eucm.ead.editor.view.widgets.draw.ColorPickerPanel.java

License:Open Source License

public void completeRowsIfPossible(WidgetGroup reference) {
    reference.layout();//from w  ww  . j  a v  a 2 s .co m
    IconButton image = (IconButton) colors.getChildren().first();

    int rowsToAdd = Math.min(
            (int) Math.floor((Gdx.graphics.getHeight() - reference.getPrefHeight()) / image.getPrefHeight()),
            style.rows - colors.getRows());

    for (int i = 0; i < rowsToAdd; i++) {
        addColorRow();
    }

    SnapshotArray<Actor> children = colors.getChildren();
    for (int i = 0, n = children.size; i < n; ++i) {
        Actor actor = children.get(i);

        int intCol = prefs.getInteger(Preferences.PREF_COLOR + i, -1);
        if (intCol == -1) {
            float[] rgb = picker.HSBtoRGB(i / (float) n, 1, 1);
            actor.setColor(rgb[0], rgb[1], rgb[2], 1f);
        } else {
            Color.rgba8888ToColor(actor.getColor(), intCol);
            actor.setColor(actor.getColor());
        }
    }
}