com.threerings.opengl.gui
Class UserInterface

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.Container
          extended by com.threerings.opengl.gui.UserInterface
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>

public class UserInterface
extends Container

A user interface component configured from a resource.


Nested Class Summary
static interface UserInterface.Controller
          An interface that can be implemented by a controller class, specified by name in the UserInterfaceConfig, to automatically wire-up functionality to a UI.
 
Nested classes/interfaces inherited from class com.threerings.opengl.gui.Container
Container.ChildOp
 
Field Summary
protected  UserInterfaceConfig _config
          The configuration of this interface.
protected  UserInterface.Controller _controller
          Our controller, if any.
protected  Root _root
          The root to which we were added.
protected  DynamicScope _scope
          The user interface scope.
protected  com.google.common.collect.ListMultimap<String,Component> _tagged
          The sets of components registered under each tag.
 
Fields inherited from class com.threerings.opengl.gui.Container
_children, _layout
 
Fields inherited from class com.threerings.opengl.gui.Component
_alpha, _backgrounds, _borders, _colors, _ctx, _cursor, _enabled, _height, _hover, _hoverable, _insets, _listeners, _parent, _preferredSize, _properties, _rect, _styleConfigs, _tipmouse, _tiptext, _tooltipStyle, _transferHandler, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Constructor Summary
UserInterface(GlContext ctx)
          Creates a new user interface.
UserInterface(GlContext ctx, ConfigReference<UserInterfaceConfig> ref)
          Creates a new interface with the referenced configuration.
UserInterface(GlContext ctx, String name)
          Creates a new interface with the named configuration.
UserInterface(GlContext ctx, String name, String firstKey, Object firstValue, Object... otherArgs)
          Creates a new interface with the named configuration and arguments.
UserInterface(GlContext ctx, UserInterfaceConfig config)
          Creates a new interface with the given configuration.
 
Method Summary
 void addListener(String tag, ComponentListener listener)
          Shortcut method to add a listener to all components with the specified tag.
 void configUpdated(ConfigEvent<ManagedConfig> event)
          Called when a configuration has been updated.
 Component getComponent(String tag)
          Returns a reference to the first component registered with the specified tag, or null if there are no such components.
<C extends Component>
C
getComponent(String tag, Class<C> clazz)
          Returns a reference to the first component registered with the specified tag and implementing the specified class or interface, or null if there are no such components.
 Iterable<Component> getComponents(String tag)
          Returns the Components registered with the specified tag.
<C extends Component>
Iterable<C>
getComponents(String tag, Class<C> clazz)
          Returns the Components registered with the specified tag.
 UserInterfaceConfig getConfig()
          Returns a reference to the configuration.
protected  UserInterfaceConfig.Original getOriginal()
          Convenience to get a non-null Original implementation.
 DynamicScope getScope()
          Returns a reference to the interface's scope.
 Map<String,Collection<Component>> getTagged()
          Returns a reference to the tagged component map.
 String getText(String tag)
          Shortcut method for retrieving the text of a tagged TextComponent.
 boolean isSelected(String tag)
          Shortcut method for retrieving the selected state of a tagged ToggleButton.
protected  void registerComponent(String tag, Component comp)
          Registers a component with the specified tag.
protected  void registerComponents(Map<String,Collection<Component>> tagged)
          Registers a group of components mapped by tag.
 void removeAllListeners(String tag)
          Shortcut method to remove all listeners from all components with the specified tag.
 void removeListener(String tag, ComponentListener listener)
          Shortcut method to remove a listener from all components with the specified tag.
 boolean replace(String tag, Component newc)
          Replaces the component at the tag with a new component.
 void setConfig(ConfigReference<UserInterfaceConfig> ref)
          Sets the configuration.
 void setConfig(String name)
          Sets the configuration.
 void setConfig(String name, String firstKey, Object firstValue, Object... otherArgs)
          Sets the configuration.
 void setConfig(UserInterfaceConfig config)
          Sets the configuration.
 void setEnabled(String tag, boolean enabled)
          Shortcut method for setting the enabled status of all components bearing the specified tag.
 void setText(String tag, String text)
          Shortcut method for setting the text of all TextComponents bearing the specified tag.
 void setVisible(String tag, boolean visible)
          Shortcut method for setting the visibility status of all components bearing the specified tag.
protected  void updateFromConfig()
          Updates the interface to match its new or modified configuration.
protected  void wasAdded()
          This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up).
protected  void wasRemoved()
          This method is called when we are removed from a hierarchy that is connected to a top-level window.
 
Methods inherited from class com.threerings.opengl.gui.Container
add, add, add, add, applyOperation, computePreferredSize, getComponent, getComponentCount, getComponentIndex, getDefaultStyleConfig, getFirstDescendantFocus, getHitComponent, getLastDescendantFocus, getLayoutManager, getNextFocus, getPreviousFocus, layout, remove, remove, removeAll, renderComponent, replace, setAlpha, setEnabled, setHoverable, setLayoutManager, validate
 
Methods inherited from class com.threerings.opengl.gui.Component
acceptsFocus, addListener, boundsToString, changeCursor, contains, createDefaultTooltipComponent, createDefaultTooltipComponent, createTooltipComponent, dispatchEvent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getContext, getCursor, getFallbackState, getFocusTarget, getHeight, getInsets, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleConfigs, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, getTransferHandler, getWidth, getWindow, getX, getY, hasFocus, intersectScissor, invalidate, isAdded, isEnabled, isHoverable, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, scrollRectToVisible, scrollRectToVisible, setBackground, setBounds, setCursor, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleConfig, setStyleConfig, setStyleConfig, setStyleConfigs, setTooltipRelativeToMouse, setTooltipText, setTransferHandler, setVisible, stateDidChange, updateCursor, updateFromStyleConfig, updateFromStyleConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_scope

protected DynamicScope _scope
The user interface scope.


_config

protected UserInterfaceConfig _config
The configuration of this interface.


_controller

protected UserInterface.Controller _controller
Our controller, if any.


_tagged

protected com.google.common.collect.ListMultimap<String,Component> _tagged
The sets of components registered under each tag.


_root

protected Root _root
The root to which we were added.

Constructor Detail

UserInterface

public UserInterface(GlContext ctx)
Creates a new user interface.


UserInterface

public UserInterface(GlContext ctx,
                     String name)
Creates a new interface with the named configuration.


UserInterface

public UserInterface(GlContext ctx,
                     String name,
                     String firstKey,
                     Object firstValue,
                     Object... otherArgs)
Creates a new interface with the named configuration and arguments.


UserInterface

public UserInterface(GlContext ctx,
                     ConfigReference<UserInterfaceConfig> ref)
Creates a new interface with the referenced configuration.


UserInterface

public UserInterface(GlContext ctx,
                     UserInterfaceConfig config)
Creates a new interface with the given configuration.

Method Detail

getScope

public DynamicScope getScope()
Returns a reference to the interface's scope.


setConfig

public void setConfig(String name)
Sets the configuration.


setConfig

public void setConfig(ConfigReference<UserInterfaceConfig> ref)
Sets the configuration.


setConfig

public void setConfig(String name,
                      String firstKey,
                      Object firstValue,
                      Object... otherArgs)
Sets the configuration.


setConfig

public void setConfig(UserInterfaceConfig config)
Sets the configuration.


getConfig

public UserInterfaceConfig getConfig()
Returns a reference to the configuration.


setEnabled

public void setEnabled(String tag,
                       boolean enabled)
Shortcut method for setting the enabled status of all components bearing the specified tag.


setVisible

public void setVisible(String tag,
                       boolean visible)
Shortcut method for setting the visibility status of all components bearing the specified tag.


setText

public void setText(String tag,
                    String text)
Shortcut method for setting the text of all TextComponents bearing the specified tag.


getText

public String getText(String tag)
Shortcut method for retrieving the text of a tagged TextComponent.


isSelected

public boolean isSelected(String tag)
Shortcut method for retrieving the selected state of a tagged ToggleButton.


addListener

public void addListener(String tag,
                        ComponentListener listener)
Shortcut method to add a listener to all components with the specified tag.


removeListener

public void removeListener(String tag,
                           ComponentListener listener)
Shortcut method to remove a listener from all components with the specified tag.


removeAllListeners

public void removeAllListeners(String tag)
Shortcut method to remove all listeners from all components with the specified tag.


getComponent

public Component getComponent(String tag)
Returns a reference to the first component registered with the specified tag, or null if there are no such components.


getComponent

public <C extends Component> C getComponent(String tag,
                                            Class<C> clazz)
Returns a reference to the first component registered with the specified tag and implementing the specified class or interface, or null if there are no such components.


getComponents

public <C extends Component> Iterable<C> getComponents(String tag,
                                                       Class<C> clazz)
Returns the Components registered with the specified tag.


getComponents

public Iterable<Component> getComponents(String tag)
Returns the Components registered with the specified tag.


getTagged

public Map<String,Collection<Component>> getTagged()
Returns a reference to the tagged component map.


replace

public boolean replace(String tag,
                       Component newc)
Replaces the component at the tag with a new component.


configUpdated

public void configUpdated(ConfigEvent<ManagedConfig> event)
Description copied from interface: ConfigUpdateListener
Called when a configuration has been updated.

Specified by:
configUpdated in interface ConfigUpdateListener<ManagedConfig>
Overrides:
configUpdated in class Component

wasAdded

protected void wasAdded()
Description copied from class: Component
This method is called when we are added to a hierarchy that is connected to a top-level window (at which point we can rely on having a look and feel and can set ourselves up).

Overrides:
wasAdded in class Container

wasRemoved

protected void wasRemoved()
Description copied from class: Component
This method is called when we are removed from a hierarchy that is connected to a top-level window. If we wish to clean up after things done in Component.wasAdded(), this is a fine place to do so.

Overrides:
wasRemoved in class Container

updateFromConfig

protected void updateFromConfig()
Updates the interface to match its new or modified configuration.


getOriginal

protected UserInterfaceConfig.Original getOriginal()
Convenience to get a non-null Original implementation.


registerComponents

@Scoped
protected void registerComponents(Map<String,Collection<Component>> tagged)
Registers a group of components mapped by tag.


registerComponent

@Scoped
protected void registerComponent(String tag,
                                        Component comp)
Registers a component with the specified tag.