Add "Fit to original" and "Adjust and center in frame " in resize options

CCBUG: 364510
parent ac06cad1
......@@ -389,6 +389,7 @@ ParameterContainer::ParameterContainer(const QDomElement &effect, const ItemInfo
connect(m_geometryWidget, SIGNAL(importClipKeyframes()), this, SIGNAL(importClipKeyframes()));
connect(this, SIGNAL(syncEffectsPos(int)), m_geometryWidget, SLOT(slotSyncPosition(int)));
connect(this, SIGNAL(initScene(int)), m_geometryWidget, SLOT(slotInitScene(int)));
connect(this, &ParameterContainer::updateFrameInfo, m_geometryWidget, &GeometryWidget::setFrameSize);
} else {
Geometryval *geo = new Geometryval(m_metaInfo->monitor->profile(), m_metaInfo->monitor->timecode(), m_metaInfo->frameSize, 0);
if (minFrame == maxFrame) {
......
......@@ -104,7 +104,9 @@ GeometryWidget::GeometryWidget(EffectMetaInfo *info, int clipPos, bool showRotat
m_ui.horizontalLayout->setColumnStretch(4, 10);
QMenu *menu = new QMenu(this);
QAction *adjustSize = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-fit-best")), i18n("Adjust to original size"), this);
QAction *originalSize = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-original")), i18n("Adjust to original size"), this);
connect(originalSize, SIGNAL(triggered()), this, SLOT(slotAdjustToSource()));
QAction *adjustSize = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-fit-best")), i18n("Adjust and center in frame"), this);
connect(adjustSize, SIGNAL(triggered()), this, SLOT(slotAdjustToFrameSize()));
QAction *fitToWidth = new QAction(KoIconUtils::themedIcon(QStringLiteral("zoom-fit-width")), i18n("Fit to width"), this);
connect(fitToWidth, SIGNAL(triggered()), this, SLOT(slotFitToWidth()));
......@@ -182,6 +184,11 @@ GeometryWidget::GeometryWidget(EffectMetaInfo *info, int clipPos, bool showRotat
alignButton->setAutoRaise(true);
alignLayout->addWidget(alignButton);
alignButton = new QToolButton;
alignButton->setDefaultAction(originalSize);
alignButton->setAutoRaise(true);
alignLayout->addWidget(alignButton);
alignButton = new QToolButton;
alignButton->setDefaultAction(adjustSize);
alignButton->setAutoRaise(true);
......@@ -856,7 +863,7 @@ void GeometryWidget::setFrameSize(const QPoint &size)
m_frameSize = size;
}
void GeometryWidget::slotAdjustToFrameSize()
void GeometryWidget::slotAdjustToSource()
{
if (m_frameSize == QPoint() || m_frameSize.x() == 0 || m_frameSize.y() == 0) {
m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
......@@ -870,6 +877,39 @@ void GeometryWidget::slotAdjustToFrameSize()
updateMonitorGeometry();
}
void GeometryWidget::slotAdjustToFrameSize()
{
if (m_frameSize == QPoint() || m_frameSize.x() == 0 || m_frameSize.y() == 0) {
m_frameSize = QPoint(m_monitor->render->frameRenderWidth(), m_monitor->render->renderHeight());
}
double monitorDar = m_monitor->render->frameRenderWidth() / m_monitor->render->renderHeight();
double sourceDar = m_frameSize.x() / m_frameSize.y();
m_spinWidth->blockSignals(true);
m_spinHeight->blockSignals(true);
if (sourceDar > monitorDar) {
// Fit to width
double factor = (double) m_monitor->render->frameRenderWidth() / m_frameSize.x() * m_monitor->render->sar();
m_spinHeight->setValue((int) (m_frameSize.y() * factor + 0.5));
m_spinWidth->setValue(m_monitor->render->frameRenderWidth());
// Center
m_spinY->blockSignals(true);
m_spinY->setValue((m_monitor->render->renderHeight() - m_spinHeight->value()) / 2);
m_spinY->blockSignals(false);
} else {
// Fit to height
double factor = (double) m_monitor->render->renderHeight() / m_frameSize.y();
m_spinHeight->setValue(m_monitor->render->renderHeight());
m_spinWidth->setValue((int) (m_frameSize.x() / m_monitor->render->sar() * factor + 0.5));
// Center
m_spinX->blockSignals(true);
m_spinX->setValue((m_monitor->render->frameRenderWidth() - m_spinWidth->value()) / 2);
m_spinX->blockSignals(false);
}
m_spinWidth->blockSignals(false);
m_spinHeight->blockSignals(false);
updateMonitorGeometry();
}
void GeometryWidget::slotFitToWidth()
{
if (m_frameSize == QPoint() || m_frameSize.x() == 0 || m_frameSize.y() == 0) {
......
......@@ -176,6 +176,9 @@ private slots:
/** @brief Enables/Disables syncing with the timeline according to @param sync. */
void slotSetSynchronize(bool sync);
/** @brief Adjust size to source clip original resolution*/
void slotAdjustToSource();
/** @brief Adjust size to project's frame size */
void slotAdjustToFrameSize();
void slotFitToWidth();
void slotFitToHeight();
......
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