From: Till Theato Date: Thu, 27 Jan 2011 21:06:34 +0000 (+0000) Subject: on-monitor editing: show controls next to the edit monitor X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c25ab9b9c4e14e3d3e8b0cfb37868e87152ae8c9;p=kdenlive on-monitor editing: show controls next to the edit monitor svn path=/trunk/kdenlive/; revision=5356 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 11f3e5ff..a3b74c03 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -123,6 +123,7 @@ kde4_add_ui_files(kdenlive_UI widgets/spectrogram_ui.ui widgets/smconfig_ui.ui widgets/bezierspline_ui.ui + widgets/monitoreditwidget_ui.ui ) set(kdenlive_SRCS @@ -267,6 +268,7 @@ set(kdenlive_SRCS beziercurve/bpoint.cpp beziercurve/cubicbezierspline.cpp dragvalue.cpp + monitoreditwidget.cpp ) add_definitions(${KDE4_DEFINITIONS}) diff --git a/src/cornerswidget.cpp b/src/cornerswidget.cpp index 9744e3d6..46f2a133 100644 --- a/src/cornerswidget.cpp +++ b/src/cornerswidget.cpp @@ -20,13 +20,14 @@ #include "cornerswidget.h" #include "monitor.h" #include "monitorscene.h" -#include "monitorscenecontrolwidget.h" +#include "monitoreditwidget.h" #include "onmonitoritems/onmonitorcornersitem.h" #include "renderer.h" #include "kdenlivesettings.h" #include #include +#include #include @@ -41,33 +42,33 @@ CornersWidget::CornersWidget(Monitor *monitor, QDomElement e, int minFrame, int m_showScene(true), m_pos(0) { - m_scene = monitor->getEffectScene(); + MonitorEditWidget *edit = monitor->getEffectEdit(); + edit->showVisibilityButton(true); + m_scene = edit->getScene(); m_item = new OnMonitorCornersItem(m_scene); m_scene->addItem(m_item); - m_config = new MonitorSceneControlWidget(m_scene, this); - QGridLayout *l = static_cast(layout()); - l->addWidget(m_config->getShowHideButton(), 1, 1); - l->addWidget(m_config, 1, 2); - - QToolButton *buttonShowLines = new QToolButton(m_config); // TODO: Better Icons - buttonShowLines->setIcon(KIcon("insert-horizontal-rule")); - buttonShowLines->setToolTip(i18n("Show/Hide the lines connecting the corners")); - buttonShowLines->setCheckable(true); - buttonShowLines->setChecked(KdenliveSettings::onmonitoreffects_cornersshowlines()); - connect(buttonShowLines, SIGNAL(toggled(bool)), this, SLOT(slotShowLines(bool))); - m_config->addWidget(buttonShowLines, 0, 2); - QToolButton *buttonShowControls = new QToolButton(m_config); + QToolButton *buttonShowControls = new QToolButton(); buttonShowControls->setIcon(KIcon("transform-move")); buttonShowControls->setToolTip(i18n("Show additional controls")); buttonShowControls->setCheckable(true); + buttonShowControls->setAutoRaise(true); buttonShowControls->setChecked(KdenliveSettings::onmonitoreffects_cornersshowcontrols()); connect(buttonShowControls, SIGNAL(toggled(bool)), this, SLOT(slotShowControls(bool))); - m_config->addWidget(buttonShowControls, 0, 3); + edit->addCustomControl(buttonShowControls); - connect(m_config, SIGNAL(showScene(bool)), this, SLOT(slotShowScene(bool))); + QToolButton *buttonShowLines = new QToolButton(); + buttonShowLines->setIcon(KIcon("insert-horizontal-rule")); + buttonShowLines->setToolTip(i18n("Show/Hide the lines connecting the corners")); + buttonShowLines->setCheckable(true); + buttonShowControls->setAutoRaise(true); + buttonShowLines->setChecked(KdenliveSettings::onmonitoreffects_cornersshowlines()); + connect(buttonShowLines, SIGNAL(toggled(bool)), this, SLOT(slotShowLines(bool))); + edit->addCustomControl(buttonShowLines); + + connect(edit, SIGNAL(showEdit(bool)), this, SLOT(slotShowScene(bool))); connect(m_monitor, SIGNAL(renderPosition(int)), this, SLOT(slotCheckMonitorPosition(int))); connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateProperties())); connect(m_scene, SIGNAL(addKeyframe()), this, SLOT(slotInsertKeyframe())); @@ -77,11 +78,14 @@ CornersWidget::CornersWidget(Monitor *monitor, QDomElement e, int minFrame, int CornersWidget::~CornersWidget() { - delete m_config; m_scene->removeItem(m_item); delete m_item; - if (m_monitor) + if (m_monitor) { + MonitorEditWidget *edit = m_monitor->getEffectEdit(); + edit->showVisibilityButton(false); + edit->removeCustomControls(); m_monitor->slotEffectScene(false); + } } void CornersWidget::addParameter(QDomElement e, int activeKeyframe) @@ -98,7 +102,7 @@ void CornersWidget::slotUpdateItem() return; QTableWidgetItem *keyframe, *keyframeOld; - keyframe = keyframe_list->item(0, 0); + keyframe = keyframeOld = keyframe_list->item(0, 0); for (int row = 0; row < keyframe_list->rowCount(); ++row) { keyframeOld = keyframe; keyframe = keyframe_list->item(row, 0); @@ -218,7 +222,7 @@ void CornersWidget::slotInsertKeyframe() int row; QTableWidgetItem *keyframe, *keyframeOld; - keyframe = keyframe_list->item(0, 0); + keyframe = keyframeOld = keyframe_list->item(0, 0); for (row = 0; row < keyframe_list->rowCount(); ++row) { keyframeOld = keyframe; keyframe = keyframe_list->item(row, 0); diff --git a/src/cornerswidget.h b/src/cornerswidget.h index 6f13846c..d71f656c 100644 --- a/src/cornerswidget.h +++ b/src/cornerswidget.h @@ -28,7 +28,6 @@ class QDomElement; class Monitor; class MonitorScene; class OnMonitorCornersItem; -class MonitorSceneControlWidget; class CornersWidget : public KeyframeEdit @@ -57,7 +56,6 @@ private: MonitorScene *m_scene; OnMonitorCornersItem *m_item; bool m_showScene; - MonitorSceneControlWidget *m_config; int m_pos; /** @brief Returns the corner positions set in the row of @param keyframe. */ diff --git a/src/effectstackview.cpp b/src/effectstackview.cpp index cb0851b8..944e2841 100644 --- a/src/effectstackview.cpp +++ b/src/effectstackview.cpp @@ -23,6 +23,7 @@ #include "docclipbase.h" #include "projectlist.h" #include "kthumb.h" +#include "monitoreditwidget.h" #include "monitorscene.h" #include "kdenlivesettings.h" @@ -484,7 +485,7 @@ void EffectStackView::slotCheckAll(int state) void EffectStackView::slotCheckMonitorPosition(int renderPos) { if (m_trackMode || (renderPos >= m_clipref->startPos().frames(KdenliveSettings::project_fps()) && renderPos <= m_clipref->endPos().frames(KdenliveSettings::project_fps()))) { - if (!m_monitor->getEffectScene()->views().at(0)->isVisible()) + if (!m_monitor->getEffectEdit()->getScene()->views().at(0)->isVisible()) m_monitor->slotEffectScene(true); } else { m_monitor->slotEffectScene(false); diff --git a/src/geometrywidget.cpp b/src/geometrywidget.cpp index eaaa5329..7e0aca9a 100644 --- a/src/geometrywidget.cpp +++ b/src/geometrywidget.cpp @@ -24,7 +24,7 @@ #include "keyframehelper.h" #include "timecodedisplay.h" #include "monitorscene.h" -#include "monitorscenecontrolwidget.h" +#include "monitoreditwidget.h" #include "onmonitoritems/onmonitorrectitem.h" #include "kdenlivesettings.h" @@ -48,7 +48,10 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos, m_showScene(true) { m_ui.setupUi(this); - m_scene = monitor->getEffectScene(); + + MonitorEditWidget *edit = monitor->getEffectEdit(); + edit->showVisibilityButton(true); + m_scene = edit->getScene(); /* @@ -123,12 +126,7 @@ GeometryWidget::GeometryWidget(Monitor* monitor, Timecode timecode, int clipPos, Setup of configuration controls */ - m_config = new MonitorSceneControlWidget(m_scene, m_ui.frameSettings); - QHBoxLayout *settingsLayout = new QHBoxLayout(m_ui.frameSettings); - settingsLayout->addWidget(m_config); - settingsLayout->setContentsMargins(0, 0, 0, 0); - ((QGridLayout *)m_ui.widgetConfigButton->layout())->addWidget(m_config->getShowHideButton(), 1, 1); - connect(m_config, SIGNAL(showScene(bool)), this, SLOT(slotShowScene(bool))); + connect(edit, SIGNAL(showEdit(bool)), this, SLOT(slotShowScene(bool))); connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateGeometry())); connect(m_scene, SIGNAL(addKeyframe()), this, SLOT(slotAddKeyframe())); @@ -143,9 +141,10 @@ GeometryWidget::~GeometryWidget() delete m_timeline; m_scene->removeItem(m_rect); delete m_geometry; - delete m_config; - if (m_monitor) + if (m_monitor) { + m_monitor->getEffectEdit()->showVisibilityButton(false); m_monitor->slotEffectScene(false); + } } void GeometryWidget::updateTimecodeFormat() diff --git a/src/geometrywidget.h b/src/geometrywidget.h index 55423be5..aa47d7f4 100644 --- a/src/geometrywidget.h +++ b/src/geometrywidget.h @@ -33,7 +33,6 @@ class MonitorScene; class KeyframeHelper; class TimecodeDisplay; class OnMonitorRectItem; -class MonitorSceneControlWidget; class GeometryWidget : public QWidget @@ -81,7 +80,6 @@ private: /** Stores the different settings in the MLT geometry format. */ Mlt::Geometry *m_geometry; bool m_showScene; - MonitorSceneControlWidget *m_config; private slots: /** @brief Updates controls according to position. diff --git a/src/monitor.cpp b/src/monitor.cpp index 3c2dbae1..bc75e187 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -23,8 +23,9 @@ #include "monitormanager.h" #include "smallruler.h" #include "docclipbase.h" -#include "monitorscene.h" #include "abstractclipitem.h" +#include "monitorscene.h" +#include "monitoreditwidget.h" #include "kdenlivesettings.h" #include @@ -42,7 +43,6 @@ #include #include #include -#include Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget *parent) : @@ -58,8 +58,7 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget m_length(0), m_dragStarted(false), m_monitorRefresh(NULL), - m_effectScene(NULL), - m_effectView(NULL), + m_effectWidget(NULL), m_selectedClip(NULL), m_loopClipTransition(true) @@ -148,15 +147,6 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget m_volumePopup->show(); m_volumePopup->hide(); - QWidget *spacer = new QWidget(this); - spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - m_toolbar->addWidget(spacer); - m_timePos = new TimecodeDisplay(m_monitorManager->timecode(), this); - m_toolbar->addWidget(m_timePos); - connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotSeek())); - m_toolbar->setMaximumHeight(s * 1.5); - layout->addWidget(m_toolbar); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); setLayout(layout); setMinimumHeight(200); @@ -207,15 +197,20 @@ Monitor::Monitor(QString name, MonitorManager *manager, QString profile, QWidget if (m_monitorRefresh) m_monitorRefresh->show(); if (name == "project") { - m_effectScene = new MonitorScene(render); - m_effectView = new QGraphicsView(m_effectScene, m_videoBox); - lay->addWidget(m_effectView); - m_effectView->setRenderHints(QFlags()); - m_effectView->scale(((double) render->renderWidth()) / render->frameRenderWidth(), 1.0); - m_effectView->setMouseTracking(true); - m_effectScene->setUp(); - m_effectView->hide(); + m_effectWidget = new MonitorEditWidget(render, m_videoBox); + m_toolbar->addAction(m_effectWidget->getVisibilityAction()); + lay->addWidget(m_effectWidget); + m_effectWidget->hide(); } + + QWidget *spacer = new QWidget(this); + spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + m_toolbar->addWidget(spacer); + m_timePos = new TimecodeDisplay(m_monitorManager->timecode(), this); + m_toolbar->addWidget(m_timePos); + connect(m_timePos, SIGNAL(editingFinished()), this, SLOT(slotSeek())); + m_toolbar->setMaximumHeight(s * 1.5); + layout->addWidget(m_toolbar); } Monitor::~Monitor() @@ -223,10 +218,8 @@ Monitor::~Monitor() delete m_ruler; delete m_timePos; delete m_overlay; - if (m_name == "project") { - delete m_effectView; - delete m_effectScene; - } + if (m_effectWidget) + delete m_effectWidget; delete m_monitorRefresh; delete render; } @@ -466,7 +459,7 @@ void Monitor::slotSwitchFullScreen() void Monitor::mouseReleaseEvent(QMouseEvent * event) { if (m_dragStarted) { - if (m_videoBox->underMouse() && (!m_effectView || !m_effectView->isVisible())) { + if (m_videoBox->underMouse() && (!m_effectWidget || !m_effectWidget->isVisible())) { if (isActive()) slotPlay(); else activateMonitor(); } else QWidget::mouseReleaseEvent(event); @@ -858,10 +851,8 @@ void Monitor::resetProfile(const QString profile) m_timePos->updateTimeCode(m_monitorManager->timecode()); if (render == NULL) return; render->resetProfile(profile); - if (m_effectScene) { - m_effectView->scale(((double) render->renderWidth()) / render->frameRenderWidth(), 1.0); - m_effectScene->resetProfile(); - } + if (m_effectWidget) + m_effectWidget->resetProfile(render); } void Monitor::saveSceneList(QString path, QDomElement info) @@ -960,23 +951,24 @@ void Monitor::slotEffectScene(bool show) m_glWidget->setVisible(!show); #endif } - m_effectView->setVisible(show); + m_effectWidget->setVisible(show); + m_effectWidget->getVisibilityAction()->setChecked(show); emit requestFrameForAnalysis(show); if (show) { + m_effectWidget->getScene()->slotZoomFit(); render->doRefresh(); - m_effectScene->slotZoomFit(); } } } -MonitorScene * Monitor::getEffectScene() +MonitorEditWidget* Monitor::getEffectEdit() { - return m_effectScene; + return m_effectWidget; } bool Monitor::effectSceneDisplayed() { - return m_effectView->isVisible(); + return m_effectWidget->isVisible(); } void Monitor::slotSetVolume(int volume) diff --git a/src/monitor.h b/src/monitor.h index 70fce38a..faaf5021 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -41,12 +41,10 @@ class MonitorManager; class Render; class SmallRuler; class DocClipBase; -class MonitorScene; class AbstractClipItem; class Transition; class ClipItem; -class QGraphicsView; -class QGraphicsPixmapItem; +class MonitorEditWidget; class Monitor; @@ -120,7 +118,7 @@ public: void checkOverlay(); void updateTimecodeFormat(); void updateMarkers(DocClipBase *source); - MonitorScene *getEffectScene(); + MonitorEditWidget *getEffectEdit(); QWidget *container(); QFrame *m_volumePopup; @@ -164,8 +162,7 @@ private: QMenu *m_playMenu; QMenu *m_markerMenu; QPoint m_DragStartPosition; - MonitorScene *m_effectScene; - QGraphicsView *m_effectView; + MonitorEditWidget *m_effectWidget; VideoContainer *m_videoBox; /** Selected clip/transition in timeline. Used for looping it. */ AbstractClipItem *m_selectedClip; diff --git a/src/monitoreditwidget.cpp b/src/monitoreditwidget.cpp new file mode 100644 index 00000000..f72bfacf --- /dev/null +++ b/src/monitoreditwidget.cpp @@ -0,0 +1,115 @@ +/*************************************************************************** + * Copyright (C) 2011 by Till Theato (root@ttill.de) * + * 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 . * + ***************************************************************************/ + + +#include "monitoreditwidget.h" +#include "renderer.h" +#include "monitorscene.h" +#include "kdenlivesettings.h" + +#include +#include +#include + +#include + +MonitorEditWidget::MonitorEditWidget(Render* renderer, QWidget* parent) : + QWidget(parent) +{ + m_ui.setupUi(this); + + m_scene = new MonitorScene(renderer); + m_view = new QGraphicsView(m_scene, m_ui.frameVideo); + m_view->setRenderHints(QFlags()); + m_view->scale(((double) renderer->renderWidth()) / renderer->frameRenderWidth(), 1.0); + m_view->setMouseTracking(true); + m_scene->setUp(); + + ((QVBoxLayout*)m_ui.frameVideo->layout())->addWidget(m_view); + + m_customControlsLayout = static_cast(m_ui.frameCustomControls->layout()); + + m_visibilityAction = new QAction(KIcon("video-display"), i18n("Show/Hide edit mode"), this); + m_visibilityAction->setCheckable(true); + m_visibilityAction->setVisible(false); + + m_ui.buttonDirectUpdate->setIcon(KIcon("transform-scale")); + m_ui.buttonDirectUpdate->setToolTip(i18n("Update parameters while monitor scene changes")); + m_ui.buttonDirectUpdate->setChecked(KdenliveSettings::monitorscene_directupdate()); + + m_ui.buttonZoomFit->setIcon(KIcon("zoom-fit-best")); + m_ui.buttonZoomFit->setToolTip(i18n("Fit zoom to monitor size")); + m_ui.buttonZoomOriginal->setIcon(KIcon("zoom-original")); + m_ui.buttonZoomOriginal->setToolTip(i18n("Original size")); + + connect(m_ui.sliderZoom, SIGNAL(valueChanged(int)), m_scene, SLOT(slotZoom(int))); + connect(m_scene, SIGNAL(zoomChanged(int)), m_ui.sliderZoom, SLOT(setValue(int))); + connect(m_ui.buttonZoomFit, SIGNAL(clicked()), m_scene, SLOT(slotZoomFit())); + connect(m_ui.buttonZoomOriginal, SIGNAL(clicked()), m_scene, SLOT(slotZoomOriginal())); + m_scene->slotZoomFit(); + + connect(m_visibilityAction, SIGNAL(triggered(bool)), this, SIGNAL(showEdit(bool))); + connect(m_ui.buttonDirectUpdate, SIGNAL(toggled(bool)), this, SLOT(slotSetDirectUpdate(bool))); +} + +MonitorEditWidget::~MonitorEditWidget() +{ + delete m_view; + delete m_scene; + delete m_visibilityAction; +} + +void MonitorEditWidget::resetProfile(Render* renderer) +{ + m_view->scale(((double) renderer->renderWidth()) / renderer->frameRenderWidth(), 1.0); + m_scene->resetProfile(); +} + +MonitorScene* MonitorEditWidget::getScene() +{ + return m_scene; +} + +QAction* MonitorEditWidget::getVisibilityAction() +{ + return m_visibilityAction; +} + +void MonitorEditWidget::showVisibilityButton(bool show) +{ + m_visibilityAction->setVisible(show); +} + +void MonitorEditWidget::addCustomControl(QWidget* widget) +{ + m_customControlsLayout->addWidget(widget); +} + +void MonitorEditWidget::removeCustomControls() +{ + QLayoutItem *child; + while ((child = m_customControlsLayout->takeAt(0)) != 0) + delete child; +} + +void MonitorEditWidget::slotSetDirectUpdate(bool directUpdate) +{ + KdenliveSettings::setMonitorscene_directupdate(directUpdate); +} + +#include "monitoreditwidget.moc" diff --git a/src/monitoreditwidget.h b/src/monitoreditwidget.h new file mode 100644 index 00000000..843a2bb1 --- /dev/null +++ b/src/monitoreditwidget.h @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (C) 2011 by Till Theato (root@ttill.de) * + * 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 . * + ***************************************************************************/ + +#ifndef MONITOREDITWIDGET_H_ +#define MONITOREDITWIDGET_H_ + +#include "ui_monitoreditwidget_ui.h" + +#include + +class MonitorScene; +class Render; +class QGraphicsView; +class QToolButton; +class QVBoxLayout; + + + +class MonitorEditWidget : public QWidget +{ + Q_OBJECT + +public: + MonitorEditWidget(Render *renderer, QWidget* parent = 0); + virtual ~MonitorEditWidget(); + + /** @brief Updates the necessary settings on a profile change. */ + void resetProfile(Render *renderer); + + /** @brief Returns the on-monitor scene. */ + MonitorScene *getScene(); + + /** @brief Returns the action toggling between the normal monitor and the editor. */ + QAction *getVisibilityAction(); + /** @brief Shows/Hides the visibility button/action. */ + void showVisibilityButton(bool show); + + /** @brief Adds a custom widget to the controls. */ + void addCustomControl(QWidget *widget); + /** @brief Empties the list of custom controls. */ + void removeCustomControls(); + +private slots: + /** @brief Sets the KdenliveSetting directupdate with true = update parameters (rerender frame) during mouse move (before mouse button is released) */ + void slotSetDirectUpdate(bool directUpdate); + +private: + Ui::MonitorEditWidget_UI m_ui; + MonitorScene *m_scene; + QGraphicsView *m_view; + QAction *m_visibilityAction; + QVBoxLayout *m_customControlsLayout; + +signals: + /** true = show edit monitor, false = show normal monitor */ + void showEdit(bool show); +}; + + +#endif diff --git a/src/widgets/monitoreditwidget_ui.ui b/src/widgets/monitoreditwidget_ui.ui new file mode 100644 index 00000000..6b816818 --- /dev/null +++ b/src/widgets/monitoreditwidget_ui.ui @@ -0,0 +1,130 @@ + + + MonitorEditWidget_UI + + + + 0 + 0 + 498 + 290 + + + + Form + + + + 0 + + + 0 + + + + + + 0 + + + 0 + + + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + QFrame::Plain + + + + 0 + + + 0 + + + + + + + + ... + + + true + + + true + + + + + + + ... + + + true + + + + + + + ... + + + true + + + + + + + + 0 + 0 + + + + 1 + + + 300 + + + 100 + + + Qt::Vertical + + + + + + + + + + +