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

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

Introduction

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

Prototype

public void layout() 

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();
    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();//  w w  w . ja v a  2  s. co  m
    }

    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());
        }
    }
}