<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 java.util.ArrayList;
import java.util.List;

import playn.core.Game;
import playn.core.GroupLayer;
import playn.core.Layer;
import playn.core.Pointer;

/**
 * The main class that integrates the Triple Play UI with a PlayN game. This class is mainly
 * necessary to handle the proper dispatching of input events to UI elements. Create an interface
 * instance, create {@link Root} groups via the interface and add the {@link Root#layer}s into your
 * scene graph wherever you desire. Call {@link #update} and {@link #paint} from {@link
 * Game#update} and {@link Game#paint} to render your interface.
 */
public class Interface
{
    /**
     * This pointer listener must be configured in order to make this interface active. It is
     * exposed so that apps can manage their pointer listener stack however they like.
     */
    public final Pointer.Listener plistener = new Pointer.Listener() {
        @Override public void onPointerStart (Pointer.Event event) {
            float x = event.x(), y = event.y();
            try {
                // copy our roots to a separate list to avoid conflicts if a root is added or
                // removed while dispatching an event
                _dispatch.addAll(_roots);
                for (Root root : _dispatch) {
                    if (root.dispatchPointerStart(x, y)) {
                        _active = root;
                        return;
                    }
                }
                _delegate.onPointerStart(event);
            } finally {
                _dispatch.clear();
            }<commit_msg>Dispatch to roots in most-recently-created order<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 java.util.ArrayList;
import java.util.List;

import playn.core.Game;
import playn.core.GroupLayer;
import playn.core.Layer;
import playn.core.Pointer;

/**
 * The main class that integrates the Triple Play UI with a PlayN game. This class is mainly
 * necessary to handle the proper dispatching of input events to UI elements. Create an interface
 * instance, create {@link Root} groups via the interface and add the {@link Root#layer}s into your
 * scene graph wherever you desire. Call {@link #update} and {@link #paint} from {@link
 * Game#update} and {@link Game#paint} to render your interface.
 */
public class Interface
{
    /**
     * This pointer listener must be configured in order to make this interface active. It is
     * exposed so that apps can manage their pointer listener stack however they like.
     */
    public final Pointer.Listener plistener = new Pointer.Listener() {
        @Override public void onPointerStart (Pointer.Event event) {
            float x = event.x(), y = event.y();
            try {
                // copy our roots to a separate list to avoid conflicts if a root is added or
                // removed while dispatching an event.
                _dispatch.addAll(_roots);
                // dispatch to the roots in most-recently-created order as a more recently added
                // root is probably on top. TODO - use layer depth
                for (int ii = _dispatch.size() - 1; ii >= 0; ii--) {
                    if (_dispatch.get(ii).dispatchPointerStart(x, y)) {
                        _active = _dispatch.get(ii);
                        return;
                    }
                }
                _delegate.onPointerStart(event);
            } finally {
                _dispatch.clear();
            }
{'fraction_non_alphanumeric': 0.08649625613219726, 'fraction_numerical': 0.002581977794990963, 'mean_word_length': 2.188477366255144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3942940', 'n_tokens_mistral': 1010, 'n_tokens_neox': 959, 'n_words': 402}