Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Initial reimplementation of geometry parameter

parent 94d991dd
......@@ -18,6 +18,7 @@ set(kdenlive_SRCS
# assets/view/widgets/keyframeedit.cpp
assets/view/widgets/keyframewidget.cpp
assets/view/widgets/listparamwidget.cpp
# assets/view/widgets/positioneditwidget.cpp
assets/view/widgets/geometryeditwidget.cpp
#assets/view/widgets/positioneditwidget.cpp
PARENT_SCOPE)
......@@ -23,6 +23,7 @@
#include "boolparamwidget.hpp"
#include "doubleparamwidget.hpp"
#include "keyframeedit.h"
#include "geometryeditwidget.hpp"
#include "keyframewidget.hpp"
#include "listparamwidget.h"
#include "positioneditwidget.hpp"
......@@ -83,6 +84,8 @@ AbstractParamWidget *AbstractParamWidget::construct(const std::shared_ptr<AssetP
widget = new KeyframeWidget(model, index, parent);
break;
case ParamType::Geometry:
widget = new GeometryEditWidget(model, index, range, parent);
break;
case ParamType::Animated:
case ParamType::RestrictedAnim:
case ParamType::AnimatedRect:
......
/***************************************************************************
* Copyright (C) 2017 by Jean-Baptiste Mardelle *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* 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 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* 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 "geometryeditwidget.hpp"
#include "kdenlivesettings.h"
#include "timecodedisplay.h"
#include "core.h"
#include "monitor/monitor.h"
#include "widgets/geometrywidget.h"
#include "monitor/monitormanager.h"
#include "assets/model/assetparametermodel.hpp"
#include <QHBoxLayout>
#include <QLabel>
#include <QSlider>
GeometryEditWidget::GeometryEditWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QPair<int, int> range, QWidget *parent)
: AbstractParamWidget(std::move(model), index, parent)
, m_min(range.first)
, m_max(range.second)
, m_active(false)
{
auto *layout = new QVBoxLayout(this);
QString comment = m_model->data(m_index, AssetParameterModel::CommentRole).toString();
const QString value = m_model->data(m_index, AssetParameterModel::ValueRole).toString();
m_geom = new GeometryWidget(QRect(100, 100, 500, 500), false, this);
m_geom->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred));
/*QString name = m_model->data(m_index, AssetParameterModel::NameRole).toString();
QLabel *label = new QLabel(name, this);
layout->addWidget(label);*/
layout->addWidget(m_geom);
m_monitor = pCore->getMonitor(m_model->monitorId);
connect(m_monitor, &Monitor::seekPosition, this, &GeometryEditWidget::monitorSeek, Qt::UniqueConnection);
// emit the signal of the base class when appropriate
connect(this->m_geom, &GeometryWidget::valueChanged, [this](const QString val) {
emit AbstractParamWidget::valueChanged(m_index, val, true); });
setToolTip(comment);
}
GeometryEditWidget::~GeometryEditWidget()
{
}
void GeometryEditWidget::slotSetRange(QPair <int, int> range)
{
m_min = range.first;
m_max = range.second;
}
void GeometryEditWidget::slotRefresh()
{
/* int min = m_model->data(m_index, AssetParameterModel::ParentInRole).toInt();
int max = min + m_model->data(m_index, AssetParameterModel::ParentDurationRole).toInt();
int val = m_model->data(m_index, AssetParameterModel::ValueRole).toInt();
m_slider->blockSignals(true);
slotSetRange(QPair<int, int>(min, max));
m_slider->setValue(val);
m_display->setValue(val);
m_slider->blockSignals(false);*/
}
void GeometryEditWidget::slotShowComment(bool show)
{
Q_UNUSED(show);
}
void GeometryEditWidget::monitorSeek(int pos)
{
// Update monitor scene for geometry params
if (pos >= m_min && pos < m_max) {
connectMonitor(true);
m_monitor->slotShowEffectScene(MonitorSceneGeometry);
m_monitor->setEffectKeyframe(true);
} else {
connectMonitor(false);
m_monitor->slotShowEffectScene(MonitorSceneDefault);
}
}
void GeometryEditWidget::connectMonitor(bool activate)
{
if (m_active == activate) {
return;
}
m_active = activate;
if (activate) {
connect(m_monitor, &Monitor::effectChanged, m_geom, &GeometryWidget::slotUpdateGeometryRect, Qt::UniqueConnection);
/*double ratio = (double)m_spinWidth->value() / m_spinHeight->value();
if (m_frameSize.width() != m_monitorSize.width() || m_frameSize.height() != m_monitorSize.height()) {
// Source frame size different than project frame size, enable original size option accordingly
bool isOriginalSize =
qAbs((double)m_frameSize.width() / m_frameSize.height() - ratio) < qAbs((double)m_monitorSize.width() / m_monitorSize.height() - ratio);
if (isOriginalSize) {
m_originalSize->blockSignals(true);
m_originalSize->setChecked(true);
m_originalSize->blockSignals(false);
}
}*/
} else {
disconnect(m_monitor, &Monitor::effectChanged, m_geom, &GeometryWidget::slotUpdateGeometryRect);
}
}
/***************************************************************************
* Copyright (C) 2017 by Jean-Baptiste Mardelle *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* 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 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* 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 GEOMEDITWIDGET_H
#define GEOMEDITWIDGET_H
#include "timecode.h"
#include <QString>
#include <QWidget>
#include "abstractparamwidget.hpp"
class QSlider;
class GeometryWidget;
class Monitor;
/*@brief This class is used to display a parameter with time value */
class GeometryEditWidget : public AbstractParamWidget
{
Q_OBJECT
public:
/** @brief Sets up the parameter's GUI.*/
explicit GeometryEditWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QPair<int, int> range, QWidget *parent = nullptr);
~GeometryEditWidget();
public slots:
/** @brief Toggle the comments on or off
*/
void slotShowComment(bool show) override;
/** @brief refresh the properties to reflect changes in the model
*/
void slotRefresh() override;
/** @brief update the clip's in/out point
*/
void slotSetRange(QPair<int, int>) override;
private:
GeometryWidget *m_geom;
int m_min;
int m_max;
bool m_active;
Monitor *m_monitor;
void connectMonitor(bool activate);
private slots:
/** @brief monitor seek pos changed. */
void monitorSeek(int pos);
signals:
void valueChanged();
};
#endif
......@@ -6,5 +6,6 @@ set(kdenlive_SRCS
widgets/dragvalue.cpp
widgets/positionwidget.cpp
widgets/progressbutton.cpp
widgets/geometrywidget.cpp
PARENT_SCOPE
)
This diff is collapsed.
/***************************************************************************
* Copyright (C) 2017 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
* This file is part of Kdenlive (www.kdenlive.org). *
* *
* Kdenlive 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 2 of the License, or *
* (at your option) any later version. *
* *
* Kdenlive 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 Kdenlive. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef GEOMETRYWIDGET2_H
#define GEOMETRYWIDGET2_H
#include <QDoubleSpinBox>
#include <QLayout>
#include <QSpinBox>
#include <QWidget>
#include <kselectaction.h>
class QAction;
class QMenu;
class KSelectAction;
class DragValue;
/**
* @brief A widget for modifying numbers by dragging, using the mouse wheel or entering them with the keyboard.
*/
class GeometryWidget : public QWidget
{
Q_OBJECT
public:
/**
* @brief Default constructor.
* @param label The label that will be displayed in the progress bar
* @param defaultValue The default value
* @param decimals The number of decimals for the parameter. 0 means it is an integer
* @param min The minimum value
* @param max The maximum value
* @param id Used to identify this widget. If this parameter is set, "Show in Timeline" will be available in context menu.
* @param suffix The suffix that will be displayed in the spinbox (for example '%')
* @param showSlider If disabled, user can still drag on the label but no progress bar is shown
*/
explicit GeometryWidget(const QRect &rect, bool useRatioLock, QWidget *parent = nullptr);
private:
DragValue *m_spinX;
DragValue *m_spinY;
DragValue *m_spinWidth;
DragValue *m_spinHeight;
DragValue *m_spinSize;
QSize m_defaultSize;
QAction *m_originalSize;
QAction *m_lockRatio;
const QString getValue() const;
public slots:
void slotUpdateGeometryRect(const QRect r);
private slots:
void slotAdjustRectKeyframeValue();
void slotAdjustToSource();
void slotAdjustToFrameSize();
void slotFitToWidth();
void slotFitToHeight();
void slotResize(double value);
/** @brief Moves the rect to the left frame border (x position = 0). */
void slotMoveLeft();
/** @brief Centers the rect horizontally. */
void slotCenterH();
/** @brief Moves the rect to the right frame border (x position = frame width - rect width). */
void slotMoveRight();
/** @brief Moves the rect to the top frame border (y position = 0). */
void slotMoveTop();
/** @brief Centers the rect vertically. */
void slotCenterV();
/** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
void slotMoveBottom();
/** @brief Un/Lock aspect ratio for size in effect parameter. */
void slotLockRatio();
void slotAdjustRectHeight();
void slotAdjustRectWidth();
signals:
void valueChanged(const QString val);
};
#endif
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