Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
590 additions
and
0 deletions.
There are no files selected for viewing
144 changes: 144 additions & 0 deletions
144
helloworld.lrdevplugin/CustomDialogWithMultipleBind.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
--[[---------------------------------------------------------------------------- | ||
ADOBE SYSTEMS INCORPORATED | ||
Copyright 2007-2009 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. | ||
-------------------------------------------------------------------------------- | ||
CustomDialogMultipleBind.lua | ||
From the Hello World sample plug-in. Displays several custom dialog and writes debug info. | ||
------------------------------------------------------------------------------]] | ||
-- Access the Lightroom SDK namespaces. | ||
local LrFunctionContext = import 'LrFunctionContext' | ||
local LrBinding = import 'LrBinding' | ||
local LrDialogs = import 'LrDialogs' | ||
local LrView = import 'LrView' | ||
--[[ | ||
Demonstrates a custom dialog with a multi binding, two properties from | ||
separate tables are bound to the value of a text field. The dialog displays two | ||
sliders. Each sliders value is shown in a field next to the slider. A third text field | ||
displayes the values form both sliders. | ||
Whenever the either of the sliders value changes the third text field will be updated. | ||
The binding is done by overrriding the default property table for the key value that resides | ||
in the second property table. | ||
]] | ||
local function showCustomDialogWithMultipleBind() | ||
|
||
LrFunctionContext.callWithContext( "showCustomDialogWithMultipleBind", function( context ) | ||
|
||
-- Create two observable tables. | ||
|
||
local tableOne = LrBinding.makePropertyTable( context ) -- This will be bound to the view | ||
local tableTwo = LrBinding.makePropertyTable( context ) | ||
|
||
-- Add a property to each table. | ||
|
||
tableOne.sliderOne = 0 | ||
tableTwo.sliderTwo = 50 | ||
|
||
local f = LrView.osFactory() | ||
|
||
local c = f:column { | ||
|
||
bind_to_object = tableOne, -- bind tableOne | ||
spacing = f:control_spacing(), | ||
|
||
f:row { | ||
f:group_box { | ||
title = "Slider One", | ||
font = "<system>", | ||
f:slider { | ||
value = LrView.bind( "sliderOne" ), | ||
min = 0, | ||
max = 100, | ||
width = LrView.share( "slider_width" ) | ||
}, | ||
|
||
f:edit_field { | ||
place_horizontal = 0.5, | ||
value = LrView.bind( "sliderOne" ), | ||
width_in_digits = 7 | ||
}, | ||
}, | ||
|
||
f:group_box { | ||
title = "Slider Two", | ||
font = "<system>", | ||
f:slider { | ||
bind_to_object = tableTwo, | ||
value = LrView.bind( "sliderTwo" ), | ||
min = 0, | ||
max = 100, | ||
width = LrView.share( "slider_width" ) | ||
}, | ||
|
||
f:edit_field { | ||
place_horizontal = 0.5, | ||
bind_to_object = tableTwo, | ||
value = LrView.bind( "sliderTwo" ), | ||
width_in_digits = 7 | ||
} | ||
}, | ||
}, | ||
|
||
f:group_box { | ||
fill_horizontal = 1, | ||
title = "Both Values", | ||
font = "<system>", | ||
|
||
f:edit_field{ | ||
place_horizontal = 0.5, | ||
value = LrView.bind { | ||
|
||
-- Supply a table with table keys. | ||
|
||
keys = { | ||
{ | ||
-- Only the key name is needed as sliderOne in tableOne and that is already bound. | ||
|
||
key = "sliderOne" | ||
}, | ||
{ | ||
-- We need to supply the key and the table to which it belongs. | ||
|
||
key = "sliderTwo", | ||
bind_to_object = tableTwo | ||
} | ||
}, | ||
|
||
-- This operation will create the value for this edit_field. | ||
-- The bound values are accessed with the arg 'values'. | ||
operation = function( _, values, _ ) | ||
return values.sliderTwo + values.sliderOne | ||
end | ||
}, | ||
width_in_digits = 7 | ||
}, | ||
} | ||
} | ||
|
||
LrDialogs.presentModalDialog { | ||
title = "Custom Dialog Multiple Bind", | ||
contents = c | ||
} | ||
|
||
end ) | ||
|
||
|
||
end | ||
|
||
-- Now display the dialogs. | ||
|
||
showCustomDialogWithMultipleBind() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
--[[---------------------------------------------------------------------------- | ||
ADOBE SYSTEMS INCORPORATED | ||
Copyright 2007 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. | ||
-------------------------------------------------------------------------------- | ||
CustomDialogWithObserver.lua | ||
From the Hello World sample plug-in. Displays several custom dialog and writes debug info. | ||
------------------------------------------------------------------------------]] | ||
-- Access the Lightroom SDK namespaces. | ||
local LrFunctionContext = import 'LrFunctionContext' | ||
local LrBinding = import 'LrBinding' | ||
local LrDialogs = import 'LrDialogs' | ||
local LrView = import 'LrView' | ||
local LrLogger = import 'LrLogger' | ||
local LrColor = import 'LrColor' | ||
-- Create the logger and enable the print function. | ||
local myLogger = LrLogger( 'libraryLogger' ) | ||
myLogger:enable( "print" ) -- Pass either a string or a table of actions. | ||
-- Write trace information to the logger. | ||
local function outputToLog( message ) | ||
myLogger:trace( message ) | ||
end | ||
--[[ | ||
Demonstrates a custom dialog with a simple binding. The dialog has a text field | ||
that is used to update a value in an observable table. The table has an observer | ||
attached that will be notified when a key value is updated. The observer is | ||
only interested in the props.myObservedString. When that value changes the | ||
observer will be notified. | ||
]] | ||
local function showCustomDialogWithObserver() | ||
|
||
LrFunctionContext.callWithContext( "showCustomDialogWithObserver", function( context ) | ||
|
||
-- Create a bindable table. Whenever a field in this table changes then notifications | ||
-- will be sent. Note that we do NOT bind this to the UI. | ||
|
||
local props = LrBinding.makePropertyTable( context ) | ||
props.myObservedString = "This is my string" | ||
|
||
local f = LrView.osFactory() | ||
|
||
-- Create the UI components like this so we can access the values as vars. | ||
|
||
local staticTextValue = f:static_text { | ||
title = props.myObservedString, | ||
} | ||
|
||
local updateField = f:edit_field { | ||
immediate = true, | ||
value = "Enter some text!!" | ||
} | ||
|
||
-- This is the function that will run when the value props.myString is changed. | ||
|
||
local function myCalledFunction() | ||
outputToLog( "props.myObservedString has been updated." ) | ||
staticTextValue.title = updateField.value | ||
staticTextValue.text_color = LrColor ( 1, 0, 0 ) | ||
end | ||
|
||
-- Add an observer to the property table. We pass in the key and the function | ||
-- we want called when the value for the key changes. | ||
-- Note: Only when the value changes will there be a notification sent which | ||
-- causes the function to be invoked. | ||
|
||
props:addObserver( "myObservedString", myCalledFunction ) | ||
|
||
-- Create the contents for the dialog. | ||
|
||
local c = f:column { | ||
spacing = f:dialog_spacing(), | ||
f:row{ | ||
fill_horizontal = 1, | ||
f:static_text { | ||
alignment = "right", | ||
width = LrView.share "label_width", | ||
title = "Bound value: " | ||
}, | ||
staticTextValue, | ||
}, -- end f:row | ||
|
||
f:row { | ||
f:static_text { | ||
alignment = "right", | ||
width = LrView.share "label_width", | ||
title = "New value: " | ||
}, | ||
updateField, | ||
f:push_button { | ||
title = "Update", | ||
|
||
-- When the 'Update' button is clicked. | ||
|
||
action = function() | ||
outputToLog( "Update button clicked." ) | ||
staticTextValue.text_color = LrColor ( 0, 0, 0) | ||
|
||
-- When this property is updated, the observer is notified. | ||
|
||
props.myObservedString = updateField.value | ||
end | ||
}, | ||
}, -- end row | ||
} -- end column | ||
|
||
LrDialogs.presentModalDialog { | ||
title = "Custom Dialog Observer", | ||
contents = c | ||
} | ||
|
||
end) -- end main function | ||
|
||
|
||
end | ||
|
||
-- Now display the dialogs. | ||
|
||
showCustomDialogWithObserver() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--[[---------------------------------------------------------------------------- | ||
ADOBE SYSTEMS INCORPORATED | ||
Copyright 2007 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. | ||
-------------------------------------------------------------------------------- | ||
ExportMenuItem.lua | ||
From the Hello World sample plug-in. Displays a modal dialog and writes debug info. | ||
------------------------------------------------------------------------------]] | ||
-- Access the Lightroom SDK namespaces. | ||
local LrDialogs = import 'LrDialogs' | ||
local LrLogger = import 'LrLogger' | ||
-- Create the logger and enable the print function. | ||
local myLogger = LrLogger( 'exportLogger' ) | ||
myLogger:enable( "print" ) -- Pass either a string or a table of actions. | ||
-------------------------------------------------------------------------------- | ||
-- Write trace information to the logger. | ||
local function outputToLog( message ) | ||
myLogger:trace( message ) | ||
end | ||
-------------------------------------------------------------------------------- | ||
-- Display a modal information dialog. | ||
local function showModalDialog() | ||
outputToLog( "MyHWExportItem.showModalMessage function entered." ) | ||
LrDialogs.message( "ExportMenuItem Selected", "Hello World!", "info" ); | ||
outputToLog( "MyHWExportItem.showModalMessage function exiting." ) | ||
end | ||
-------------------------------------------------------------------------------- | ||
-- Display a dialog. | ||
showModalDialog() | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--[[---------------------------------------------------------------------------- | ||
ADOBE SYSTEMS INCORPORATED | ||
Copyright 2007 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. | ||
-------------------------------------------------------------------------------- | ||
Info.lua | ||
Summary information for Hello World sample plug-in. | ||
Adds two menu items to Lightroom. | ||
------------------------------------------------------------------------------]] | ||
return { | ||
LrSdkVersion = 3.0, | ||
LrSdkMinimumVersion = 1.3, -- minimum SDK version required by this plug-in | ||
LrToolkitIdentifier = 'com.adobe.lightroom.sdk.helloworld', | ||
LrPluginName = LOC "$$$/HelloWorld/PluginName=Hello World Sample", | ||
-- Add the menu item to the File menu. | ||
LrExportMenuItems = { | ||
title = "Hello World Dialog", | ||
file = "ExportMenuItem.lua", | ||
}, | ||
-- Add the menu item to the Library menu. | ||
LrLibraryMenuItems = { | ||
{ | ||
title = LOC "$$$/HelloWorld/CustomDialog=Hello World Custom Dialog", | ||
file = "ShowCustomDialog.lua", | ||
}, | ||
{ | ||
title = LOC "$$$/HelloWorld/MultiBind=Hello world Custom Dialog with MultipleBind", | ||
file = "CustomDialogWithMultipleBind.lua", | ||
}, | ||
{ | ||
title = LOC "$$$/HelloWorld/RadioButtons=Hello world RadioButtons", | ||
file = "RadioButtons.lua", | ||
}, | ||
{ | ||
title = LOC "$$$/HelloWorld/DialogObserver=Hello world Custom Dialog with Observer", | ||
file = "CustomDialogWithObserver.lua", | ||
}, | ||
}, | ||
VERSION = { major=3, minor=0, revision=0, build=200000, }, | ||
} | ||
Oops, something went wrong.