widgets/trackheader_ui.ui
widgets/clipproperties_ui.ui
widgets/markerdialog_ui.ui
+ widgets/keyframedialog_ui.ui
)
set(kdenlive_SRCS
#include "abstractclipitem.h"
-AbstractClipItem::AbstractClipItem(const ItemInfo info, const QRectF& rect, double fps): QGraphicsRectItem(rect), m_track(0), m_fps(fps), m_editedKeyframe(-1), m_selectedKeyframe(0) {
+AbstractClipItem::AbstractClipItem(const ItemInfo info, const QRectF& rect, double fps): QGraphicsRectItem(rect), m_track(0), m_fps(fps), m_editedKeyframe(-1), m_selectedKeyframe(0), m_keyframeFactor(1) {
setFlags(QGraphicsItem::ItemClipsToShape | QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
setTrack(info.track);
m_startPos = info.startPos;
update(br.x() + maxw * (m_selectedKeyframe - m_cropStart.frames(m_fps)) - 3, br.bottom() - m_keyframes[m_selectedKeyframe] * maxh - 3, 12, 12);
}
-void AbstractClipItem::updateKeyFramePos(const GenTime pos, const int value) {
+int AbstractClipItem::selectedKeyFramePos() const {
+ return m_editedKeyframe;
+}
+
+double AbstractClipItem::selectedKeyFrameValue() const {
+ return m_keyframes[m_editedKeyframe];
+}
+
+void AbstractClipItem::updateKeyFramePos(const GenTime pos, const double value) {
if (!m_keyframes.contains(m_selectedKeyframe)) return;
- QRectF br = rect();
- double maxh = 100.0 / br.height();
- double newval = (br.bottom() - value) * maxh;
int newpos = (int) pos.frames(m_fps);
int start = m_cropStart.frames(m_fps);
int end = (m_cropStart + m_cropDuration).frames(m_fps);
newpos = qMax(newpos, start);
newpos = qMin(newpos, end);
- if (newval < -50 && m_selectedKeyframe != start && m_selectedKeyframe != end) {
+ if (value < -50 && m_selectedKeyframe != start && m_selectedKeyframe != end) {
// remove kexframe if it is dragged outside
m_keyframes.remove(m_selectedKeyframe);
m_selectedKeyframe = -1;
update();
return;
}
- if (newval > 150 && m_selectedKeyframe != start && m_selectedKeyframe != end) {
+ if (value > 150 && m_selectedKeyframe != start && m_selectedKeyframe != end) {
// remove kexframe if it is dragged outside
m_keyframes.remove(m_selectedKeyframe);
m_selectedKeyframe = -1;
update();
return;
}
- newval = qMax(newval, 0.0);
+ double newval = qMax(value, 0.0);
newval = qMin(newval, 100.0);
newval = newval / m_keyframeFactor;
if (m_selectedKeyframe != newpos) m_keyframes.remove(m_selectedKeyframe);
update();
}
-void AbstractClipItem::addKeyFrame(const GenTime pos, const int value) {
+double AbstractClipItem::keyFrameFactor() const {
+ return m_keyframeFactor;
+}
+
+void AbstractClipItem::addKeyFrame(const GenTime pos, const double value) {
QRectF br = rect();
double maxh = 100.0 / br.height() / m_keyframeFactor;
double newval = (br.bottom() - value) * maxh;
public:
AbstractClipItem(const ItemInfo info, const QRectF& rect, double fps);
void updateSelectedKeyFrame();
- void updateKeyFramePos(const GenTime pos, const int value);
- void addKeyFrame(const GenTime pos, const int value);
+ void updateKeyFramePos(const GenTime pos, const double value);
+ void addKeyFrame(const GenTime pos, const double value);
bool hasKeyFrames() const;
+ int selectedKeyFramePos() const;
+ double selectedKeyFrameValue() const;
+ double keyFrameFactor() const;
virtual OPERATIONTYPE operationMode(QPointF pos, double scale) = 0;
virtual GenTime startPos() const ;
#include "renderer.h"
#include "markerdialog.h"
#include "mainwindow.h"
+#include "ui_keyframedialog_ui.h"
//TODO:
((ClipItem*) m_dragItem)->setFadeOut((int)(m_dragItem->endPos().frames(m_document->fps()) - pos), m_scale);
} else if (m_operationMode == KEYFRAME) {
GenTime keyFramePos = GenTime((int)(mapToScene(event->pos()).x() / m_scale), m_document->fps()) - m_dragItem->startPos() + m_dragItem->cropStart();
- m_dragItem->updateKeyFramePos(keyFramePos, mapToScene(event->pos()).toPoint().y());
+ double pos = mapToScene(event->pos()).toPoint().y();
+ QRectF br = m_dragItem->rect();
+ double maxh = 100.0 / br.height();
+ pos = (br.bottom() - pos) * maxh;
+ m_dragItem->updateKeyFramePos(keyFramePos, pos);
}
if (m_animation) delete m_animation;
if (m_dragItem && m_dragItem->hasKeyFrames()) {
if (m_moveOpMode == KEYFRAME) {
// user double clicked on a keyframe, open edit dialog
+ QDialog d(parentWidget());
+ Ui::KeyFrameDialog_UI view;
+ view.setupUi(&d);
+ view.kfr_position->setText(m_document->timecode().getTimecode(GenTime(m_dragItem->selectedKeyFramePos(), m_document->fps()), m_document->fps()));
+ view.kfr_value->setValue(m_dragItem->selectedKeyFrameValue());
+ view.kfr_value->setFocus();
+ if (d.exec() == QDialog::Accepted) {
+ int pos = m_document->timecode().getFrameCount(view.kfr_position->text(), m_document->fps());
+ m_dragItem->updateKeyFramePos(GenTime(pos, m_document->fps()), (double) view.kfr_value->value() * m_dragItem->keyFrameFactor());
+ ClipItem *item = (ClipItem *)m_dragItem;
+ item->updateKeyframeEffect();
+ updateEffect(m_tracksList.count() - item->track(), item->startPos(), item->selectedEffect());
+ }
} else {
// add keyframe
void MarkerDialog::slotUpdateThumb() {
m_previewTimer->stop();
int pos = m_tc.getFrameCount(m_view.marker_position->text(), m_fps);
- kDebug() << "// getting thumb for: " << pos;
QPixmap p = KThumb::getFrame(*m_producer, pos, (int)(100 * m_dar), 100);
if (!p.isNull()) m_view.clip_thumb->setPixmap(p);
else kDebug() << "!!!!!!!!!!! ERROR CREATING THUMB";
--- /dev/null
+<ui version="4.0" >
+ <class>KeyFrameDialog_UI</class>
+ <widget class="QDialog" name="KeyFrameDialog_UI" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>324</width>
+ <height>75</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Edit Keyframe</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout" >
+ <item row="0" column="0" >
+ <widget class="QLabel" name="clip_filesize_2" >
+ <property name="text" >
+ <string>Position</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2" >
+ <widget class="KRestrictedLine" name="kfr_position" >
+ <property name="inputMask" >
+ <string>99:99:99:99; </string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3" >
+ <widget class="QLabel" name="clip_filesize_3" >
+ <property name="text" >
+ <string>Value</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4" >
+ <widget class="KDoubleNumInput" name="kfr_value" />
+ </item>
+ <item rowspan="2" row="1" column="1" colspan="2" >
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>147</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="2" colspan="3" >
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>KDoubleNumInput</class>
+ <extends>QWidget</extends>
+ <header>knuminput.h</header>
+ </customwidget>
+ <customwidget>
+ <class>KRestrictedLine</class>
+ <extends>KLineEdit</extends>
+ <header>krestrictedline.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>KeyFrameDialog_UI</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>KeyFrameDialog_UI</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>