<plugin id="tuto10_launch_basic_config">
    <requirement id="sight::module::ui" />
    <requirement id="sight::module::ui::qt" />
    <requirement id="sight::module::service" />

    <!-- Allows to include a xml file containing a sub-configuration -->
    <xi:include href="basic_frame_config.xml" xmlns:xi="http://www.w3.org/2003/XInclude" />

    <extension implements="sight::app::extension::config">
        <id>tuto10_launch_basic_config</id>
        <config>
            <!-- ******************************* Objects declaration ****************************** -->

            <object uid="image" type="sight::data::image" />
            <object uid="config_started" type="sight::data::boolean" value="false" />

            <!-- ******************************* UI declaration *********************************** -->

            <service uid="main_frame" type="sight::module::ui::frame">
                <gui>
                    <frame>
                        <name>Tutorial 10: Launch a configuration</name>
                        <icon>tuto10_launch_basic_config/tuto.ico</icon>
                        <min_size width="800" height="600" />
                    </frame>
                    <menubar />
                </gui>
                <registry>
                    <menubar sid="menu_bar_view" />
                    <view sid="image_renderer_srv" />
                </registry>
            </service>

            <service uid="menu_bar_view" type="sight::module::ui::menubar">
                <gui>
                    <layout>
                        <menu name="File" />
                    </layout>
                </gui>
                <registry>
                    <menu sid="menu_file_view" />
                </registry>
            </service>

            <service uid="menu_file_view" type="sight::module::ui::menu">
                <gui>
                    <layout>
                        <menu_item name="Open image" shortcut="Ctrl+O" />
                        <separator />
                        <menu_item name="Launch config" style="check" shortcut="Ctrl+L" />
                        <separator />
                        <menu_item name="Quit" special_action="QUIT" shortcut="Ctrl+Q" />
                    </layout>
                </gui>
                <registry>
                    <menu_item sid="open_image_act" />
                    <menu_item sid="launch_config_act" />
                    <menu_item sid="quit_act" />
                </registry>
            </service>

            <!-- ******************************* Actions ****************************************** -->

            <service uid="open_image_act" type="sight::module::ui::action" />

            <service uid="quit_act" type="sight::module::ui::quit" />
            <service uid="launch_config_act" type="sight::module::ui::action">
                <properties checked="${config_started}" />
            </service>

            <!-- ************************ Configuration launchers ********************************* -->

            <!--
                Configuration launcher:
                This service allows to launch a sub-configuration.
                The configuration is defined by its id.
            -->
            <service uid="frame_cfg" type="sight::app::config_launcher">
                <properties config="tuto10_launch_basic_config::basic_frame_config" start="${config_started}" />
                <!--
                    replace ${image} in the sub-config by the uid of the object with the key
                    (ie. ${image} is replaced by "image")
                -->
                <inout group="object">
                    <key name="image" uid="image" />
                </inout>
            </service>

            <!-- ******************************* Services ***************************************** -->

            <service uid="image_reader_srv" type="sight::module::ui::io::selector">
                <inout key="data" uid="image" />
            </service>

            <service uid="image_renderer_srv" type="sight::module::viz::sample::image">
                <in key="image" uid="image" />
            </service>

            <connect>
                <signal>open_image_act/clicked</signal>
                <slot>image_reader_srv/update</slot>
            </connect>
        </config>
    </extension>
</plugin>
