Various small fixes for monitor scene and keyframe effects UI

parent 8be2febd
......@@ -443,12 +443,6 @@ QVariant AssetParameterModel::parseAttribute(const ObjectId owner, const QString
if (attribute == QLatin1String("default")) {
if (type == ParamType::RestrictedAnim) {
content = getDefaultKeyframes(0, content, true);
} else {
if (element.hasAttribute(QStringLiteral("factor"))) {
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
return QVariant(locale.toDouble(content) / locale.toDouble(element.attribute(QStringLiteral("factor"))));
}
}
}
return content;
......
......@@ -70,7 +70,7 @@ 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) {
if (type == ParamType::KeyframeParam || type == ParamType::AnimatedRect || type == ParamType::Roto_spline || paramTag == QLatin1String("frei0r.c0rners")) {
m_mainKeyframeWidget = static_cast<KeyframeWidget *>(w);
}
connect(w, &AbstractParamWidget::valueChanged, this, &AssetParameterView::commitChanges);
......@@ -187,10 +187,7 @@ int AssetParameterView::contentHeight() const
MonitorSceneType AssetParameterView::needsMonitorEffectScene() const
{
if (m_mainKeyframeWidget) {
if (m_model->getAssetId() == QLatin1String("frei0r.c0rners")) {
return MonitorSceneCorners;
}
return MonitorSceneGeometry;
return m_mainKeyframeWidget->requiredScene();
}
for (int i = 0; i < m_model->rowCount(); ++i) {
QModelIndex index = m_model->index(i, 0);
......@@ -199,9 +196,6 @@ MonitorSceneType AssetParameterView::needsMonitorEffectScene() const
return MonitorSceneGeometry;
}
}
if (m_model->getAssetId() == QLatin1String("rotoscoping")) {
return MonitorSceneRoto;
}
return MonitorSceneDefault;
}
......
......@@ -38,6 +38,7 @@
KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent)
: AbstractParamWidget(model, index, parent)
, m_keyframes(model->getKeyframeModel())
, m_neededScene(MonitorSceneDefault)
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
......@@ -259,6 +260,7 @@ void KeyframeWidget::addParameter(const QPersistentModelIndex &index)
// Construct object
QWidget *paramWidget = nullptr;
if (type == ParamType::AnimatedRect) {
m_neededScene = MonitorSceneGeometry;
int inPos = m_model->data(index, AssetParameterModel::ParentInRole).toInt();
QPair<int, int> range(inPos, inPos + m_model->data(index, AssetParameterModel::ParentDurationRole).toInt());
QSize frameSize = pCore->getCurrentFrameSize();
......@@ -278,7 +280,11 @@ void KeyframeWidget::addParameter(const QPersistentModelIndex &index)
connect(roto, &RotoWidget::updateRotoKeyframe, this, &KeyframeWidget::slotUpdateRotoMonitor, Qt::UniqueConnection);
paramWidget = roto;
paramWidget->setMaximumHeight(1);
m_neededScene = MonitorSceneRoto;
} else {
if (m_neededScene == MonitorSceneDefault && m_model->getAssetId() == QLatin1String("frei0r.c0rners")) {
m_neededScene = MonitorSceneCorners;
}
double value = m_keyframes->getInterpolatedValue(getPosition(), index).toDouble();
double min = locale.toDouble(m_model->data(index, AssetParameterModel::MinRole).toString());
double max = locale.toDouble(m_model->data(index, AssetParameterModel::MaxRole).toString());
......@@ -340,3 +346,9 @@ void KeyframeWidget::slotUpdateRotoMonitor(QPersistentModelIndex index, const QV
m_keyframes->updateKeyframe(GenTime(getPosition(), pCore->getCurrentFps()), res, index);
}
}
MonitorSceneType KeyframeWidget::requiredScene() const
{
qDebug()<<"// // // RESULTING REQUIRED SCENE: "<<m_neededScene;
return m_neededScene;
}
......@@ -48,7 +48,9 @@ public:
void addParameter(const QPersistentModelIndex &index);
int getPosition() const;
void addKeyframe(int pos = -1);
/** @brief Returns the monitor scene required for this asset
*/
MonitorSceneType requiredScene() const;
void updateTimecodeFormat();
public slots:
......@@ -78,6 +80,7 @@ private:
QToolButton *m_buttonNext;
KSelectAction *m_selectType;
TimecodeDisplay *m_time;
MonitorSceneType m_neededScene;
void connectMonitor(bool active);
std::unordered_map<QPersistentModelIndex, QWidget *> m_parameters;
};
......
......@@ -195,7 +195,6 @@ CollapsibleEffectView::CollapsibleEffectView(std::shared_ptr<EffectItemModel> ef
CollapsibleEffectView::~CollapsibleEffectView()
{
qDebug() << "deleting collapsibleeffectview";
// delete m_view;
delete m_menu;
}
......
......@@ -159,7 +159,7 @@ void EffectStackView::setModel(std::shared_ptr<EffectStackModel> model, const QS
{
qDebug() << "MUTEX LOCK!!!!!!!!!!!! setmodel";
m_mutex.lock();
unsetModel();
unsetModel(false);
m_model = model;
m_sourceFrameSize = frameSize;
m_effectsTree->setModel(m_model.get());
......@@ -188,8 +188,6 @@ void EffectStackView::loadEffects()
return;
}
int active = qBound(0, m_model->getActiveEffect(), max - 1);
std::shared_ptr<AbstractEffectItem> activeItem = m_model->getEffectStackRow(active);
std::shared_ptr<EffectItemModel> activeModel = std::static_pointer_cast<EffectItemModel>(activeItem);
for (int i = 0; i < max; i++) {
std::shared_ptr<AbstractEffectItem> item = m_model->getEffectStackRow(i);
QSize size;
......@@ -199,34 +197,31 @@ void EffectStackView::loadEffects()
}
std::shared_ptr<EffectItemModel> effectModel = std::static_pointer_cast<EffectItemModel>(item);
CollapsibleEffectView *view = nullptr;
if (i >= 0 && i <= max) {
// We need to rebuild the effect view
QImage effectIcon = m_thumbnailer->requestImage(effectModel->getAssetId(), &size, QSize(QStyle::PM_SmallIconSize, QStyle::PM_SmallIconSize));
view = new CollapsibleEffectView(effectModel, m_sourceFrameSize, effectIcon, this);
connect(view, &CollapsibleEffectView::deleteEffect, m_model.get(), &EffectStackModel::removeEffect);
connect(view, &CollapsibleEffectView::moveEffect, m_model.get(), &EffectStackModel::moveEffect);
connect(view, &CollapsibleEffectView::switchHeight, this, &EffectStackView::slotAdjustDelegate, Qt::DirectConnection);
connect(view, &CollapsibleEffectView::startDrag, this, &EffectStackView::slotStartDrag);
connect(view, &CollapsibleEffectView::createGroup, m_model.get(), &EffectStackModel::slotCreateGroup);
connect(view, &CollapsibleEffectView::activateEffect, this, &EffectStackView::slotActivateEffect);
connect(view, &CollapsibleEffectView::seekToPos, [this](int pos) {
// at this point, the effects returns a pos relative to the clip. We need to convert it to a global time
int clipIn = pCore->getItemPosition(m_model->getOwnerId());
emit seekToPos(pos + clipIn);
});
connect(this, &EffectStackView::doActivateEffect, view, &CollapsibleEffectView::slotActivateEffect);
QModelIndex ix = m_model->getIndexFromItem(effectModel);
m_effectsTree->setIndexWidget(ix, view);
WidgetDelegate *del = static_cast<WidgetDelegate *>(m_effectsTree->itemDelegate(ix));
del->setHeight(ix, view->height());
} else {
QModelIndex ix = m_model->getIndexFromItem(effectModel);
auto w = m_effectsTree->indexWidget(ix);
view = static_cast<CollapsibleEffectView *>(w);
}
view->slotActivateEffect(m_model->getIndexFromItem(activeModel));
// We need to rebuild the effect view
QImage effectIcon = m_thumbnailer->requestImage(effectModel->getAssetId(), &size, QSize(QStyle::PM_SmallIconSize, QStyle::PM_SmallIconSize));
view = new CollapsibleEffectView(effectModel, m_sourceFrameSize, effectIcon, this);
connect(view, &CollapsibleEffectView::deleteEffect, m_model.get(), &EffectStackModel::removeEffect);
connect(view, &CollapsibleEffectView::moveEffect, m_model.get(), &EffectStackModel::moveEffect);
connect(view, &CollapsibleEffectView::switchHeight, this, &EffectStackView::slotAdjustDelegate, Qt::DirectConnection);
connect(view, &CollapsibleEffectView::startDrag, this, &EffectStackView::slotStartDrag);
connect(view, &CollapsibleEffectView::createGroup, m_model.get(), &EffectStackModel::slotCreateGroup);
connect(view, &CollapsibleEffectView::activateEffect, this, &EffectStackView::slotActivateEffect);
connect(view, &CollapsibleEffectView::seekToPos, [this](int pos) {
// at this point, the effects returns a pos relative to the clip. We need to convert it to a global time
int clipIn = pCore->getItemPosition(m_model->getOwnerId());
emit seekToPos(pos + clipIn);
});
connect(this, &EffectStackView::doActivateEffect, view, &CollapsibleEffectView::slotActivateEffect);
QModelIndex ix = m_model->getIndexFromItem(effectModel);
m_effectsTree->setIndexWidget(ix, view);
WidgetDelegate *del = static_cast<WidgetDelegate *>(m_effectsTree->itemDelegate(ix));
del->setHeight(ix, view->height());
view->buttonUp->setEnabled(i > 0);
view->buttonDown->setEnabled(i < max - 1);
if (i == active) {
m_model->setActiveEffect(i);
emit doActivateEffect(ix);
}
}
updateTreeHeight();
qDebug() << "MUTEX UNLOCK!!!!!!!!!!!! loadEffects";
......@@ -248,7 +243,7 @@ void EffectStackView::updateTreeHeight()
void EffectStackView::slotActivateEffect(std::shared_ptr<EffectItemModel> effectModel)
{
qDebug() << "MUTEX LOCK!!!!!!!!!!!! slotactivateeffect";
qDebug() << "MUTEX LOCK!!!!!!!!!!!! slotactivateeffect: "<<effectModel->row();
QMutexLocker lock(&m_mutex);
m_model->setActiveEffect(effectModel->row());
QModelIndex activeIx = m_model->getIndexFromItem(effectModel);
......@@ -309,11 +304,19 @@ void EffectStackView::refresh(const QModelIndex &topLeft, const QModelIndex &bot
void EffectStackView::unsetModel(bool reset)
{
// Release ownership of smart pointer
Kdenlive::MonitorId id = Kdenlive::NoMonitor;
if (m_model) {
ObjectId item = m_model->getOwnerId();
id = item.first == ObjectType::BinClip ? Kdenlive::ClipMonitor : Kdenlive::ProjectMonitor;
disconnect(m_model.get(), &EffectStackModel::dataChanged, this, &EffectStackView::refresh);
}
if (reset) {
QMutexLocker lock(&m_mutex);
m_model.reset();
m_effectsTree->setModel(nullptr);
}
if (id != Kdenlive::NoMonitor) {
pCore->getMonitor(id)->slotShowEffectScene(MonitorSceneDefault);
}
}
......
......@@ -21,6 +21,9 @@
*/
#include <KMessageBox>
#include <KDeclarative/KDeclarative>
#include <KDeclarative/KDeclarative>
#include <kdeclarative_version.h>
#include <QApplication>
#include <QOpenGLFunctions_3_2_Core>
#include <QPainter>
......@@ -105,6 +108,15 @@ GLWidget::GLWidget(int id, QObject *parent)
, m_fbo(nullptr)
, m_rulerHeight(QFontMetrics(QApplication::font()).lineSpacing() * 0.7)
{
KDeclarative::KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(engine());
#if KDECLARATIVE_VERSION >= QT_VERSION_CHECK(5, 45, 0)
kdeclarative.setupEngine(engine());
kdeclarative.setupContext();
#else
kdeclarative.setupBindings();
#endif
m_texture[0] = m_texture[1] = m_texture[2] = 0;
qRegisterMetaType<Mlt::Frame>("Mlt::Frame");
qRegisterMetaType<SharedFrame>("SharedFrame");
......
......@@ -2,7 +2,7 @@ import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Window 2.2
import Kdenlive.Controls 1.0
import QtQuick 2.4
import QtQuick 2.6
import AudioThumb 1.0
Item {
......
import QtQuick 2.4
import QtQuick 2.6
import QtQuick.Controls 1.4
Item {
id: root
......@@ -68,19 +69,6 @@ Item {
canvas.requestPaint()
}
onDurationChanged: {
timeScale = width / duration
if (duration < 200) {
frameSize = 5 * timeScale
} else if (duration < 2500) {
frameSize = 25 * timeScale
} else if (duration < 10000) {
frameSize = 50 * timeScale
} else {
frameSize = 100 * timeScale
}
}
Item {
id: monitorOverlay
height: root.height - controller.rulerHeight
......@@ -197,14 +185,34 @@ Item {
border.color: "#ffffff00"
}
Rectangle {
anchors.centerIn: parent
width: label.contentWidth + 6
height: label.contentHeight + 6
visible: !root.isDefined && !global.containsMouse
opacity: 0.8
Text {
id: label
text: i18n('Click to add points,\nleft click to close shape.')
font.pointSize: root.baseUnit
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
anchors {
fill: parent
}
color: 'black'
}
color: "yellow"
}
MouseArea {
id: global
objectName: "global"
acceptedButtons: Qt.LeftButton | Qt.RightButton
anchors.fill: parent
property bool containsMouse
property bool pointContainsMouse
hoverEnabled: true
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
cursorShape: !root.isDefined ? Qt.PointingHandCursor : pointContainsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: {
if (!root.isDefined) {
......@@ -269,12 +277,12 @@ Item {
var p1 = canvas.convertPoint(root.centerPoints[i])
if (Math.abs(p1.x - mouseX) <= canvas.handleSize && Math.abs(p1.y - mouseY) <= canvas.handleSize) {
if (i == root.requestedKeyFrame) {
containsMouse = true;
pointContainsMouse = true;
return;
}
root.requestedKeyFrame = i
canvas.requestPaint()
containsMouse = true;
pointContainsMouse = true;
return;
}
}
......@@ -283,12 +291,12 @@ Item {
var p1 = canvas.convertPoint(root.centerPointsTypes[i])
if (Math.abs(p1.x - mouseX) <= canvas.handleSize/2 && Math.abs(p1.y - mouseY) <= canvas.handleSize/2) {
if (i == root.requestedSubKeyFrame) {
containsMouse = true;
pointContainsMouse = true;
return;
}
root.requestedSubKeyFrame = i
canvas.requestPaint()
containsMouse = true;
pointContainsMouse = true;
return;
}
}
......@@ -297,7 +305,7 @@ Item {
}
root.requestedKeyFrame = -1
root.requestedSubKeyFrame = -1
containsMouse = false;
pointContainsMouse = false;
canvas.requestPaint()
}
}
......
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