1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * This file is part of openfx-supportext <https://github.com/devernay/openfx-supportext>,
4 * Copyright (C) 2013-2018 INRIA
5 *
6 * openfx-supportext is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * openfx-supportext is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with openfx-supportext. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>
18 * ***** END LICENSE BLOCK ***** */
19
20 /*
21 * OFX Shutter parameter support
22 */
23
24 #include "ofxsShutter.h"
25
26 using namespace OFX;
27
28 namespace OFX {
29 void
shutterDescribeInContext(ImageEffectDescriptor & desc,ContextEnum,PageParamDescriptor * page)30 shutterDescribeInContext(ImageEffectDescriptor &desc,
31 ContextEnum /*context*/,
32 PageParamDescriptor* page)
33 {
34 // shutter
35 {
36 DoubleParamDescriptor* param = desc.defineDoubleParam(kParamShutter);
37 param->setLabel(kParamShutterLabel);
38 param->setHint(kParamShutterHint);
39 param->setDefault(0.5);
40 param->setIncrement(0.01);
41 param->setRange(0., 2.);
42 param->setDisplayRange(0., 2.);
43 if (page) {
44 page->addChild(*param);
45 }
46 }
47
48 // shutteroffset
49 {
50 ChoiceParamDescriptor* param = desc.defineChoiceParam(kParamShutterOffset);
51 param->setLabel(kParamShutterOffsetLabel);
52 param->setHint(kParamShutterOffsetHint);
53 assert(param->getNOptions() == eShutterOffsetCentered);
54 param->appendOption(kParamShutterOffsetOptionCentered);
55 assert(param->getNOptions() == eShutterOffsetStart);
56 param->appendOption(kParamShutterOffsetOptionStart);
57 assert(param->getNOptions() == eShutterOffsetEnd);
58 param->appendOption(kParamShutterOffsetOptionEnd);
59 assert(param->getNOptions() == eShutterOffsetCustom);
60 param->appendOption(kParamShutterOffsetOptionCustom);
61 param->setAnimates(true);
62 param->setDefault(eShutterOffsetStart);
63 if (page) {
64 page->addChild(*param);
65 }
66 }
67
68 // shuttercustomoffset
69 {
70 DoubleParamDescriptor* param = desc.defineDoubleParam(kParamShutterCustomOffset);
71 param->setLabel(kParamShutterCustomOffsetLabel);
72 param->setHint(kParamShutterCustomOffsetHint);
73 param->setDefault(0.);
74 param->setIncrement(0.1);
75 param->setRange(-1., 1.);
76 param->setDisplayRange(-1., 1.);
77 if (page) {
78 page->addChild(*param);
79 }
80 }
81 } // shutterDescribeInContext
82
83 void
shutterRange(double time,double shutter,ShutterOffsetEnum shutteroffset,double shuttercustomoffset,OfxRangeD * range)84 shutterRange(double time,
85 double shutter,
86 ShutterOffsetEnum shutteroffset,
87 double shuttercustomoffset,
88 OfxRangeD* range)
89 {
90 switch (shutteroffset) {
91 case eShutterOffsetCentered:
92 range->min = time - shutter / 2;
93 range->max = time + shutter / 2;
94 break;
95 case eShutterOffsetStart:
96 range->min = time;
97 range->max = time + shutter;
98 break;
99 case eShutterOffsetEnd:
100 range->min = time - shutter;
101 range->max = time;
102 break;
103 case eShutterOffsetCustom:
104 range->min = time + shuttercustomoffset;
105 range->max = time + shuttercustomoffset + shutter;
106 break;
107 default:
108 range->min = time;
109 range->max = time;
110 break;
111 }
112 }
113 } // namespace OFX
114