{
  "namespace": "gamepad_layout",

  //---------------------------------------------------------------------------
  // Common
  //---------------------------------------------------------------------------
  "dark_thin_button": {
    "type": "image",
    "texture": "textures/ui/dark_thin_button",
    "layer": 3
  },

  "normal_stroke_button": {
    "type": "image",
    "texture": "textures/ui/normal_stroke_button",
    "layer": 3
  },

  "normal_thin_button": {
    "type": "image",
    "texture": "textures/ui/NormalButtonThinNewBevel",
    "layer": 3
  },

  "hover_thin_stroke_button": {
    "type": "image",
    "texture": "textures/ui/hover_thin_stroke_button",
    "layer": 3
  },

  "hover_thin_button": {
    "type": "image",
    "texture": "textures/ui/HoverButtonThinNewBevel2",
    "layer": 3
  },

  "indent": {
    "type": "image",
    "texture": "textures/ui/default_indent",
    "layer": 3
  },

  //---------------------------------------------------------------------------
  // Text
  //---------------------------------------------------------------------------

  "gamepad_action_text": {
    "type": "label",
    "color": "$generic_button_text_color",
    "shadow": true,
    "layer": 5
  },

  "actions@gamepad_action_text": {
    "text": "controllerLayoutScreen.actions",
    "offset": [ "23%", "8%" ]
  },

  "bindings@gamepad_action_text": {
    "text": "controllerLayoutScreen.bindings",
    "offset": [ "-20%", "8%" ]
  },

  "header@gamepad_action_text": {
    "text": "options.controllerLayout",
    "offset": [ 0, "2%" ]
  },

  "gamepad_action@gamepad_action_text": {
    "text": "#action",
    "bindings": [
      {
        "binding_name": "#action",
        "binding_type": "collection",
        "binding_collection_name": "gamepad_action_items"
      }
    ]
  },

  "gamepad_binding@gamepad_action_text": {
    "text": "#binding",
    "bindings": [
      {
        "binding_name": "#binding",
        "binding_type": "collection",
        "binding_collection_name": "gamepad_action_items"
      }
    ]
  },

  "confirmation_text@gamepad_action_text": {
    "text": "#confirmation",
    "offset": [ 0, "-5%" ],
    "bindings": [
      {
        "binding_name": "#confirmation"
      }
    ]
  },


  //---------------------------------------------------------------------------
  // Buttons
  //---------------------------------------------------------------------------

  "back_button@common.button": {
    "$pressed_button_name": "button.menu_exit",
    "size": [ "33%-2px", "100%" ],
    "offset": [ -1, 0 ],
    "anchor_to": "bottom_right",
    "anchor_from": "bottom_right",
    "layer": 4,
    "controls": [
      {
        "default@normal_thin_button": {
          "controls": [
            {
              "back_button_text@common.button_text": {
                "text": "controllerLayoutScreen.cancel"
              }
            }
          ]
        }
      },
      {
        "hover@hover_thin_button": {
          "controls": [
            {
              "back_button_text@common.button_text": {
                "text": "controllerLayoutScreen.cancel",
                "color": "$generic_button_text_color"
              }
            }
          ]
        }
      },
      {
        "pressed@normal_thin_button": {
          "controls": [
            {
              "back_button_text@common.button_text": {
                "text": "controllerLayoutScreen.cancel",
                "color": "$generic_button_text_color",
                "alpha": 0.65
              }
            }
          ]
        }
      }
    ]
  },

  "accept_button@common.button": {
    "$pressed_button_name": "button.menu_save_and_exit",
    "size": [ "33%-2px", "100%" ],
    "offset": [ 1, 0 ],
    "anchor_to": "bottom_left",
    "anchor_from": "bottom_left",
    "layer": 4,
    "controls": [
      {
        "default@normal_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "controllerLayoutScreen.save"
              }
            }
          ]
        }
      },
      {
        "hover@hover_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "controllerLayoutScreen.save",
                "color": "$generic_button_text_color"
              }
            }
          ]
        }
      },
      {
        "pressed@normal_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "controllerLayoutScreen.save",
                "color": "$generic_button_text_color",
                "alpha": 0.65
              }
            }
          ]
        }
      }
    ]
  },

  "reset_button@common.button": {
    "$pressed_button_name": "button.menu_reset_default",
    "size": [ "33%-2px", "100%" ],
    "offset": [ 0, 0 ],
    "anchor_to": "bottom_middle",
    "anchor_from": "bottom_middle",
    "layer": 4,
    "controls": [
      {
        "default@normal_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "controls.reset"
              }
            }
          ]
        }
      },
      {
        "hover@hover_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "controls.reset",
                "color": "$generic_button_text_color"
              }
            }
          ]
        }
      },
      {
        "pressed@normal_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "controls.reset",
                "color": "$generic_button_text_color",
                "alpha": 0.65
              }
            }
          ]
        }
      }
    ]
  },

  "yes_button@common.button": {
    "$pressed_button_name": "button.menu_yes",
    "size": [ "50%-2px", "100%" ],
    "offset": [ 1, 0 ],
    "anchor_to": "bottom_left",
    "anchor_from": "bottom_left",
    "layer": 4,
    "controls": [
      {
        "default@normal_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "gui.yes"
              }
            }
          ]
        }
      },
      {
        "hover@hover_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "gui.yes",
                "color": "$generic_button_text_color"
              }
            }
          ]
        }
      },
      {
        "pressed@normal_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "gui.yes",
                "color": "$generic_button_text_color",
                "alpha": 0.65
              }
            }
          ]
        }
      }
    ]
  },

  "no_button@common.button": {
    "$pressed_button_name": "button.menu_no",
    "size": [ "50%-2px", "100%" ],
    "offset": [ -1, 0 ],
    "anchor_to": "bottom_right",
    "anchor_from": "bottom_right",
    "layer": 4,
    "controls": [
      {
        "default@normal_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "gui.no"
              }
            }
          ]
        }
      },
      {
        "hover@hover_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "gui.no",
                "color": "$generic_button_text_color"
              }
            }
          ]
        }
      },
      {
        "pressed@normal_thin_button": {
          "controls": [
            {
              "accept_button_text@common.button_text": {
                "text": "gui.no",
                "color": "$generic_button_text_color",
                "alpha": 0.65
              }
            }
          ]
        }
      }
    ]
  },

  "bottom_buttons": {
    "type": "panel",
    "anchor_to": "bottom_middle",
    "anchor_from": "bottom_middle",
    "size": [ "100%-6px", "15%" ],
    "offset": [ 0, -4 ],
    "controls": [
      { "accept@accept_button": { } },
      { "reset@reset_button": { } },
      { "back@back_button": { } }
    ]
  },

  "cda_button_buttons": {
    "type": "panel",
    "anchor_to": "bottom_middle",
    "anchor_from": "bottom_middle",
    "size": [ "100%-6px", "25%" ],
    "offset": [ 0, -4 ],
    "controls": [
      { "yes@yes_button": { } },
      { "no@no_button": { } }
    ]
  },

  "gamepad_action_item_button_default_state": {
    "type": "panel",
    "size": [ "60%-1px", 25 ],
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "layer": 4,
    "controls": [
      { "action_bg@normal_thin_button": { } },
      { "action_text@gamepad_action": { } }
    ]
  },

  "gamepad_action_item_button_hover_state": {
    "type": "panel",
    "layer": 4,
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "controls": [
      { "action_bg@hover_thin_stroke_button": { } },
      {
        "action_text@gamepad_action": {
          "color": "$generic_button_text_color"
        }
      }
    ]
  },

  "gamepad_binding_button_hover_state": {
    "type": "panel",
    "layer": 4,
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "controls": [
      { "binding_bg@hover_thin_stroke_button": { } },
      {
        "binding_text@gamepad_binding": {
          "color": "$generic_button_text_color"
        }
      }
    ]
  },

  "gamepad_binding_button_default_state": {
    "type": "panel",
    "layer": 4,
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "controls": [
      { "binding_bg@dark_thin_button": { } },
      { "binding_text@gamepad_binding": { } }
    ]
  },

  "gamepad_action_item_button@common.button": {
    "$pressed_button_name": "button.menu_binding_start",
    "size": [ "60%-1px", 25 ],
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "bindings": [
      {
        "binding_type": "collection_details",
        "binding_collection_name": "gamepad_action_items"
      }
    ],
    "controls": [
      { "default@gamepad_action_item_button_default_state": { } },
      { "hover@gamepad_action_item_button_hover_state": { } },
      { "pressed@gamepad_action_item_button_hover_state": { } }
    ]
  },

  "gamepad_binding_button@common.button": {
    "$pressed_button_name": "button.menu_binding_start",
    "size": [ "40%-1px", 25 ],
    "anchor_from": "top_right",
    "anchor_to": "top_right",
    "bindings": [
      {
        "binding_type": "collection_details",
        "binding_collection_name": "gamepad_action_items"
      }
    ],
    "controls": [
      { "default@gamepad_binding_button_default_state": { } },
      { "hover@gamepad_binding_button_hover_state": { } },
      { "pressed@gamepad_binding_button_hover_state": { } }
    ]
  },

  //---------------------------------------------------------------------------
  // Grid Items
  //---------------------------------------------------------------------------

  "gamepad_action_items": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "100%", 26 ],
    "controls": [
      { "action_panel@gamepad_action_item_button_default_state": { } },
      { "binding_button@gamepad_binding_button": { } }
    ]
  },


  "gamepad_action_grid": {
    "type": "grid",
    "grid_item_template": "gamepad_action_items",
    "grid_dimension_binding": "#gamepad_action_item_grid_dimension",
    "collection_name": "gamepad_action_items",
    "anchor_to": "top_left",
    "anchor_from": "top_left",
    "size": [ "100%", "default" ],
    "bindings": [
      {
        "binding_name": "#gamepad_action_item_grid_dimension"
      }
    ]
  },

  "gamepad_action_grid_layout": {
    "type": "panel",
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "size": [ "100% - 4px", "100%c + 4px" ],
    "offset": [ 2, 2 ],
    "layer": 1,
    "controls": [
      {
        "gamepad_action_grid@gamepad_layout.gamepad_action_grid": { }
      }
    ]
  },

  //---------------------------------------------------------------------------
  // Panels
  //---------------------------------------------------------------------------

  "root_panel_common": {
    "type": "panel",
    "anchor_to": "top_middle",
    "anchor_from": "top_middle",
    "size": [ "100%", "100%" ],
    "controls": [
      { "root_button@normal_stroke_button": { "layer": 1 } },
      { "header_text@header": { } },
      { "bindings_text@bindings": { } },
      { "actions_text@actions": { } },
      { "root_edit_panel@gamepad_edit_panel": { } },
      { "root_bottom_buttons@bottom_buttons": { "layer": 2 } },
      { "input_siphon@ghost_binding": { "visible": false } }
    ],
    "bindings": [
      {
        "binding_name": "#root_visible",
        "binding_name_override": "#visible"
      }
    ]
  },

  "cda_panel": {
    "type": "panel",
    "anchor_to": "center",
    "anchor_from": "center",
    "size": [ "70%", "60%" ],
    "controls": [
      { "bg@normal_stroke_button": { } },
      { "cda_text@confirmation_text": { } },
      { "test_buttons@cda_button_buttons": { } }
    ],
    "bindings": [
      {
        "binding_name": "#cda_visible",
        "binding_name_override": "#visible"
      }
    ]
  },

  "gamepad_action_binding": {
    "type": "panel",
    "anchor_to": "top_right",
    "anchor_from": "top_right",
    "size": [ "50%", 25 ],
    "offset": [ 0, 2 ],
    "controls": [
      { "binding_bg@dark_thin_button": { } },
      { "binding_txt@gamepad_binding": { } }
    ]
  },

  "gamepad_edit_panel": {
    "type": "panel",
    "anchor_to": "top_middle",
    "anchor_from": "top_middle",
    "size": [ "100%-14px", "68%" ],
    "offset": [ 0, "15%" ],
    "controls": [
      {
        "scroll_area_panel": {
          "type": "panel",
          "anchor_from": "top_left",
          "anchor_to": "top_left",
          "size": [ "100%", "100%" ],
          "offset": [ 0, -6 ],
          "controls": [
            {
              "scroll_section": {
                "type": "panel",
                "controls": [
                  {
                    "scrolling_panel@common.scrolling_panel": {
                      "$scrolling_pane_size": [ "100%", "100%" ],
                      "$scrolling_content": "gamepad_layout.gamepad_action_grid_layout"
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  "ghost_binding": {
    "type": "input_panel",
    "button_mappings": [
      {
        "from_button_id": "any",
        "mapping_type": "global"
      }
    ],
    "bindings": [
      {
        "binding_name": "#binding_state",
        "binding_name_override": "#visible"
      }
    ]
  },
  //---------------------------------------------------------------------------
  // Screen
  //---------------------------------------------------------------------------
  "gamepad_layout_screen@common.base_screen": {
    "button_mappings": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.menu_exit",
        "mapping_type": "global"
      },
      {
        "from_button_id": "button.menu_tab_left",
        "to_button_id": "button.menu_tab_left",
        "mapping_type": "global",
        "scope": "view"
      },
      {
        "from_button_id": "button.menu_tab_right",
        "to_button_id": "button.menu_tab_right",
        "mapping_type": "global",
        "scope": "view"
      }
    ],
    "$screen_content": "gamepad_layout.gamepad_layout_screen_content"
  },

  "gamepad_layout_screen_content": {
    "type": "panel",
    "controls": [

      { "fade_panel@cda_panel": { } },
      { "root_panel@root_panel_common": { } }
    ]
  }

}