]> git.sesse.net Git - kdenlive/commitdiff
Continue work on slider widget, rewrote layout for geometry param (used in composite...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 10 Feb 2011 01:27:37 +0000 (01:27 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 10 Feb 2011 01:27:37 +0000 (01:27 +0000)
svn path=/trunk/kdenlive/; revision=5386

src/dragvalue.cpp
src/dragvalue.h
src/effectstackedit.cpp
src/geometryval.cpp
src/geometrywidget.cpp
src/geometrywidget.h
src/widgets/geometrywidget_ui.ui

index 2e469be78926415c5b938e9408acbf186970e8b9..29cf87feae2cd0163b3f1e69b119ce922393c6f3 100644 (file)
@@ -41,7 +41,7 @@
 #include <KLocalizedString>
 #include <KGlobalSettings>
 
-DragValue::DragValue(const QString &label, int defaultValue, int id, const QString suffix, QWidget* parent) :
+DragValue::DragValue(const QString &label, int defaultValue, int id, const QString suffix, bool showSlider, QWidget* parent) :
         QWidget(parent),
         m_maximum(100),
         m_minimum(0),
@@ -49,27 +49,30 @@ DragValue::DragValue(const QString &label, int defaultValue, int id, const QStri
         m_default(defaultValue),
         m_id(id)
 {
-    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+    if (showSlider) setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
+    else setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
     setFocusPolicy(Qt::StrongFocus);
     setContextMenuPolicy(Qt::CustomContextMenu);
     
     QHBoxLayout *l = new QHBoxLayout;
     l->setSpacing(0);
     l->setContentsMargins(0, 0, 0, 0);
-    m_label = new CustomLabel(label, this);
+    m_label = new CustomLabel(label, showSlider, this);
     m_label->setCursor(Qt::PointingHandCursor);
     m_label->setRange(m_minimum, m_maximum);
     l->addWidget(m_label);
     m_edit = new KIntSpinBox(this);
+    m_edit->setObjectName("dragBox");
     if (!suffix.isEmpty()) m_edit->setSuffix(suffix);
 
     m_edit->setButtonSymbols(QAbstractSpinBox::NoButtons);
     m_edit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
-    m_edit->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
+    m_edit->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
     m_edit->setRange(m_minimum, m_maximum);
     l->addWidget(m_edit);
     connect(m_edit, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
     connect(m_label, SIGNAL(valueChanged(int,bool)), this, SLOT(setValue(int,bool)));
+    connect(m_label, SIGNAL(resetValue()), this, SLOT(slotReset()));
     setLayout(l);
     m_label->setMaximumHeight(m_edit->sizeHint().height());
 
@@ -97,8 +100,6 @@ DragValue::DragValue(const QString &label, int defaultValue, int id, const QStri
         connect(m_label, SIGNAL(setInTimeline()), this, SLOT(slotSetInTimeline()));
         m_menu->addAction(timeline);
     }
-                        
-    m_label->setRange(m_minimum, m_maximum);
 
     connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotShowContextMenu(const QPoint&)));
     connect(m_scale, SIGNAL(triggered(int)), this, SLOT(slotSetScaleMode(int)));
@@ -259,18 +260,24 @@ void DragValue::setInTimelineProperty(bool intimeline)
     m_edit->update();
 }
 
-CustomLabel::CustomLabel(const QString &label, QWidget* parent) :
+CustomLabel::CustomLabel(const QString &label, bool showSlider, QWidget* parent) :
     QProgressBar(parent),
     m_dragMode(false),
-    m_step(1)
-
+    m_step(1),
+    m_showSlider(showSlider)
 {
+    setFont(KGlobalSettings::toolBarFont());
     setFormat(" " + label);
     setFocusPolicy(Qt::ClickFocus);
     setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
-    setRange(0, 100);
+    if (!showSlider) {
+        QSize sh;
+        const QFontMetrics &fm = fontMetrics();
+        sh.setWidth(fm.width(" " + label + " "));
+        setMaximumWidth(sh.width());
+        setObjectName("dragOnly");
+    }
     setValue(0);
-    setFont(KGlobalSettings::toolBarFont());
 }
 
 void CustomLabel::mousePressEvent(QMouseEvent* e)
@@ -279,38 +286,53 @@ void CustomLabel::mousePressEvent(QMouseEvent* e)
         m_dragStartPosition = m_dragLastPosition = e->pos();
         e->accept();
     }
+    else if (e->button() == Qt::MiddleButton) {
+        emit resetValue();
+        m_dragStartPosition = QPoint(-1, -1);
+    }
     else QWidget::mousePressEvent(e);
 }
 
 void CustomLabel::mouseMoveEvent(QMouseEvent* e)
 {
-    if ((e->pos() - m_dragStartPosition).manhattanLength() >= QApplication::startDragDistance()) {
-        m_dragMode = true;
-        if (KdenliveSettings::dragvalue_mode() > 0) {
-            int diff = e->x() - m_dragLastPosition.x();
-
-            if (e->modifiers() == Qt::ControlModifier)
-                diff *= 2;
-            else if (e->modifiers() == Qt::ShiftModifier)
-                diff /= 2;
-            if (KdenliveSettings::dragvalue_mode() == 2)
-                diff = (diff > 0 ? 1 : -1) * pow(diff, 2);
-
-            int nv = value() + diff / m_step;
-            if (nv != value()) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
+    if (m_dragStartPosition != QPoint(-1, -1)) {
+        if (!m_dragMode && (e->pos() - m_dragStartPosition).manhattanLength() >= QApplication::startDragDistance()) {
+            m_dragMode = true;
+            m_dragLastPosition = e->pos();
+            e->accept();
+            return;
         }
-        else {
-            int nv = minimum() + ((double) maximum() - minimum()) / width() * e->pos().x();
-            if (nv != value()) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
+        if (m_dragMode) {
+            if (KdenliveSettings::dragvalue_mode() > 0 || !m_showSlider) {
+                int diff = e->x() - m_dragLastPosition.x();
+
+                if (e->modifiers() == Qt::ControlModifier)
+                    diff *= 2;
+                else if (e->modifiers() == Qt::ShiftModifier)
+                    diff /= 2;
+                if (KdenliveSettings::dragvalue_mode() == 2)
+                    diff = (diff > 0 ? 1 : -1) * pow(diff, 2);
+
+                int nv = value() + diff / m_step;
+                if (nv != value()) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
+            }
+            else {
+                int nv = minimum() + ((double) maximum() - minimum()) / width() * e->pos().x();
+                if (nv != value()) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
+            }
+            m_dragLastPosition = e->pos();
+            e->accept();
         }
-        m_dragLastPosition = e->pos();
-        e->accept();
     }
     else QWidget::mouseMoveEvent(e);
 }
 
 void CustomLabel::mouseReleaseEvent(QMouseEvent* e)
 {
+    if (e->button() == Qt::MiddleButton) {
+        e->accept();
+        return;
+    }
     if (e->modifiers() == Qt::ControlModifier) {
         emit setInTimeline();
         e->accept();
@@ -321,7 +343,7 @@ void CustomLabel::mouseReleaseEvent(QMouseEvent* e)
         m_dragLastPosition = m_dragStartPosition;
         e->accept();
     }
-    else {
+    else if (m_showSlider) {
         setNewValue((int) (minimum() + ((double)maximum() - minimum()) / width() * e->pos().x()), true);
         m_dragLastPosition = m_dragStartPosition;
         e->accept();
index 9b89ee31f0df82ae7a71f25e5f56332c56f6f72b..0053405773064e69199e62d7962f90b6515a85b1 100644 (file)
@@ -37,7 +37,7 @@ class CustomLabel : public QProgressBar
 {
     Q_OBJECT
 public:
-    CustomLabel(const QString &label, QWidget *parent = 0);
+    CustomLabel(const QString &label, bool showSlider = true, QWidget *parent = 0);
     
 protected:
     //virtual void mouseDoubleClickEvent(QMouseEvent * event);
@@ -52,6 +52,7 @@ private:
     QPoint m_dragLastPosition;
     bool m_dragMode;
     double m_step;
+    bool m_showSlider;
     //QStyleOptionProgressBarV2 m_progressOptions;
     void slotValueInc(int factor = 1);
     void slotValueDec(int factor = 1);
@@ -60,6 +61,7 @@ private:
 signals:
     void valueChanged(int, bool);
     void setInTimeline();
+    void resetValue();
 };
 
 /**
@@ -71,7 +73,7 @@ class DragValue : public QWidget
     Q_OBJECT
 
 public:
-    DragValue(const QString &label, int defaultValue, int id, const QString suffix, QWidget* parent = 0);
+    DragValue(const QString &label, int defaultValue, int id, const QString suffix, bool showSlider = true, QWidget* parent = 0);
     virtual ~DragValue();
 
     /** @brief Returns the precision = number of decimals */
@@ -100,7 +102,7 @@ public:
     int spinSize();
     /** @brief Sets the minimum size for QSpinBox, used to set all spinboxes to the same width. */
     void setSpinSize(int width);
-       
+    
 public slots:
     /** @brief Sets the value (forced to be in the valid range) and emits valueChanged. */
     void setValue(int value, bool final = true);
index 3c38a39c3fb6677f67320afc92370b3d772c99b0..fe62a739fc22442e33af06d48da7464c87a0382e 100644 (file)
@@ -94,7 +94,7 @@ EffectStackEdit::EffectStackEdit(Monitor *monitor, QWidget *parent) :
     QColor light_bg = scheme.shade(KColorScheme::LightShade);
     QColor mid_bg = scheme.shade(KColorScheme::DarkShade);
     
-    QString stylesheet(QString("QProgressBar:horizontal {border: 1px solid %5;border-radius:0px;border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right: 0px;background:%4;padding: 0px;text-align:left center} QProgressBar:horizontal:hover {border: 1px solid %3;border-right: 0px;} QProgressBar::chunk:horizontal {background: %5;} QProgressBar::chunk:horizontal:hover {background: %3;} QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %2;border-right: 0px;background: %4;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %2;} QSpinBox {border: 1px solid %1;border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QSpinBox::down-button {width:0px;padding:0px;} QSpinBox::up-button {width:0px;padding:0px;} QSpinBox[inTimeline=\"true\"]{ border: 1px solid %2;} QSpinBox:hover {border: 1px solid %3;} ").arg(dark_bg.name()).arg(selected_bg.name()).arg(hover_bg.name()).arg(light_bg.name()).arg(mid_bg.name()));
+    QString stylesheet(QString("QProgressBar:horizontal {border: 1px solid %5;border-radius:0px;border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right: 0px;background:%4;padding: 0px;text-align:left center} QProgressBar:horizontal#dragOnly {background: %5} QProgressBar:horizontal:hover#dragOnly {background: %3} QProgressBar:horizontal:hover {border: 1px solid %3;border-right: 0px;} QProgressBar::chunk:horizontal {background: %5;} QProgressBar::chunk:horizontal:hover {background: %3;} QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %2;border-right: 0px;background: %4;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %2;} QSpinBox#dragBox {border: 1px solid %1;border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QSpinBox::down-button#dragBox {width:0px;padding:0px;} QSpinBox::up-button#dragBox {width:0px;padding:0px;} QSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QSpinBox:hover#dragBox {border: 1px solid %3;} ").arg(dark_bg.name()).arg(selected_bg.name()).arg(hover_bg.name()).arg(light_bg.name()).arg(mid_bg.name()));
     setStyleSheet(stylesheet);
     
     setWidget(m_baseWidget);
@@ -120,10 +120,17 @@ void EffectStackEdit::setFrameSize(QPoint p)
         QString type = pa.attributes().namedItem("type").nodeValue();
         QString paramName = i18n(na.toElement().text().toUtf8().data());
 
-        if (type == "geometry" && !KdenliveSettings::on_monitor_effects()) {
-            Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
-            geom->setFrameSize(m_frameSize);
-            break;
+        if (type == "geometry") {
+            if (!KdenliveSettings::on_monitor_effects()) {
+                Geometryval *geom = ((Geometryval*)m_valueItems[paramName+"geometry"]);
+                geom->setFrameSize(m_frameSize);
+                break;
+            }
+            else {
+                GeometryWidget *geom = ((GeometryWidget*)m_valueItems[paramName+"geometry"]);
+                geom->setFrameSize(m_frameSize);
+                break;
+            }
         }
     }
 }
@@ -325,6 +332,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int pos, int in, in
         } else if (type == "geometry") {
             if (KdenliveSettings::on_monitor_effects()) {
                 GeometryWidget *geometry = new GeometryWidget(m_monitor, m_timecode, pos, isEffect, this);
+                geometry->setFrameSize(m_frameSize);
                 geometry->slotShowScene(!disable);
                 // connect this before setupParam to make sure the monitor scene shows up at startup
                 connect(geometry, SIGNAL(checkMonitorPosition(int)), this, SIGNAL(checkMonitorPosition(int)));
index 5182c83d7efa449e284b2daae31737019ecdcd6b..290435b9cfdbe5f476bc67e046f8055bf9c253f2 100644 (file)
@@ -65,7 +65,7 @@ Geometryval::Geometryval(const MltVideoProfile profile, Timecode t, QPoint frame
     m_sceneview->setScene(m_scene);
     m_dar = (m_profile.height * m_profile.display_aspect_num / (double) m_profile.display_aspect_den) / (double) m_profile.width;
 
-    m_realWidth = (int)(profile.height * profile.display_aspect_num / (double) profile.display_aspect_den);
+    m_realWidth = (int)(profile.height * profile.display_aspect_num / (double) profile.display_aspect_den + 0.5);
     QGraphicsRectItem *frameBorder = new QGraphicsRectItem(QRectF(0, 0, m_realWidth, profile.height));
     frameBorder->setZValue(-1100);
     frameBorder->setBrush(QColor(255, 255, 0, 30));
index e92e8281442e9dcb38c22eb326da8b0f9c54c1ae..3b1ca9bb69e212489eda15afb34345cc54f08f08 100644 (file)
 #include "monitoreditwidget.h"
 #include "onmonitoritems/onmonitorrectitem.h"
 #include "kdenlivesettings.h"
+#include "dragvalue.h"
 
 #include <QtCore>
 #include <QGraphicsView>
 #include <QVBoxLayout>
 #include <QGridLayout>
+#include <QMenu>
 
 
 
@@ -48,7 +50,6 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos,
     m_showScene(true)
 {
     m_ui.setupUi(this);
-
     MonitorEditWidget *edit = monitor->getEffectEdit();
     edit->showVisibilityButton(true);
     m_scene = edit->getScene();
@@ -86,40 +87,81 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos,
     connect(m_ui.buttonAddDelete, SIGNAL(clicked()), this, SLOT(slotAddDeleteKeyframe()));
     connect(m_ui.buttonSync,      SIGNAL(toggled(bool)), this, SLOT(slotSetSynchronize(bool)));
 
-
+    m_spinX = new DragValue(i18n("X"), 0, -1, QString(), false, this);
+    m_spinX->setRange(-10000, 10000);
+    m_ui.horizontalLayout->addWidget(m_spinX);
+    
+    m_spinY = new DragValue(i18n("Y"), 0, -1, QString(), false, this);
+    m_spinY->setRange(-10000, 10000);
+    m_ui.horizontalLayout->addWidget(m_spinY);
+    
+    m_spinWidth = new DragValue(i18n("W"), m_monitor->render->frameRenderWidth(), -1, QString(), false, this);
+    m_spinWidth->setRange(1, 10000);
+    m_ui.horizontalLayout->addWidget(m_spinWidth);
+    
+    m_spinHeight = new DragValue(i18n("H"), m_monitor->render->renderHeight(), -1, QString(), false, this);
+    m_spinHeight->setRange(1, 10000);
+    m_ui.horizontalLayout->addWidget(m_spinHeight);
+    m_ui.horizontalLayout->addStretch(10);
+    
+    m_spinSize = new DragValue(i18n("Size"), 100, -1, i18n("%"), false, this);
+    m_spinSize->setRange(1, 10000);
+    m_ui.horizontalLayout2->addWidget(m_spinSize);
+    
+    m_opacity = new DragValue(i18n("Opacity"), 100, -1, i18n("%"), true, this);
+    m_ui.horizontalLayout2->addWidget(m_opacity);
+    
     /*
         Setup of geometry controls
     */
 
-    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.spinOpacity,      SIGNAL(valueChanged(int)), this, SLOT(slotSetOpacity(int)));
-    connect(m_ui.sliderOpacity,    SIGNAL(valueChanged(int)), m_ui.spinOpacity, SLOT(setValue(int)));
-
-    connect(m_ui.buttonMoveLeft,   SIGNAL(clicked()), this, SLOT(slotMoveLeft()));
+    connect(m_spinX,            SIGNAL(valueChanged(int)), this, SLOT(slotSetX(int)));
+    connect(m_spinY,            SIGNAL(valueChanged(int)), this, SLOT(slotSetY(int)));
+    connect(m_spinWidth,        SIGNAL(valueChanged(int)), this, SLOT(slotSetWidth(int)));
+    connect(m_spinHeight,       SIGNAL(valueChanged(int)), this, SLOT(slotSetHeight(int)));
+
+    connect(m_spinSize,         SIGNAL(valueChanged(int)), this, SLOT(slotResize(int)));
+
+    connect(m_opacity, SIGNAL(valueChanged(int)), this, SLOT(slotSetOpacity(int)));
+    
+    QMenu *menu = new QMenu(this);
+    QAction *adjustSize = new QAction(i18n("Adjust to original size"), this);
+    connect(adjustSize, SIGNAL(triggered()), this, SLOT(slotAdjustToFrameSize()));
+    menu->addAction(adjustSize);
+    QAction *fitToWidth = new QAction(i18n("Fit to width"), this);
+    connect(fitToWidth, SIGNAL(triggered()), this, SLOT(slotFitToWidth()));
+    menu->addAction(fitToWidth);
+    QAction *fitToHeight = new QAction(i18n("Fit to height"), this);
+    connect(fitToHeight, SIGNAL(triggered()), this, SLOT(slotFitToHeight()));
+    menu->addAction(fitToHeight);
+    menu->addSeparator();
+
+    QAction *alignleft = new QAction(KIcon("kdenlive-align-left"), i18n("Align left"), this);
+    connect(alignleft, SIGNAL(triggered()), this, SLOT(slotMoveLeft()));
+    menu->addAction(alignleft);
+    QAction *alignhcenter = new QAction(KIcon("kdenlive-align-hor"), i18n("Center horizontally"), this);
+    connect(alignhcenter, SIGNAL(triggered()), this, SLOT(slotCenterH()));
+    menu->addAction(alignhcenter);
+    QAction *alignright = new QAction(KIcon("kdenlive-align-right"), i18n("Align right"), this);
+    connect(alignright, SIGNAL(triggered()), this, SLOT(slotMoveRight()));
+    menu->addAction(alignright);
+    QAction *aligntop = new QAction(KIcon("kdenlive-align-top"), i18n("Align top"), this);
+    connect(aligntop, SIGNAL(triggered()), this, SLOT(slotMoveTop()));
+    menu->addAction(aligntop);    
+    QAction *alignvcenter = new QAction(KIcon("kdenlive-align-vert"), i18n("Center vertically"), this);
+    connect(alignvcenter, SIGNAL(triggered()), this, SLOT(slotCenterV()));
+    menu->addAction(alignvcenter);
+    QAction *alignbottom = new QAction(KIcon("kdenlive-align-bottom"), i18n("Align bottom"), this);
+    connect(alignbottom, SIGNAL(triggered()), this, SLOT(slotMoveBottom()));
+    menu->addAction(alignbottom);
+    m_ui.buttonOptions->setMenu(menu);
+
+    /*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.buttonMoveBottom, SIGNAL(clicked()), this, SLOT(slotMoveBottom()));*/
 
 
     /*
@@ -138,6 +180,11 @@ GeometryWidget::~GeometryWidget()
     m_scene->setEnabled(true);
     delete m_timePos;
     delete m_timeline;
+    delete m_spinX;
+    delete m_spinY;
+    delete m_spinWidth;
+    delete m_spinHeight;
+    delete m_opacity;
     m_scene->removeItem(m_rect);
     delete m_geometry;
     if (m_monitor) {
@@ -177,8 +224,10 @@ void GeometryWidget::setupParam(const QDomElement elem, int minframe, int maxfra
     }
 
     // no opacity
-    if (elem.attribute("opacity") == "false")
-        m_ui.widgetOpacity->setHidden(true);
+    if (elem.attribute("opacity") == "false") {
+        m_opacity->setHidden(true);
+        m_ui.horizontalLayout2->addStretch(2);
+    }
 
     Mlt::GeometryItem item;
 
@@ -237,12 +286,9 @@ void GeometryWidget::slotPositionChanged(int pos, bool seek)
     m_rect->setPos(item.x(), item.y());
     m_rect->setRect(0, 0, item.w(), item.h());
 
-    m_ui.spinOpacity->blockSignals(true);
-    m_ui.sliderOpacity->blockSignals(true);
-    m_ui.spinOpacity->setValue(item.mix());
-    m_ui.sliderOpacity->setValue(item.mix());
-    m_ui.spinOpacity->blockSignals(false);
-    m_ui.sliderOpacity->blockSignals(false);
+    m_opacity->blockSignals(true);
+    m_opacity->setValue(item.mix());
+    m_opacity->blockSignals(false);
 
     slotUpdateProperties();
 
@@ -269,7 +315,7 @@ void GeometryWidget::slotAddKeyframe(int pos)
     item.y(rectpos.y());
     item.w(r.width());
     item.h(r.height());
-    item.mix(m_ui.spinOpacity->value());
+    //item.mix(m_ui.spinOpacity->value());
     m_geometry->insert(item);
 
     m_timeline->update();
@@ -377,47 +423,47 @@ void GeometryWidget::slotUpdateProperties()
     else
         size = (int)((rectSize.height() * 100.0 / m_monitor->render->renderHeight()) + 0.5);
 
-    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);
+    m_spinX->blockSignals(true);
+    m_spinY->blockSignals(true);
+    m_spinWidth->blockSignals(true);
+    m_spinHeight->blockSignals(true);
+    m_spinSize->blockSignals(true);
+
+    m_spinX->setValue(rectPos.x());
+    m_spinY->setValue(rectPos.y());
+    m_spinWidth->setValue(rectSize.width());
+    m_spinHeight->setValue(rectSize.height());
+    m_spinSize->setValue(size);
+
+    m_spinX->blockSignals(false);
+    m_spinY->blockSignals(false);
+    m_spinWidth->blockSignals(false);
+    m_spinHeight->blockSignals(false);
+    m_spinSize->blockSignals(false);
 }
 
 
 void GeometryWidget::slotSetX(int value)
 {
-    m_rect->setPos(value, m_ui.spinY->value());
+    m_rect->setPos(value, m_spinY->value());
     slotUpdateGeometry();
 }
 
 void GeometryWidget::slotSetY(int value)
 {
-    m_rect->setPos(m_ui.spinX->value(), value);
+    m_rect->setPos(m_spinX->value(), value);
     slotUpdateGeometry();
 }
 
 void GeometryWidget::slotSetWidth(int value)
 {
-    m_rect->setRect(0, 0, value, m_ui.spinHeight->value());
+    m_rect->setRect(0, 0, value, m_spinHeight->value());
     slotUpdateGeometry();
 }
 
 void GeometryWidget::slotSetHeight(int value)
 {
-    m_rect->setRect(0, 0, m_ui.spinWidth->value(), value);
+    m_rect->setRect(0, 0, m_spinWidth->value(), value);
     slotUpdateGeometry();
 }
 
@@ -433,17 +479,12 @@ void GeometryWidget::slotResize(int value)
 
 void GeometryWidget::slotSetOpacity(int value)
 {
-    m_ui.sliderOpacity->blockSignals(true);
-    m_ui.sliderOpacity->setValue(value);
-    m_ui.sliderOpacity->blockSignals(false);
-
     int pos = m_timePos->getValue();
     Mlt::GeometryItem item;
     if (m_geometry->fetch(&item, pos) || item.key() == false)
         return;
     item.mix(value);
     m_geometry->insert(item);
-
     emit parameterChanged();
 }
 
@@ -501,4 +542,30 @@ void GeometryWidget::slotShowScene(bool show)
         slotCheckMonitorPosition(m_monitor->render->seekFramePosition());
 }
 
+void GeometryWidget::setFrameSize(QPoint size)
+{
+    m_frameSize = size;
+}
+
+void GeometryWidget::slotAdjustToFrameSize()
+{
+    if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
+    m_spinWidth->setValue(m_frameSize.x());
+    m_spinHeight->setValue(m_frameSize.y());
+}
+
+void GeometryWidget::slotFitToWidth()
+{
+    if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
+    double factor = 100.0 * m_monitor->render->frameRenderWidth() / m_frameSize.x() + 0.5;
+    m_spinSize->setValue(factor);
+}
+
+void GeometryWidget::slotFitToHeight()
+{
+    if (m_frameSize == QPoint()) m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
+    double factor = 100.0 * m_monitor->render->renderHeight() / m_frameSize.y() + 0.5;
+    m_spinSize->setValue(factor);
+}
+
 #include "geometrywidget.moc"
index aa47d7f46d0420fee8ea6603e16e0df31ad4f425..e42675ba60ac078db98f97e2fab736d5467f3fff 100644 (file)
@@ -33,7 +33,7 @@ class MonitorScene;
 class KeyframeHelper;
 class TimecodeDisplay;
 class OnMonitorRectItem;
-
+class DragValue;
 
 class GeometryWidget : public QWidget
 {
@@ -51,6 +51,8 @@ public:
     QString getValue() const;
     /** @brief Updates the timecode display according to settings (frame number or hh:mm:ss:ff) */
     void updateTimecodeFormat();
+    /** @brief Sets the size of the original clip. */
+    void setFrameSize(QPoint size);
 
 public slots:
     /** @brief Sets up the rect and the geometry object.
@@ -80,6 +82,13 @@ private:
     /** Stores the different settings in the MLT geometry format. */
     Mlt::Geometry *m_geometry;
     bool m_showScene;
+    DragValue *m_spinX;
+    DragValue *m_spinY;
+    DragValue *m_spinWidth;
+    DragValue *m_spinHeight;
+    DragValue *m_spinSize;
+    DragValue *m_opacity;
+    QPoint m_frameSize;
 
 private slots:
     /** @brief Updates controls according to position.
@@ -143,6 +152,9 @@ private slots:
 
     /** @brief Enables/Disables syncing with the timeline according to @param sync. */
     void slotSetSynchronize(bool sync);
+    void slotAdjustToFrameSize();
+    void slotFitToWidth();
+    void slotFitToHeight();
 
 signals:
     void parameterChanged();
index 679ea64a43897f01151d3a589c112cde4783b1dd..46916f0cc46ae9a3a8209dd6a7d83b0e824ab0b0 100644 (file)
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>364</width>
-    <height>187</height>
+    <width>129</width>
+    <height>78</height>
    </rect>
   </property>
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QGridLayout" name="gridLayout">
-   <item row="1" column="1">
-    <widget class="QWidget" name="widgetGeometry" native="true">
-     <layout class="QGridLayout" name="gridLayout_3">
-      <property name="leftMargin">
-       <number>0</number>
-      </property>
-      <property name="topMargin">
-       <number>0</number>
-      </property>
-      <property name="rightMargin">
-       <number>0</number>
-      </property>
-      <item row="0" column="0">
-       <widget class="QLabel" name="label">
-        <property name="text">
-         <string>X</string>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="1">
-       <widget class="QSpinBox" name="spinX">
-        <property name="minimum">
-         <number>-10000</number>
-        </property>
-        <property name="maximum">
-         <number>10000</number>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="3">
-       <widget class="QWidget" name="widget" native="true">
-        <layout class="QHBoxLayout" name="horizontalLayout">
-         <property name="margin">
-          <number>0</number>
-         </property>
-         <item>
-          <widget class="QLabel" name="label_5">
-           <property name="text">
-            <string>Resize:</string>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QSpinBox" name="spinSize">
-           <property name="suffix">
-            <string>%</string>
-           </property>
-           <property name="minimum">
-            <number>1</number>
-           </property>
-           <property name="maximum">
-            <number>10000</number>
-           </property>
-           <property name="value">
-            <number>100</number>
-           </property>
-          </widget>
-         </item>
-        </layout>
-       </widget>
-      </item>
-      <item row="0" column="2" rowspan="5">
-       <widget class="Line" name="line">
-        <property name="orientation">
-         <enum>Qt::Vertical</enum>
-        </property>
-       </widget>
-      </item>
-      <item row="0" column="4" rowspan="5">
-       <widget class="QWidget" name="widgetOpacity" native="true">
-        <layout class="QGridLayout" name="gridLayout_5">
-         <property name="margin">
-          <number>0</number>
-         </property>
-         <item row="0" column="1">
-          <widget class="QLabel" name="label_6">
-           <property name="text">
-            <string>Opacity</string>
-           </property>
-           <property name="alignment">
-            <set>Qt::AlignCenter</set>
-           </property>
-          </widget>
-         </item>
-         <item row="2" column="1">
-          <widget class="QSpinBox" name="spinOpacity">
-           <property name="maximum">
-            <number>100</number>
-           </property>
-           <property name="value">
-            <number>100</number>
-           </property>
-          </widget>
-         </item>
-         <item row="0" column="0" rowspan="3">
-          <widget class="Line" name="line_2">
-           <property name="orientation">
-            <enum>Qt::Vertical</enum>
-           </property>
-          </widget>
-         </item>
-         <item row="1" column="1">
-          <widget class="QWidget" name="widget_2" native="true">
-           <property name="sizePolicy">
-            <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
-             <horstretch>0</horstretch>
-             <verstretch>0</verstretch>
-            </sizepolicy>
-           </property>
-           <layout class="QHBoxLayout" name="horizontalLayout_2">
-            <property name="spacing">
-             <number>0</number>
-            </property>
-            <property name="margin">
-             <number>0</number>
-            </property>
-            <item>
-             <spacer name="horizontalSpacer_4">
-              <property name="orientation">
-               <enum>Qt::Horizontal</enum>
-              </property>
-              <property name="sizeHint" stdset="0">
-               <size>
-                <width>40</width>
-                <height>20</height>
-               </size>
-              </property>
-             </spacer>
-            </item>
-            <item>
-             <widget class="QSlider" name="sliderOpacity">
-              <property name="maximum">
-               <number>100</number>
-              </property>
-              <property name="value">
-               <number>100</number>
-              </property>
-              <property name="orientation">
-               <enum>Qt::Vertical</enum>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <spacer name="horizontalSpacer_5">
-              <property name="orientation">
-               <enum>Qt::Horizontal</enum>
-              </property>
-              <property name="sizeHint" stdset="0">
-               <size>
-                <width>40</width>
-                <height>20</height>
-               </size>
-              </property>
-             </spacer>
-            </item>
-           </layout>
-          </widget>
-         </item>
-        </layout>
-       </widget>
-      </item>
-      <item row="1" column="1">
-       <widget class="QSpinBox" name="spinY">
-        <property name="minimum">
-         <number>-10000</number>
-        </property>
-        <property name="maximum">
-         <number>10000</number>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="0">
-       <widget class="QLabel" name="label_2">
-        <property name="text">
-         <string>Y</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="0">
-       <widget class="QLabel" name="label_3">
-        <property name="text">
-         <string>Width</string>
-        </property>
-       </widget>
-      </item>
-      <item row="2" column="1">
-       <widget class="QSpinBox" name="spinWidth">
-        <property name="minimum">
-         <number>1</number>
-        </property>
-        <property name="maximum">
-         <number>10000</number>
-        </property>
-       </widget>
-      </item>
-      <item row="3" column="0">
-       <widget class="QLabel" name="label_4">
-        <property name="text">
-         <string>Height</string>
-        </property>
-       </widget>
-      </item>
-      <item row="3" column="1">
-       <widget class="QSpinBox" name="spinHeight">
-        <property name="minimum">
-         <number>1</number>
-        </property>
-        <property name="maximum">
-         <number>10000</number>
-        </property>
-       </widget>
-      </item>
-      <item row="1" column="3" rowspan="3">
-       <widget class="QFrame" name="frame">
-        <property name="frameShape">
-         <enum>QFrame::StyledPanel</enum>
-        </property>
-        <property name="frameShadow">
-         <enum>QFrame::Raised</enum>
-        </property>
-        <layout class="QGridLayout" name="gridLayout_2">
-         <property name="margin">
-          <number>0</number>
-         </property>
-         <item row="0" column="0">
-          <widget class="QToolButton" name="buttonMoveLeft">
-           <property name="text">
-            <string>...</string>
-           </property>
-          </widget>
-         </item>
-         <item row="0" column="2">
-          <widget class="QToolButton" name="buttonMoveRight">
-           <property name="text">
-            <string>...</string>
-           </property>
-          </widget>
-         </item>
-         <item row="0" column="1">
-          <widget class="QToolButton" name="buttonCenterH">
-           <property name="text">
-            <string>...</string>
-           </property>
-          </widget>
-         </item>
-         <item row="1" column="0">
-          <widget class="QToolButton" name="buttonMoveTop">
-           <property name="text">
-            <string>...</string>
-           </property>
-          </widget>
-         </item>
-         <item row="1" column="1">
-          <widget class="QToolButton" name="buttonCenterV">
-           <property name="text">
-            <string>...</string>
-           </property>
-          </widget>
-         </item>
-         <item row="1" column="2">
-          <widget class="QToolButton" name="buttonMoveBottom">
-           <property name="text">
-            <string>...</string>
-           </property>
-          </widget>
-         </item>
-        </layout>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
-   <item row="0" column="0" colspan="4">
+  <layout class="QGridLayout" name="gridLayout_3">
+   <property name="horizontalSpacing">
+    <number>0</number>
+   </property>
+   <property name="margin">
+    <number>0</number>
+   </property>
+   <item row="0" column="0">
     <widget class="QWidget" name="widgetTimeWrapper" native="true">
      <layout class="QGridLayout" name="gridLayout_4">
       <property name="margin">
      </layout>
     </widget>
    </item>
-   <item row="2" column="0" colspan="4">
-    <spacer name="verticalSpacer_2">
-     <property name="orientation">
-      <enum>Qt::Vertical</enum>
+   <item row="1" column="0">
+    <widget class="QFrame" name="widgetGeometry">
+     <property name="frameShape">
+      <enum>QFrame::NoFrame</enum>
      </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>20</width>
-       <height>40</height>
-      </size>
+     <property name="frameShadow">
+      <enum>QFrame::Plain</enum>
      </property>
-    </spacer>
-   </item>
-   <item row="1" column="2">
-    <widget class="QWidget" name="widgetConfigButton" native="true">
-     <layout class="QGridLayout" name="gridLayout_6">
-      <property name="leftMargin">
-       <number>0</number>
-      </property>
-      <property name="topMargin">
-       <number>0</number>
-      </property>
-      <property name="rightMargin">
-       <number>0</number>
-      </property>
-      <property name="spacing">
+     <layout class="QGridLayout" name="gridLayout">
+      <property name="margin">
        <number>0</number>
       </property>
-      <item row="0" column="1">
-       <spacer name="verticalSpacer">
-        <property name="orientation">
-         <enum>Qt::Vertical</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>20</width>
-          <height>40</height>
-         </size>
-        </property>
-       </spacer>
-      </item>
-      <item row="0" column="2">
-       <spacer name="horizontalSpacer_2">
-        <property name="orientation">
-         <enum>Qt::Horizontal</enum>
-        </property>
-        <property name="sizeHint" stdset="0">
-         <size>
-          <width>40</width>
-          <height>20</height>
-         </size>
-        </property>
-       </spacer>
+      <item row="0" column="0" colspan="5">
+       <layout class="QHBoxLayout" name="horizontalLayout"/>
+      </item>
+      <item row="1" column="0" colspan="5">
+       <layout class="QHBoxLayout" name="horizontalLayout2">
+        <property name="leftMargin">
+         <number>0</number>
+        </property>
+        <item>
+         <widget class="QToolButton" name="buttonOptions">
+          <property name="text">
+           <string>Options</string>
+          </property>
+          <property name="popupMode">
+           <enum>QToolButton::InstantPopup</enum>
+          </property>
+          <property name="autoRaise">
+           <bool>false</bool>
+          </property>
+         </widget>
+        </item>
+       </layout>
       </item>
      </layout>
     </widget>
    </item>
-   <item row="1" column="0">
-    <spacer name="horizontalSpacer">
-     <property name="orientation">
-      <enum>Qt::Horizontal</enum>
-     </property>
-     <property name="sizeHint" stdset="0">
-      <size>
-       <width>40</width>
-       <height>20</height>
-      </size>
-     </property>
-    </spacer>
-   </item>
   </layout>
  </widget>
  <tabstops>
-  <tabstop>spinX</tabstop>
-  <tabstop>spinY</tabstop>
-  <tabstop>spinWidth</tabstop>
-  <tabstop>spinHeight</tabstop>
-  <tabstop>spinSize</tabstop>
-  <tabstop>buttonMoveLeft</tabstop>
-  <tabstop>buttonCenterH</tabstop>
-  <tabstop>buttonMoveRight</tabstop>
-  <tabstop>buttonMoveTop</tabstop>
-  <tabstop>buttonCenterV</tabstop>
-  <tabstop>buttonMoveBottom</tabstop>
-  <tabstop>spinOpacity</tabstop>
-  <tabstop>sliderOpacity</tabstop>
   <tabstop>buttonPrevious</tabstop>
   <tabstop>buttonAddDelete</tabstop>
   <tabstop>buttonNext</tabstop>