]> git.sesse.net Git - kdenlive/commitdiff
Allow non integer values in drag widget, fix some scaling issues in Kdenlive's compos...
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 14 Feb 2011 00:17:21 +0000 (00:17 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 14 Feb 2011 00:17:21 +0000 (00:17 +0000)
svn path=/trunk/kdenlive/; revision=5403

src/doubleparameterwidget.cpp
src/dragvalue.cpp
src/dragvalue.h
src/effectstackedit.cpp
src/geometrywidget.cpp
src/geometrywidget.h

index 65baf59190be57cff340dabc4459eb75766c6dad..0925ce2228b8b921f88e9c1835f7b9544551d56c 100644 (file)
@@ -39,7 +39,7 @@ DoubleParameterWidget::DoubleParameterWidget(const QString &name, int value, int
     layout->setContentsMargins(0, 0, 0, 0);
     layout->setSpacing(0);
     
-    m_dragVal = new DragValue(name, defaultValue, id, suffix, this);
+    m_dragVal = new DragValue(name, defaultValue, 0, id, suffix, this);
     m_dragVal->setRange(min, max);
     m_dragVal->setPrecision(0);
     layout->addWidget(m_dragVal, 0, 1);
index a7264803a35974e7b96c4dddf266e01e7e971761..377dd952187f4d1818f127bfae5e044d85c9c47c 100644 (file)
 #include <KLocalizedString>
 #include <KGlobalSettings>
 
-DragValue::DragValue(const QString &label, int defaultValue, int id, const QString suffix, bool showSlider, QWidget* parent) :
+DragValue::DragValue(const QString &label, double defaultValue, int decimals, int id, const QString suffix, bool showSlider, QWidget* parent) :
         QWidget(parent),
         m_maximum(100),
         m_minimum(0),
-        m_precision(2),
+        m_decimals(decimals),
         m_default(defaultValue),
-        m_id(id)
+        m_id(id),
+        m_intEdit(NULL),
+        m_doubleEdit(NULL)
 {
     if (showSlider) setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
     else setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
@@ -57,24 +59,43 @@ DragValue::DragValue(const QString &label, int defaultValue, int id, const QStri
     QHBoxLayout *l = new QHBoxLayout;
     l->setSpacing(0);
     l->setContentsMargins(0, 0, 0, 0);
-    m_label = new CustomLabel(label, showSlider, this);
+    m_label = new CustomLabel(label, showSlider, decimals, 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::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)));
+    if (decimals == 0) {
+        m_intEdit = new QSpinBox(this);
+        m_intEdit->setObjectName("dragBox");
+        if (!suffix.isEmpty()) m_intEdit->setSuffix(suffix);
+        m_intEdit->setKeyboardTracking(false);
+        m_intEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
+        m_intEdit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
+        m_intEdit->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+        m_intEdit->setRange((int) m_minimum, (int)m_maximum);
+        l->addWidget(m_intEdit);
+        connect(m_intEdit, SIGNAL(valueChanged(int)), this, SLOT(slotSetValue(int)));
+        connect(m_intEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
+    }
+    else {
+        m_doubleEdit = new QDoubleSpinBox(this);
+        m_doubleEdit->setDecimals(decimals);
+        m_doubleEdit->setObjectName("dragBox");
+        if (!suffix.isEmpty()) m_doubleEdit->setSuffix(suffix);
+        m_doubleEdit->setKeyboardTracking(false);
+        m_doubleEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
+        m_doubleEdit->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
+        m_doubleEdit->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
+        m_doubleEdit->setRange(m_minimum, m_maximum);
+        l->addWidget(m_doubleEdit);
+        connect(m_doubleEdit, SIGNAL(valueChanged(double)), this, SLOT(slotSetValue(double)));
+        connect(m_doubleEdit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
+    }
+    
+    connect(m_label, SIGNAL(valueChanged(double,bool)), this, SLOT(setValue(double,bool)));
     connect(m_label, SIGNAL(resetValue()), this, SLOT(slotReset()));
     setLayout(l);
-    m_label->setMaximumHeight(m_edit->sizeHint().height());
+    if (m_intEdit) m_label->setMaximumHeight(m_intEdit->sizeHint().height());
+    else m_label->setMaximumHeight(m_doubleEdit->sizeHint().height());
 
     m_menu = new QMenu(this);
   
@@ -104,13 +125,13 @@ DragValue::DragValue(const QString &label, int defaultValue, int id, const QStri
     connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotShowContextMenu(const QPoint&)));
     connect(m_scale, SIGNAL(triggered(int)), this, SLOT(slotSetScaleMode(int)));
     connect(m_directUpdate, SIGNAL(triggered(bool)), this, SLOT(slotSetDirectUpdate(bool)));
-
-    connect(m_edit, SIGNAL(editingFinished()), this, SLOT(slotEditingFinished()));
 }
 
+
 DragValue::~DragValue()
 {
-    delete m_edit;
+    if (m_intEdit) delete m_intEdit;
+    if (m_doubleEdit) delete m_doubleEdit;
     delete m_menu;
     delete m_scale;
     delete m_directUpdate;
@@ -118,12 +139,14 @@ DragValue::~DragValue()
 
 int DragValue::spinSize()
 {
-    return m_edit->sizeHint().width();
+    if (m_intEdit) return m_intEdit->sizeHint().width();
+    else return m_doubleEdit->sizeHint().width();
 }
 
 void DragValue::setSpinSize(int width)
 {
-    m_edit->setMinimumWidth(width);
+    if (m_intEdit) m_intEdit->setMinimumWidth(width);
+    else m_doubleEdit->setMinimumWidth(width);
 }
 
 void DragValue::slotSetInTimeline()
@@ -133,7 +156,7 @@ void DragValue::slotSetInTimeline()
 
 int DragValue::precision() const
 {
-    return m_precision;
+    return m_decimals;
 }
 
 qreal DragValue::maximum() const
@@ -148,21 +171,24 @@ qreal DragValue::minimum() const
 
 qreal DragValue::value() const
 {
-    return m_edit->value();
+    if (m_intEdit) return m_intEdit->value();
+    else return m_doubleEdit->value();
 }
 
 void DragValue::setMaximum(qreal max)
 {
     m_maximum = max;
     m_label->setRange(m_minimum, m_maximum);
-    m_edit->setRange(m_minimum, m_maximum);
+    if (m_intEdit) m_intEdit->setRange(m_minimum, m_maximum);
+    else m_doubleEdit->setRange(m_minimum, m_maximum);
 }
 
 void DragValue::setMinimum(qreal min)
 {
     m_minimum = min;
     m_label->setRange(m_minimum, m_maximum);
-    m_edit->setRange(m_minimum, m_maximum);
+    if (m_intEdit) m_intEdit->setRange(m_minimum, m_maximum);
+    else m_doubleEdit->setRange(m_minimum, m_maximum);
 }
 
 void DragValue::setRange(qreal min, qreal max)
@@ -170,7 +196,8 @@ void DragValue::setRange(qreal min, qreal max)
     m_maximum = max;
     m_minimum = min;
     m_label->setRange(m_minimum, m_maximum);
-    m_edit->setRange(m_minimum, m_maximum);
+    if (m_intEdit) m_intEdit->setRange(m_minimum, m_maximum);
+    else m_doubleEdit->setRange(m_minimum, m_maximum);
 }
 
 void DragValue::setPrecision(int /*precision*/)
@@ -190,11 +217,19 @@ void DragValue::setStep(qreal /*step*/)
 
 void DragValue::slotReset()
 {
-    m_edit->blockSignals(true);
-    m_edit->setValue(m_default);
-    m_label->setValue(m_default);
-    m_edit->blockSignals(false);
-    emit valueChanged(m_default, true);
+    if (m_intEdit) {
+        m_intEdit->blockSignals(true);
+        m_intEdit->setValue(m_default);
+        m_intEdit->blockSignals(false);
+        emit valueChanged((int) m_default, true);
+    }
+    else {
+        m_doubleEdit->blockSignals(true);
+        m_doubleEdit->setValue(m_default);
+        m_doubleEdit->blockSignals(false);
+        emit valueChanged(m_default, true);
+    }
+    m_label->setProgressValue(m_default);
 }
 
 void DragValue::slotSetValue(int value)
@@ -202,21 +237,34 @@ void DragValue::slotSetValue(int value)
     setValue(value, KdenliveSettings::dragvalue_directupdate());
 }
 
-void DragValue::setValue(int value, bool final)
+void DragValue::slotSetValue(double value)
+{
+    setValue(value, KdenliveSettings::dragvalue_directupdate());
+}
+
+void DragValue::setValue(double value, bool final)
 {
     value = qBound(m_minimum, value, m_maximum);
-    m_edit->blockSignals(true);
-    m_edit->setValue(value);
-    m_edit->blockSignals(false);
-    m_label->setValue(value);
-    emit valueChanged(value, final);
+    if (m_intEdit) {
+        m_intEdit->blockSignals(true);
+        m_intEdit->setValue((int) value);
+        m_intEdit->blockSignals(false);
+        emit valueChanged((int) value, final);
+    }
+    else {
+        m_doubleEdit->blockSignals(true);
+        m_doubleEdit->setValue(value);
+        m_doubleEdit->blockSignals(false);
+        emit valueChanged(value, final);
+    }
+    m_label->setProgressValue(value);
 }
 
 void DragValue::focusInEvent(QFocusEvent* e)
 {
     if (e->reason() == Qt::TabFocusReason || e->reason() == Qt::BacktabFocusReason) {
-        //m_edit->setEnabled(true);
-        m_edit->setFocus(e->reason());
+        if (m_intEdit) m_intEdit->setFocus(e->reason());
+        else m_doubleEdit->setFocus(e->reason());
     } else {
         QWidget::focusInEvent(e);
     }
@@ -224,8 +272,15 @@ void DragValue::focusInEvent(QFocusEvent* e)
 
 void DragValue::slotEditingFinished()
 {
-    qreal value = m_edit->value();
-    m_edit->clearFocus();
+    qreal value;
+    if (m_intEdit) {
+        value = m_intEdit->value();
+        m_intEdit->clearFocus();
+    }
+    else {
+        value = m_doubleEdit->value();
+        m_doubleEdit->clearFocus();
+    }
     emit valueChanged(value, true);
 }
 
@@ -251,20 +306,31 @@ void DragValue::setInTimelineProperty(bool intimeline)
 {
     if (m_label->property("inTimeline").toBool() == intimeline) return;
     m_label->setProperty("inTimeline", intimeline);
-    m_edit->setProperty("inTimeline", intimeline);
     style()->unpolish(m_label);
     style()->polish(m_label);
     m_label->update();
-    style()->unpolish(m_edit);
-    style()->polish(m_edit);
-    m_edit->update();
+    if (m_intEdit) {
+        m_intEdit->setProperty("inTimeline", intimeline);
+        style()->unpolish(m_intEdit);
+        style()->polish(m_intEdit);
+        m_intEdit->update();
+    }
+    else {
+        m_doubleEdit->setProperty("inTimeline", intimeline);
+        style()->unpolish(m_doubleEdit);
+        style()->polish(m_doubleEdit);
+        m_doubleEdit->update();
+    }
+    
 }
 
-CustomLabel::CustomLabel(const QString &label, bool showSlider, QWidget* parent) :
+CustomLabel::CustomLabel(const QString &label, bool showSlider, int precision, QWidget* parent) :
     QProgressBar(parent),
     m_dragMode(false),
-    m_step(1),
-    m_showSlider(showSlider)
+    m_step(1.0),
+    m_showSlider(showSlider),
+    m_precision(pow(10, precision)),
+    m_value(0)
 {
     setFont(KGlobalSettings::toolBarFont());
     setFormat(" " + label);
@@ -313,12 +379,12 @@ void CustomLabel::mouseMoveEvent(QMouseEvent* e)
                 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());
+                int nv = m_value + diff / m_step;
+                if (nv != m_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());
+                double nv = minimum() + ((double) maximum() - minimum()) / width() * e->pos().x();
+                if (nv != m_value) setNewValue(nv, KdenliveSettings::dragvalue_directupdate());
             }
             m_dragLastPosition = e->pos();
             e->accept();
@@ -339,12 +405,12 @@ void CustomLabel::mouseReleaseEvent(QMouseEvent* e)
         return;
     }
     if (m_dragMode) {
-        setNewValue(value(), true);
+        setNewValue(m_value, true);
         m_dragLastPosition = m_dragStartPosition;
         e->accept();
     }
     else if (m_showSlider) {
-        setNewValue((int) (minimum() + ((double)maximum() - minimum()) / width() * e->pos().x()), true);
+        setNewValue((minimum() + ((double)maximum() - minimum()) / width() * e->pos().x()), true);
         m_dragLastPosition = m_dragStartPosition;
         e->accept();
     }
@@ -355,27 +421,36 @@ void CustomLabel::wheelEvent(QWheelEvent* e)
 {
     if (e->delta() > 0) {
         if (e->modifiers() == Qt::ControlModifier) slotValueInc(10);
+        else if (e->modifiers() == Qt::AltModifier) slotValueInc(1.0 / m_precision);
         else slotValueInc();
     }
     else {
         if (e->modifiers() == Qt::ControlModifier) slotValueDec(10);
+        else if (e->modifiers() == Qt::AltModifier) slotValueDec(1.0 / m_precision);
         else slotValueDec();
     }
     e->accept();
 }
 
-void CustomLabel::slotValueInc(int factor)
+void CustomLabel::slotValueInc(double factor)
+{
+    setNewValue(m_value + m_step * factor, true);
+}
+
+void CustomLabel::slotValueDec(double factor)
 {
-    setNewValue((int) (value() + m_step * factor), true);
+    setNewValue(m_value - m_step * factor, true);
 }
 
-void CustomLabel::slotValueDec(int factor)
+void CustomLabel::setProgressValue(double value)
 {
-    setNewValue((int) (value() - m_step * factor), true);
+    m_value = value;
+    setValue((int) value);
 }
 
-void CustomLabel::setNewValue(int value, bool update)
+void CustomLabel::setNewValue(double value, bool update)
 {
+    m_value = value;
     setValue(value);
     emit valueChanged(value, update);
 }
index 0053405773064e69199e62d7962f90b6515a85b1..d39c9ebc276be06207091a4659850217dcb99c08 100644 (file)
@@ -21,7 +21,8 @@
 
 #include <QWidget>
 #include <kselectaction.h>
-#include <KIntSpinBox>
+#include <QSpinBox>
+#include <QDoubleSpinBox>
 #include <QLabel>
 #include <QProgressBar>
 
@@ -37,7 +38,8 @@ class CustomLabel : public QProgressBar
 {
     Q_OBJECT
 public:
-    CustomLabel(const QString &label, bool showSlider = true, QWidget *parent = 0);
+    CustomLabel(const QString &label, bool showSlider = true, int precision = 0, QWidget *parent = 0);
+    void setProgressValue(double value);
     
 protected:
     //virtual void mouseDoubleClickEvent(QMouseEvent * event);
@@ -51,15 +53,16 @@ private:
     QPoint m_dragStartPosition;
     QPoint m_dragLastPosition;
     bool m_dragMode;
+    double m_value;
     double m_step;
+    double m_precision;
     bool m_showSlider;
-    //QStyleOptionProgressBarV2 m_progressOptions;
-    void slotValueInc(int factor = 1);
-    void slotValueDec(int factor = 1);
-    void setNewValue(int, bool);
+    void slotValueInc(double factor = 1);
+    void slotValueDec(double factor = 1);
+    void setNewValue(double, bool);
     
 signals:
-    void valueChanged(int, bool);
+    void valueChanged(double, bool);
     void setInTimeline();
     void resetValue();
 };
@@ -73,7 +76,7 @@ class DragValue : public QWidget
     Q_OBJECT
 
 public:
-    DragValue(const QString &label, int defaultValue, int id, const QString suffix, bool showSlider = true, QWidget* parent = 0);
+    DragValue(const QString &label, double defaultValue, int decimals, int id, const QString suffix, bool showSlider = true, QWidget* parent = 0);
     virtual ~DragValue();
 
     /** @brief Returns the precision = number of decimals */
@@ -105,12 +108,13 @@ public:
     
 public slots:
     /** @brief Sets the value (forced to be in the valid range) and emits valueChanged. */
-    void setValue(int value, bool final = true);
+    void setValue(double value, bool final = true);
     /** @brief Resets to default value */
     void slotReset();
 
 signals:
     void valueChanged(int value, bool final = true);
+    void valueChanged(double value, bool final = true);
     void inTimeline(int);
 
 
@@ -137,14 +141,16 @@ private slots:
     void slotSetDirectUpdate(bool directUpdate);
     void slotShowContextMenu(const QPoint &pos);
     void slotSetValue(int value);
+    void slotSetValue(double value);
     void slotSetInTimeline();
 
 private:
-    int m_maximum;
-    int m_minimum;
-    int m_precision;
-    KIntSpinBox *m_edit;
-    int m_default;
+    double m_maximum;
+    double m_minimum;
+    int m_decimals;
+    QSpinBox *m_intEdit;
+    QDoubleSpinBox *m_doubleEdit;
+    double m_default;
 
     QMenu *m_menu;
     KSelectAction *m_scale;
index c1f81bee94d2726a6ca68615a727039268d415f1..c861f188b521de742c177f5b269740932a34a71c 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#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()));
+    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;} QAbstractSpinBox#dragBox {border: 1px solid %1;border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QAbstractSpinBox::down-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox: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);
index 75c4d0fd45ee94f58a8a41f7f2cc63435485d725..78f6c7231c22837315e985684f2af51bc6575398 100644 (file)
@@ -88,28 +88,28 @@ 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 = new DragValue(i18n("X"), 0, 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 = new DragValue(i18n("Y"), 0, 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 = new DragValue(i18n("W"), m_monitor->render->frameRenderWidth(), 0, -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 = new DragValue(i18n("H"), m_monitor->render->renderHeight(), 0, -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 = new DragValue(i18n("Size"), 100, 2, -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_opacity = new DragValue(i18n("Opacity"), 100, 0, -1, i18n("%"), true, this);
     m_ui.horizontalLayout2->addWidget(m_opacity);
     
     /*
@@ -121,7 +121,7 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos,
     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_spinSize,         SIGNAL(valueChanged(double)), this, SLOT(slotResize(double)));
 
     connect(m_opacity, SIGNAL(valueChanged(int)), this, SLOT(slotSetOpacity(int)));
     
@@ -417,11 +417,11 @@ 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.0 / m_monitor->render->frameRenderWidth()) + 0.5);
+    double size;
+    if (rectSize.width() / m_monitor->render->dar() > rectSize.height())
+        size = rectSize.width() * 100.0 / m_monitor->render->frameRenderWidth();
     else
-        size = (int)((rectSize.height() * 100.0 / m_monitor->render->renderHeight()) + 0.5);
+        size = rectSize.height() * 100.0 / m_monitor->render->renderHeight();
 
     m_spinX->blockSignals(true);
     m_spinY->blockSignals(true);
@@ -468,7 +468,7 @@ void GeometryWidget::slotSetHeight(int value)
 }
 
 
-void GeometryWidget::slotResize(int value)
+void GeometryWidget::slotResize(double value)
 {
     m_rect->setRect(0, 0,
                     (int)((m_monitor->render->frameRenderWidth() * value / 100.0) + 0.5),
@@ -557,15 +557,17 @@ void GeometryWidget::slotAdjustToFrameSize()
 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);
+    double factor = (double) m_monitor->render->frameRenderWidth() / m_frameSize.x();
+    m_spinHeight->setValue(m_frameSize.y() * factor);
+    m_spinWidth->setValue(m_monitor->render->frameRenderWidth());
 }
 
 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);
+    double factor = m_monitor->render->renderHeight() / m_frameSize.y();
+    m_spinHeight->setValue(m_monitor->render->renderHeight());
+    m_spinWidth->setValue(m_frameSize.x() * factor);
 }
 
 #include "geometrywidget.moc"
index e42675ba60ac078db98f97e2fab736d5467f3fff..9425eacb8f3cec65a0d9d6c8dea4b1f5c7406634 100644 (file)
@@ -132,7 +132,7 @@ private slots:
     void slotSetHeight(int value);
 
     /** @brief Resizes the rect by @param value (in perecent) compared to the frame size. */
-    void slotResize(int value);
+    void slotResize(double value);
 
     /** @brief Sets the opacity to @param value. */
     void slotSetOpacity(int value);