Olive
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
effectfield.h
Go to the documentation of this file.
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program 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 3 of the License, or
9  (at your option) any later version.
10 
11  This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef EFFECTFIELD_H
22 #define EFFECTFIELD_H
23 
24 #include <QObject>
25 #include <QVariant>
26 #include <QVector>
27 
28 #include "effects/keyframe.h"
29 #include "undo/undo.h"
30 #include "undo/undostack.h"
31 
32 class EffectRow;
33 class ComboAction;
34 
56 class EffectField : public QObject {
57  Q_OBJECT
58 public:
70 
73 
76 
79 
82 
85 
88 
91  };
92 
115  EffectField(EffectRow* parent, const QString& i, EffectFieldType t);
116 
127 
135  const EffectFieldType& type();
136 
144  const QString& id();
145 
169  QVariant GetValueAt(double timecode);
170 
194  void SetValueAt(double time, const QVariant& value);
195 
206  double Now();
207 
229  void PrepareDataForKeyframing(bool enabled, ComboAction* ca);
230 
241  int GetColumnSpan();
242 
253  void SetColumnSpan(int i);
254 
272  virtual QString ConvertValueToString(const QVariant& v);
273 
287  virtual QVariant ConvertStringToValue(const QString& s);
288 
289 
317  virtual QWidget* CreateWidget(QWidget* existing = nullptr) = 0;
318 
339  virtual void UpdateWidgetValue(QWidget* widget, double timecode);
340 
365  double GetValidKeyframeHandlePosition(int key, bool post);
366 
374  bool IsEnabled();
375 
382  void SetEnabled(bool e);
383 
393 
402  QVector<EffectKeyframe> keyframes;
403 
404 signals:
411  void Changed();
412 
419  void Clicked();
420 
427  void EnabledChanged(bool);
428 
429 private:
434 
438  QString id_;
439 
446  bool HasKeyframes();
447 
459  double FrameToSeconds(long frame);
460 
472  long SecondsToFrame(double seconds);
473 
493  void GetKeyframeData(double timecode, int& before, int& after, double& d);
494 
505  long NowInFrames();
506 
510  bool enabled_;
511 
515  int colspan_;
516 
517 };
518 
519 #endif // EFFECTFIELD_H
bool IsEnabled()
Return whether this field is enabled or not.
Definition: effectfield.cpp:384
Definition: effectfield.h:78
int colspan_
Internal column span value.
Definition: effectfield.h:515
void PrepareDataForKeyframing(bool enabled, ComboAction *ca)
Set up keyframing on this field.
Definition: effectfield.cpp:249
EffectField(EffectRow *parent, const QString &i, EffectFieldType t)
EffectField Constructor.
Definition: effectfield.cpp:41
Definition: effectfield.h:90
const QString & id()
Get the unique identifier of this field set in the constructor.
Definition: effectfield.cpp:284
EffectFieldType
The EffectFieldType enum.
Definition: effectfield.h:67
void EnabledChanged(bool)
Enable change state signal.
virtual QWidget * CreateWidget(QWidget *existing=nullptr)=0
Create a widget for the user to interact with this field.
const EffectFieldType & type()
Get the type of data to expect from this field.
Definition: effectfield.cpp:279
QString id_
Internal unique identifier for this field set in the constructor. Access with id().
Definition: effectfield.h:438
void Clicked()
Clicked signal.
int GetColumnSpan()
Get field&#39;s column span.
Definition: effectfield.cpp:67
QVariant GetValueAt(double timecode)
Get the value of this field at a given timecode.
Definition: effectfield.cpp:90
Definition: effectfield.h:75
void SetColumnSpan(int i)
Set field&#39;s column span.
Definition: effectfield.cpp:72
void SetValueAt(double time, const QVariant &value)
Set the value of this field at a given timecode.
Definition: effectfield.cpp:198
double FrameToSeconds(long frame)
Convert clip time in frames to clip time in seconds.
Definition: effectfield.cpp:335
void SetEnabled(bool e)
Set the enabled state of this field.
Definition: effectfield.cpp:388
Definition: effectfield.h:72
double Now()
Get the current clip/media time.
Definition: effectfield.cpp:237
Definition: effectfield.h:81
Definition: effectfield.h:87
bool HasKeyframes()
Used by GetValueAt() to determine whether to use keyframe data or persistent data.
Definition: effectfield.cpp:380
The ComboAction class.
Definition: comboaction.h:19
virtual QString ConvertValueToString(const QVariant &v)
Convert a value from this field to a string.
Definition: effectfield.cpp:83
Definition: effectfield.h:69
virtual QVariant ConvertStringToValue(const QString &s)
Convert a string to a value appropriate for this field.
Definition: effectfield.cpp:78
void Changed()
Changed signal.
The EffectField class.
Definition: effectfield.h:56
QVariant persistent_data_
Persistent data object.
Definition: effectfield.h:392
void GetKeyframeData(double timecode, int &before, int &after, double &d)
Internal function for determining where we are between the available keyframes.
Definition: effectfield.cpp:343
virtual void UpdateWidgetValue(QWidget *widget, double timecode)
Update a widget created by CreateWidget() using the value at a given time.
Definition: effectfield.cpp:88
EffectFieldType type_
Internal type variable set in the constructor. Access with type().
Definition: effectfield.h:433
EffectRow * GetParentRow()
Get the EffectRow that this field is a member of.
Definition: effectfield.cpp:62
long NowInFrames()
Retrieve the current clip as a frame number.
Definition: effectfield.cpp:243
QVector< EffectKeyframe > keyframes
Keyframe array.
Definition: effectfield.h:402
bool enabled_
Internal enabled value.
Definition: effectfield.h:510
Definition: effectfield.h:84
double GetValidKeyframeHandlePosition(int key, bool post)
Get the correct X position/time value of a bezier keyframe&#39;s handles.
Definition: effectfield.cpp:289
The EffectRow class.
Definition: effectrow.h:51
long SecondsToFrame(double seconds)
Convert clip time in seconds to clip time in frames.
Definition: effectfield.cpp:339