Adobe 65007312 Programming Guide - Page 54

A custom example

Page 54 highlights

CHAPTER 3: Creating Export and Publish Services Customizing the Export and Publishing Manager dialogs 54 The function that you define here returns a table of tables, where each table defines one dialog section: sectionsForTopOfDialog = function( viewFactory, propertyTable ) return { { ...section entry section entry end A section entry table defines the contents of an implicit container, which Lightroom creates to hold your view hierarchy. X Each section entry sets a title and synopsis for the section; the section is identified by the title text on the left, and is collapsible. When in the collapsed state, the synopsis text is shown on the right: X The rest of the table entry creates the UI elements that are shown when the section is expanded. To create the UI elements, use the LrView factory passed to your top-level sectionsFor... function. This process is explained in more detail in Chapter 5, "Creating a User Interface for Your Plug-in." When adding sections to the Export dialog, the propertyTable parameter for both functions is the property table containing the plug-in and Lightroom-defined export settings. When your plug-in is being used as a publish service provider, the property table contains additional values that tell you about the publishing status; see "Publish Service properties" on page 67. You can add your own program data values to this table (see "Remembering user choices" on page 57), and create bindings between the UI elements and the data values, so that the UI text is dynamically tied to your plug-in data. This is shown in the example below, and explained more fully in "Binding UI values to data values" on page 94. A custom section example This sample code creates a section in the destination dialog with two UI controls, an editable text field and a button. These are in a container, a row element which controls the placement of its child nodes, but is not drawn on the screen. The value of the edit field is tied to a data key in the property table. The enabled state of the button is also tied to a data key, so that the button is only enabled when the user types into the edit field, thus setting the data value. In this example, the synopsis text is also dynamic, bound to the same data key as the edit field value. (Currently, you cannot bind the title value.) Notice that for synopsis, you must specify the bound table explicitly. This is because it is not part of the view hierarchy, where the propertyTable is automatically assigned as the default bound table. All of these concepts and techniques are explained more fully and described in more detail in Chapter 5, "Creating a User Interface for Your Plug-in." sectionsForTopOfDialog = function( viewFactory, propertyTable ) local LrDialogs = import "LrDialogs" -- get the namespaces we need local LrView = import "LrView" local bind = LrView.bind -- a local shortcut for the binding function propertyTable.user_text = "" -- add program data, no initial value propertyTable.buttonEnabled = false -- button starts out disabled

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204

C
HAPTER
3: Creating Export and Publish Services
Customizing the Export and Publishing Manager dialogs
54
The function that you define here returns a table of tables, where each table defines one dialog section:
sectionsForTopOfDialog =
function( viewFactory, propertyTable )
return {
{ ...
section entry
... },
{ ...
section entry
... },
...
}
}
end
A section entry table defines the contents of an implicit container, which Lightroom creates to hold your
view hierarchy.
X
Each section entry sets a
title
and
synopsis
for the section; the section is identified by the
title
text on the left, and is collapsible. When in the collapsed state, the
synopsis
text is shown on the
right:
X
The rest of the table entry creates the UI elements that are shown when the section is expanded. To
create the UI elements, use the
LrView
factory passed to your top-level
sectionsFor...
function.
This process is explained in more detail in
Chapter 5, “Creating a User Interface for Your Plug-in
.”
When adding sections to the Export dialog, the
propertyTable
parameter for both functions is the property
table containing the plug-in and Lightroom-defined export settings. When your plug-in is being used as a
publish service provider, the property table contains additional values that tell you about the publishing
status; see
“Publish Service properties” on page 67
.
You can add your own program data values to this table (see
“Remembering user choices” on page 57
),
and create
bindings
between the UI elements and the data values, so that the UI text is dynamically tied to
your plug-in data. This is shown in the example below, and explained more fully in
“Binding UI values to
data values” on page 94
.
A custom section example
This sample code creates a section in the destination dialog with two UI controls, an editable text field and
a button. These are in a container, a
row
element which controls the placement of its child nodes, but is not
drawn on the screen.
The value of the edit field is tied to a data key in the property table. The enabled state of the button is also
tied to a data key, so that the button is only enabled when the user types into the edit field, thus setting
the data value.
In this example, the
synopsis
text is also dynamic, bound to the same data key as the edit field value.
(Currently, you cannot bind the
title
value.) Notice that for
synopsis
, you must specify the bound table
explicitly. This is because it is not part of the view hierarchy, where the
propertyTable
is automatically
assigned as the default bound table.
All of these concepts and techniques are explained more fully and described in more detail in
Chapter 5,
“Creating a User Interface for Your Plug-in
."
sectionsForTopOfDialog
= function(
viewFactory
,
propertyTable
)
local LrDialogs = import "LrDialogs" -- get the namespaces we need
local LrView = import "LrView"
local bind = LrView.bind -- a local shortcut for the binding function
propertyTable.user_text = "" -- add program data, no initial value
propertyTable.buttonEnabled = false -- button starts out disabled