001package 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. 002 003import com.google.gwt.dom.client.*; 004import com.google.gwt.user.client.*; 005import com.google.gwt.user.client.ui.*; 006import votorola.s.gwt.stage.*; 007 008import static com.google.gwt.dom.client.Style.Unit.EM; 009 010 011/** The top view of the Scenes UI. It lays out the root panel as follows:<pre> 012 * 013 * +--------------------------------------+ 014 * | stage | 015 * +-----------+--------------------------+ 016 * | | | 017 * | | | 018 * | | | 019 * | feed | scene | 020 * | | | 021 * | | | 022 * | | | 023 * | | | 024 * +-----------+--------------------------+</pre> 025 */ 026public final class ScenesV 027{ 028 029 030 /** Constructs the single instance of ScenesV. 031 * 032 * @see #i() 033 */ 034 ScenesV() 035 { 036 Window.enableScrolling( false ); // root panel fills whatever is given 037 final RootPanel body = RootPanel.get(); 038 // body.addStyleName( "ScenesV" ); 039 final RootLayoutPanel p = RootLayoutPanel.get(); // adds itself to body 040 p.add( dockPanel ); 041 final float stageHeight = 3.8f; // em, this is what I see (MCA) 042 p.setWidgetTopBottom( dockPanel, stageHeight + 0.2f/* spare room*/, EM, 0,EM ); 043 // maybe just temporary for sake of feed's scroll bar which is otherwise 044 // obscured by stage, or maybe required for future scenes in any case. But 045 // stage height is not exactly proportional to font height (because of images, 046 // padding and such) so this only a rough estimate. It would be better in 047 // future if we expose this number and let each scene take whatever evasive 048 // action is necessary (padding or moving controls around) rather than squeezing 049 // the size of all scenes regardless, as we're doing here 050 dockPanel.addWest( feedPanel, 20 ); // edge widgets cannot be changed after widget added to center, so provide a panel 051 body.add( new StageV( /*toDisplay*/true )); 052 // add after p, else z-index rule in CSS has no effect. Add to body for natural 053 // height instead of to p whose RootLayoutPanel insists on setting a height 054 } 055 056 057 058 /** The single instance of ScenesV. 059 */ 060 public static ScenesV i() { return instance; } 061 062 063 private static ScenesV instance; 064 065 { // constructed by Entry 066 if( instance != null ) throw new IllegalStateException(); 067 068 instance = ScenesV.this; 069 } 070 071 072 073 // ------------------------------------------------------------------------------------ 074 075 076 /** Sets the feed view. 077 */ 078 public void setFeed( final Widget feedV ) { feedPanel.setWidget( feedV ); } 079 080 081 082 /** Sets the scene view. 083 */ 084 public void setScene( final Widget sceneV ) { dockPanel.add( sceneV ); } // to center 085 086 087 088//// P r i v a t e /////////////////////////////////////////////////////////////////////// 089 090 091 private final ScrollPanel feedPanel = new ScrollPanel(); 092 093 { 094 feedPanel.setAlwaysShowScrollBars( true ); 095 feedPanel.getElement().getStyle().setOverflowX( Style.Overflow.HIDDEN ); 096 // no horizontal scroll bar 097 } 098 099 100 101 private final DockLayoutPanel dockPanel = new DockLayoutPanel( EM ); 102 103 104 105}