--[[

galleryInfo.lrweb
This file specifies the development environment within Lightroom.
For this sample we have defined sizes for large and thumbnail images which will be used in the large.html
and grid.html pages when displaying the selected photos.

The views table creates the panel entries available within the Lightroom UI.  For this sample the
user can dynamically edit the site title of the website before it is published.

--------------------------------------------------------------------------------

ADOBE SYSTEMS INCORPORATED
Copyright 2014 Adobe Systems Incorporated
All Rights Reserved.

NOTICE: Adobe permits you to use, modify, and distribute this file in accordance
with the terms of the Adobe license agreement accompanying it. If you have received
this file from a source other than Adobe, then your use, modification, or distribution
of it requires the prior written permission of Adobe.

]]

local warningFontName, warningFontSize

if MAC_ENV then
    warningFontName = LOC "$$$/locale_metric/Mac/Panel/Content/Italic/FontName=MyriadWebPro-Italic"
    warningFontSize = LOC "$$$/locale_metric/Mac/Panel/SmallBodyText/SmallFontSize=11"
else
    warningFontName = LOC "$$$/locale_metric/Win/Panel/Content/Italic/FontName=MyriadWebPro-Italic"
    warningFontSize = LOC "$$$/locale_metric/Win/Panel/SmallBodyText/SmallFontSize=10"
end

local warningFont = {
    name = warningFontName,
    size = tonumber( warningFontSize ),
}

local useMultiBind = true

return {
    LrSdkVersion = 2.0,
    LrSdkMinimumVersion = 2.0,
    title = LOC "$$$/AgWPG/Templates/HTML/Boxes/Title=Square Gallery",
    id = "com.adobe.wpg.templates.html5.boxes",
    galleryType = "lua",
    maximumGallerySize = 10000,
    aboutBoxFile = "about.html",
    supportsLiveUpdate = true,
    
    model = {

        ["lightroomApplication.jpegQuality"] = 75,
        ["lightroomApplication.useWatermark"] = true,
        ["lightroomApplication.watermarkID"] = "",
        ["lightroomApplication.outputSharpeningOn"] = true,
        ["lightroomApplication.outputSharpening"] = 2,
        
        ["metadata.galleryTitle.value"] = {
			value = LOC "$$$/AgWPG/Templates/Square/Info/GalleryTitle=Lightroom Gallery", -- default value for the siteTitle variable
			metadata = {
				[ "ag:templateBehavior" ] = "keepFromNil",
			},
		},
		
        ["metadata.thumbnailSize.value"] = "md", -- default to the "Medium" size

        ["nonCSS.galleryAuthor.value"] = {
            value = "",
            metadata = {
                [ "ag:templateBehavior" ] = "keepFromNil",
            },
        },
        
        ["nonCSS.galleryAuthor.url"] = {
            value = "",
            metadata = {
                [ "ag:templateBehavior" ] = "keepFromNil",
            },
        },
        
        ["nonCSS.galleryExtra.value"] = {
            value = "",
            metadata = {
                [ "ag:templateBehavior" ] = "keepFromNil",
            },
        },

        ["nonCSS.tracking"] = false,
        ["nonCSS.imageBase"] = "images",
        ["nonCSS.showHeader"] = true,
        ["nonCSS.floatingHeader"] = false,
        ["nonCSS.photoCorners"] = false,
        ["nonCSS.pagination"] = "scroll",

        ["photoSizes.large.width"] = 1200,
        ["photoSizes.large.height"] = 1200,
        ["photoSizes.large.maxWidth"] = 2560,
        ["photoSizes.large.maxHeight"] = 1440,
        ["photoSizes.large.directory"] = "large",

        ["appearance.html.cssID"] = "html",
        ["appearance.html.background-color"] = "#000000",

        ["appearance.body.cssID"] = "body",
        ["appearance.body.background-color"] = "#000000",
        ["appearance.body.color"] = "#828282",

        ["appearance.header_background.cssID"] = "header div.background",
        ["appearance.header_background.background-color"] = "#000000",

        ["appearance.icons.cssID"] = ".custom-colorable",
        ["appearance.icons.fill"] = "#a0a0a0",
        
        ["appearance.thumbnail.cssID"] = ".thumb-img",

        ["appearance.loupeContainer_background.cssID"] = "#loupeContainer div.background",
        ["appearance.loupeContainer_background.background-color"] = "#000000",
        
        ["photoSizes.thumb.height"] = 500,
        ["photoSizes.thumb.width"] = 500,
        ["photoSizes.thumb.metadataExportMode"] = "copyright", -- add copyright to images when published
        ["photoSizes.thumb.directory"] = "thumbnails",

        ["perImageSetting.description"] = {
            enabled = true,
            value = "{{com.adobe.caption}}",
            title = LOC "$$$/WPG/HTML/CSS/properties/ImageCaption=Caption",
        },

        ["perImageSetting.title"] = {
            enabled = true,
            value = "{{com.adobe.title}}",
            title = LOC "$$$/WPG/HTML/CSS/properties/ImageTitle=Title",
        },
        
    },

	iconicPreview = {
		flashMovie = "boxes_html",
		flashvars = function()
			local iconicData = {
				gallery_id = "boxes_html",
				bodyBackgroundColor = appearance.body[ "background-color" ],
				foregroundColor = appearance.body.color,
				thumbnailSize = metadata.thumbnailSize.value,
				showHeader = nonCSS.showHeader,
			}
			return iconicData
		end,
	},
    
    views = function( controller, f )

        local LrView = import "LrView"
        local LrBinding = import "LrBinding"
        local bind = LrView.bind
        local multibind = f.multibind

        return {
            -- "Site Info" panel
            labels = f:panel_content {
                bindToObject = controller,
                f:subdivided_sections {
                    f:labeled_text_input  {
                        title = LOC "$$$/AgWPG/Templates/HTML/Panel/Info/GalleryTitle=Gallery Title",
                        value = bind "metadata.galleryTitle.value",
                    },
                    f:labeled_text_input  {
                        title = LOC "$$$/AgWPG/Templates/HTML/Panel/Info/GalleryAuthor=Gallery Author",
                        value = bind "nonCSS.galleryAuthor.value",
                    },
                    f:labeled_text_input  {
                        title = LOC "$$$/AgWPG/Templates/HTML/Panel/Info/AuthorURL=Gallery Author URL",
                        value = bind "nonCSS.galleryAuthor.url",
                    },
                    f:labeled_text_input  {
                        title = LOC "$$$/AgWPG/Templates/HTML/Panel/Info/GalleryExtra=Extra Info",
                        value = bind "nonCSS.galleryExtra.value",
                    },
                },
            },
            -- "Color Palette" panel
            colorPalette = f:panel_content {
                bindToObject = controller,
                f:subdivided_sections {
                    f:color_content_column {
                        f:label_and_color_row {
                            color = multibind {
                                "appearance.html.background-color",
                                "appearance.body.background-color",
                                "appearance.header_background.background-color",
                                "appearance.loupeContainer_background.background-color"
                            },
                            title = LOC "$$$/AgWPG/Templates/HTML/Panel/Colors/Background=Background",
                        },
                        f:label_and_color_row {
                            color = bind "appearance.body.color",
                            title = LOC "$$$/AgWPG/Templates/HTML/Panel/Colors/Text=Text",
                        },
                        f:label_and_color_row {
                            color = bind "appearance.icons.fill",
                            title = LOC "$$$/AgWPG/Templates/HTML/Panel/Colors/Icons=Icons",
                        },
                    },
                },
            },
            -- "Appearance" panel
            appearanceConfiguration = f:panel_content {
                bindToObject = controller,
                f:subdivided_sections {
                    f:header_section_label {
                        title = LOC "$$$/AgWPG/Templates/HTML/Panel/Appearance/Settings=Common Settings",
                    },
                    f:content_section {
                        ui.popup_row {
                            title = LOC "$$$/AgWPG/Templates/HTML/Panel/Appearance/ThumbnailSize=Thumbnail Size:", 
                            bindingValue = "metadata.thumbnailSize.value",
                            items = { 
                                        { title = LOC "$$$/AgWPG/Templates/HTML/Panel/Appearance/ThumbnailSize/OptionSmall=Small", value = "sm" }, 
                                        { title = LOC "$$$/AgWPG/Templates/HTML/Panel/Appearance/ThumbnailSize/OptionMedium=Medium", value = "md" }, 
                                        { title = LOC "$$$/AgWPG/Templates/HTML/Panel/Appearance/ThumbnailSize/OptionLarge=Large", value = "lg" }
                                    },
                        },
                    },
                    f:content_section {
                        ui.popup_row {
                            title = LOC "$$$/AgWPG/Templates/HTML/Panel/Appearance/ThumbnailLoading=Thumbnail Loading:",
                            bindingValue = "nonCSS.pagination",
                            items = {
                                        { title = LOC "$$$/AgWPG/Templates/HTML/Panel/Appearance/ThumbnailLoading/All=All at Once", value = "none" }, 
                                        { title = LOC "$$$/AgWPG/Templates/HTML/Panel/Appearance/ThumbnailLoading/Load=On Scroll", value = "scroll" }
                                    },
                        },
                    },
                    f:content_section {
                        f:checkbox_row {
                            title = LOC "$$$/AgWPG/Templates/HTML/Panel/Appearance/ShowHeader=Show Header",
                            value = bind "nonCSS.showHeader",
                        },
                    },
                    f:content_section {
                        f:checkbox_row {
                            title = LOC "$$$/AgWPG/Templates/HTML/Panel/Appearance/FloatingHeader=Floating Header",
                            value = bind "nonCSS.floatingHeader",
                            bindingEnabled = "nonCSS.showHeader",
                        },
                    },
                },
            },
            outputSettings = f:panel_content {
                bindToObject = controller,
                f:subdivided_sections {
                    f:header_section_label {
                        title = LOC "$$$/AgWPG/Templates/HTML/Panel/Output/ImageHandling=Large Images",
                    },
                    f:slider_content_column {
                        f:slider_row {
                            title = LOC "$$$/AgWPG/Templates/HTML/Panel/Output/JPEGQuality=Quality",
                            value = bind "lightroomApplication.jpegQuality",
                            tracking = bind "lightroomApplication.jpegQuality.tracking",
                            tracking_value = "qualityTracking",
                            unit = "",
                            max = 100,
                            min = 0,
                            width_in_digits = 4,
                            precision = 0,
                        },
                        f:metadataModeControl {
                            value = useMultiBind and multibind {
                                "photoSizes.thumb.metadataExportMode",
                                "photoSizes.large.metadataExportMode",
                            }
                            or bind "photoSizes.thumb.metadataExportMode",
                        },
                    },
                    f:watermark_section( controller ),
                },
                f:subdivided_sections {
                    f:header_section {
                        ui.popup_row {
                            title = LOC "$$$/AgWPG/Templates/HTML/Panel/Output/Sharpening=Sharpening:", 
                            checkbox = {
                                bindingValue = "lightroomApplication.outputSharpeningOn",
                            },
                            bindingValue = "lightroomApplication.outputSharpening",
                            items = { { title = LOC( "$$$/AgWPG/Templates/HTML/Panel/Output/SharpeningLow=Low" ), value = 1 }, 
                                        { title = LOC( "$$$/AgWPG/Templates/HTML/Panel/Output/SharpeningStandard=Standard" ), value = 2 }, 
                                        { title = LOC( "$$$/AgWPG/Templates/HTML/Panel/Output/SharpeningHigh=High" ), value = 3 } },
                            bindingEnabled = "lightroomApplication.outputSharpeningOn",
                        },
                    },
                    f:content_section {
                        margin_left = 30,
                        f:static_text {
                            fill_horizontal = 1,
                            title = LOC "$$$/AgWPG/Templates/HTML/Panel/Output/SharpeningMessage=Sharpening is applied on output.",
                            font = warningFont,
                        },
                    },
                },
            },
        }
    end,
    
}
