reimplemented double and bool widgets separately
This commit is contained in:
+9
-7
@@ -197,10 +197,12 @@ void Clip::reset_audio() {
|
||||
cacher.ResetAudio();
|
||||
}
|
||||
if (media() != nullptr && media()->get_type() == MEDIA_TYPE_SEQUENCE) {
|
||||
Sequence* nested_sequence = media()->to_sequence();
|
||||
Sequence* nested_sequence = media()->to_sequence().get();
|
||||
for (int i=0;i<nested_sequence->clips.size();i++) {
|
||||
ClipPtr c = nested_sequence->clips.at(i);
|
||||
if (c != nullptr) c->reset_audio();
|
||||
Clip* c = nested_sequence->clips.at(i).get();
|
||||
if (c != nullptr) {
|
||||
c->reset_audio();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -391,7 +393,7 @@ long Clip::media_length() {
|
||||
}
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
Sequence* s = media_->to_sequence();
|
||||
Sequence* s = media_->to_sequence().get();
|
||||
return rescale_frame_number(s->getEndFrame(), s->frame_rate, fr);
|
||||
}
|
||||
}
|
||||
@@ -412,7 +414,7 @@ int Clip::media_width() {
|
||||
}
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
Sequence* s = media_->to_sequence();
|
||||
Sequence* s = media_->to_sequence().get();
|
||||
return s->width;
|
||||
}
|
||||
}
|
||||
@@ -431,7 +433,7 @@ int Clip::media_height() {
|
||||
break;
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
Sequence* s = media_->to_sequence();
|
||||
Sequence* s = media_->to_sequence().get();
|
||||
return s->height;
|
||||
}
|
||||
}
|
||||
@@ -489,7 +491,7 @@ void Clip::Close(bool wait) {
|
||||
open_ = false;
|
||||
|
||||
if (media() != nullptr && media()->get_type() == MEDIA_TYPE_SEQUENCE) {
|
||||
close_active_clips(media()->to_sequence());
|
||||
close_active_clips(media()->to_sequence().get());
|
||||
}
|
||||
|
||||
// destroy opengl texture in main thread
|
||||
|
||||
+2
-6
@@ -290,10 +290,6 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (field != nullptr) {
|
||||
connect(field, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -393,7 +389,7 @@ int Effect::gizmo_count() {
|
||||
|
||||
void Effect::refresh() {}
|
||||
|
||||
void Effect::field_changed() {
|
||||
void Effect::FieldChanged() {
|
||||
panel_sequence_viewer->viewer_widget->frame_update();
|
||||
panel_graph_editor->update_panel();
|
||||
}
|
||||
@@ -465,7 +461,7 @@ void Effect::load_from_file() {
|
||||
QFile file_handle(file);
|
||||
if (file_handle.open(QFile::ReadOnly)) {
|
||||
|
||||
olive::UndoStack.push(new SetEffectData(EffectPtr(this), file_handle.readAll()));
|
||||
olive::UndoStack.push(new SetEffectData(this, file_handle.readAll()));
|
||||
|
||||
file_handle.close();
|
||||
|
||||
|
||||
+1
-1
@@ -214,7 +214,7 @@ public:
|
||||
static EffectPtr Create(Clip *c, const EffectMeta *em);
|
||||
static const EffectMeta* GetInternalMeta(int internal_id, int type);
|
||||
public slots:
|
||||
void field_changed();
|
||||
void FieldChanged();
|
||||
signals:
|
||||
void EnabledChanged(bool);
|
||||
private slots:
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "boolfield.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
BoolField::BoolField(EffectRow *parent, const QString &id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_BOOL)
|
||||
{}
|
||||
@@ -9,6 +11,17 @@ bool BoolField::GetBoolAt(double timecode)
|
||||
return GetValueAt(timecode).toBool();
|
||||
}
|
||||
|
||||
QWidget *BoolField::CreateWidget()
|
||||
{
|
||||
QCheckBox* cb = new QCheckBox();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
QVariant BoolField::ConvertStringToValue(const QString &s)
|
||||
{
|
||||
return (s == "1");
|
||||
@@ -18,3 +31,8 @@ QString BoolField::ConvertValueToString(const QVariant &v)
|
||||
{
|
||||
return QString::number(v.toBool());
|
||||
}
|
||||
|
||||
void BoolField::UpdateFromWidget(bool b)
|
||||
{
|
||||
SetValueAt(Now(), b);
|
||||
}
|
||||
|
||||
@@ -11,8 +11,14 @@ public:
|
||||
|
||||
bool GetBoolAt(double timecode);
|
||||
|
||||
virtual QWidget* CreateWidget() override;
|
||||
|
||||
virtual QVariant ConvertStringToValue(const QString& s) override;
|
||||
virtual QString ConvertValueToString(const QVariant& v) override;
|
||||
signals:
|
||||
void Toggled(bool);
|
||||
private slots:
|
||||
void UpdateFromWidget(bool b);
|
||||
};
|
||||
|
||||
#endif // BOOLFIELD_H
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
DoubleField::DoubleField(EffectRow* parent, const QString& id) :
|
||||
EffectField(parent, id, EFFECT_FIELD_DOUBLE),
|
||||
min_(DBL_MIN),
|
||||
max_(DBL_MAX),
|
||||
min_(qSNaN()),
|
||||
max_(qSNaN()),
|
||||
default_(0),
|
||||
display_type_(LabelSlider::LABELSLIDER_NORMAL),
|
||||
frame_rate_(30),
|
||||
value_set_(false)
|
||||
{
|
||||
connect(this, SIGNAL(Changed()), this, SLOT(ValueHasBeenSet()), Qt::DirectConnection);
|
||||
@@ -54,12 +57,33 @@ QString DoubleField::ConvertValueToString(const QVariant &v)
|
||||
return QString::number(v.toDouble());
|
||||
}
|
||||
|
||||
//QWidget *DoubleField::CreateWidget()
|
||||
//{
|
||||
QWidget *DoubleField::CreateWidget()
|
||||
{
|
||||
LabelSlider* ls = new LabelSlider();
|
||||
|
||||
//}
|
||||
if (!qIsNaN(min_)) {
|
||||
ls->set_minimum_value(min_);
|
||||
}
|
||||
ls->set_default_value(default_);
|
||||
if (!qIsNaN(max_)) {
|
||||
ls->set_maximum_value(max_);
|
||||
}
|
||||
ls->set_display_type(display_type_);
|
||||
ls->set_frame_rate(frame_rate_);
|
||||
|
||||
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)));
|
||||
|
||||
return ls;
|
||||
}
|
||||
|
||||
void DoubleField::ValueHasBeenSet()
|
||||
{
|
||||
value_set_ = true;
|
||||
}
|
||||
|
||||
void DoubleField::UpdateFromWidget(double d)
|
||||
{
|
||||
SetValueAt(Now(), d);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
virtual QVariant ConvertStringToValue(const QString& s);
|
||||
virtual QString ConvertValueToString(const QVariant& v);
|
||||
|
||||
//virtual QWidget* CreateWidget() override;
|
||||
virtual QWidget* CreateWidget() override;
|
||||
private:
|
||||
double min_;
|
||||
double max_;
|
||||
@@ -47,6 +47,7 @@ private:
|
||||
bool value_set_;
|
||||
private slots:
|
||||
void ValueHasBeenSet();
|
||||
void UpdateFromWidget(double d);
|
||||
};
|
||||
|
||||
#endif // DOUBLEFIELD_H
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "effectfield.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QtMath>
|
||||
|
||||
#include "ui/labelslider.h"
|
||||
#include "ui/colorbutton.h"
|
||||
#include "ui/texteditex.h"
|
||||
@@ -28,6 +31,8 @@
|
||||
#include "ui/fontcombobox.h"
|
||||
#include "ui/embeddedfilechooser.h"
|
||||
|
||||
#include "rendering/renderfunctions.h"
|
||||
|
||||
#include "io/config.h"
|
||||
|
||||
#include "project/effectrow.h"
|
||||
@@ -39,9 +44,6 @@
|
||||
|
||||
#include "io/math.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QtMath>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
EffectField::EffectField(EffectRow* parent, const QString &i, EffectFieldType t) :
|
||||
@@ -54,74 +56,14 @@ EffectField::EffectField(EffectRow* parent, const QString &i, EffectFieldType t)
|
||||
Q_ASSERT(parent != nullptr);
|
||||
Q_ASSERT(!i.isEmpty() || t == EFFECT_FIELD_UI);
|
||||
|
||||
// Add this field to the parent row specified
|
||||
parent->AddField(this);
|
||||
/*
|
||||
switch (t) {
|
||||
case EFFECT_FIELD_DOUBLE:
|
||||
{
|
||||
LabelSlider* ls = new LabelSlider();
|
||||
ui_element = ls;
|
||||
connect(ls, SIGNAL(valueChanged()), this, SLOT(ui_element_change()));
|
||||
connect(ls, SIGNAL(clicked()), this, SIGNAL(clicked()));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_COLOR:
|
||||
{
|
||||
ColorButton* cb = new ColorButton();
|
||||
ui_element = cb;
|
||||
connect(cb, SIGNAL(color_changed()), this, SLOT(ui_element_change()));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_STRING:
|
||||
{
|
||||
TextEditEx* edit = new TextEditEx();
|
||||
|
||||
// TODO magic number 2 - It seems to just be +1 for the top and +1 for the bottom, which is sort of sensible but
|
||||
// feels a little tacky?
|
||||
edit->setFixedHeight(qCeil(edit->fontMetrics().lineSpacing()*olive::CurrentConfig.effect_textbox_lines
|
||||
+ edit->document()->documentMargin()
|
||||
+ edit->document()->documentMargin()
|
||||
+ 2));
|
||||
|
||||
edit->setUndoRedoEnabled(true);
|
||||
ui_element = edit;
|
||||
connect(edit, SIGNAL(textChanged()), this, SLOT(ui_element_change()));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_BOOL:
|
||||
{
|
||||
CheckboxEx* cb = new CheckboxEx();
|
||||
ui_element = cb;
|
||||
connect(cb, SIGNAL(clicked(bool)), this, SLOT(ui_element_change()));
|
||||
connect(cb, SIGNAL(toggled(bool)), this, SIGNAL(toggled(bool)));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_COMBO:
|
||||
{
|
||||
ComboBoxEx* cb = new ComboBoxEx();
|
||||
ui_element = cb;
|
||||
connect(cb, SIGNAL(activated(int)), this, SLOT(ui_element_change()));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_FONT:
|
||||
{
|
||||
FontCombobox* fcb = new FontCombobox();
|
||||
ui_element = fcb;
|
||||
connect(fcb, SIGNAL(activated(int)), this, SLOT(ui_element_change()));
|
||||
}
|
||||
break;
|
||||
case EFFECT_FIELD_FILE:
|
||||
{
|
||||
EmbeddedFileChooser* efc = new EmbeddedFileChooser();
|
||||
ui_element = efc;
|
||||
connect(efc, SIGNAL(changed()), this, SLOT(ui_element_change()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
// Set a very base default value
|
||||
SetValueAt(0, 0);
|
||||
|
||||
// Connect this field to the effect's changed function
|
||||
connect(this, SIGNAL(Changed()), parent->GetParentEffect(), SLOT(FieldChanged()));
|
||||
}
|
||||
|
||||
EffectField::~EffectField() {}
|
||||
@@ -223,6 +165,8 @@ QVariant EffectField::GetValueAt(double timecode)
|
||||
case EFFECT_FIELD_FONT:
|
||||
case EFFECT_FIELD_FILE:
|
||||
return before_data;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,6 +191,12 @@ void EffectField::SetValueAt(double timecode, const QVariant &value)
|
||||
emit Changed();
|
||||
}
|
||||
|
||||
double EffectField::Now()
|
||||
{
|
||||
Clip* c = GetParentRow()->GetParentEffect()->parent_clip;
|
||||
return playhead_to_clip_seconds(c, c->sequence->playhead);
|
||||
}
|
||||
|
||||
const EffectField::EffectFieldType &EffectField::type()
|
||||
{
|
||||
return type_;
|
||||
@@ -351,6 +301,7 @@ bool EffectField::HasKeyframes() {
|
||||
return (GetParentRow()->IsKeyframing() && keyframes.size() > 1);
|
||||
}
|
||||
|
||||
/*
|
||||
void EffectField::ui_element_change() {
|
||||
// TODO address this
|
||||
//bool dragging_double = (type_ == EFFECT_FIELD_DOUBLE && static_cast<LabelSlider*>(ui_element)->is_dragging());
|
||||
@@ -361,6 +312,7 @@ void EffectField::ui_element_change() {
|
||||
if (!dragging_double) olive::UndoStack.push(ca);
|
||||
emit Changed();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void EffectField::make_key_from_change(ComboAction* ca) {
|
||||
|
||||
@@ -55,6 +55,8 @@ public:
|
||||
QVariant GetValueAt(double timecode);
|
||||
void SetValueAt(double timecode, const QVariant& value);
|
||||
|
||||
double Now();
|
||||
|
||||
int GetColumnSpan();
|
||||
void SetColumnSpan(int i);
|
||||
|
||||
@@ -69,8 +71,6 @@ public:
|
||||
void SetEnabled(bool e);
|
||||
QVector<EffectKeyframe> keyframes;
|
||||
|
||||
public slots:
|
||||
void ui_element_change();
|
||||
private:
|
||||
EffectFieldType type_;
|
||||
QString id_;
|
||||
|
||||
+4
-4
@@ -77,8 +77,8 @@ Footage* Media::to_footage() {
|
||||
return static_cast<Footage*>(object.get());
|
||||
}
|
||||
|
||||
Sequence* Media::to_sequence() {
|
||||
return static_cast<Sequence*>(object.get());
|
||||
SequencePtr Media::to_sequence() {
|
||||
return std::static_pointer_cast<Sequence>(object);
|
||||
}
|
||||
|
||||
void Media::set_footage(FootagePtr f) {
|
||||
@@ -192,7 +192,7 @@ void Media::update_tooltip(const QString& error) {
|
||||
break;
|
||||
case MEDIA_TYPE_SEQUENCE:
|
||||
{
|
||||
Sequence* s = to_sequence();
|
||||
Sequence* s = to_sequence().get();
|
||||
|
||||
tooltip = QCoreApplication::translate("Media", "Name: %1"
|
||||
"\nVideo Dimensions: %2x%3"
|
||||
@@ -311,7 +311,7 @@ QVariant Media::data(int column, int role) {
|
||||
case 1:
|
||||
if (root) return QCoreApplication::translate("Media", "Duration");
|
||||
if (get_type() == MEDIA_TYPE_SEQUENCE) {
|
||||
Sequence* s = to_sequence();
|
||||
Sequence* s = to_sequence().get();
|
||||
return frame_to_timecode(s->getEndFrame(), olive::CurrentConfig.timecode_view, s->frame_rate);
|
||||
}
|
||||
if (get_type() == MEDIA_TYPE_FOOTAGE) {
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public:
|
||||
Media(Media* iparent);
|
||||
~Media();
|
||||
Footage *to_footage();
|
||||
Sequence *to_sequence();
|
||||
SequencePtr to_sequence();
|
||||
void set_icon(const QString& str);
|
||||
void set_icon(const QIcon &ico);
|
||||
void set_footage(FootagePtr f);
|
||||
|
||||
@@ -192,4 +192,4 @@ void Sequence::getTrackLimits(int* video_tracks, int* audio_tracks) {
|
||||
}
|
||||
|
||||
// static variable for the currently active sequence
|
||||
Sequence* olive::ActiveSequence = nullptr;
|
||||
SequencePtr olive::ActiveSequence = nullptr;
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ using SequencePtr = std::shared_ptr<Sequence>;
|
||||
|
||||
// static variable for the currently active sequence
|
||||
namespace olive {
|
||||
extern Sequence* ActiveSequence;
|
||||
extern SequencePtr ActiveSequence;
|
||||
}
|
||||
|
||||
#endif // SEQUENCE_H
|
||||
|
||||
@@ -424,7 +424,7 @@ void SourcesCommon::clear_proxies_from_selected() {
|
||||
|
||||
if (olive::ActiveSequence != nullptr) {
|
||||
// close all clips so we can delete any proxies requested to be deleted
|
||||
close_active_clips(olive::ActiveSequence);
|
||||
close_active_clips(olive::ActiveSequence.get());
|
||||
}
|
||||
|
||||
// delete proxies requested to be deleted
|
||||
|
||||
+7
-7
@@ -140,7 +140,7 @@ void DeleteClipAction::doRedo() {
|
||||
}
|
||||
}
|
||||
|
||||
ChangeSequenceAction::ChangeSequenceAction(Sequence *s) {
|
||||
ChangeSequenceAction::ChangeSequenceAction(SequencePtr s) {
|
||||
new_sequence = s;
|
||||
}
|
||||
|
||||
@@ -514,7 +514,7 @@ void ReplaceMediaCommand::replace(QString& filename) {
|
||||
// close any clips currently using this media
|
||||
QVector<Media*> all_sequences = panel_project->list_all_project_sequences();
|
||||
for (int i=0;i<all_sequences.size();i++) {
|
||||
Sequence* s = all_sequences.at(i)->to_sequence();
|
||||
Sequence* s = all_sequences.at(i)->to_sequence().get();
|
||||
for (int j=0;j<s->clips.size();j++) {
|
||||
ClipPtr c = s->clips.at(j);
|
||||
if (c != nullptr && c->media() == item && c->IsOpen()) {
|
||||
@@ -879,7 +879,7 @@ void SetSelectionsCommand::doRedo() {
|
||||
}
|
||||
}
|
||||
|
||||
EditSequenceCommand::EditSequenceCommand(Media* i, Sequence *s) {
|
||||
EditSequenceCommand::EditSequenceCommand(Media* i, SequencePtr s) {
|
||||
item = i;
|
||||
seq = s;
|
||||
old_name = s->name;
|
||||
@@ -959,7 +959,7 @@ void CloseAllClipsCommand::doUndo() {
|
||||
}
|
||||
|
||||
void CloseAllClipsCommand::doRedo() {
|
||||
close_active_clips(olive::ActiveSequence);
|
||||
close_active_clips(olive::ActiveSequence.get());
|
||||
}
|
||||
|
||||
UpdateFootageTooltip::UpdateFootageTooltip(Media *i) {
|
||||
@@ -1156,9 +1156,9 @@ void RefreshClips::doRedo() {
|
||||
// close any clips currently using this media
|
||||
QVector<Media*> all_sequences = panel_project->list_all_project_sequences();
|
||||
for (int i=0;i<all_sequences.size();i++) {
|
||||
Sequence* s = all_sequences.at(i)->to_sequence();
|
||||
Sequence* s = all_sequences.at(i)->to_sequence().get();
|
||||
for (int j=0;j<s->clips.size();j++) {
|
||||
ClipPtr c = s->clips.at(j);
|
||||
Clip* c = s->clips.at(j).get();
|
||||
if (c != nullptr && c->media() == media) {
|
||||
c->replaced = true;
|
||||
c->refresh();
|
||||
@@ -1175,7 +1175,7 @@ void UpdateViewer::doRedo() {
|
||||
panel_sequence_viewer->viewer_widget->frame_update();
|
||||
}
|
||||
|
||||
SetEffectData::SetEffectData(EffectPtr e, const QByteArray &s) {
|
||||
SetEffectData::SetEffectData(Effect *e, const QByteArray &s) {
|
||||
effect = e;
|
||||
data = s;
|
||||
}
|
||||
|
||||
+7
-7
@@ -115,12 +115,12 @@ private:
|
||||
|
||||
class ChangeSequenceAction : public OliveAction {
|
||||
public:
|
||||
ChangeSequenceAction(Sequence* s);
|
||||
ChangeSequenceAction(SequencePtr s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
Sequence* old_sequence;
|
||||
Sequence* new_sequence;
|
||||
SequencePtr old_sequence;
|
||||
SequencePtr new_sequence;
|
||||
};
|
||||
|
||||
class AddEffectCommand : public OliveAction {
|
||||
@@ -455,7 +455,7 @@ private:
|
||||
|
||||
class EditSequenceCommand : public OliveAction {
|
||||
public:
|
||||
EditSequenceCommand(Media *i, Sequence* s);
|
||||
EditSequenceCommand(Media *i, SequencePtr s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
void update();
|
||||
@@ -468,7 +468,7 @@ public:
|
||||
int audio_layout;
|
||||
private:
|
||||
Media* item;
|
||||
Sequence* seq;
|
||||
SequencePtr seq;
|
||||
|
||||
QString old_name;
|
||||
int old_width;
|
||||
@@ -626,11 +626,11 @@ public:
|
||||
|
||||
class SetEffectData : public OliveAction {
|
||||
public:
|
||||
SetEffectData(EffectPtr e, const QByteArray &s);
|
||||
SetEffectData(Effect* e, const QByteArray &s);
|
||||
virtual void doUndo() override;
|
||||
virtual void doRedo() override;
|
||||
private:
|
||||
EffectPtr effect;
|
||||
Effect* effect;
|
||||
QByteArray data;
|
||||
QByteArray old_data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user