<commit_before>//
// Triple Play - utilities for use in PlayN-based games
// Copyright (c) 2011, Three Rings Design, Inc. - All rights reserved.
// http://github.com/threerings/tripleplay/blob/master/LICENSE

package tripleplay.ui;

import pythagoras.f.IDimension;
import react.UnitSlot;
import tripleplay.util.DimensionValue;

/**
 * A group that allows configuring its preferred size. The size is always returned when the size
 * of the group is calculated, but the group may end up being stretched when contained in a
 * layout that does so.
 */
public class SizableGroup extends Group
{
    /** The preferred size of this widget. Update at will. */
    public final DimensionValue preferredSize = new DimensionValue(0, 0);

    /** Creates the sizable group with preferred width and height of 0. Note that this will
     * cause the base layout preferred size to be used, if overridden. */
    public SizableGroup (Layout layout) {
        this(layout, 0, 0);
    }

    /** Creates the sizable group with the given preferred size. */
    public SizableGroup (Layout layout, IDimension size) {
        this(layout, size.width(), size.height());
    }

    /** Creates the sizable group with preferred width and height. */
    public SizableGroup (Layout layout, float wid, float hei) {
        super(layout);
        preferredSize.update(wid, hei);
        preferredSize.connect(new UnitSlot() {
            @Override public void onEmit () {
                invalidate();
            }
        });
    }

    /** Creates the layout to which the group's {@link Element.SizableLayoutData} will delegate. */
    protected BaseLayoutData createBaseLayoutData (float hintX, float hintY) {
        return null;
    }

    @Override protected LayoutData createLayoutData (float hintX, float hintY) {
        // use a sizable layout data with our preferred size and delegate to the base, if any
        return new SizableLayoutData(createBaseLayoutData(hintX, hintY), preferredSize.get());
    }
}
<commit_msg>Don't provide the base layout feature for SizableGroup<commit_after>//
// Triple Play - utilities for use in PlayN-based games
// Copyright (c) 2011, Three Rings Design, Inc. - All rights reserved.
// http://github.com/threerings/tripleplay/blob/master/LICENSE

package tripleplay.ui;

import pythagoras.f.IDimension;
import react.UnitSlot;
import tripleplay.util.DimensionValue;

/**
 * A group that allows configuring its preferred size. The size is always returned when the size
 * of the group is calculated, but the group may end up being stretched when contained in a
 * layout that does so.
 */
public class SizableGroup extends Group
{
    /** The preferred size of this widget. Update at will. */
    public final DimensionValue preferredSize = new DimensionValue(0, 0);

    /** Creates the sizable group with preferred width and height of 0. Note that this will
     * cause the base layout preferred size to be used, if overridden. */
    public SizableGroup (Layout layout) {
        this(layout, 0, 0);
    }

    /** Creates the sizable group with the given preferred size. */
    public SizableGroup (Layout layout, IDimension size) {
        this(layout, size.width(), size.height());
    }

    /** Creates the sizable group with preferred width and height. */
    public SizableGroup (Layout layout, float wid, float hei) {
        super(layout);
        preferredSize.update(wid, hei);
        preferredSize.connect(new UnitSlot() {
            @Override public void onEmit () {
                invalidate();
            }
        });
    }

    @Override protected LayoutData createLayoutData (float hintX, float hintY) {
        // use a sizable layout data with our preferred size and delegate to the base, if any
        return new SizableLayoutData(super.createLayoutData(hintX, hintY), preferredSize.get());
    }
}

{'fraction_non_alphanumeric': 0.08757796257796258, 'fraction_numerical': 0.004677754677754678, 'mean_word_length': 2.9927385892116183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '129308', 'n_tokens_mistral': 1039, 'n_tokens_neox': 1005, 'n_words': 413}