-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathofxsShutter.cpp
114 lines (107 loc) · 3.72 KB
/
ofxsShutter.cpp
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
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; -*- */
/* ***** BEGIN LICENSE BLOCK *****
* This file is part of openfx-supportext <https://github.com/NatronGitHub/openfx-supportext>,
* (C) 2018-2021 The Natron Developers
* (C) 2013-2018 INRIA
*
* openfx-supportext is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* openfx-supportext is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with openfx-supportext. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>
* ***** END LICENSE BLOCK ***** */
/*
* OFX Shutter parameter support
*/
#include "ofxsShutter.h"
using namespace OFX;
namespace OFX {
void
shutterDescribeInContext(ImageEffectDescriptor &desc,
ContextEnum /*context*/,
PageParamDescriptor* page)
{
// shutter
{
DoubleParamDescriptor* param = desc.defineDoubleParam(kParamShutter);
param->setLabel(kParamShutterLabel);
param->setHint(kParamShutterHint);
param->setDefault(0.5);
param->setIncrement(0.01);
param->setRange(0., 2.);
param->setDisplayRange(0., 2.);
if (page) {
page->addChild(*param);
}
}
// shutteroffset
{
ChoiceParamDescriptor* param = desc.defineChoiceParam(kParamShutterOffset);
param->setLabel(kParamShutterOffsetLabel);
param->setHint(kParamShutterOffsetHint);
assert(param->getNOptions() == eShutterOffsetCentered);
param->appendOption(kParamShutterOffsetOptionCentered);
assert(param->getNOptions() == eShutterOffsetStart);
param->appendOption(kParamShutterOffsetOptionStart);
assert(param->getNOptions() == eShutterOffsetEnd);
param->appendOption(kParamShutterOffsetOptionEnd);
assert(param->getNOptions() == eShutterOffsetCustom);
param->appendOption(kParamShutterOffsetOptionCustom);
param->setAnimates(true);
param->setDefault(eShutterOffsetStart);
if (page) {
page->addChild(*param);
}
}
// shuttercustomoffset
{
DoubleParamDescriptor* param = desc.defineDoubleParam(kParamShutterCustomOffset);
param->setLabel(kParamShutterCustomOffsetLabel);
param->setHint(kParamShutterCustomOffsetHint);
param->setDefault(0.);
param->setIncrement(0.1);
param->setRange(-1., 1.);
param->setDisplayRange(-1., 1.);
if (page) {
page->addChild(*param);
}
}
} // shutterDescribeInContext
void
shutterRange(double time,
double shutter,
ShutterOffsetEnum shutteroffset,
double shuttercustomoffset,
OfxRangeD* range)
{
switch (shutteroffset) {
case eShutterOffsetCentered:
range->min = time - shutter / 2;
range->max = time + shutter / 2;
break;
case eShutterOffsetStart:
range->min = time;
range->max = time + shutter;
break;
case eShutterOffsetEnd:
range->min = time - shutter;
range->max = time;
break;
case eShutterOffsetCustom:
range->min = time + shuttercustomoffset;
range->max = time + shuttercustomoffset + shutter;
break;
default:
range->min = time;
range->max = time;
break;
}
}
} // namespace OFX