001package votorola.s.gwt.stage; // Copyright 2011-2013, 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.storage.client.Storage;
005import com.google.gwt.user.client.ui.*;
006import votorola.g.web.gwt.*;
007
008
009/** A view of the Crossforum Theatre {@linkplain Stage stage}.  The rough layout is
010  * specified by the scene author.  Only the simplest layout is currently supported, an
011  * example of which is <a href='http://reluk.ca/w/User:Test-bg-ZeleaCom/G/p/sandbox' target='_top'>running here</a>.
012  * It consists mainly of a single array of {@linkplain
013  * Track tracks} (1) positioned at page top.  It also includes an inset {@linkplain WarnV
014  * warning indicator} that is invisible when inactive.<pre>
015  *
016  *                                (2)
017  *      +--------------------------v-----------------------------+
018  *      |--------------------------------------------------------|
019  *      |--------------------------------------------------------| (1)
020  *      |--------------------------------------------------------|
021  *      |                                               /        |
022  *      |                                              /         |
023  *      |                                         tracks         |
024  *      |                                                        |
025  *      |                                                        |
026  *      |                        scene                           |
027  *      |                                                        |
028  *      |                                                        |
029  *      |                                                        |
030  *      |                                                        |
031  *      |                                                        |
032  *      |                                                        |
033  *      +--------------------------------------------------------+</pre>
034  *
035  * <p>The array of tracks encodes itself within an element tagged <code>&lt;div
036  * id='StageV-top'&gt;</code>.  The page author must attach this element either to the
037  * top of the document such that it moves with the scene, or to the top of the viewport
038  * such that the scene scrolls beneath it.  Here are some mockups of simple layouts for
039  * two staged scenes, Votorola's home page and the difference bridge.  Many of the track
040  * visuals here are outdated and no longer reflect the running code, but the overall
041  * layout of tracks is roughly correct:</p><ul>
042  *
043  * <li><a href='http://reluk.ca/project/votorola/s/gwt/stage/_/mock/home-1.xht' target='_blank'>home-1</a></li>
044  * <li><a href='http://reluk.ca/project/votorola/s/gwt/stage/_/mock/home-2.xht' target='_blank'>home-2</a></li>
045  * <li><a href='http://reluk.ca/project/votorola/s/gwt/stage/_/mock/home-3.xht' target='_blank'>home-3</a></li>
046  * <li><a href='http://reluk.ca/project/votorola/s/gwt/stage/_/mock/home-4.xht' target='_blank'>home-4</a></li>
047  * <li><a href='http://reluk.ca/project/votorola/s/gwt/stage/_/mock/diff-1.xht' target='_blank'>diff-1</a></li>
048  * <li><a href='http://reluk.ca/project/votorola/s/gwt/stage/_/mock/diff-2.xht' target='_blank'>diff-2</a></li>
049  *
050  * </ul><p>The composition of the track array (which tracks? in what order?) is a user
051  * preference and does not vary from scene to scene.  More complex layouts of up to four
052  * arrays (1-4) will eventually be supported.  The top array will be present in all such
053  * layouts and all arrays will attach to the viewport, not the page:</p><pre
054  *
055 *>      +--------------------------v-----------------------------+
056  *      |--------------------------------------------------------|
057  *      |--------------------------------------------------------| (1)
058  *      |--------------------------------------------------------|
059  *      ||| (       )                                  /       |||
060  *      |||                                           /        |||
061  *      |||                                       tracks ----- ||| (2)
062  *      |||                                                    |||
063  *      |||                      scene                         |||
064  *      |||                                                    |||
065  *      |||                                                    |||
066  *  (4) ||| ----- tracks                                       |||
067  *      |||       /                                            |||
068  *      |||      /                                             |||
069  *      |--------------------------------------------------------|
070  *  (3) |--------------------------------------------------------|
071  *      +--------------------------------------------------------+</pre>
072  *
073  * <p>There will also be a "curtain", as shown below.  It will temporarily and partially
074  * overlay the scene in order to present larger props, such as navigational views, that
075  * cannot easily be squeezed into the confines of a track:</p><pre
076  *
077 *>      +--------------------------v-----------------------------+
078  *      |--------------------------------------------------------|
079  *      |--------------------------------------------------------|
080  *      |--------------------------------------------------------|
081  *      ||| (       )                                          |||
082  *      |||    |                                               |||
083  *      |||    |                                               |||
084  *      |||    |                                               |||
085  *      |||    |                   curtain                     |||
086  *      |||    |                                               |||
087  *      |||    |                                               |||
088  *      |||    |                                               |||
089  *      |||    +---------------------------------------------- |||
090  *      |||                                                    |||
091  *      |--------------------------------------------------------|
092  *      |--------------------------------------------------------|
093  *      +--------------------------------------------------------+</pre>
094  *
095  * <p>These "curtained props" will include votespace and geomap views.  They are shown
096  * below in stand-alone mockups and prototypes that pre-date the newer stage
097  * design.</p><ul>
098  *
099  * <li><a href='http://reluk.ca/project/votorola/s/gwt/scene/vote/_/1.xht' target='_blank'>Votespace-1</a></li>
100  * <li><a href='http://reluk.ca/project/votorola/s/gwt/scene/vote/_/2.xht' target='_blank'>Votespace-2</a></li>
101  * <li><a href='http://reluk.ca/project/votorola/s/gwt/scene/vote/_/3.xht' target='_blank'>Votespace-3</a></li>
102  * <li><a href='http://reluk.ca/y/vw/xf/#s=G!p!sandbox*f&c=DV' target='_blank'>Votespace-live</a></li>
103  * <li><a href='http://reluk.ca/project/votorola/s/gwt/scene/geo/Geomap.png' target='_blank'>Geomap</a></li>
104  * <li><a href='http://reluk.ca/y/vw/xf/#c=DG' target='_blank'>Geomap-live</a></li>
105  *
106  * </ul><p>You must imagine away the difference feed on the left side of these because it
107  * will not be present in the curtained versions.  The difference feed will eventually be
108  * replaced by a much slimmer talk track, as shown in the previous set of mockups.</p>
109  */
110public final class StageV extends FlowPanel // HTML div
111{
112
113
114    /** Creates the {@linkplain #i() single instance} of StageV.
115      *
116      *     @param toDisplay whether to style the view for immediate display.  Set false
117      *       for embedded displays that require stabilization, then subsequently call
118      *       {@linkplain #initEmbeddedDisplay() initEmbeddedDisplay}() to actually
119      *       display the view.
120      */
121    public StageV( final boolean toDisplay )
122    {
123        final Element element = getElement();
124        element.setId( "StageV-top" );
125        element.addClassName( "staged" );
126        if( !toDisplay ) element.getStyle().setDisplay( Style.Display.NONE );
127        add( new WarnV() );
128        for( Track track: Stage.i().tracks() ) add( track.newView( StageV.this ));
129
130     // final Anchor testTool = new Anchor( "TEST", "HREF" );
131     // final Button testTool = new Button( "TEST" );
132     // testTool.addClickHandler( new com.google.gwt.event.dom.client.ClickHandler()
133     // {
134     //     public void onClick( com.google.gwt.event.dom.client.ClickEvent _e )
135     //     {
136     //         // put your test code here
137     //     }
138     // });
139     // votorola.s.gwt.stage.link.LinkTrackV.i(StageV.this).addLeftTool( testTool );
140    }
141
142
143
144    /** The single instance of StageV.
145      */
146    public static StageV i() { return instance; }
147
148
149        private static StageV instance;
150
151        {
152            if( instance != null ) throw new IllegalStateException();
153
154            instance = StageV.this;
155        }
156
157
158
159    /** Displays the stage view, simultaneously removing any stabilization view from the
160      * top of the document body.
161      */
162    public void initEmbeddedDisplay()
163    {
164      // Display the stage view.
165      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
166        getElement().getStyle().clearDisplay();
167
168      // Undisplay any stabilization view.
169      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
170        final Element div = Document.get().getElementById( "voLayoutStabilizer-top" );
171        if( div != null ) div.getStyle().setDisplay( Style.Display.NONE );
172        else // standard border stabilizer
173        {
174            final Style style = Document.get().getBody().getStyle();
175            final String p = "borderTopStyle";
176            if( "solid".equals(style.getProperty(p)) ) style.setProperty( p, "none" );
177            // else there was no stabilzation
178        }
179    }
180
181
182}