forked from NatronGitHub/Natron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KnobTypes.h
1215 lines (931 loc) · 35.1 KB
/
KnobTypes.h
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ***** BEGIN LICENSE BLOCK *****
* This file is part of Natron <https://natrongithub.github.io/>,
* (C) 2018-2021 The Natron developers
* (C) 2013-2018 INRIA and Alexandre Gauthier-Foichat
*
* Natron 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.
*
* Natron 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 Natron. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>
* ***** END LICENSE BLOCK ***** */
#ifndef NATRON_ENGINE_KNOBTYPES_H
#define NATRON_ENGINE_KNOBTYPES_H
// ***** BEGIN PYTHON BLOCK *****
// from <https://docs.python.org/3/c-api/intro.html#include-files>:
// "Since Python may define some pre-processor definitions which affect the standard headers on some systems, you must include Python.h before any standard headers are included."
#include <Python.h>
// ***** END PYTHON BLOCK *****
#include "Global/Macros.h"
#include <vector>
#include <string>
#include <map>
CLANG_DIAG_OFF(deprecated)
#include <QtCore/QCoreApplication>
#include <QtCore/QObject>
CLANG_DIAG_ON(deprecated)
GCC_ONLY_DIAG_OFF(class-memaccess)
#include <QtCore/QVector>
GCC_ONLY_DIAG_ON(class-memaccess)
#include <QtCore/QMutex>
#include <QtCore/QString>
#include "Global/GlobalDefines.h"
#include "Engine/Knob.h"
#include "Engine/ViewIdx.h"
#include "Engine/EngineFwd.h"
#include "Engine/ChoiceOption.h"
#define kFontSizeTag "<font size=\""
#define kFontColorTag "color=\""
#define kFontFaceTag "face=\""
#define kFontEndTag "</font>"
#define kBoldStartTag "<b>"
#define kBoldEndTag "</b>"
#define kItalicStartTag "<i>"
#define kItalicEndTag "</i>"
NATRON_NAMESPACE_ENTER
/******************************KnobInt**************************************/
class KnobInt
: public QObject, public KnobIntBase
{
GCC_DIAG_SUGGEST_OVERRIDE_OFF
Q_OBJECT
GCC_DIAG_SUGGEST_OVERRIDE_ON
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobInt(holder, label, dimension, declaredByPlugin);
}
KnobInt(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin);
KnobInt(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin);
void disableSlider();
bool isSliderDisabled() const;
bool isAutoFoldDimensionsEnabled() const { return false; };
static const std::string & typeNameStatic();
void setAsRectangle()
{
if (getDimension() == 4) {
_isRectangle = true;
disableSlider();
}
}
bool isRectangle() const
{
return _isRectangle;
}
public:
virtual bool supportsInViewerContext() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return true;
}
void setIncrement(int incr, int index = 0);
void setIncrement(const std::vector<int> &incr);
const std::vector<int> &getIncrements() const;
Q_SIGNALS:
void incrementChanged(double incr, int index = 0);
private:
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
std::vector<int> _increments;
bool _disableSlider;
bool _isRectangle;
static const std::string _typeNameStr;
};
/******************************KnobBool**************************************/
class KnobBool
: public KnobBoolBase
{
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobBool(holder, label, dimension, declaredByPlugin);
}
KnobBool(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin);
KnobBool(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin);
/// Can this type be animated?
/// BooleanParam animation may not be quite perfect yet,
/// @see Curve::getValueAt() for the animation code.
static bool canAnimateStatic()
{
return true;
}
static const std::string & typeNameStatic();
virtual bool supportsInViewerContext() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return true;
}
private:
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
static const std::string _typeNameStr;
};
/******************************KnobDouble**************************************/
class KnobDouble
: public QObject, public KnobDoubleBase
{
GCC_DIAG_SUGGEST_OVERRIDE_OFF
Q_OBJECT
GCC_DIAG_SUGGEST_OVERRIDE_ON
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobDouble(holder, label, dimension, declaredByPlugin);
}
KnobDouble(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin );
KnobDouble(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin );
virtual ~KnobDouble();
virtual bool supportsInViewerContext() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return true;
}
void disableSlider();
bool isSliderDisabled() const;
void setCanAutoFoldDimensions(bool v) { _autoFoldEnabled = v; }
bool isAutoFoldDimensionsEnabled() const { return _autoFoldEnabled; };
const std::vector<double> &getIncrements() const;
const std::vector<int> &getDecimals() const;
void setIncrement(double incr, int index = 0);
void setDecimals(int decis, int index = 0);
void setIncrement(const std::vector<double> &incr);
void setDecimals(const std::vector<int> &decis);
static const std::string & typeNameStatic();
ValueIsNormalizedEnum getValueIsNormalized(int dimension) const
{
return _valueIsNormalized[dimension];
}
void setValueIsNormalized(int dimension,
ValueIsNormalizedEnum state)
{
_valueIsNormalized[dimension] = state;
}
void setSpatial(bool spatial)
{
_spatial = spatial;
}
bool getIsSpatial() const
{
return _spatial;
}
/**
* @brief Normalize the default values, set the _defaultValuesAreNormalized to true and
* calls setDefaultValue with the good parameters.
* Later when restoring the default values, this flag will be used to know whether we need
* to denormalize the default stored values to the set the "live" values.
* Hence this SHOULD NOT bet set for old deprecated < OpenFX 1.2 normalized parameters otherwise
* they would be denormalized before being passed to the plug-in.
*
* If *all* the following conditions hold:
* - this is a double value
* - this is a non normalised spatial double parameter, i.e. kOfxParamPropDoubleType is set to one of
* - kOfxParamDoubleTypeX
* - kOfxParamDoubleTypeXAbsolute
* - kOfxParamDoubleTypeY
* - kOfxParamDoubleTypeYAbsolute
* - kOfxParamDoubleTypeXY
* - kOfxParamDoubleTypeXYAbsolute
* - kOfxParamPropDefaultCoordinateSystem is set to kOfxParamCoordinatesNormalised
* Knob<T>::resetToDefaultValue should denormalize
* the default value, using the input size.
* Input size be defined as the first available of:
* - the RoD of the "Source" clip
* - the RoD of the first non-mask non-optional input clip (in case there is no "Source" clip) (note that if these clips are not connected, you get the current project window, which is the default value for GetRegionOfDefinition)
* see http://openfx.sourceforge.net/Documentation/1.3/ofxProgrammingReference.html#kOfxParamPropDefaultCoordinateSystem
* and http://openfx.sourceforge.net/Documentation/1.3/ofxProgrammingReference.html#APIChanges_1_2_SpatialParameters
**/
void setDefaultValuesAreNormalized(bool normalized)
{
_defaultValuesAreNormalized = normalized;
}
/**
* @brief Returns whether the default values are stored normalized or not.
**/
bool getDefaultValuesAreNormalized() const
{
return _defaultValuesAreNormalized;
}
/**
* @brief Denormalize the given value according to the RoD of the attached effect's input's RoD.
* WARNING: Can only be called once setValueIsNormalized has been called!
**/
double denormalize(int dimension, double time, double value) const;
/**
* @brief Normalize the given value according to the RoD of the attached effect's input's RoD.
* WARNING: Can only be called once setValueIsNormalized has been called!
**/
double normalize(int dimension, double time, double value) const;
void setHasHostOverlayHandle(bool handle);
bool getHasHostOverlayHandle() const;
virtual bool useHostOverlayHandle() const OVERRIDE { return getHasHostOverlayHandle(); }
void setAsRectangle()
{
if (getDimension() == 4) {
_isRectangle = true;
}
}
bool isRectangle() const
{
return _isRectangle;
}
Q_SIGNALS:
void incrementChanged(double incr, int index = 0);
void decimalsChanged(int deci, int index = 0);
private:
virtual bool computeValuesHaveModifications(int dimension,
const double& value,
const double& defaultValue) const OVERRIDE FINAL;
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
bool _spatial;
bool _isRectangle;
std::vector<double> _increments;
std::vector<int> _decimals;
bool _disableSlider;
bool _autoFoldEnabled;
/// to support ofx deprecated normalizd params:
/// the first and second dimensions of the double param( hence a pair ) have a normalized state.
/// BY default they have eValueIsNormalizedNone
/// if the double type is one of
/// - kOfxParamDoubleTypeNormalisedX - normalised size wrt to the project's X dimension (1D only),
/// - kOfxParamDoubleTypeNormalisedXAbsolute - normalised absolute position on the X axis (1D only)
/// - kOfxParamDoubleTypeNormalisedY - normalised size wrt to the project's Y dimension(1D only),
/// - kOfxParamDoubleTypeNormalisedYAbsolute - normalised absolute position on the Y axis (1D only)
/// - kOfxParamDoubleTypeNormalisedXY - normalised to the project's X and Y size (2D only),
/// - kOfxParamDoubleTypeNormalisedXYAbsolute - normalised to the projects X and Y size, and is an absolute position on the image plane,
std::vector<ValueIsNormalizedEnum> _valueIsNormalized;
///For double params respecting the kOfxParamCoordinatesNormalised
///This tells us that only the default value is stored normalized.
///This SHOULD NOT bet set for old deprecated < OpenFX 1.2 normalized parameters.
bool _defaultValuesAreNormalized;
bool _hasHostOverlayHandle;
static const std::string _typeNameStr;
};
/******************************KnobButton**************************************/
class KnobButton
: public KnobBoolBase
{
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobButton(holder, label, dimension, declaredByPlugin);
}
KnobButton(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin);
KnobButton(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin);
static const std::string & typeNameStatic();
void setAsRenderButton()
{
_renderButton = true;
}
bool isRenderButton() const
{
return _renderButton;
}
// Trigger the knobChanged handler for this knob
// Returns true if the knobChanged handler was caught and an action was done
bool trigger();
virtual bool supportsInViewerContext() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return true;
}
void setCheckable(bool b)
{
_checkable = b;
}
bool getIsCheckable() const
{
return _checkable;
}
void setAsToolButtonAction(bool b)
{
_isToolButtonAction = b;
}
bool getIsToolButtonAction() const
{
return _isToolButtonAction;
}
private:
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
static const std::string _typeNameStr;
bool _renderButton;
bool _checkable;
bool _isToolButtonAction;
};
/******************************KnobChoice**************************************/
class KnobChoice
: public QObject, public KnobIntBase
{
GCC_DIAG_SUGGEST_OVERRIDE_OFF
Q_OBJECT
GCC_DIAG_SUGGEST_OVERRIDE_ON
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobChoice(holder, label, dimension, declaredByPlugin);
}
KnobChoice(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin);
KnobChoice(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin);
virtual ~KnobChoice();
virtual bool supportsInViewerContext() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return true;
}
/**
* @brief Fills-up the menu with the given entries and optionnally their tooltip.
* @param entriesHelp Can either be empty, meaning no-tooltip or must be of the size of the entries.
* @param mergingFunctor If not set, the internal menu will be completely reset and replaced with the given entries.
* Otherwise the internal menu entries will be merged with the given entries according to this equality functor.
* @param mergingData Can be passed when mergingFunctor is not null to speed up the comparisons.
*
* @returns true if something changed, false otherwise.
**/
bool populateChoices(const std::vector<ChoiceOption> &entries);
void resetChoices();
void appendChoice( const ChoiceOption& entry);
bool isActiveEntryPresentInEntries() const;
std::vector<ChoiceOption> getEntries_mt_safe() const;
ChoiceOption getEntry(int v) const;
ChoiceOption getActiveEntry();
void setActiveEntry(const ChoiceOption& opt);
int getNumEntries() const;
/// Can this type be animated?
/// ChoiceParam animation may not be quite perfect yet,
/// @see Curve::getValueAt() for the animation code.
static bool canAnimateStatic()
{
return true;
}
static const std::string & typeNameStatic();
std::string getHintToolTipFull() const;
static int choiceMatch(const std::string& choice, const std::vector<ChoiceOption>& entries, ChoiceOption* matchedEntry);
int choiceRestorationId(KnobChoice* knob, const std::string& optionID);
void choiceRestoration(KnobChoice* knob, const std::string& optionID, int id);
/**
* @brief When set the menu will have a "New" entry which the user can select to create a new entry on its own.
**/
void setHostCanAddOptions(bool add);
bool getHostCanAddOptions() const;
void setCascading(bool cascading)
{
_isCascading = cascading;
}
bool isCascading() const
{
return _isCascading;
}
/// set the KnobChoice value from the label
ValueChangedReturnCodeEnum setValueFromID(const std::string & value,
int dimension,
bool turnOffAutoKeying = false);
/// set the KnobChoice default value from the label
void setDefaultValueFromID(const std::string & value, int dimension = 0);
void setDefaultValueFromIDWithoutApplying(const std::string & value, int dimension = 0);
public Q_SLOTS:
void onOriginalKnobPopulated();
void onOriginalKnobEntriesReset();
void onOriginalKnobEntryAppend();
Q_SIGNALS:
void populated();
void entriesReset();
void entryAppended();
private:
virtual void onKnobAboutToAlias(const KnobIPtr& slave) OVERRIDE FINAL;
void findAndSetOldChoice();
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
virtual void handleSignalSlotsForAliasLink(const KnobIPtr& alias, bool connect) OVERRIDE FINAL;
virtual void onInternalValueChanged(int dimension, double time, ViewSpec view) OVERRIDE FINAL;
virtual void cloneExtraData(KnobI* other, int dimension = -1, int otherDimension = -1) OVERRIDE FINAL;
virtual bool cloneExtraDataAndCheckIfChanged(KnobI* other, int dimension = -1, int otherDimension = -1) OVERRIDE FINAL;
virtual void cloneExtraData(KnobI* other, double offset, const RangeD* range, int dimension = -1, int otherDimension = -1) OVERRIDE FINAL;
private:
mutable QMutex _entriesMutex;
std::vector<ChoiceOption> _entries;
ChoiceOption _currentEntry; // protected by _entriesMutex
bool _addNewChoice;
static const std::string _typeNameStr;
bool _isCascading;
};
/******************************KnobSeparator**************************************/
class KnobSeparator
: public KnobBoolBase
{
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobSeparator(holder, label, dimension, declaredByPlugin);
}
KnobSeparator(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin);
KnobSeparator(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin);
static const std::string & typeNameStatic();
virtual bool supportsInViewerContext() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return true;
}
private:
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
static const std::string _typeNameStr;
};
/******************************RGBA_KNOB**************************************/
/**
* @brief A color knob with of variable dimension. Each color is a double ranging in [0. , 1.]
* In dimension 1 the knob will have a single channel being a gray-scale
* In dimension 3 the knob will have 3 channel R,G,B
* In dimension 4 the knob will have R,G,B and A channels.
**/
class KnobColor
: public QObject, public KnobDoubleBase
{
GCC_DIAG_SUGGEST_OVERRIDE_OFF
Q_OBJECT
GCC_DIAG_SUGGEST_OVERRIDE_ON
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobColor(holder, label, dimension, declaredByPlugin);
}
KnobColor(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin);
KnobColor(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin);
static const std::string & typeNameStatic();
bool areAllDimensionsEnabled() const;
void activateAllDimensions()
{
Q_EMIT mustActivateAllDimensions();
}
void setPickingEnabled(bool enabled)
{
Q_EMIT pickingEnabled(enabled);
}
/**
* @brief When simplified, the GUI of the knob should not have any spinbox and sliders but just a label to click and openup a color dialog
**/
void setSimplified(bool simp);
bool isSimplified() const;
virtual bool supportsInViewerContext() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return true;
}
public Q_SLOTS:
void onDimensionSwitchToggled(bool b);
Q_SIGNALS:
void pickingEnabled(bool);
void minMaxChanged(double mini, double maxi, int index = 0);
void displayMinMaxChanged(double mini, double maxi, int index = 0);
void mustActivateAllDimensions();
private:
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
bool _allDimensionsEnabled;
bool _simplifiedMode;
static const std::string _typeNameStr;
};
/******************************KnobString**************************************/
class KnobString
: public AnimatingKnobStringHelper
{
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobString(holder, label, dimension, declaredByPlugin);
}
KnobString(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin);
KnobString(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin);
virtual ~KnobString();
/// Can this type be animated?
/// String animation consists in setting constant strings at
/// each keyframe, which are valid until the next keyframe.
/// It can be useful for titling/subtitling.
static bool canAnimateStatic()
{
return true;
}
static const std::string & typeNameStatic();
void setAsMultiLine()
{
_multiLine = true;
}
void setUsesRichText(bool useRichText)
{
_richText = useRichText;
}
bool isMultiLine() const
{
return _multiLine;
}
bool usesRichText() const
{
return _richText;
}
void setAsCustomHTMLText(bool custom)
{
_customHtmlText = custom;
}
bool isCustomHTMLText() const
{
return _customHtmlText;
}
void setAsLabel();
bool isLabel() const
{
return _isLabel;
}
void setAsCustom()
{
_isCustom = true;
}
bool isCustomKnob() const
{
return _isCustom;
}
virtual bool supportsInViewerContext() const OVERRIDE FINAL WARN_UNUSED_RETURN
{
return !_multiLine;
}
/**
* @brief Relevant for multi-lines with rich text enables. It tells if
* the string has content without the html tags
**/
bool hasContentWithoutHtmlTags();
private:
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
static const std::string _typeNameStr;
bool _multiLine;
bool _richText;
bool _customHtmlText;
bool _isLabel;
bool _isCustom;
};
/******************************KnobGroup**************************************/
class KnobGroup
: public QObject, public KnobBoolBase
{
GCC_DIAG_SUGGEST_OVERRIDE_OFF
Q_OBJECT
GCC_DIAG_SUGGEST_OVERRIDE_ON
std::vector<KnobIWPtr> _children;
bool _isTab;
bool _isToolButton;
bool _isDialog;
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobGroup(holder, label, dimension, declaredByPlugin);
}
KnobGroup(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin);
KnobGroup(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin);
void addKnob(const KnobIPtr& k);
void removeKnob(KnobI* k);
bool moveOneStepUp(KnobI* k);
bool moveOneStepDown(KnobI* k);
void insertKnob(int index, const KnobIPtr& k);
std::vector<KnobIPtr> getChildren() const;
void setAsTab();
bool isTab() const;
void setAsToolButton(bool b);
bool getIsToolButton() const;
void setAsDialog(bool b);
bool getIsDialog() const;
static const std::string & typeNameStatic();
private:
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
static const std::string _typeNameStr;
};
/******************************PAGE_KNOB**************************************/
class KnobPage
: public QObject, public KnobBoolBase
{
GCC_DIAG_SUGGEST_OVERRIDE_OFF
Q_OBJECT
GCC_DIAG_SUGGEST_OVERRIDE_ON
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobPage(holder, label, dimension, declaredByPlugin);
}
KnobPage(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin);
KnobPage(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin);
void addKnob(const KnobIPtr& k);
void setAsToolBar(bool b)
{
_isToolBar = b;
}
bool getIsToolBar() const
{
return _isToolBar;
}
bool moveOneStepUp(KnobI* k);
bool moveOneStepDown(KnobI* k);
void removeKnob(KnobI* k);
void insertKnob(int index, const KnobIPtr& k);
std::vector<KnobIPtr> getChildren() const;
static const std::string & typeNameStatic();
private:
virtual bool canAnimate() const OVERRIDE FINAL;
virtual const std::string & typeName() const OVERRIDE FINAL;
private:
bool _isToolBar;
std::vector<KnobIWPtr> _children;
static const std::string _typeNameStr;
};
/******************************KnobParametric**************************************/
class KnobParametric
: public QObject, public KnobDoubleBase
{
GCC_DIAG_SUGGEST_OVERRIDE_OFF
Q_OBJECT
GCC_DIAG_SUGGEST_OVERRIDE_ON
mutable QMutex _curvesMutex;
std::vector<CurvePtr> _curves, _defaultCurves;
std::vector<RGBAColourD> _curvesColor;
public:
static KnobHelper * BuildKnob(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin = true)
{
return new KnobParametric(holder, label, dimension, declaredByPlugin);
}
KnobParametric(KnobHolder* holder,
const std::string &label,
int dimension,
bool declaredByPlugin );
KnobParametric(KnobHolder* holder,
const QString &label,
int dimension,
bool declaredByPlugin );
void setPeriodic(bool periodic);