package votorola.s.gwt.scene; // Copyright 2010-2011, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import com.google.gwt.dom.client.*; import com.google.gwt.user.client.*; import com.google.gwt.user.client.ui.*; import votorola.s.gwt.stage.*; import static com.google.gwt.dom.client.Style.Unit.EM; /** The top view of the Scenes UI. It lays out the root panel as follows:
  *
  *    +--------------------------------------+
  *    |                stage                 |
  *    +-----------+--------------------------+
  *    |           |                          |
  *    |           |                          |
  *    |           |                          |
  *    |   feed    |          scene           |
  *    |           |                          |
  *    |           |                          |
  *    |           |                          |
  *    |           |                          |
  *    +-----------+--------------------------+
*/ public final class ScenesV { /** Constructs the single instance of ScenesV. * * @see #i() */ ScenesV() { Window.enableScrolling( false ); // root panel fills whatever is given final RootPanel body = RootPanel.get(); // body.addStyleName( "ScenesV" ); final RootLayoutPanel p = RootLayoutPanel.get(); // adds itself to body p.add( dockPanel ); final float stageHeight = 3.8f; // em, this is what I see (MCA) p.setWidgetTopBottom( dockPanel, stageHeight + 0.2f/* spare room*/, EM, 0,EM ); // maybe just temporary for sake of feed's scroll bar which is otherwise // obscured by stage, or maybe required for future scenes in any case. But // stage height is not exactly proportional to font height (because of images, // padding and such) so this only a rough estimate. It would be better in // future if we expose this number and let each scene take whatever evasive // action is necessary (padding or moving controls around) rather than squeezing // the size of all scenes regardless, as we're doing here dockPanel.addWest( feedPanel, 20 ); // edge widgets cannot be changed after widget added to center, so provide a panel body.add( new StageV( /*toDisplay*/true )); // add after p, else z-index rule in CSS has no effect. Add to body for natural // height instead of to p whose RootLayoutPanel insists on setting a height } /** The single instance of ScenesV. */ public static ScenesV i() { return instance; } private static ScenesV instance; { // constructed by Entry if( instance != null ) throw new IllegalStateException(); instance = ScenesV.this; } // ------------------------------------------------------------------------------------ /** Sets the feed view. */ public void setFeed( final Widget feedV ) { feedPanel.setWidget( feedV ); } /** Sets the scene view. */ public void setScene( final Widget sceneV ) { dockPanel.add( sceneV ); } // to center //// P r i v a t e /////////////////////////////////////////////////////////////////////// private final ScrollPanel feedPanel = new ScrollPanel(); { feedPanel.setAlwaysShowScrollBars( true ); feedPanel.getElement().getStyle().setOverflowX( Style.Overflow.HIDDEN ); // no horizontal scroll bar } private final DockLayoutPanel dockPanel = new DockLayoutPanel( EM ); }