From 4ce0fd0c62d53563044362045c55042252ad1a76 Mon Sep 17 00:00:00 2001 From: Till Theato Date: Sun, 8 Aug 2010 13:36:38 +0000 Subject: [PATCH] Add move and resize controls to geometry widget svn path=/trunk/kdenlive/; revision=4686 --- src/geometrywidget.cpp | 93 +++++++++++++++++++++--- src/geometrywidget.h | 39 +++++++++- src/widgets/geometrywidget_ui.ui | 120 ++++++++++++++++++++++++++++++- 3 files changed, 241 insertions(+), 11 deletions(-) diff --git a/src/geometrywidget.cpp b/src/geometrywidget.cpp index 9e7dc29a..79bf0331 100644 --- a/src/geometrywidget.cpp +++ b/src/geometrywidget.cpp @@ -38,15 +38,38 @@ GeometryWidget::GeometryWidget(Monitor* monitor, int clipPos, QWidget* parent ): { m_ui.setupUi(this); m_scene = monitor->getEffectScene(); - connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateGeometry())); - connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateProperties())); - connect(m_monitor->render, SIGNAL(rendererPosition(int)), this, SLOT(slotCheckPosition(int))); + m_ui.buttonMoveLeft->setIcon(KIcon("kdenlive-align-left")); + m_ui.buttonMoveLeft->setToolTip(i18n("Move to left")); + m_ui.buttonCenterH->setIcon(KIcon("kdenlive-align-hor")); + m_ui.buttonCenterH->setToolTip(i18n("Center horizontally")); + m_ui.buttonMoveRight->setIcon(KIcon("kdenlive-align-right")); + m_ui.buttonMoveRight->setToolTip(i18n("Move to right")); + m_ui.buttonMoveTop->setIcon(KIcon("kdenlive-align-top")); + m_ui.buttonMoveTop->setToolTip(i18n("Move to top")); + m_ui.buttonCenterV->setIcon(KIcon("kdenlive-align-vert")); + m_ui.buttonCenterV->setToolTip(i18n("Center vertically")); + m_ui.buttonMoveBottom->setIcon(KIcon("kdenlive-align-bottom")); + m_ui.buttonMoveBottom->setToolTip(i18n("Move to bottom")); + + + connect(m_ui.spinX, SIGNAL(valueChanged(int)), this, SLOT(slotSetX(int))); + connect(m_ui.spinY, SIGNAL(valueChanged(int)), this, SLOT(slotSetY(int))); + connect(m_ui.spinWidth, SIGNAL(valueChanged(int)), this, SLOT(slotSetWidth(int))); + connect(m_ui.spinHeight, SIGNAL(valueChanged(int)), this, SLOT(slotSetHeight(int))); + + connect(m_ui.spinSize, SIGNAL(valueChanged(int)), this, SLOT(slotResize(int))); + + connect(m_ui.buttonMoveLeft, SIGNAL(clicked()), this, SLOT(slotMoveLeft())); + connect(m_ui.buttonCenterH, SIGNAL(clicked()), this, SLOT(slotCenterH())); + connect(m_ui.buttonMoveRight, SIGNAL(clicked()), this, SLOT(slotMoveRight())); + connect(m_ui.buttonMoveTop, SIGNAL(clicked()), this, SLOT(slotMoveTop())); + connect(m_ui.buttonCenterV, SIGNAL(clicked()), this, SLOT(slotCenterV())); + connect(m_ui.buttonMoveBottom, SIGNAL(clicked()), this, SLOT(slotMoveBottom())); - connect(m_ui.spinX, SIGNAL(valueChanged(int)), this, SLOT(slotSetX(int))); - connect(m_ui.spinY, SIGNAL(valueChanged(int)), this, SLOT(slotSetY(int))); - connect(m_ui.spinWidth, SIGNAL(valueChanged(int)), this, SLOT(slotSetWidth(int))); - connect(m_ui.spinHeight, SIGNAL(valueChanged(int)), this, SLOT(slotSetHeight(int))); + connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateGeometry())); + connect(m_monitor->render, SIGNAL(rendererPosition(int)), this, SLOT(slotCheckPosition(int))); + connect(this, SIGNAL(parameterChanged()), this, SLOT(slotUpdateProperties())); } GeometryWidget::~GeometryWidget() @@ -99,8 +122,9 @@ void GeometryWidget::slotCheckPosition(int renderPos) if (renderPos >= m_clipPos && renderPos <= m_clipPos + m_outPoint - m_inPoint) { if (!m_scene->views().at(0)->isVisible()) m_monitor->slotEffectScene(true); - } else + } else { m_monitor->slotEffectScene(false); + } } void GeometryWidget::slotUpdateGeometry() @@ -122,23 +146,32 @@ void GeometryWidget::slotUpdateProperties() { QRectF rectSize = m_rect->rect().normalized(); QPointF rectPos = m_rect->pos(); + int size; + if (rectSize.width() / m_monitor->render->dar() < rectSize.height()) + size = (int)(rectSize.width() * 100 / m_monitor->render->renderWidth()); + else + size = (int)(rectSize.height() * 100 / m_monitor->render->renderHeight()); m_ui.spinX->blockSignals(true); m_ui.spinY->blockSignals(true); m_ui.spinWidth->blockSignals(true); m_ui.spinHeight->blockSignals(true); + m_ui.spinSize->blockSignals(true); m_ui.spinX->setValue(rectPos.x()); m_ui.spinY->setValue(rectPos.y()); m_ui.spinWidth->setValue(rectSize.width()); m_ui.spinHeight->setValue(rectSize.height()); + m_ui.spinSize->setValue(size); m_ui.spinX->blockSignals(false); m_ui.spinY->blockSignals(false); m_ui.spinWidth->blockSignals(false); m_ui.spinHeight->blockSignals(false); + m_ui.spinSize->blockSignals(false); } + void GeometryWidget::slotSetX(int value) { m_rect->setPos(value, m_ui.spinY->value()); @@ -163,4 +196,48 @@ void GeometryWidget::slotSetHeight(int value) slotUpdateGeometry(); } + +void GeometryWidget::slotResize(int value) +{ + m_rect->setRect(0, 0, m_monitor->render->renderWidth() * value / 100, m_monitor->render->renderHeight() * value / 100); + slotUpdateGeometry(); +} + + +void GeometryWidget::slotMoveLeft() +{ + m_rect->setPos(0, m_rect->pos().y()); + slotUpdateGeometry(); +} + +void GeometryWidget::slotCenterH() +{ + m_rect->setPos((m_monitor->render->renderWidth() - m_rect->rect().width()) / 2, m_rect->pos().y()); + slotUpdateGeometry(); +} + +void GeometryWidget::slotMoveRight() +{ + m_rect->setPos(m_monitor->render->renderWidth() - m_rect->rect().width(), m_rect->pos().y()); + slotUpdateGeometry(); +} + +void GeometryWidget::slotMoveTop() +{ + m_rect->setPos(m_rect->pos().x(), 0); + slotUpdateGeometry(); +} + +void GeometryWidget::slotCenterV() +{ + m_rect->setPos(m_rect->pos().x(), (m_monitor->render->renderHeight() - m_rect->rect().height()) / 2); + slotUpdateGeometry(); +} + +void GeometryWidget::slotMoveBottom() +{ + m_rect->setPos(m_rect->pos().x(), m_monitor->render->renderHeight() - m_rect->rect().height()); + slotUpdateGeometry(); +} + #include "geometrywidget.moc" diff --git a/src/geometrywidget.h b/src/geometrywidget.h index 192c73a0..c4290ff1 100644 --- a/src/geometrywidget.h +++ b/src/geometrywidget.h @@ -35,32 +35,69 @@ class GeometryWidget : public QWidget { Q_OBJECT public: - GeometryWidget(Monitor *monitor, int clipPos = 0, QWidget* parent = 0); + /** @brief Sets up the UI and connects it. + * @param monitor Project monitor + * @param clipPos Position of the clip in timeline + * @param parent (optional) Parent widget */ + GeometryWidget(Monitor *monitor, int clipPos, QWidget* parent = 0); virtual ~GeometryWidget(); + /** @brief Gets the geometry as a serialized string. */ QString getValue() const; public slots: + /** @brief Sets up the rect and the geometry object. + * @param elem DomElement representing this effect parameter + * @param minframe In point of the clip + * @param maxframe Out point of the clip */ void setupParam(const QDomElement elem, int minframe, int maxframe); private: Ui::GeometryWidget_UI m_ui; Monitor *m_monitor; + /** Position of the clip in timeline. */ int m_clipPos; + /** In point of the clip (crop from start). */ int m_inPoint; + /** Out point of the clip (crop from end). */ int m_outPoint; MonitorScene *m_scene; QGraphicsRectItem *m_rect; Mlt::Geometry *m_geometry; private slots: + /** @brief Makes sure the monitor effect scene is only visible if the clip this geometry belongs to is visible. + * @param renderPos Postion of the Monitor / Timeline cursor */ void slotCheckPosition(int renderPos); + /** @brief Updates the Mlt::Geometry object. */ void slotUpdateGeometry(); + /** @brief Updates the spinBoxes according to the rect. */ void slotUpdateProperties(); + + /** @brief Sets the rect's x position to @param value. */ void slotSetX(int value); + /** @brief Sets the rect's y position to @param value. */ void slotSetY(int value); + /** @brief Sets the rect's width to @param value. */ void slotSetWidth(int value); + /** @brief Sets the rect's height to @param value. */ void slotSetHeight(int value); + /** @brief Resizes the rect by @param value (in perecent) compared to the frame size. */ + void slotResize(int 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(); + signals: void parameterChanged(); }; diff --git a/src/widgets/geometrywidget_ui.ui b/src/widgets/geometrywidget_ui.ui index 55daaafb..264b4d61 100644 --- a/src/widgets/geometrywidget_ui.ui +++ b/src/widgets/geometrywidget_ui.ui @@ -6,8 +6,8 @@ 0 0 - 256 - 120 + 274 + 133 @@ -82,6 +82,122 @@ + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + ... + + + + + + + ... + + + + + + + ... + + + + + + + ... + + + + + + + ... + + + + + + + ... + + + + + + + + + + + + + Resize: + + + + + + + % + + + 1 + + + 500 + + + 100 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + -- 2.39.5