fix line endings

This commit is contained in:
itsmattkc
2019-06-15 07:39:55 -07:00
parent 13d6f9f5b2
commit 0acee942f4
300 changed files with 49260 additions and 49254 deletions
+99 -99
View File
@@ -1,99 +1,99 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "boolfield.h"
#include <QCheckBox>
#include "nodes/node.h"
#include "undo/undo.h"
BoolField::BoolField(NodeIO *parent) :
EffectField(parent, EffectField::EFFECT_FIELD_BOOL)
{}
bool BoolField::GetBoolAt(double timecode)
{
return GetValueAt(timecode).toBool();
}
QWidget *BoolField::CreateWidget(QWidget *existing)
{
QCheckBox* cb;
if (existing == nullptr) {
cb = new QCheckBox();
cb->setEnabled(IsEnabled());
} else {
cb = static_cast<QCheckBox*>(existing);
}
connect(cb, SIGNAL(toggled(bool)), this, SLOT(UpdateFromWidget(bool)));
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
connect(cb, SIGNAL(toggled(bool)), this, SIGNAL(Toggled(bool)));
return cb;
}
void BoolField::UpdateWidgetValue(QWidget *widget, double timecode)
{
QCheckBox* cb = static_cast<QCheckBox*>(widget);
// Setting the checked state on the checkbox below normally triggers a change() signal that will then trickle back
// to setting a value on this field. Therefore we block its signals while we're setting this.
cb->blockSignals(true);
if (qIsNaN(timecode)) {
cb->setTristate(true);
cb->setCheckState(Qt::PartiallyChecked);
} else {
cb->setTristate(false);
cb->setChecked(GetBoolAt(timecode));
}
cb->blockSignals(false);
emit Toggled(cb->isChecked());
}
QVariant BoolField::ConvertStringToValue(const QString &s)
{
return (s == "1");
}
QString BoolField::ConvertValueToString(const QVariant &v)
{
return QString::number(v.toBool());
}
void BoolField::UpdateFromWidget(bool b)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), b);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "boolfield.h"
#include <QCheckBox>
#include "nodes/node.h"
#include "undo/undo.h"
BoolField::BoolField(NodeIO *parent) :
EffectField(parent, EffectField::EFFECT_FIELD_BOOL)
{}
bool BoolField::GetBoolAt(double timecode)
{
return GetValueAt(timecode).toBool();
}
QWidget *BoolField::CreateWidget(QWidget *existing)
{
QCheckBox* cb;
if (existing == nullptr) {
cb = new QCheckBox();
cb->setEnabled(IsEnabled());
} else {
cb = static_cast<QCheckBox*>(existing);
}
connect(cb, SIGNAL(toggled(bool)), this, SLOT(UpdateFromWidget(bool)));
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
connect(cb, SIGNAL(toggled(bool)), this, SIGNAL(Toggled(bool)));
return cb;
}
void BoolField::UpdateWidgetValue(QWidget *widget, double timecode)
{
QCheckBox* cb = static_cast<QCheckBox*>(widget);
// Setting the checked state on the checkbox below normally triggers a change() signal that will then trickle back
// to setting a value on this field. Therefore we block its signals while we're setting this.
cb->blockSignals(true);
if (qIsNaN(timecode)) {
cb->setTristate(true);
cb->setCheckState(Qt::PartiallyChecked);
} else {
cb->setTristate(false);
cb->setChecked(GetBoolAt(timecode));
}
cb->blockSignals(false);
emit Toggled(cb->isChecked());
}
QVariant BoolField::ConvertStringToValue(const QString &s)
{
return (s == "1");
}
QString BoolField::ConvertValueToString(const QVariant &v)
{
return QString::number(v.toBool());
}
void BoolField::UpdateFromWidget(bool b)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), b);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
+101 -101
View File
@@ -1,101 +1,101 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef BOOLFIELD_H
#define BOOLFIELD_H
#include "../effectfield.h"
/**
* @brief The BoolField class
*
* An EffectField derivative the produces boolean values (true or false) and uses a checkbox as its visual representation.
*/
class BoolField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
BoolField(NodeIO* parent);
/**
* @brief Get the boolean value at a given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).toBool()
*
* @param timecode
*
* The timecode to retrieve the value at
*
* @return
*
* The boolean value at this timecode
*/
bool GetBoolAt(double timecode);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a QCheckBox.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
/**
* @brief Reimplementation of EffectField::ConvertStringToValue()
*/
virtual QVariant ConvertStringToValue(const QString& s) override;
/**
* @brief Reimplementation of EffectField::ConvertValueToString()
*/
virtual QString ConvertValueToString(const QVariant& v) override;
signals:
/**
* @brief Emitted whenever the UI widget's boolean value has changed
*
* For any QCheckBox created through this field's CreateWidget() function, this signal is emitted any time the
* checkbox value changes (either through user intervention or keyframing). It is mostly useful for
* enabling/disabling/changing other UI elements based on the checked
* state of this field's value (e.g. enabling other fields if this field is checked).
*
* It is NOT a reliable signal that the value has changed at all, as it is only emitted if a widget (created
* from CreateWidget() ) is currently active.
*/
void Toggled(bool);
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current checked state of the QWidget (QCheckBox in this case). Automatically set when this slot is connected
* to the QCheckBox::toggled() signal.
*/
void UpdateFromWidget(bool b);
};
#endif // BOOLFIELD_H
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef BOOLFIELD_H
#define BOOLFIELD_H
#include "../effectfield.h"
/**
* @brief The BoolField class
*
* An EffectField derivative the produces boolean values (true or false) and uses a checkbox as its visual representation.
*/
class BoolField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
BoolField(NodeIO* parent);
/**
* @brief Get the boolean value at a given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).toBool()
*
* @param timecode
*
* The timecode to retrieve the value at
*
* @return
*
* The boolean value at this timecode
*/
bool GetBoolAt(double timecode);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a QCheckBox.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
/**
* @brief Reimplementation of EffectField::ConvertStringToValue()
*/
virtual QVariant ConvertStringToValue(const QString& s) override;
/**
* @brief Reimplementation of EffectField::ConvertValueToString()
*/
virtual QString ConvertValueToString(const QVariant& v) override;
signals:
/**
* @brief Emitted whenever the UI widget's boolean value has changed
*
* For any QCheckBox created through this field's CreateWidget() function, this signal is emitted any time the
* checkbox value changes (either through user intervention or keyframing). It is mostly useful for
* enabling/disabling/changing other UI elements based on the checked
* state of this field's value (e.g. enabling other fields if this field is checked).
*
* It is NOT a reliable signal that the value has changed at all, as it is only emitted if a widget (created
* from CreateWidget() ) is currently active.
*/
void Toggled(bool);
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current checked state of the QWidget (QCheckBox in this case). Automatically set when this slot is connected
* to the QCheckBox::toggled() signal.
*/
void UpdateFromWidget(bool b);
};
#endif // BOOLFIELD_H
+66 -66
View File
@@ -1,66 +1,66 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "buttonfield.h"
#include <QPushButton>
ButtonField::ButtonField(NodeIO *parent, const QString &string) :
EffectField(parent, EffectField::EFFECT_FIELD_UI),
button_text_(string)
{}
void ButtonField::SetCheckable(bool c)
{
checkable_ = c;
}
void ButtonField::SetChecked(bool c)
{
checked_ = c;
emit CheckedChanged(c);
}
QWidget *ButtonField::CreateWidget(QWidget *existing)
{
QPushButton* button;
if (existing == nullptr) {
button = new QPushButton();
button->setCheckable(checkable_);
button->setEnabled(IsEnabled());
button->setText(button_text_);
} else {
button = static_cast<QPushButton*>(existing);
}
connect(this, SIGNAL(CheckedChanged(bool)), button, SLOT(setChecked(bool)));
connect(this, SIGNAL(EnabledChanged(bool)), button, SLOT(setEnabled(bool)));
connect(button, SIGNAL(clicked(bool)), this, SIGNAL(Clicked()));
connect(button, SIGNAL(toggled(bool)), this, SLOT(SetChecked(bool)));
connect(button, SIGNAL(toggled(bool)), this, SIGNAL(Toggled(bool)));
return button;
}
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "buttonfield.h"
#include <QPushButton>
ButtonField::ButtonField(NodeIO *parent, const QString &string) :
EffectField(parent, EffectField::EFFECT_FIELD_UI),
button_text_(string)
{}
void ButtonField::SetCheckable(bool c)
{
checkable_ = c;
}
void ButtonField::SetChecked(bool c)
{
checked_ = c;
emit CheckedChanged(c);
}
QWidget *ButtonField::CreateWidget(QWidget *existing)
{
QPushButton* button;
if (existing == nullptr) {
button = new QPushButton();
button->setCheckable(checkable_);
button->setEnabled(IsEnabled());
button->setText(button_text_);
} else {
button = static_cast<QPushButton*>(existing);
}
connect(this, SIGNAL(CheckedChanged(bool)), button, SLOT(setChecked(bool)));
connect(this, SIGNAL(EnabledChanged(bool)), button, SLOT(setEnabled(bool)));
connect(button, SIGNAL(clicked(bool)), this, SIGNAL(Clicked()));
connect(button, SIGNAL(toggled(bool)), this, SLOT(SetChecked(bool)));
connect(button, SIGNAL(toggled(bool)), this, SIGNAL(Toggled(bool)));
return button;
}
+111 -111
View File
@@ -1,111 +1,111 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef BUTTONFIELD_H
#define BUTTONFIELD_H
#include "../effectfield.h"
/**
* @brief The ButtonField class
*
* A UI-type EffectField. This field is largely an EffectField wrapper around a QPushButton and provides no data that's
* usable in the Effect. It's primarily useful for other UI functions (e.g. showing/hiding a dialog or other UI
* elements). This field is not exposed to the external shader API as it requires raw C++ code to connect it to other
* elements.
*
* As with all widgets created from EffectField::CreateWidget(), you should never interface with the resulting widget
* directly (apart from adding it to a layout and deleting it when it's unnecessary). All signals/slots should pass
* through ButtonField instead to keep consistency with every layer involved.
*/
class ButtonField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
ButtonField(NodeIO* parent, const QString& string);
/**
* @brief Set whether this pushbutton is checkable
*
* This function is mainly a wrapper around QPushButton::setCheckable().
*
* "Checkable" means the button can be toggled between a state of being "normal" and being "pressed". In checkable
* mode this field still cannot be used as a value in an Effect. Instead use BoolField (which uses a QCheckBox
* representation) for passing values to the Effect that can only be true or false.
*
* @param c
*
* TRUE if this button should be checkable or not.
*/
void SetCheckable(bool c);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a QPushButton.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
public slots:
/**
* @brief A slot for when a widget's (created and connected from CreateWidget() ) checked state is changed
*
* @param c
*
* The current checked state (automatically filled by the QPushButton::toggled() signal)
*/
void SetChecked(bool c);
signals:
/**
* @brief A signal emitted whenever the field's internal checked state is changed
*
* Primarily used to set any connected widget's checked state to be consistent with the field's.
*/
void CheckedChanged(bool);
/**
* @brief A signal emitted whenever the checked state of a connected widget changes
*
* Any widgets associated with this field will emit this signal when their checked state changes.
*/
void Toggled(bool);
private:
/**
* @brief Internal button text string passed to widgets created by CreateWidget()
*/
bool checkable_;
/**
* @brief Internal checked value passed to and from widgets created by CreateWidget()
*/
bool checked_;
/**
* @brief Internal button text string passed to widgets created by CreateWidget()
*/
QString button_text_;
};
#endif // BUTTONFIELD_H
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef BUTTONFIELD_H
#define BUTTONFIELD_H
#include "../effectfield.h"
/**
* @brief The ButtonField class
*
* A UI-type EffectField. This field is largely an EffectField wrapper around a QPushButton and provides no data that's
* usable in the Effect. It's primarily useful for other UI functions (e.g. showing/hiding a dialog or other UI
* elements). This field is not exposed to the external shader API as it requires raw C++ code to connect it to other
* elements.
*
* As with all widgets created from EffectField::CreateWidget(), you should never interface with the resulting widget
* directly (apart from adding it to a layout and deleting it when it's unnecessary). All signals/slots should pass
* through ButtonField instead to keep consistency with every layer involved.
*/
class ButtonField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
ButtonField(NodeIO* parent, const QString& string);
/**
* @brief Set whether this pushbutton is checkable
*
* This function is mainly a wrapper around QPushButton::setCheckable().
*
* "Checkable" means the button can be toggled between a state of being "normal" and being "pressed". In checkable
* mode this field still cannot be used as a value in an Effect. Instead use BoolField (which uses a QCheckBox
* representation) for passing values to the Effect that can only be true or false.
*
* @param c
*
* TRUE if this button should be checkable or not.
*/
void SetCheckable(bool c);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a QPushButton.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
public slots:
/**
* @brief A slot for when a widget's (created and connected from CreateWidget() ) checked state is changed
*
* @param c
*
* The current checked state (automatically filled by the QPushButton::toggled() signal)
*/
void SetChecked(bool c);
signals:
/**
* @brief A signal emitted whenever the field's internal checked state is changed
*
* Primarily used to set any connected widget's checked state to be consistent with the field's.
*/
void CheckedChanged(bool);
/**
* @brief A signal emitted whenever the checked state of a connected widget changes
*
* Any widgets associated with this field will emit this signal when their checked state changes.
*/
void Toggled(bool);
private:
/**
* @brief Internal button text string passed to widgets created by CreateWidget()
*/
bool checkable_;
/**
* @brief Internal checked value passed to and from widgets created by CreateWidget()
*/
bool checked_;
/**
* @brief Internal button text string passed to widgets created by CreateWidget()
*/
QString button_text_;
};
#endif // BUTTONFIELD_H
+73 -73
View File
@@ -1,73 +1,73 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "colorfield.h"
#include <QColor>
#include "ui/colorbutton.h"
#include "nodes/node.h"
#include "undo/undo.h"
ColorField::ColorField(NodeIO* parent) :
EffectField(parent, EffectField::EFFECT_FIELD_COLOR)
{}
QColor ColorField::GetColorAt(double timecode)
{
return GetValueAt(timecode).value<QColor>();
}
QWidget *ColorField::CreateWidget(QWidget *existing)
{
ColorButton* cb = (existing != nullptr) ? static_cast<ColorButton*>(existing) : new ColorButton();
connect(cb, SIGNAL(color_changed(const QColor &)), this, SLOT(UpdateFromWidget(const QColor &)));
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
return cb;
}
void ColorField::UpdateWidgetValue(QWidget *widget, double timecode)
{
ColorButton* cb = static_cast<ColorButton*>(widget);
cb->set_color(GetColorAt(timecode));
}
QVariant ColorField::ConvertStringToValue(const QString &s)
{
return QColor(s);
}
QString ColorField::ConvertValueToString(const QVariant &v)
{
return v.value<QColor>().name();
}
void ColorField::UpdateFromWidget(const QColor& c)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), c);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "colorfield.h"
#include <QColor>
#include "ui/colorbutton.h"
#include "nodes/node.h"
#include "undo/undo.h"
ColorField::ColorField(NodeIO* parent) :
EffectField(parent, EffectField::EFFECT_FIELD_COLOR)
{}
QColor ColorField::GetColorAt(double timecode)
{
return GetValueAt(timecode).value<QColor>();
}
QWidget *ColorField::CreateWidget(QWidget *existing)
{
ColorButton* cb = (existing != nullptr) ? static_cast<ColorButton*>(existing) : new ColorButton();
connect(cb, SIGNAL(color_changed(const QColor &)), this, SLOT(UpdateFromWidget(const QColor &)));
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
return cb;
}
void ColorField::UpdateWidgetValue(QWidget *widget, double timecode)
{
ColorButton* cb = static_cast<ColorButton*>(widget);
cb->set_color(GetColorAt(timecode));
}
QVariant ColorField::ConvertStringToValue(const QString &s)
{
return QColor(s);
}
QString ColorField::ConvertValueToString(const QVariant &v)
{
return v.value<QColor>().name();
}
void ColorField::UpdateFromWidget(const QColor& c)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), c);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
+88 -88
View File
@@ -1,88 +1,88 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef COLORFIELD_H
#define COLORFIELD_H
#include "../effectfield.h"
/**
* @brief The ColorField class
*
* An EffectField derivative that produces color values and uses a ColorButton as its UI representative.
*/
class ColorField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
ColorField(NodeIO* parent);
/**
* @brief Get the color value at a given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).value<QColor>().
*
* @param timecode
*
* The timecode to retrieve the color at
*
* @return
*
* The color value at this timecode
*/
QColor GetColorAt(double timecode);
/**
* @brief CreateWidget
*
* Creates and connects to a ColorButton.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
/**
* @brief Reimplementation of EffectField::ConvertStringToValue()
*/
virtual QVariant ConvertStringToValue(const QString& s) override;
/**
* @brief Reimplementation of EffectField::ConvertValueToString()
*/
virtual QString ConvertValueToString(const QVariant& v) override;
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current color selected by the QWidget (ColorButton in this case). Automatically triggered when this slot is
* connected to the ColorButton::color_changed() signal.
*/
void UpdateFromWidget(const QColor &c);
};
#endif // COLORFIELD_H
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef COLORFIELD_H
#define COLORFIELD_H
#include "../effectfield.h"
/**
* @brief The ColorField class
*
* An EffectField derivative that produces color values and uses a ColorButton as its UI representative.
*/
class ColorField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
ColorField(NodeIO* parent);
/**
* @brief Get the color value at a given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).value<QColor>().
*
* @param timecode
*
* The timecode to retrieve the color at
*
* @return
*
* The color value at this timecode
*/
QColor GetColorAt(double timecode);
/**
* @brief CreateWidget
*
* Creates and connects to a ColorButton.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
/**
* @brief Reimplementation of EffectField::ConvertStringToValue()
*/
virtual QVariant ConvertStringToValue(const QString& s) override;
/**
* @brief Reimplementation of EffectField::ConvertValueToString()
*/
virtual QString ConvertValueToString(const QVariant& v) override;
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current color selected by the QWidget (ColorButton in this case). Automatically triggered when this slot is
* connected to the ColorButton::color_changed() signal.
*/
void UpdateFromWidget(const QColor &c);
};
#endif // COLORFIELD_H
+93 -93
View File
@@ -1,93 +1,93 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "combofield.h"
#include <QDebug>
#include "nodes/node.h"
#include "ui/comboboxex.h"
#include "undo/undo.h"
ComboField::ComboField(NodeIO* parent) :
EffectField(parent, EffectField::EFFECT_FIELD_COMBO)
{}
void ComboField::AddItem(const QString &text, const QVariant &data)
{
ComboFieldItem item;
item.name = text;
item.data = data;
items_.append(item);
}
QWidget *ComboField::CreateWidget(QWidget *existing)
{
ComboBoxEx* cb;
if (existing == nullptr) {
cb = new ComboBoxEx();
cb->setScrollingEnabled(false);
for (int i=0;i<items_.size();i++) {
cb->addItem(items_.at(i).name);
}
} else {
cb = static_cast<ComboBoxEx*>(existing);
}
connect(cb, SIGNAL(activated(int)), this, SLOT(UpdateFromWidget(int)));
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
return cb;
}
void ComboField::UpdateWidgetValue(QWidget *widget, double timecode)
{
QVariant data = GetValueAt(timecode);
ComboBoxEx* cb = static_cast<ComboBoxEx*>(widget);
for (int i=0;i<items_.size();i++) {
if (items_.at(i).data == data) {
cb->blockSignals(true);
cb->setCurrentIndex(i);
cb->blockSignals(false);
emit DataChanged(data);
return;
}
}
qWarning() << "Failed to set ComboField value from data";
}
void ComboField::UpdateFromWidget(int index)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), items_.at(index).data);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "combofield.h"
#include <QDebug>
#include "nodes/node.h"
#include "ui/comboboxex.h"
#include "undo/undo.h"
ComboField::ComboField(NodeIO* parent) :
EffectField(parent, EffectField::EFFECT_FIELD_COMBO)
{}
void ComboField::AddItem(const QString &text, const QVariant &data)
{
ComboFieldItem item;
item.name = text;
item.data = data;
items_.append(item);
}
QWidget *ComboField::CreateWidget(QWidget *existing)
{
ComboBoxEx* cb;
if (existing == nullptr) {
cb = new ComboBoxEx();
cb->setScrollingEnabled(false);
for (int i=0;i<items_.size();i++) {
cb->addItem(items_.at(i).name);
}
} else {
cb = static_cast<ComboBoxEx*>(existing);
}
connect(cb, SIGNAL(activated(int)), this, SLOT(UpdateFromWidget(int)));
connect(this, SIGNAL(EnabledChanged(bool)), cb, SLOT(setEnabled(bool)));
return cb;
}
void ComboField::UpdateWidgetValue(QWidget *widget, double timecode)
{
QVariant data = GetValueAt(timecode);
ComboBoxEx* cb = static_cast<ComboBoxEx*>(widget);
for (int i=0;i<items_.size();i++) {
if (items_.at(i).data == data) {
cb->blockSignals(true);
cb->setCurrentIndex(i);
cb->blockSignals(false);
emit DataChanged(data);
return;
}
}
qWarning() << "Failed to set ComboField value from data";
}
void ComboField::UpdateFromWidget(int index)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), items_.at(index).data);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
+113 -113
View File
@@ -1,113 +1,113 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef COMBOFIELD_H
#define COMBOFIELD_H
#include "../effectfield.h"
/**
* @brief The ComboFieldItem struct
*
* An internal string+value pair used to represent a combobox item. name is used for the UI
* representation of the choices and the data is what can be retrieved by code.
*
* \see ComboField::AddItem.
*/
struct ComboFieldItem {
QString name;
QVariant data;
};
/**
* @brief The ComboField class
*
* An EffectField derivative to produce arbitrary data based on a fixed selection of items.
*/
class ComboField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
ComboField(NodeIO* parent);
/**
* @brief Add an item to this ComboField
*
* Adds a choice that the user can choose from this ComboField. All choices need text (for the on-screen
* choice) and data, which gets read on the backend. The selected data is what gets saved and loaded from
* project files, and therefore the data should be unique to this item. In case more items get added to
* this ComboField later, old project files will still open correctly. This is also why simple selected
* indices are not available. The text is only shown on the UI so it can be safely translated during runtime.
*
* @param text
*
* The text to show at this index.
*
* @param data
*
* The data to be retrieved at this index.
*/
void AddItem(const QString& text, const QVariant& data);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a QComboBox with the set of items added in AddItem().
*/
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
signals:
/**
* @brief Signal emitted whenever a connected widget's data gets changed
*
* Useful for UI events that need to occur with the change of this ComboField's value.
*/
void DataChanged(const QVariant&);
private:
/**
* @brief Internal array of string+value pair items.
*
* \see ComboFieldItem
*/
QVector<ComboFieldItem> items_;
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current index of the QWidget (QComboBox in this case). Automatically set when this slot is connected
* to the QComboBox::currentIndexChanged() signal. This is the only time ComboFields deal with indices since the
* QComboBox's indices will match precisely to the items_ array. Outside of this function, QVariant data is preferred.
*/
void UpdateFromWidget(int index);
};
#endif // COMBOFIELD_H
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef COMBOFIELD_H
#define COMBOFIELD_H
#include "../effectfield.h"
/**
* @brief The ComboFieldItem struct
*
* An internal string+value pair used to represent a combobox item. name is used for the UI
* representation of the choices and the data is what can be retrieved by code.
*
* \see ComboField::AddItem.
*/
struct ComboFieldItem {
QString name;
QVariant data;
};
/**
* @brief The ComboField class
*
* An EffectField derivative to produce arbitrary data based on a fixed selection of items.
*/
class ComboField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
ComboField(NodeIO* parent);
/**
* @brief Add an item to this ComboField
*
* Adds a choice that the user can choose from this ComboField. All choices need text (for the on-screen
* choice) and data, which gets read on the backend. The selected data is what gets saved and loaded from
* project files, and therefore the data should be unique to this item. In case more items get added to
* this ComboField later, old project files will still open correctly. This is also why simple selected
* indices are not available. The text is only shown on the UI so it can be safely translated during runtime.
*
* @param text
*
* The text to show at this index.
*
* @param data
*
* The data to be retrieved at this index.
*/
void AddItem(const QString& text, const QVariant& data);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a QComboBox with the set of items added in AddItem().
*/
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
signals:
/**
* @brief Signal emitted whenever a connected widget's data gets changed
*
* Useful for UI events that need to occur with the change of this ComboField's value.
*/
void DataChanged(const QVariant&);
private:
/**
* @brief Internal array of string+value pair items.
*
* \see ComboFieldItem
*/
QVector<ComboFieldItem> items_;
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current index of the QWidget (QComboBox in this case). Automatically set when this slot is connected
* to the QComboBox::currentIndexChanged() signal. This is the only time ComboFields deal with indices since the
* QComboBox's indices will match precisely to the items_ array. Outside of this function, QVariant data is preferred.
*/
void UpdateFromWidget(int index);
};
#endif // COMBOFIELD_H
+151 -151
View File
@@ -1,151 +1,151 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "doublefield.h"
#include "nodes/node.h"
#include "undo/undo.h"
DoubleField::DoubleField(NodeIO* parent) :
EffectField(parent, EffectField::EFFECT_FIELD_DOUBLE),
min_(qSNaN()),
max_(qSNaN()),
default_(0),
display_type_(LabelSlider::Normal),
frame_rate_(30),
value_set_(false),
kdc_(nullptr)
{
connect(this, SIGNAL(Changed()), this, SLOT(ValueHasBeenSet()), Qt::DirectConnection);
}
double DoubleField::GetDoubleAt(double timecode)
{
return GetValueAt(timecode).toDouble();
}
void DoubleField::SetMinimum(double minimum)
{
min_ = minimum;
emit MinimumChanged(min_);
}
void DoubleField::SetMaximum(double maximum)
{
max_ = maximum;
emit MaximumChanged(max_);
}
void DoubleField::SetDefault(double d)
{
default_ = d;
if (!value_set_) {
SetValueAt(0, d);
}
}
void DoubleField::SetDisplayType(LabelSlider::DisplayType type)
{
display_type_ = type;
}
void DoubleField::SetFrameRate(const double &rate)
{
frame_rate_ = rate;
}
QVariant DoubleField::ConvertStringToValue(const QString &s)
{
return s.toDouble();
}
QString DoubleField::ConvertValueToString(const QVariant &v)
{
return QString::number(v.toDouble());
}
QWidget *DoubleField::CreateWidget(QWidget *existing)
{
LabelSlider* ls;
if (existing == nullptr) {
ls = new LabelSlider();
if (!qIsNaN(min_)) {
ls->SetMinimum(min_);
}
ls->SetDefault(default_);
if (!qIsNaN(max_)) {
ls->SetMaximum(max_);
}
ls->SetDisplayType(display_type_);
ls->SetFrameRate(frame_rate_);
ls->setEnabled(IsEnabled());
} else {
ls = static_cast<LabelSlider*>(existing);
}
connect(ls, SIGNAL(valueChanged(double)), this, SLOT(UpdateFromWidget(double)));
connect(ls, SIGNAL(clicked()), this, SIGNAL(Clicked()));
connect(this, SIGNAL(EnabledChanged(bool)), ls, SLOT(setEnabled(bool)));
connect(this, SIGNAL(MaximumChanged(double)), ls, SLOT(SetMaximum(double)));
connect(this, SIGNAL(MinimumChanged(double)), ls, SLOT(SetMinimum(double)));
return ls;
}
void DoubleField::UpdateWidgetValue(QWidget *widget, double timecode)
{
if (qIsNaN(timecode)) {
static_cast<LabelSlider*>(widget)->SetValue(qSNaN());
} else {
static_cast<LabelSlider*>(widget)->SetValue(GetDoubleAt(timecode));
}
}
void DoubleField::ValueHasBeenSet()
{
value_set_ = true;
}
void DoubleField::UpdateFromWidget(double d)
{
LabelSlider* ls = static_cast<LabelSlider*>(sender());
if (ls->IsDragging() && kdc_ == nullptr) {
kdc_ = new KeyframeDataChange(this);
}
SetValueAt(GetParentRow()->ParentNode()->Time(), d);
if (!ls->IsDragging() && kdc_ != nullptr) {
kdc_->SetNewKeyframes();
olive::undo_stack.push(kdc_);
kdc_ = nullptr;
}
}
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "doublefield.h"
#include "nodes/node.h"
#include "undo/undo.h"
DoubleField::DoubleField(NodeIO* parent) :
EffectField(parent, EffectField::EFFECT_FIELD_DOUBLE),
min_(qSNaN()),
max_(qSNaN()),
default_(0),
display_type_(LabelSlider::Normal),
frame_rate_(30),
value_set_(false),
kdc_(nullptr)
{
connect(this, SIGNAL(Changed()), this, SLOT(ValueHasBeenSet()), Qt::DirectConnection);
}
double DoubleField::GetDoubleAt(double timecode)
{
return GetValueAt(timecode).toDouble();
}
void DoubleField::SetMinimum(double minimum)
{
min_ = minimum;
emit MinimumChanged(min_);
}
void DoubleField::SetMaximum(double maximum)
{
max_ = maximum;
emit MaximumChanged(max_);
}
void DoubleField::SetDefault(double d)
{
default_ = d;
if (!value_set_) {
SetValueAt(0, d);
}
}
void DoubleField::SetDisplayType(LabelSlider::DisplayType type)
{
display_type_ = type;
}
void DoubleField::SetFrameRate(const double &rate)
{
frame_rate_ = rate;
}
QVariant DoubleField::ConvertStringToValue(const QString &s)
{
return s.toDouble();
}
QString DoubleField::ConvertValueToString(const QVariant &v)
{
return QString::number(v.toDouble());
}
QWidget *DoubleField::CreateWidget(QWidget *existing)
{
LabelSlider* ls;
if (existing == nullptr) {
ls = new LabelSlider();
if (!qIsNaN(min_)) {
ls->SetMinimum(min_);
}
ls->SetDefault(default_);
if (!qIsNaN(max_)) {
ls->SetMaximum(max_);
}
ls->SetDisplayType(display_type_);
ls->SetFrameRate(frame_rate_);
ls->setEnabled(IsEnabled());
} else {
ls = static_cast<LabelSlider*>(existing);
}
connect(ls, SIGNAL(valueChanged(double)), this, SLOT(UpdateFromWidget(double)));
connect(ls, SIGNAL(clicked()), this, SIGNAL(Clicked()));
connect(this, SIGNAL(EnabledChanged(bool)), ls, SLOT(setEnabled(bool)));
connect(this, SIGNAL(MaximumChanged(double)), ls, SLOT(SetMaximum(double)));
connect(this, SIGNAL(MinimumChanged(double)), ls, SLOT(SetMinimum(double)));
return ls;
}
void DoubleField::UpdateWidgetValue(QWidget *widget, double timecode)
{
if (qIsNaN(timecode)) {
static_cast<LabelSlider*>(widget)->SetValue(qSNaN());
} else {
static_cast<LabelSlider*>(widget)->SetValue(GetDoubleAt(timecode));
}
}
void DoubleField::ValueHasBeenSet()
{
value_set_ = true;
}
void DoubleField::UpdateFromWidget(double d)
{
LabelSlider* ls = static_cast<LabelSlider*>(sender());
if (ls->IsDragging() && kdc_ == nullptr) {
kdc_ = new KeyframeDataChange(this);
}
SetValueAt(GetParentRow()->ParentNode()->Time(), d);
if (!ls->IsDragging() && kdc_ != nullptr) {
kdc_->SetNewKeyframes();
olive::undo_stack.push(kdc_);
kdc_ = nullptr;
}
}
+210 -210
View File
@@ -1,210 +1,210 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef DOUBLEFIELD_H
#define DOUBLEFIELD_H
#include "../effectfield.h"
#include "ui/labelslider.h"
class KeyframeDataChange;
/**
* @brief The DoubleField class
*
* An EffectField derivative the produces number values (integer or floating-point) and uses a LabelSlider as its
* visual representation.
*/
class DoubleField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
DoubleField(NodeIO* parent);
/**
* @brief Get double value at timecode
*
* Convenience function. Equivalent to GetValueAt().toDouble()
*
* @param timecode
*
* Timecode to retrieve value at
*
* @return
*
* Double value at the set timecode
*/
double GetDoubleAt(double timecode);
/**
* @brief Sets the minimum allowed number for the user to set to `minimum`.
*/
void SetMinimum(double minimum);
/**
* @brief Sets the maximum allowed number for the user to set to `maximum`.
*/
void SetMaximum(double maximum);
/**
* @brief Sets the default number for this field to `d`.
*/
void SetDefault(double d);
/**
* @brief Sets the UI display type to a member of LabelSlider::DisplayType.
*/
void SetDisplayType(LabelSlider::DisplayType type);
/**
* @brief For a timecode-based display type, sets the frame rate to be used for the displayed timecode
*
* \see SetDisplayType() and LabelSlider::SetFrameRate().
*/
void SetFrameRate(const double& rate);
/**
* @brief Reimplementation of EffectField::ConvertStringToValue()
*/
virtual QVariant ConvertStringToValue(const QString& s) override;
/**
* @brief Reimplementation of EffectField::ConvertValueToString()
*/
virtual QString ConvertValueToString(const QVariant& v) override;
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a LabelSlider.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
signals:
/**
* @brief Signal emitted when the field's maximum value has changed
*
* This signal gets connected to any LabelSlider created from CreateWidget() so the maximum value is
* always synchronized between them.
*
* Note: A connection is not made both ways as you should never manipulate a UI object created from
* an EffectField directly. Always access data through the EffectField itself.
*
* \see SetMaximum()
*
* @param maximum
*
* The new maximum value.
*/
void MaximumChanged(double maximum);
/**
* @brief Signal emitted when the field's minimum value has changed
*
* This signal gets connected to any LabelSlider created from CreateWidget() so the minimum value is
* always synchronized between them.
*
* Note: A connection is not made both ways as you should never manipulate a UI object created from
* an EffectField directly. Always access data through the EffectField itself.
*
* \see SetMinimum()
*
* @param minimum
*
* The new minimum value.
*/
void MinimumChanged(double minimum);
private:
/**
* @brief Internal minimum value
*
* \see SetMinimum().
*/
double min_;
/**
* @brief Internal maximum value
*
* \see SetMaximum().
*/
double max_;
/**
* @brief Internal default value
*
* \see SetDefault().
*/
double default_;
/**
* @brief Internal display type value
*
* \see SetDisplayType().
*/
LabelSlider::DisplayType display_type_;
/**
* @brief Internal frame rate value
*
* \see SetFrameRate().
*/
double frame_rate_;
/**
* @brief Internal value used to allow SetDefault() to set the value as well if none has been set
*
* Initialized to FALSE, then set to TRUE indefinitely whenever the value gets set on this field.
*/
bool value_set_;
/**
* @brief An internal KeyframeDataChange undoable command
*
* This is stored to allow for the value to be changed by dragging without every single "step" being pushed to
* the undo stack. Instead an undo command can be created at the start of a drag, and then pushed at the end
* to make it one single undoable action.
*/
KeyframeDataChange* kdc_;
private slots:
/**
* @brief Connected to EffectField::Changed() to ensure value_set_ gets set to TRUE whenever a value is set on this
* field.
*/
void ValueHasBeenSet();
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current number value of the QWidget (LabelSlider in this case). Automatically set when this slot is connected
* to the LabelSlider::valueChanged() signal.
*/
void UpdateFromWidget(double d);
};
#endif // DOUBLEFIELD_H
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef DOUBLEFIELD_H
#define DOUBLEFIELD_H
#include "../effectfield.h"
#include "ui/labelslider.h"
class KeyframeDataChange;
/**
* @brief The DoubleField class
*
* An EffectField derivative the produces number values (integer or floating-point) and uses a LabelSlider as its
* visual representation.
*/
class DoubleField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
DoubleField(NodeIO* parent);
/**
* @brief Get double value at timecode
*
* Convenience function. Equivalent to GetValueAt().toDouble()
*
* @param timecode
*
* Timecode to retrieve value at
*
* @return
*
* Double value at the set timecode
*/
double GetDoubleAt(double timecode);
/**
* @brief Sets the minimum allowed number for the user to set to `minimum`.
*/
void SetMinimum(double minimum);
/**
* @brief Sets the maximum allowed number for the user to set to `maximum`.
*/
void SetMaximum(double maximum);
/**
* @brief Sets the default number for this field to `d`.
*/
void SetDefault(double d);
/**
* @brief Sets the UI display type to a member of LabelSlider::DisplayType.
*/
void SetDisplayType(LabelSlider::DisplayType type);
/**
* @brief For a timecode-based display type, sets the frame rate to be used for the displayed timecode
*
* \see SetDisplayType() and LabelSlider::SetFrameRate().
*/
void SetFrameRate(const double& rate);
/**
* @brief Reimplementation of EffectField::ConvertStringToValue()
*/
virtual QVariant ConvertStringToValue(const QString& s) override;
/**
* @brief Reimplementation of EffectField::ConvertValueToString()
*/
virtual QString ConvertValueToString(const QVariant& v) override;
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a LabelSlider.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
signals:
/**
* @brief Signal emitted when the field's maximum value has changed
*
* This signal gets connected to any LabelSlider created from CreateWidget() so the maximum value is
* always synchronized between them.
*
* Note: A connection is not made both ways as you should never manipulate a UI object created from
* an EffectField directly. Always access data through the EffectField itself.
*
* \see SetMaximum()
*
* @param maximum
*
* The new maximum value.
*/
void MaximumChanged(double maximum);
/**
* @brief Signal emitted when the field's minimum value has changed
*
* This signal gets connected to any LabelSlider created from CreateWidget() so the minimum value is
* always synchronized between them.
*
* Note: A connection is not made both ways as you should never manipulate a UI object created from
* an EffectField directly. Always access data through the EffectField itself.
*
* \see SetMinimum()
*
* @param minimum
*
* The new minimum value.
*/
void MinimumChanged(double minimum);
private:
/**
* @brief Internal minimum value
*
* \see SetMinimum().
*/
double min_;
/**
* @brief Internal maximum value
*
* \see SetMaximum().
*/
double max_;
/**
* @brief Internal default value
*
* \see SetDefault().
*/
double default_;
/**
* @brief Internal display type value
*
* \see SetDisplayType().
*/
LabelSlider::DisplayType display_type_;
/**
* @brief Internal frame rate value
*
* \see SetFrameRate().
*/
double frame_rate_;
/**
* @brief Internal value used to allow SetDefault() to set the value as well if none has been set
*
* Initialized to FALSE, then set to TRUE indefinitely whenever the value gets set on this field.
*/
bool value_set_;
/**
* @brief An internal KeyframeDataChange undoable command
*
* This is stored to allow for the value to be changed by dragging without every single "step" being pushed to
* the undo stack. Instead an undo command can be created at the start of a drag, and then pushed at the end
* to make it one single undoable action.
*/
KeyframeDataChange* kdc_;
private slots:
/**
* @brief Connected to EffectField::Changed() to ensure value_set_ gets set to TRUE whenever a value is set on this
* field.
*/
void ValueHasBeenSet();
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current number value of the QWidget (LabelSlider in this case). Automatically set when this slot is connected
* to the LabelSlider::valueChanged() signal.
*/
void UpdateFromWidget(double d);
};
#endif // DOUBLEFIELD_H
+68 -68
View File
@@ -1,68 +1,68 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "filefield.h"
#include <QDebug>
#include "ui/embeddedfilechooser.h"
#include "nodes/node.h"
#include "undo/undo.h"
FileField::FileField(NodeIO* parent) :
EffectField(parent, EffectField::EFFECT_FIELD_FILE)
{
// Set default value to an empty string
SetValueAt(0, "");
}
QString FileField::GetFileAt(double timecode)
{
return GetValueAt(timecode).toString();
}
QWidget *FileField::CreateWidget(QWidget *existing)
{
EmbeddedFileChooser* efc = (existing != nullptr) ? static_cast<EmbeddedFileChooser*>(existing) : new EmbeddedFileChooser();
connect(efc, SIGNAL(changed(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
connect(this, SIGNAL(EnabledChanged(bool)), efc, SLOT(setEnabled(bool)));
return efc;
}
void FileField::UpdateWidgetValue(QWidget *widget, double timecode)
{
EmbeddedFileChooser* efc = static_cast<EmbeddedFileChooser*>(widget);
efc->blockSignals(true);
efc->setFilename(GetFileAt(timecode));
efc->blockSignals(false);
}
void FileField::UpdateFromWidget(const QString &s)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), s);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "filefield.h"
#include <QDebug>
#include "ui/embeddedfilechooser.h"
#include "nodes/node.h"
#include "undo/undo.h"
FileField::FileField(NodeIO* parent) :
EffectField(parent, EffectField::EFFECT_FIELD_FILE)
{
// Set default value to an empty string
SetValueAt(0, "");
}
QString FileField::GetFileAt(double timecode)
{
return GetValueAt(timecode).toString();
}
QWidget *FileField::CreateWidget(QWidget *existing)
{
EmbeddedFileChooser* efc = (existing != nullptr) ? static_cast<EmbeddedFileChooser*>(existing) : new EmbeddedFileChooser();
connect(efc, SIGNAL(changed(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
connect(this, SIGNAL(EnabledChanged(bool)), efc, SLOT(setEnabled(bool)));
return efc;
}
void FileField::UpdateWidgetValue(QWidget *widget, double timecode)
{
EmbeddedFileChooser* efc = static_cast<EmbeddedFileChooser*>(widget);
efc->blockSignals(true);
efc->setFilename(GetFileAt(timecode));
efc->blockSignals(false);
}
void FileField::UpdateFromWidget(const QString &s)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), s);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
+79 -79
View File
@@ -1,79 +1,79 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef FILEFIELD_H
#define FILEFIELD_H
#include "../effectfield.h"
/**
* @brief The FileInput class
*
* An EffectField derivative that produces filenames in string and uses an EmbeddedFileChooser
* as its visual representation.
*/
class FileField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
FileField(NodeIO* parent);
/**
* @brief Get the filename at the given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).toString()
*
* @param timecode
*
* The timecode to retrieve the filename at
*
* @return
*
* The filename at this timecode
*/
QString GetFileAt(double timecode);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a EmbeddedFileChooser.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget *widget, double timecode) override;
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current string of the QWidget (TextEditEx in this case). Automatically set when this slot
* is connected to the TextEditEx::textModified() signal.
*/
void UpdateFromWidget(const QString &s);
};
#endif // FILEFIELD_H
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef FILEFIELD_H
#define FILEFIELD_H
#include "../effectfield.h"
/**
* @brief The FileInput class
*
* An EffectField derivative that produces filenames in string and uses an EmbeddedFileChooser
* as its visual representation.
*/
class FileField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
FileField(NodeIO* parent);
/**
* @brief Get the filename at the given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).toString()
*
* @param timecode
*
* The timecode to retrieve the filename at
*
* @return
*
* The filename at this timecode
*/
QString GetFileAt(double timecode);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a EmbeddedFileChooser.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget *widget, double timecode) override;
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current string of the QWidget (TextEditEx in this case). Automatically set when this slot
* is connected to the TextEditEx::textModified() signal.
*/
void UpdateFromWidget(const QString &s);
};
#endif // FILEFIELD_H
+95 -95
View File
@@ -1,95 +1,95 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "fontfield.h"
#include <QFontDatabase>
#include <QDebug>
#include "ui/comboboxex.h"
#include "nodes/node.h"
#include "undo/undo.h"
// NOTE/TODO: This shares a lot of similarity with ComboInput, and could probably be a derived class of it
FontField::FontField(NodeIO* parent) :
EffectField(parent, EffectField::EFFECT_FIELD_FONT)
{
font_list = QFontDatabase().families();
SetValueAt(0, font_list.first());
}
QString FontField::GetFontAt(double timecode)
{
return GetValueAt(timecode).toString();
}
QWidget *FontField::CreateWidget(QWidget *existing)
{
ComboBoxEx* fcb = new ComboBoxEx();
if (existing == nullptr) {
fcb = new ComboBoxEx();
fcb->setScrollingEnabled(false);
fcb->addItems(font_list);
} else {
fcb = static_cast<ComboBoxEx*>(existing);
}
connect(fcb, SIGNAL(currentTextChanged(const QString &)), this, SLOT(UpdateFromWidget(const QString &)));
connect(this, SIGNAL(EnabledChanged(bool)), fcb, SLOT(setEnabled(bool)));
return fcb;
}
void FontField::UpdateWidgetValue(QWidget *widget, double timecode)
{
QVariant data = GetValueAt(timecode);
ComboBoxEx* cb = static_cast<ComboBoxEx*>(widget);
for (int i=0;i<font_list.size();i++) {
if (font_list.at(i) == data) {
cb->blockSignals(true);
cb->setCurrentIndex(i);
cb->blockSignals(false);
return;
}
}
qWarning() << "Failed to set FontField value from data";
}
void FontField::UpdateFromWidget(const QString& s)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), s);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "fontfield.h"
#include <QFontDatabase>
#include <QDebug>
#include "ui/comboboxex.h"
#include "nodes/node.h"
#include "undo/undo.h"
// NOTE/TODO: This shares a lot of similarity with ComboInput, and could probably be a derived class of it
FontField::FontField(NodeIO* parent) :
EffectField(parent, EffectField::EFFECT_FIELD_FONT)
{
font_list = QFontDatabase().families();
SetValueAt(0, font_list.first());
}
QString FontField::GetFontAt(double timecode)
{
return GetValueAt(timecode).toString();
}
QWidget *FontField::CreateWidget(QWidget *existing)
{
ComboBoxEx* fcb = new ComboBoxEx();
if (existing == nullptr) {
fcb = new ComboBoxEx();
fcb->setScrollingEnabled(false);
fcb->addItems(font_list);
} else {
fcb = static_cast<ComboBoxEx*>(existing);
}
connect(fcb, SIGNAL(currentTextChanged(const QString &)), this, SLOT(UpdateFromWidget(const QString &)));
connect(this, SIGNAL(EnabledChanged(bool)), fcb, SLOT(setEnabled(bool)));
return fcb;
}
void FontField::UpdateWidgetValue(QWidget *widget, double timecode)
{
QVariant data = GetValueAt(timecode);
ComboBoxEx* cb = static_cast<ComboBoxEx*>(widget);
for (int i=0;i<font_list.size();i++) {
if (font_list.at(i) == data) {
cb->blockSignals(true);
cb->setCurrentIndex(i);
cb->blockSignals(false);
return;
}
}
qWarning() << "Failed to set FontField value from data";
}
void FontField::UpdateFromWidget(const QString& s)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), s);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
+88 -88
View File
@@ -1,88 +1,88 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef FONTFIELD_H
#define FONTFIELD_H
#include "combofield.h"
/**
* @brief The FontField class
*
* An EffectField derivative the produces font family names in string and uses a QComboBox
* as its visual representation.
*
* TODO Upgrade to QFontComboBox.
*/
class FontField : public EffectField {
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
FontField(NodeIO* parent);
/**
* @brief Get the font family name at the given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).toString()
*
* @param timecode
*
* The timecode to retrieve the font family name at
*
* @return
*
* The font family name at this timecode
*/
QString GetFontAt(double timecode);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a QComboBox.
*/
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
private:
/**
* @brief Internal list of fonts to add to a QComboBox when creating one in CreateWidget().
*
* NOTE: Deprecated. Once QComboBox is replaced by QFontComboBox this will be completely unnecessary.
*/
QStringList font_list;
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current font name specified by the QWidget (QComboBox in this case). Automatically set when this slot
* is connected to the QComboBox::currentTextChanged() signal.
*/
void UpdateFromWidget(const QString& index);
};
#endif // FONTFIELD_H
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef FONTFIELD_H
#define FONTFIELD_H
#include "combofield.h"
/**
* @brief The FontField class
*
* An EffectField derivative the produces font family names in string and uses a QComboBox
* as its visual representation.
*
* TODO Upgrade to QFontComboBox.
*/
class FontField : public EffectField {
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
FontField(NodeIO* parent);
/**
* @brief Get the font family name at the given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).toString()
*
* @param timecode
*
* The timecode to retrieve the font family name at
*
* @return
*
* The font family name at this timecode
*/
QString GetFontAt(double timecode);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a QComboBox.
*/
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
private:
/**
* @brief Internal list of fonts to add to a QComboBox when creating one in CreateWidget().
*
* NOTE: Deprecated. Once QComboBox is replaced by QFontComboBox this will be completely unnecessary.
*/
QStringList font_list;
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current font name specified by the QWidget (QComboBox in this case). Automatically set when this slot
* is connected to the QComboBox::currentTextChanged() signal.
*/
void UpdateFromWidget(const QString& index);
};
#endif // FONTFIELD_H
+49 -49
View File
@@ -1,49 +1,49 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "labelfield.h"
#include <QLabel>
LabelField::LabelField(NodeIO *parent, const QString &string) :
EffectField(parent, EffectField::EFFECT_FIELD_UI),
label_text_(string)
{}
QWidget *LabelField::CreateWidget(QWidget *existing)
{
QLabel* label;
if (existing == nullptr) {
label = new QLabel(label_text_);
label->setEnabled(IsEnabled());
} else {
label = static_cast<QLabel*>(existing);
}
connect(this, SIGNAL(EnabledChanged(bool)), label, SLOT(setEnabled(bool)));
return label;
}
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "labelfield.h"
#include <QLabel>
LabelField::LabelField(NodeIO *parent, const QString &string) :
EffectField(parent, EffectField::EFFECT_FIELD_UI),
label_text_(string)
{}
QWidget *LabelField::CreateWidget(QWidget *existing)
{
QLabel* label;
if (existing == nullptr) {
label = new QLabel(label_text_);
label->setEnabled(IsEnabled());
} else {
label = static_cast<QLabel*>(existing);
}
connect(this, SIGNAL(EnabledChanged(bool)), label, SLOT(setEnabled(bool)));
return label;
}
+55 -55
View File
@@ -1,55 +1,55 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef LABELFIELD_H
#define LABELFIELD_H
#include "../effectfield.h"
/**
* @brief The LabelField class
*
* A UI-type EffectField. This field is largely an EffectField wrapper around a QLabel and provides no data that's
* usable in the Effect. It's primarily useful for showing UI information. This field is not exposed to the external
* shader API as it requires raw C++ code to connect it to other elements.
*/
class LabelField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
LabelField(NodeIO* parent, const QString& string);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a QLabel.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
private:
/**
* @brief Internal text string
*/
QString label_text_;
};
#endif // LABELFIELD_H
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef LABELFIELD_H
#define LABELFIELD_H
#include "../effectfield.h"
/**
* @brief The LabelField class
*
* A UI-type EffectField. This field is largely an EffectField wrapper around a QLabel and provides no data that's
* usable in the Effect. It's primarily useful for showing UI information. This field is not exposed to the external
* shader API as it requires raw C++ code to connect it to other elements.
*/
class LabelField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*/
LabelField(NodeIO* parent, const QString& string);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a QLabel.
*/
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
private:
/**
* @brief Internal text string
*/
QString label_text_;
};
#endif // LABELFIELD_H
+101 -101
View File
@@ -1,101 +1,101 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "stringfield.h"
#include <QtMath>
#include <QDebug>
#include "nodes/node.h"
#include "ui/texteditex.h"
#include "global/config.h"
#include "undo/undo.h"
StringField::StringField(NodeIO* parent, bool rich_text) :
EffectField(parent, EffectField::EFFECT_FIELD_STRING),
rich_text_(rich_text)
{
// Set default value to an empty string
SetValueAt(0, "");
}
QString StringField::GetStringAt(double timecode)
{
return GetValueAt(timecode).toString();
}
QWidget *StringField::CreateWidget(QWidget *existing)
{
TextEditEx* text_edit;
if (existing == nullptr) {
text_edit = new TextEditEx(nullptr, rich_text_);
text_edit->setEnabled(IsEnabled());
text_edit->setUndoRedoEnabled(true);
// the "2" is because the height needs one extra pixel of padding on the top and the bottom
text_edit->setTextHeight(qCeil(text_edit->fontMetrics().lineSpacing()*olive::config.effect_textbox_lines
+ text_edit->document()->documentMargin()
+ text_edit->document()->documentMargin() + 2));
} else {
text_edit = static_cast<TextEditEx*>(existing);
}
connect(text_edit, SIGNAL(textModified(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
connect(this, SIGNAL(EnabledChanged(bool)), text_edit, SLOT(setEnabled(bool)));
return text_edit;
}
void StringField::UpdateWidgetValue(QWidget *widget, double timecode)
{
TextEditEx* text = static_cast<TextEditEx*>(widget);
text->blockSignals(true);
int pos = text->textCursor().position();
if (rich_text_) {
text->setHtml(GetValueAt(timecode).toString());
} else {
text->setPlainText(GetValueAt(timecode).toString());
}
QTextCursor new_cursor(text->document());
new_cursor.setPosition(pos);
text->setTextCursor(new_cursor);
text->blockSignals(false);
}
void StringField::UpdateFromWidget(const QString &s)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), s);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "stringfield.h"
#include <QtMath>
#include <QDebug>
#include "nodes/node.h"
#include "ui/texteditex.h"
#include "global/config.h"
#include "undo/undo.h"
StringField::StringField(NodeIO* parent, bool rich_text) :
EffectField(parent, EffectField::EFFECT_FIELD_STRING),
rich_text_(rich_text)
{
// Set default value to an empty string
SetValueAt(0, "");
}
QString StringField::GetStringAt(double timecode)
{
return GetValueAt(timecode).toString();
}
QWidget *StringField::CreateWidget(QWidget *existing)
{
TextEditEx* text_edit;
if (existing == nullptr) {
text_edit = new TextEditEx(nullptr, rich_text_);
text_edit->setEnabled(IsEnabled());
text_edit->setUndoRedoEnabled(true);
// the "2" is because the height needs one extra pixel of padding on the top and the bottom
text_edit->setTextHeight(qCeil(text_edit->fontMetrics().lineSpacing()*olive::config.effect_textbox_lines
+ text_edit->document()->documentMargin()
+ text_edit->document()->documentMargin() + 2));
} else {
text_edit = static_cast<TextEditEx*>(existing);
}
connect(text_edit, SIGNAL(textModified(const QString&)), this, SLOT(UpdateFromWidget(const QString&)));
connect(this, SIGNAL(EnabledChanged(bool)), text_edit, SLOT(setEnabled(bool)));
return text_edit;
}
void StringField::UpdateWidgetValue(QWidget *widget, double timecode)
{
TextEditEx* text = static_cast<TextEditEx*>(widget);
text->blockSignals(true);
int pos = text->textCursor().position();
if (rich_text_) {
text->setHtml(GetValueAt(timecode).toString());
} else {
text->setPlainText(GetValueAt(timecode).toString());
}
QTextCursor new_cursor(text->document());
new_cursor.setPosition(pos);
text->setTextCursor(new_cursor);
text->blockSignals(false);
}
void StringField::UpdateFromWidget(const QString &s)
{
KeyframeDataChange* kdc = new KeyframeDataChange(this);
SetValueAt(GetParentRow()->ParentNode()->Time(), s);
kdc->SetNewKeyframes();
olive::undo_stack.push(kdc);
}
+87 -87
View File
@@ -1,87 +1,87 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef STRINGFIELD_H
#define STRINGFIELD_H
#include "../effectfield.h"
/**
* @brief The StringField class
*
* An EffectField derivative that produces arbitrary strings entered by the user and uses a TextEditEx as its
* visual representation.
*/
class StringField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*
* Provides a setting for whether this StringField - and its attached TextEditEx objects - should operate in rich
* text or plain text mode, defaulting to rich text mode.
*/
StringField(NodeIO* parent, bool rich_text = true);
/**
* @brief Get the string at the given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).toString()
*
* @param timecode
*
* The timecode to retrieve the string at
*
* @return
*
* The string at this timecode
*/
QString GetStringAt(double timecode);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a TextEditEx.
*/
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current checked state of the QWidget (EmbeddedFileChooser in this case). Automatically set when this slot
* is connected to the EmbeddedFileChooser::changed() signal.
*/
void UpdateFromWidget(const QString& b);
private:
/**
* @brief Internal value for whether this field is in rich text or plain text mode
*/
bool rich_text_;
};
#endif // STRINGFIELD_H
/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
This program 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 3 of the License, or
(at your option) any later version.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef STRINGFIELD_H
#define STRINGFIELD_H
#include "../effectfield.h"
/**
* @brief The StringField class
*
* An EffectField derivative that produces arbitrary strings entered by the user and uses a TextEditEx as its
* visual representation.
*/
class StringField : public EffectField
{
Q_OBJECT
public:
/**
* @brief Reimplementation of EffectField::EffectField().
*
* Provides a setting for whether this StringField - and its attached TextEditEx objects - should operate in rich
* text or plain text mode, defaulting to rich text mode.
*/
StringField(NodeIO* parent, bool rich_text = true);
/**
* @brief Get the string at the given timecode
*
* A convenience function, equivalent to GetValueAt(timecode).toString()
*
* @param timecode
*
* The timecode to retrieve the string at
*
* @return
*
* The string at this timecode
*/
QString GetStringAt(double timecode);
/**
* @brief Reimplementation of EffectField::CreateWidget()
*
* Creates and connects to a TextEditEx.
*/
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
/**
* @brief Reimplementation of EffectField::UpdateWidgetValue()
*/
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
private slots:
/**
* @brief Internal function connected to any QWidget made from CreateWidget() to update the value based on user input
*
* @param b
*
* The current checked state of the QWidget (EmbeddedFileChooser in this case). Automatically set when this slot
* is connected to the EmbeddedFileChooser::changed() signal.
*/
void UpdateFromWidget(const QString& b);
private:
/**
* @brief Internal value for whether this field is in rich text or plain text mode
*/
bool rich_text_;
};
#endif // STRINGFIELD_H