{
  "namespace": "library_item",

  "dark_background": {
    "type": "image",
    "texture": "textures/ui/dark_bg"
  },

  "black_background": {
    "type": "image",
    "texture": "textures/ui/Black"
  },

  "scrolling_content": {
    "size": [ "100% - 2px", "100%c + 10px" ],
    "type": "panel",
    "controls": [
      { "content@library_item.content": {} }
    ]
  },

  "content": {
    "type": "stack_panel",
    "orientation": "vertical",
    "size": [ "100% - 4px", "100%c - 4px" ],
    "controls": [
      { "stack_buffer1@library_item.black_background": { "size": [ "100%", 1 ] } },
      {
        "world_top_panel@library_item.black_background": {
          "size": [ "100%", "100%c" ],
          "controls": [
            { "world_top@library_item.world_top": {} }
          ]
        }
      },
      { "padding_middle@common.empty_panel": { "size": [ "100%", 6 ] } },
      {
        "description": {
          "type": "label",
          "size": [ "default", 10 ],
          "text": "library.item.description",
          "color": "$generic_button_text_color"
        }
      },
      {
        "world_bottom_panel@library_item.black_background": {
          "size": [ "100%", "100%c" ],
          "controls": [
            { "world_bottom@library_item.world_bottom": {} }
          ]
        }
      }
    ]
  },

  "thumbnail": {
    "type": "image",
    "bilinear": true,
    "bindings": [
      {
        "binding_name": "#world_texture",
        "binding_name_override": "#texture"
      },
      {
        "binding_name": "#file_system",
        "binding_name_override": "#texture_file_system"
      }
    ]
  },

  /*********************
        BUTTONS
  *********************/

  "import_button@common_buttons.light_text_button": {
    "$font_type": "smooth",
    "layer": 1,
    "$button_text": "gui.importWorld",
    "$pressed_button_name": "button.import_world"
  },

  "launch_button@common_buttons.light_text_button": {
    "$font_type": "smooth",
    "layer": 1,
    "$button_text": "library.item.launch",
    "$pressed_button_name": "button.launch_world"
  },

  "author@library.base_label": {
    "text": "#author",
    "bindings": [
      { "binding_name": "#author" }
    ]
  },

  "title@library.base_label": {
    "text": "#title",
    "font_scale_factor": 1.3,
    "bindings": [
      { "binding_name": "#title" }
    ]
  },

  "button_panel@library_item.button_panel": {
    "size": [ "50%", "100%" ],
    "offset": [ 2, 0 ],
    "anchor_from": "left_middle",
    "anchor_to": "left_middle"
  },

  "summary_content_label@library.base_label": {
    "size": [ "100%", "default" ],
    "offset": [ 0, 0 ],
    "text": "#subtitle",
    "bindings": [
      { "binding_name": "#subtitle" }
    ]
  },

  "summary_content@library_item.summary_content_label": {
    "controls": [
      {
        // When there is a nested scroll view, the child
        // doesn't get focus when hovered (unless directly
        // over the bar). If we put an input panel over it
        // we get focus and scrolling works as one would
        // expect. However we need to hide it if the scroll
        // bar isn't visible otherwise it will take input
        // from the parent scroll view when it shouldn't.
        // Directly binding to the bar and track wasn't
        // working so a round-a-bout method for getting
        // visiblity was set up.
        "scroll_focuser": {
          "type": "input_panel",
          "focus_enabled": true,
          "bindings": [
            {
              "binding_type": "view",
              "source_control_name": "$scroll_view_name",
              "source_property_name": "#scroll_bar_visible",
              "target_property_name": "#visible"
            }
          ]
        }
      }
    ]
  },

  "summary": {
    "type": "panel",
    "size": [ "100% - 3px", "90%" ],
    "offset": [ 3, 0 ],
    "anchor_from": "top_left",
    "anchor_to": "top_left",
    "controls": [
      {
        "summary_scrolling_panel@common.scrolling_panel": {
          "size": [ "100%", "100%" ],
          "$scroll_view_name": "summary_scroll_view",
          "$scrolling_content": "library_item.summary_content"
        }
      }
    ]
  },

  "panel_wrapper": {
    "type": "panel",
    "layer": 1,
    "$content|default": "",
    "controls": [
      {
        "place_holder@library_item.$content": { "layer": 2 }
      }
    ]
  },

  "button_panel": {
    "type": "panel",
    "controls": [
      {
        "launch_button@library_item.launch_button": {
          "bindings": [
            {
              "binding_name": "#imported_template",
              "binding_name_override": "#visible"
            }
          ]
        }
      },
      {
        "import_button@library_item.import_button": {
          "bindings": [
            {
              "binding_name": "(not #imported_template)",
              "binding_name_override": "#visible"
            }
          ]
        }
      }
    ]
  },

  "world_summary": {
    "type": "stack_panel",
    "orientation": "vertical",
    "size": [ "100%", "100%" ],
    "controls": [
      { "padding_top@common.empty_panel": { "size": [ "100%", 3 ] } },
      {
        "title_panel@library_item.panel_wrapper": {
          "size": [ "100%", 15 ],
          "$content": "title"
        }
      },
      {
        "author_panel@library_item.panel_wrapper": {
          "size": [ "100%", 15 ],
          "$content": "author"
        }
      },
      {
        "button_panel@library_item.panel_wrapper": {
          "size": [ "100%", 20 ],
          "$content": "button_panel"
        }
      },
      { "padding_before_summary@common.empty_panel": { "size": [ "100%", 3 ] } },
      {
        "summary_panel@library_item.panel_wrapper": {
          "size": [ "100%", "fill" ],
          "$content": "summary"
        }
      }
    ]
  },

  "world_top": {
    "type": "stack_panel",
    "orientation": "horizontal",
    // thumbnail scaling results in odd y value size
    "size": [ "100% - 2px", "28.75%x - 2px" ],
    "controls": [
      {
        "world_image_panel": {
          "size": [ "50%", "100%" ],
          "type": "stack_panel",
          "orientation": "vertical",
          "controls": [
            {
              // Image dimensions are 480 x 270 = 56.25% ratio of y to x. The .25% is handled in parent panel so that black borders line up nicely
              "thumbnail@library_item.thumbnail": {
                "size": [ "100%", "56%x" ],
                "layer": 1
              }
            }
          ]
        }
      },
      { "horizontal_padding@common.empty_panel": { "size": [ 1, "100%" ] } },
      {
        "world_summary_panel@library_item.dark_background": {
          "size": [ "fill", "100% - 1px" ],
          "layer": 1,
          "controls": [
            { "world_summary@library_item.world_summary": {} }
          ]
        }
      }
    ]
  },

  "world_bottom": {
    "type": "panel",
    "size": [ "100% - 2px", "100%c + 2px" ],
    "layer": 1,
    "controls": [
      {
        "dark_background@library_item.dark_background": {
          "size": [ "100%", "100%c + 2px" ],
          "controls": [
            {
              "description@library.base_label": {
                "text": "#description",
                "min_size": [ "100% - 5px", "17%x" ],
                "size": [ "100% - 5px", "default" ],
                "bindings": [
                  { "binding_name": "#description" }
                ]
              }
            }
          ]
        }
      }
    ]
  },

  //--------------------------------------------------------------------------------
  // Screen
  //--------------------------------------------------------------------------------

  "library_item_screen@common.base_screen": {
    // When the player hits Esc (menu_cancel button), they can exit the screen
    "button_mappings": [
      {
        "from_button_id": "button.menu_cancel",
        "to_button_id": "button.menu_exit",
        "mapping_type": "global"
      }
    ],
    "$is_full_screen_layout": true,
    "$screen_content": "library_item.screen_content"
  },

  "screen_content": {
    "type": "panel",
    "controls": [
      {
        "download_progress_panel@edu_common.download_progress_modal_panel": {
          "$body_text": "library.item.progress.body"
        }
      },
      {
        "header@common.fullscreen_header": {
          "$back_button_has_title": true,
          "$button_text": "gui.back",
          "$child_control": "library_item.main_panel"
        }
      }
    ]
  },

  "main_panel@common.scrolling_panel": {
    "$scroll_size": [ 6, "100% - 4px" ],
    "anchor_from": "top_middle",
    "anchor_to": "top_middle",
    "$scrolling_content": "library_item.scrolling_content",
    "$scrolling_content_anchor_from": "top_middle",
    "$scrolling_content_anchor_to": "top_middle",
    "$scroll_bar_left_padding_size": [ 0, 0 ],
    "$scroll_bar_right_padding_size": [ 2, 0 ],
    "$show_background": false
  }
}