#! /usr/bin/env python
#
import sys
from ginga.main import ReferenceViewer
from optparse import OptionParser

my_layout = ['seq', {},
               ['vbox', dict(name='top', width=1520, height=900),
                dict(row=['hbox', dict(name='menu')],
                     stretch=0),
                dict(row=['vpanel', dict(name='vpnl', height=500, width=1520),
                          ['hpanel', dict(name='hpnl'),
                           ['vpanel', dict(name='left', width=600, height=500),
                            ['ws', dict(name='uleft', wstype='tabs',
                                       width=600, height=300, group=2)],
                            ['hbox', dict(name='lleft', width=600, height=300),
                             dict(col=['ws', dict(name='pan', wstype='stack',
                                                  group=2)],
                                  stretch=1),
                             dict(col=['ws', dict(name='zoom', wstype='stack',
                                         group=2)],
                                  stretch=0),
                             ],
                            ],
                           ['ws', dict(name='right', wstype='tabs',
                                       width=600, group=2)],
                           ],
                          ['ws', dict(name='channels', wstype='mdi',
                                      height=600, width=1520, group=1),
                           ]], stretch=1),
                dict(row=['ws', dict(name='cbar', wstype='stack',
                                     group=99)], stretch=0),
                dict(row=['ws', dict(name='operations', wstype='stack',
                                       group=99)], stretch=0),
                dict(row=['ws', dict(name='toolbar', wstype='stack',
                                     height=40, group=5)],
                     stretch=0),
                dict(row=['hbox', dict(name='status')], stretch=0),
                ]]

if __name__ == "__main__":

    viewer = ReferenceViewer(layout=my_layout)
    # add global plugins
    viewer.add_global_plugin('Header', "uleft", start_plugin=True)
    viewer.add_global_plugin('Pan', "pan", start_plugin=True)
    viewer.add_global_plugin('Zoom', "zoom", start_plugin=True)

    #viewer.add_global_plugin('Info', "right", start_plugin=True)
    viewer.add_global_plugin('Thumbs', "right", start_plugin=True)

    viewer.add_global_plugin('Colorbar', "cbar", start_plugin=True)
    viewer.add_global_plugin('Operations', "operations", start_plugin=True)
    viewer.add_global_plugin('Toolbar', "toolbar", start_plugin=True)

    # add local plugins
    #viewer.add_local_plugin()

    # Parse command line options with optparse module
    usage = "usage: %prog [options] cmd [args]"
    optprs = OptionParser(usage=usage)
    viewer.add_default_options(optprs)

    (options, args) = optprs.parse_args(sys.argv[1:])

    viewer.main(options, args)
