#textdomain wesnoth
[schema]
    identifier="re ^[a-zA-Z_]+$"
    # slash-separated filenames
    path="re ^([a-z0-9\-.+]+/)*[a-z0-9\-.+]+$"
    # for non-negative geometry
    unsigned="re ^[0-9]+$"

    border="enum top,bottom,left,right,all"
    halign="enum left,right,center"
    valign="enum top,bottom,center"

    [root]
        _gui="required gui" # or repeated? maybe we need a new 'at least one' type
    [/root]

    [column]
        border="optional border"
        border_size="optional unsigned"
        grow_factor="optional unsigned"
        horizontal_alignment="optional halign"
        horizontal_grow="optional boolean"
        vertical_alignment="optional valign"
        vertical_grow="optional boolean"
        #TODO: possible other stuff

        # A column should contain exactly one widget
        # How are we going to define that, if at all?
        _button="optional button"
        _horizontal_listbox="optional horizontal_listbox"
        _horizontal_scrollbar="optional horizontal_scrollbar"
        _image="optional image"
        _label="optional label"
        _listbox="optional listbox"
        _menubar="optional menubar"
        _minimap="optional minimap"
        _multi_page="optional multi_page"
        _panel="optional panel"
        _repeating_button="optional repeating_button"
        _scroll_label="optional scroll_label"
        _scrollbar_panel="optional scrollbar_panel"
        _slider="optional slider"
        _spacer="optional spacer"
        _stacked_widget="optional stacked_widget"
        _text_box="optional text_box"
        _password_box="optional password_box"
        _toggle_button="optional toggle_button"
        _toggle_panel="optional toggle_panel"
        _tree_view="optional tree_view"
        _vertical_scrollbar="optional vertical_scrollbar"
        _grid="optional grid"
    [/column]
    [grid]
        _row="repeated row"

        id="optional identifier"
        linked_group="optional identifier"
    [/grid]
    [gui]
        _settings="required settings"

        #TODO: make sure all the below are actually optional
        _button_definition="repeated button_definition"
        _horizontal_listbox_definition="repeated horizontal_listbox_definition"
        _horizontal_scrollbar_definition="repeated horizontal_scrollbar_definition"
        _image_definition="repeated image_definition"
        _label_definition="repeated label_definition"
        _listbox_definition="repeated listbox_definition"
        _menubar_definition="repeated menubar_definition"
        _minimap_definition="repeated minimap_definition"
        _multi_page_definition="repeated multi_page_definition"
        _panel_definition="repeated panel_definition"
        _repeating_button_definition="repeated repeating_button_definition"
        _scrollbar_panel_definition="repeated scrollbar_panel_definition"
        _scroll_label_definition="repeated scroll_label_definition"
        _slider_definition="repeated slider_definition"
        _spacer_definition="repeated spacer_definition"
        _stacked_widget_definition="repeated stacked_widget_definition"
        _text_box_definition="repeated text_box_definition"
        _toggle_button_definition="repeated toggle_button_definition"
        _toggle_panel_definition="repeated toggle_panel_definition"
        _tooltip_definition="repeated tooltip_definition"
        _tree_view_definition="repeated tree_view_definition"
        _vertical_scrollbar_definition="repeated vertical_scrollbar_definition"
        _window_definition="repeated window_definition"
        _window="repeated window"

        id="required identifier"
        description="required string"
    [/gui]
    [label:control]
        wrap="optional boolean"
    [/label:control]
    [panel_definition:control_definition]
        _resolution="repeated panel_definition-resolution"
    [/panel_definition:control_definition]
    [panel_definition-resolution:resolution_definition]
        bottom_border="optional unsigned"
        left_border="optional unsigned"
        right_border="optional unsigned"
        top_border="optional unsigned"

        _background="optional state_definition"
        _foreground="optional state_definition"
    [/panel_definition-resolution:resolution_definition]
    [row]
        grow_factor="optional unsigned"

        _column="repeated column"
    [/row]
    [settings]
        double_click_time="required unsigned"
        help_show_time="optional unsigned"
        popup_show_delay="optional unsigned"
        popup_show_time="optional unsigned"
        repeat_button_repeat_time="optional unsigned"
        sound_button_click="optional path"
        sound_toggle_button_click="optional path"
        sound_toggle_panel_click="optional path"
        sound_slider_adjust="optional path"
    [/settings]
    [state_definition]
        _draw="required draw"
    [/state_definition]
    [window:widget]
        _resolution="repeated resolution"

        # We *may* want to move this to widget, if all instances of tbuilder_widget actually have it
        description="required string"
        id="required identifier"
    [/window:widget]
    [window_definition:control_definition]
        _resolution="repeated window_definition-resolution"
    [/window_definition:control_definition]
    [window_definition-resolution:panel_definition-resolution]
        _grid="optional grid" #TODO: check if it's actually required
    [/window_definition-resolution:panel_definition-resolution]

    # Base things that are only (mostly) derived from
    [control:widget]
        debug_border_colour="optional string" #TODO: colour
        debug_border_mode="optional unsigned"
        definition="optional identifier"
        help="optional string"
        id="optional identifier"
        label="optional string"
        linked_group="optional identifier"
        tooltip="optional string"
        use_tooltip_on_label_overflow="optional boolean"
    [/control:widget]
    [control_definition]
        _resolution="repeated resolution"

        description="required string"
        id="required identifier"
    [/control_definition]
    [resolution]
        _grid="required grid"
        _linked_group="repeated linked_group"

        automatic_placement="optional boolean"
        click_dismiss="optional boolean"
        definition="optional identifier"
        height="optional string" # A formula that returns unsigned
        horizontal_placement="optional halign"
        maximum_height="optional unsigned"
        maximum_width="optional unsigned"
        vertical_placement="optional valign"
        width="optional string" # A formula that returns unsigned
        window_height="optional unsigned"
        window_width="optional unsigned"
        x="optional string" # A formula that returns unsigned
        y="optional string" # A formula that returns unsigned
    [/resolution]
    [resolution_definition]
        default_height="optional unsigned"
        default_width="optional unsigned"
        max_height="optional unsigned"
        max_width="optional unsigned"
        min_height="optional unsigned"
        min_width="optional unsigned"
        text_extra_height="optional unsigned"
        text_extra_width="optional unsigned"
        text_font_size="optional unsigned"
        window_height="optional unsigned"
        window_width="optional unsigned"

        text_font_style="optional string" #TODO: this is an enum
    [/resolution_definition]
    [widget]
    [/widget]
[/schema]
