implemented #92

This commit is contained in:
itsmattkc
2019-03-15 09:59:31 +11:00
parent 058e5b25c5
commit db22704169
27 changed files with 220 additions and 72 deletions
+2 -2
View File
@@ -95,9 +95,9 @@ QString EffectField::ConvertValueToString(const QVariant &v)
return v.toString();
}
QWidget *EffectField::CreateWidget()
QWidget *EffectField::CreateWidget(QWidget *existing)
{
return new QLabel(tr("(Invalid field)"));
return (existing == nullptr) ? new QLabel(tr("(Invalid field)")) : existing;
}
void EffectField::UpdateWidgetValue(QWidget *, double) {}
+1 -1
View File
@@ -68,7 +68,7 @@ public:
virtual QVariant ConvertStringToValue(const QString& s);
virtual QString ConvertValueToString(const QVariant& v);
virtual QWidget* CreateWidget();
virtual QWidget* CreateWidget(QWidget* existing = nullptr);
virtual void UpdateWidgetValue(QWidget* widget, double);
double GetValidKeyframeHandlePosition(int key, bool post);
+5
View File
@@ -71,6 +71,11 @@ bool EffectRow::IsSavable()
return savable_;
}
bool EffectRow::IsKeyframable()
{
return keyframable_;
}
void EffectRow::SetKeyframingEnabled(bool enabled) {
if (enabled) {
+1
View File
@@ -56,6 +56,7 @@ public:
void SetKeyframingInternal(bool);
bool IsSavable();
bool IsKeyframable();
public slots:
void GoToPreviousKeyframe();
void ToggleKeyframe();
+13 -2
View File
@@ -11,9 +11,20 @@ bool BoolField::GetBoolAt(double timecode)
return GetValueAt(timecode).toBool();
}
QWidget *BoolField::CreateWidget()
QWidget *BoolField::CreateWidget(QWidget *existing)
{
QCheckBox* cb = new QCheckBox();
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)));
+1 -1
View File
@@ -11,7 +11,7 @@ public:
bool GetBoolAt(double timecode);
virtual QWidget* CreateWidget() override;
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
virtual QVariant ConvertStringToValue(const QString& s) override;
+15 -5
View File
@@ -18,13 +18,23 @@ void ButtonField::SetChecked(bool c)
emit CheckedChanged(c);
}
QWidget *ButtonField::CreateWidget()
QWidget *ButtonField::CreateWidget(QWidget *existing)
{
QPushButton* button = new QPushButton();
QPushButton* button;
button->setCheckable(checkable_);
button->setEnabled(IsEnabled());
button->setText(button_text_);
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)));
+1 -1
View File
@@ -10,7 +10,7 @@ public:
ButtonField(EffectRow* parent, const QString& string);
void SetCheckable(bool c);
virtual QWidget* CreateWidget() override;
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
public slots:
void SetChecked(bool c);
+2 -2
View File
@@ -13,9 +13,9 @@ QColor ColorField::GetColorAt(double timecode)
return GetValueAt(timecode).value<QColor>();
}
QWidget *ColorField::CreateWidget()
QWidget *ColorField::CreateWidget(QWidget *existing)
{
ColorButton* cb = new ColorButton();
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)));
+1 -1
View File
@@ -11,7 +11,7 @@ public:
QColor GetColorAt(double timecode);
virtual QWidget* CreateWidget() override;
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
virtual QVariant ConvertStringToValue(const QString& s) override;
+11 -5
View File
@@ -18,14 +18,20 @@ void ComboField::AddItem(const QString &text, const QVariant &data)
items_.append(item);
}
QWidget *ComboField::CreateWidget()
QWidget *ComboField::CreateWidget(QWidget *existing)
{
ComboBoxEx* cb = new ComboBoxEx();
ComboBoxEx* cb;
cb->setScrollingEnabled(false);
if (existing == nullptr) {
cb = new ComboBoxEx();
for (int i=0;i<items_.size();i++) {
cb->addItem(items_.at(i).name);
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)));
+1 -1
View File
@@ -16,7 +16,7 @@ public:
void AddItem(const QString& text, const QVariant& data);
virtual QWidget *CreateWidget() override;
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
signals:
+22 -13
View File
@@ -60,22 +60,31 @@ QString DoubleField::ConvertValueToString(const QVariant &v)
return QString::number(v.toDouble());
}
QWidget *DoubleField::CreateWidget()
QWidget *DoubleField::CreateWidget(QWidget *existing)
{
LabelSlider* ls = new LabelSlider();
LabelSlider* ls;
if (!qIsNaN(min_)) {
ls->SetMinimum(min_);
}
ls->SetDefault(default_);
if (!qIsNaN(max_)) {
ls->SetMaximum(max_);
}
ls->SetDisplayType(display_type_);
ls->SetFrameRate(frame_rate_);
if (existing == nullptr) {
//qDebug() << "";
ls->setEnabled(IsEnabled());
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()));
+3 -3
View File
@@ -32,10 +32,10 @@ public:
void SetDisplayType(LabelSlider::DisplayType type);
void SetFrameRate(const double& rate);
virtual QVariant ConvertStringToValue(const QString& s);
virtual QString ConvertValueToString(const QVariant& v);
virtual QVariant ConvertStringToValue(const QString& s) override;
virtual QString ConvertValueToString(const QVariant& v) override;
virtual QWidget* CreateWidget() override;
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
private:
double min_;
+2 -2
View File
@@ -13,9 +13,9 @@ QString FileField::GetFileAt(double timecode)
return GetValueAt(timecode).toString();
}
QWidget *FileField::CreateWidget()
QWidget *FileField::CreateWidget(QWidget *existing)
{
EmbeddedFileChooser* efc = new EmbeddedFileChooser();
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)));
+1 -1
View File
@@ -11,7 +11,7 @@ public:
QString GetFileAt(double timecode);
virtual QWidget* CreateWidget() override;
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
private slots:
void UpdateFromWidget(const QString &s);
};
+13 -3
View File
@@ -20,13 +20,23 @@ QString FontField::GetFontAt(double timecode)
return GetValueAt(timecode).toString();
}
QWidget *FontField::CreateWidget()
QWidget *FontField::CreateWidget(QWidget *existing)
{
ComboBoxEx* fcb = new ComboBoxEx();
fcb->setScrollingEnabled(false);
if (existing == nullptr) {
fcb->addItems(font_list);
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)));
+1 -1
View File
@@ -10,7 +10,7 @@ public:
QString GetFontAt(double timecode);
virtual QWidget *CreateWidget() override;
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
private:
+14 -3
View File
@@ -7,11 +7,22 @@ LabelField::LabelField(EffectRow *parent, const QString &string) :
label_text_(string)
{}
QWidget *LabelField::CreateWidget()
QWidget *LabelField::CreateWidget(QWidget *existing)
{
QLabel* label = new QLabel(label_text_);
QLabel* label;
if (existing == nullptr) {
label = new QLabel(label_text_);
label->setEnabled(IsEnabled());
} else {
label = static_cast<QLabel*>(existing);
}
label->setEnabled(IsEnabled());
connect(this, SIGNAL(EnabledChanged(bool)), label, SLOT(setEnabled(bool)));
return label;
+1 -1
View File
@@ -9,7 +9,7 @@ class LabelField : public EffectField
public:
LabelField(EffectRow* parent, const QString& string);
virtual QWidget* CreateWidget() override;
virtual QWidget* CreateWidget(QWidget *existing = nullptr) override;
private:
QString label_text_;
};
+18 -8
View File
@@ -18,17 +18,27 @@ QString StringField::GetStringAt(double timecode)
return GetValueAt(timecode).toString();
}
QWidget *StringField::CreateWidget()
QWidget *StringField::CreateWidget(QWidget *existing)
{
TextEditEx* text_edit = new TextEditEx(nullptr, rich_text_);
TextEditEx* text_edit;
text_edit->setEnabled(IsEnabled());
text_edit->setUndoRedoEnabled(true);
if (existing == nullptr) {
// the "2" looks like a magic number, but it's just one pixel on the top and the bottom
text_edit->setFixedHeight(qCeil(text_edit->fontMetrics().lineSpacing()*olive::CurrentConfig.effect_textbox_lines
+ text_edit->document()->documentMargin()
+ text_edit->document()->documentMargin() + 2));
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->setFixedHeight(qCeil(text_edit->fontMetrics().lineSpacing()*olive::CurrentConfig.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)));
+1 -1
View File
@@ -11,7 +11,7 @@ public:
QString GetStringAt(double timecode);
virtual QWidget *CreateWidget() override;
virtual QWidget *CreateWidget(QWidget *existing = nullptr) override;
virtual void UpdateWidgetValue(QWidget* widget, double timecode) override;
private slots:
void UpdateFromWidget(const QString& b);
+3
View File
@@ -601,8 +601,11 @@ void EffectControls::Load() {
bool already_opened = false;
for (int k=0;k<open_effects_.size();k++) {
if (open_effects_.at(k)->GetEffect()->meta == c->effects.at(j)->meta) {
open_effects_.at(k)->AddAdditionalEffect(c->effects.at(j).get());
already_opened = true;
break;
}
}
+7 -2
View File
@@ -53,7 +53,7 @@ CollapsibleWidget::CollapsibleWidget(QWidget* parent) : QWidget(parent) {
collapse_button = new QPushButton(title_bar);
collapse_button->setIconSize(collapse_button->iconSize()*0.5);
collapse_button->setFlat(true);
SetText(tr("<untitled>"));
SetTitle(tr("<untitled>"));
title_bar_layout->addWidget(collapse_button);
title_bar_layout->addWidget(enabled_check);
title_bar_layout->addWidget(header);
@@ -108,7 +108,12 @@ void CollapsibleWidget::SetContents(QWidget* c) {
}
}
void CollapsibleWidget::SetText(const QString &s) {
QString CollapsibleWidget::Title()
{
return header->text();
}
void CollapsibleWidget::SetTitle(const QString &s) {
header->setText(s);
}
+2 -1
View File
@@ -50,7 +50,8 @@ class CollapsibleWidget : public QWidget
public:
CollapsibleWidget(QWidget* parent = nullptr);
void SetContents(QWidget* c);
void SetText(const QString &);
QString Title();
void SetTitle(const QString &);
bool IsFocused();
bool IsExpanded();
bool IsSelected();
+73 -12
View File
@@ -6,14 +6,16 @@
#include "timeline/clip.h"
#include "ui/menuhelper.h"
#include "ui/keyframenavigator.h"
#include "ui/clickablelabel.h"
#include "panels/panels.h"
EffectUI::EffectUI(Effect* e) :
effect_(e)
effect_(e),
multiple_(false)
{
Q_ASSERT(e != nullptr);
SetText(e->name);
SetTitle(e->name);
QWidget* ui = new QWidget(this);
SetContents(ui);
@@ -33,7 +35,8 @@ EffectUI::EffectUI(Effect* e) :
for (int i=0;i<e->row_count();i++) {
EffectRow* row = e->row(i);
QLabel* row_label = new QLabel(row->name());
ClickableLabel* row_label = new ClickableLabel(row->name());
connect(row_label, SIGNAL(clicked()), row, SLOT(FocusRow()));
labels_.append(row_label);
@@ -61,21 +64,32 @@ EffectUI::EffectUI(Effect* e) :
// Create keyframe controls
maximum_column++;
keyframe_navigators_.resize(e->row_count());
for (int i=0;i<e->row_count();i++) {
EffectRow* row = e->row(i);
KeyframeNavigator* nav = new KeyframeNavigator();
KeyframeNavigator* nav;
nav->enable_keyframes(row->IsKeyframing());
if (row->IsKeyframable()) {
connect(nav, SIGNAL(goto_previous_key()), row, SLOT(GoToPreviousKeyframe()));
connect(nav, SIGNAL(toggle_key()), row, SLOT(ToggleKeyframe()));
connect(nav, SIGNAL(goto_next_key()), row, SLOT(GoToNextKeyframe()));
connect(nav, SIGNAL(keyframe_enabled_changed(bool)), row, SLOT(SetKeyframingEnabled(bool)));
connect(nav, SIGNAL(clicked()), row, SLOT(FocusRow()));
connect(row, SIGNAL(KeyframingSetChanged(bool)), nav, SLOT(enable_keyframes(bool)));
nav = new KeyframeNavigator();
nav->enable_keyframes(row->IsKeyframing());
AttachKeyframeNavigationToRow(row, nav);
layout_->addWidget(nav, i, maximum_column);
} else {
nav = nullptr;
}
keyframe_navigators_[i] = nav;
layout_->addWidget(nav, i, maximum_column);
}
enabled_check->setChecked(e->IsEnabled());
@@ -85,7 +99,34 @@ EffectUI::EffectUI(Effect* e) :
void EffectUI::AddAdditionalEffect(Effect *e)
{
// Ensure this is the same kind of effect and will be fully compatible
Q_ASSERT(e->meta == effect_->meta);
// Add multiple modifer to header label
QString new_title = QString(tr("%1 (multiple)")).arg(Title());
SetTitle(new_title);
// Add effect to list
additional_effects_.append(e);
// Attach this UI's widgets to the additional effect
for (int i=0;i<effect_->row_count();i++) {
EffectRow* row = effect_->row(i);
// Attach existing keyframe navigator to this effect's row
AttachKeyframeNavigationToRow(e->row(i), keyframe_navigators_.at(i));
for (int j=0;j<row->FieldCount();j++) {
EffectField* field = row->Field(j);
// Attach existing field widget to this effect's field
e->row(i)->Field(j)->CreateWidget(Widget(i, j));
}
}
}
Effect *EffectUI::GetEffect()
@@ -94,7 +135,13 @@ Effect *EffectUI::GetEffect()
}
int EffectUI::GetRowY(int row, QWidget* mapToWidget) {
// Currently to get a Y value in the context of `mapToWidget`, we use `panel_effect_controls` as the base. Mapping
// to global doesn't work for some reason, so this is the best reference point we have.
QLabel* row_label = labels_.at(row);
// Get center point of label (label->rect()->center()->y() - instead of y()+height/2 - produces an inaccurate result)
return row_label->y()
+ row_label->height() / 2
+ mapToWidget->mapFrom(panel_effect_controls, contents->mapTo(panel_effect_controls, contents->pos())).y()
@@ -147,6 +194,20 @@ QWidget *EffectUI::Widget(int row, int field)
return widgets_.at(row).at(field);
}
void EffectUI::AttachKeyframeNavigationToRow(EffectRow *row, KeyframeNavigator *nav)
{
if (nav == nullptr) {
return;
}
connect(nav, SIGNAL(goto_previous_key()), row, SLOT(GoToPreviousKeyframe()));
connect(nav, SIGNAL(toggle_key()), row, SLOT(ToggleKeyframe()));
connect(nav, SIGNAL(goto_next_key()), row, SLOT(GoToNextKeyframe()));
connect(nav, SIGNAL(keyframe_enabled_changed(bool)), row, SLOT(SetKeyframingEnabled(bool)));
connect(nav, SIGNAL(clicked()), row, SLOT(FocusRow()));
connect(row, SIGNAL(KeyframingSetChanged(bool)), nav, SLOT(enable_keyframes(bool)));
}
void EffectUI::show_context_menu(const QPoint& pos) {
if (effect_->meta->type == EFFECT_TYPE_EFFECT) {
QMenu menu;
+5
View File
@@ -29,6 +29,11 @@ private:
QGridLayout* layout_;
QVector<QLabel*> labels_;
QVector< QVector<QWidget*> > widgets_;
QVector<KeyframeNavigator*> keyframe_navigators_;
bool multiple_;
void AttachKeyframeNavigationToRow(EffectRow* row, KeyframeNavigator* nav);
private slots:
void show_context_menu(const QPoint&);
};