Commit 9cc83e80 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Cleanup effectstack layout. Fixes !58 #294

parent 4d8790ba
......@@ -41,7 +41,7 @@ KeyframeView::KeyframeView(std::shared_ptr<KeyframeModelList> model, int duratio
{
setMouseTracking(true);
setMinimumSize(QSize(150, 20));
setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum));
setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred));
setFont(QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont));
QPalette p = palette();
KColorScheme scheme(p.currentColorGroup(), KColorScheme::Window);
......
......@@ -55,6 +55,7 @@ void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &mo
unsetModel();
QMutexLocker lock(&m_lock);
m_model = model;
setSizePolicy(QSizePolicy::Preferred, addSpacer ? QSizePolicy::Preferred : QSizePolicy::Fixed);
const QString paramTag = model->getAssetId();
QDir dir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QStringLiteral("/effects/presets/"));
const QString presetFile = dir.absoluteFilePath(QString("%1.json").arg(paramTag));
......@@ -88,8 +89,13 @@ void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &mo
connect(w, &AbstractParamWidget::valuesChanged, this, &AssetParameterView::commitMultipleChanges);
connect(w, &AbstractParamWidget::valueChanged, this, &AssetParameterView::commitChanges);
m_lay->addWidget(w);
connect(w, &AbstractParamWidget::updateHeight, [&, w]() {
setFixedHeight(w->height() + m_lay->contentsMargins().bottom());
emit updateHeight();
});
m_widgets.push_back(w);
} else {
int minHeight = 0;
for (int i = 0; i < model->rowCount(); ++i) {
QModelIndex index = model->index(i, 0);
auto type = model->data(index, AssetParameterModel::TypeRole).value<ParamType>();
......@@ -101,15 +107,18 @@ void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &mo
} else {
auto w = AbstractParamWidget::construct(model, index, frameSize, this);
connect(this, &AssetParameterView::initKeyframeView, w, &AbstractParamWidget::slotInitMonitor);
if (type == ParamType::KeyframeParam || type == ParamType::AnimatedRect || type == ParamType::Roto_spline) {
m_mainKeyframeWidget = static_cast<KeyframeWidget *>(w);
}
connect(w, &AbstractParamWidget::valueChanged, this, &AssetParameterView::commitChanges);
connect(w, &AbstractParamWidget::seekToPos, this, &AssetParameterView::seekToPos);
m_lay->addWidget(w);
if (type == ParamType::KeyframeParam || type == ParamType::AnimatedRect || type == ParamType::Roto_spline) {
m_mainKeyframeWidget = static_cast<KeyframeWidget *>(w);
} else {
minHeight += w->minimumHeight();
}
m_widgets.push_back(w);
}
}
setMinimumHeight(m_mainKeyframeWidget ? m_mainKeyframeWidget->minimumHeight() + minHeight : minHeight);
}
if (addSpacer) {
m_lay->addStretch();
......@@ -294,6 +303,8 @@ void AssetParameterView::toggleKeyframes(bool enable)
{
if (m_mainKeyframeWidget) {
m_mainKeyframeWidget->showKeyframes(enable);
setFixedHeight(contentHeight());
emit updateHeight();
}
}
......
......@@ -109,6 +109,7 @@ signals:
void initKeyframeView(bool active);
/** @brief clear and refill the effect presets */
void updatePresets(const QString &presetName = QString());
void updateHeight();
};
#endif
......@@ -62,6 +62,7 @@ signals:
void disableCurrentFilter(bool);
void seekToPos(int);
void updateHeight();
public slots:
/** @brief Toggle the comments on or off
......
......@@ -26,7 +26,7 @@ BoolParamWidget::BoolParamWidget(std::shared_ptr<AssetParameterModel> model, QMo
: AbstractParamWidget(std::move(model), index, parent)
{
setupUi(this);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
// setup the comment
QString comment = m_model->data(m_index, AssetParameterModel::CommentRole).toString();
setToolTip(comment);
......@@ -35,6 +35,7 @@ BoolParamWidget::BoolParamWidget(std::shared_ptr<AssetParameterModel> model, QMo
// setup the name
m_labelName->setText(m_model->data(m_index, Qt::DisplayRole).toString());
setMinimumHeight(m_labelName->sizeHint().height());
// set check state
slotRefresh();
......
......@@ -76,6 +76,7 @@ ButtonParamWidget::ButtonParamWidget(std::shared_ptr<AssetParameterModel> model,
//layout->setSpacing(0);
m_button = new QPushButton(m_displayConditional ? m_buttonName : m_alternatebuttonName, this);
layout->addWidget(m_button);
setMinimumHeight(m_button->sizeHint().height());
// emit the signal of the base class when appropriate
connect(this->m_button, &QPushButton::clicked, [&, filterData, filterAddedParams]() {
......
......@@ -43,6 +43,7 @@ ClickableLabelParamWidget::ClickableLabelParamWidget(std::shared_ptr<AssetParame
m_label = new QLabel(this);
m_label->setWordWrap(true);
layout->addWidget(m_label);
setMinimumHeight(m_label->sizeHint().height());
connect(m_label, &QLabel::linkActivated, [&](const QString &result) {
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(result);
......
......@@ -127,6 +127,7 @@ ColorEditWidget::ColorEditWidget(std::shared_ptr<AssetParameterModel> model, QMo
// setup comment
setToolTip(comment);
setMinimumHeight(m_button->sizeHint().height());
}
void ColorEditWidget::slotShowComment(bool) {}
......
......@@ -90,10 +90,10 @@ ColorWheel::ColorWheel(QString id, QString name, NegQColor color, QWidget *paren
{
QFontInfo info(font());
m_unitSize = info.pixelSize();
m_initialSize = QSize(m_unitSize * 11.5, m_unitSize * 11);
m_initialSize = QSize(m_unitSize * 11, m_unitSize * 11);
m_sliderWidth = m_unitSize * 1.5;
resize(m_initialSize);
setMinimumSize(100, 100);
setMinimumSize(m_initialSize * .4);
setMaximumSize(m_initialSize);
setCursor(Qt::CrossCursor);
}
......@@ -153,11 +153,11 @@ NegQColor ColorWheel::colorForPoint(const QPointF &point)
QSize ColorWheel::sizeHint() const
{
return {width(), height()};
return m_initialSize * .8;
}
QSize ColorWheel::minimumSizeHint() const
{
return {100, 100};
return m_initialSize * .4;
}
void ColorWheel::mousePressEvent(QMouseEvent *event)
......
......@@ -48,6 +48,7 @@ DoubleParamWidget::DoubleParamWidget(std::shared_ptr<AssetParameterModel> model,
// Construct object
m_doubleWidget = new DoubleWidget(name, value, min, max, factor, defaultValue, comment, -1, suffix, decimals, this);
m_lay->addWidget(m_doubleWidget);
setMinimumHeight(m_doubleWidget->height());
// Connect signal
connect(m_doubleWidget, &DoubleWidget::valueChanged, [this, locale](double val) { emit valueChanged(m_index, locale.toString(val), true); });
......
......@@ -36,7 +36,7 @@ FontParamWidget::FontParamWidget(std::shared_ptr<AssetParameterModel> model, QMo
// set check state
slotRefresh();
setMinimumHeight(fontfamilywidget->sizeHint().height());
// emit the signal of the base class when appropriate
connect(this->fontfamilywidget, &QFontComboBox::currentFontChanged, [this](const QFont &font) { emit valueChanged(m_index, font.family(), true); });
}
......
......@@ -51,8 +51,10 @@ KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QMode
, m_monitorHelper(nullptr)
, m_neededScene(MonitorSceneType::MonitorSceneDefault)
, m_sourceFrameSize(frameSize.isValid() && !frameSize.isNull() ? frameSize : pCore->getCurrentFrameSize())
, m_baseHeight(0)
, m_addedHeight(0)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
m_lay = new QVBoxLayout(this);
m_lay->setContentsMargins(2, 2, 2, 0);
m_lay->setSpacing(0);
......@@ -170,6 +172,8 @@ KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QMode
connect(m_buttonAddDelete, &QAbstractButton::pressed, m_keyframeview, &KeyframeView::slotAddRemove);
connect(m_buttonPrevious, &QAbstractButton::pressed, m_keyframeview, &KeyframeView::slotGoToPrev);
connect(m_buttonNext, &QAbstractButton::pressed, m_keyframeview, &KeyframeView::slotGoToNext);
m_baseHeight = m_keyframeview->minimumHeight() + m_toolbar->sizeHint().height() + 2;
setFixedHeight(m_baseHeight);
addParameter(index);
connect(monitor, &Monitor::seekToNextKeyframe, m_keyframeview, &KeyframeView::slotGoToNext, Qt::UniqueConnection);
......@@ -388,6 +392,8 @@ void KeyframeWidget::addParameter(const QPersistentModelIndex &index)
if (paramWidget) {
m_parameters[index] = paramWidget;
m_lay->addWidget(paramWidget);
m_addedHeight += paramWidget->minimumHeight();
setFixedHeight(m_baseHeight + m_addedHeight);
}
}
......@@ -448,8 +454,12 @@ bool KeyframeWidget::keyframesVisible() const
void KeyframeWidget::showKeyframes(bool enable)
{
if (enable && m_toolbar->isVisible()) {
return;
}
m_toolbar->setVisible(enable);
m_keyframeview->setVisible(enable);
setFixedHeight(m_addedHeight + (enable ? m_baseHeight : 0));
}
void KeyframeWidget::slotCopyKeyframes()
......
......@@ -97,6 +97,8 @@ private:
QSize m_sourceFrameSize;
void connectMonitor(bool active);
std::unordered_map<QPersistentModelIndex, QWidget *> m_parameters;
int m_baseHeight;
int m_addedHeight;
signals:
void addIndex(QPersistentModelIndex ix);
......
......@@ -50,6 +50,7 @@ KeywordParamWidget::KeywordParamWidget(std::shared_ptr<AssetParameterModel> mode
comboboxwidget->setCurrentIndex(0);
// set check state
slotRefresh();
setMinimumHeight(comboboxwidget->sizeHint().height());
// emit the signal of the base class when appropriate
connect(lineeditwidget, &QLineEdit::editingFinished, [this]() {
......
......@@ -37,8 +37,9 @@ ListParamWidget::ListParamWidget(std::shared_ptr<AssetParameterModel> model, QMo
setToolTip(comment);
m_labelComment->setText(comment);
m_widgetComment->setHidden(true);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
m_list->setIconSize(QSize(50, 30));
setMinimumHeight(m_list->sizeHint().height());
// setup the name
m_labelName->setText(m_model->data(m_index, Qt::DisplayRole).toString());
slotRefresh();
......
......@@ -32,11 +32,8 @@ static const double GAIN_FACTOR = 4.0;
LumaLiftGainParam::LumaLiftGainParam(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent)
: AbstractParamWidget(std::move(model), index, parent)
{
auto *flowLayout = new FlowLayout(this, 2, 2, 2);
/*QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
*/
m_flowLayout = new FlowLayout(this, 2, 2, 2);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
m_locale.setNumberOptions(QLocale::OmitGroupSeparator);
m_lift = new ColorWheel(QStringLiteral("lift"), i18n("Lift"), NegQColor(), this);
m_lift->setFactorDefaultZero(LIFT_FACTOR, 0, 0.5);
......@@ -54,10 +51,10 @@ LumaLiftGainParam::LumaLiftGainParam(std::shared_ptr<AssetParameterModel> model,
indexes.insert(name, local_index);
}
flowLayout->addWidget(m_lift);
flowLayout->addWidget(m_gamma);
flowLayout->addWidget(m_gain);
setLayout(flowLayout);
m_flowLayout->addWidget(m_lift);
m_flowLayout->addWidget(m_gamma);
m_flowLayout->addWidget(m_gain);
setLayout(m_flowLayout);
slotRefresh();
connect(this, &LumaLiftGainParam::liftChanged, [this, indexes]() {
......@@ -111,11 +108,17 @@ void LumaLiftGainParam::updateEffect(QDomElement &effect)
}
}
void LumaLiftGainParam::resizeEvent(QResizeEvent *ev)
{
setFixedHeight(m_flowLayout->miniHeight());
QWidget::resizeEvent(ev);
emit updateHeight();
}
void LumaLiftGainParam::slotShowComment(bool) {}
void LumaLiftGainParam::slotRefresh()
{
qDebug() << "//REFRESHING WIDGET START--------------__";
QMap<QString, double> values;
for (int i = 0; i < m_model->rowCount(); ++i) {
QModelIndex local_index = m_model->index(i, 0);
......@@ -131,9 +134,7 @@ void LumaLiftGainParam::slotRefresh()
NegQColor gain = NegQColor::fromRgbF(values.value(QStringLiteral("gain_r")) / GAIN_FACTOR, values.value(QStringLiteral("gain_g")) / GAIN_FACTOR,
values.value(QStringLiteral("gain_b")) / GAIN_FACTOR);
qDebug() << "//REFRESHING WIDGET START 2--------------__";
m_lift->setColor(lift);
m_gamma->setColor(gamma);
m_gain->setColor(gain);
qDebug() << "//REFRESHING WIDGET START DONE--------------__";
}
......@@ -26,6 +26,7 @@
#include <QWidget>
class ColorWheel;
class FlowLayout;
/**
* @class LumaLiftGainParam
......@@ -49,6 +50,10 @@ private:
ColorWheel *m_lift;
ColorWheel *m_gamma;
ColorWheel *m_gain;
FlowLayout *m_flowLayout;
protected:
void resizeEvent(QResizeEvent *ev) override;
signals:
/** @brief Emitted whenever a different color was chosen. */
......
......@@ -44,6 +44,7 @@ PositionEditWidget::PositionEditWidget(std::shared_ptr<AssetParameterModel> mode
layout->addWidget(m_display);
m_inverted = m_model->data(m_index, AssetParameterModel::DefaultRole).toInt() < 0;
slotRefresh();
setMinimumHeight(m_display->sizeHint().height());
connect(m_slider, &QAbstractSlider::valueChanged, m_display, static_cast<void (TimecodeDisplay::*)(int)>(&TimecodeDisplay::setValue));
connect(m_display, &TimecodeDisplay::timeCodeEditingFinished, m_slider, &QAbstractSlider::setValue);
......
......@@ -36,6 +36,7 @@ SwitchParamWidget::SwitchParamWidget(std::shared_ptr<AssetParameterModel> model,
// setup the name
m_labelName->setText(m_model->data(m_index, Qt::DisplayRole).toString());
setMinimumHeight(m_labelName->sizeHint().height());
// set check state
slotRefresh();
......
......@@ -43,6 +43,7 @@ UrlParamWidget::UrlParamWidget(std::shared_ptr<AssetParameterModel> model, QMode
// setup the name
label->setText(m_model->data(m_index, Qt::DisplayRole).toString());
setMinimumHeight(urlwidget->sizeHint().height());
// set check state
slotRefresh();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment