// Build monitor for chapters
if (m_isPal) m_tc.setFormat(25);
- else m_tc.setFormat(30000.0 / 1001, true);
+ else m_tc.setFormat(30000.0 / 1001);
m_manager = new MonitorManager(this);
m_manager->resetProfiles(m_tc);
m_tc.setFormat(25);
profile = "dv_pal";
} else {
- m_tc.setFormat(30000.0 / 1001, true);
+ m_tc.setFormat(30000.0 / 1001);
profile = "dv_ntsc";
}
if (isWide) profile.append("_wide");
connect(buttonDelete , SIGNAL(clicked()) , this , SLOT(slotDeleteFrame()));
connect(buttonAdd , SIGNAL(clicked()) , this , SLOT(slotAddFrame()));
connect(m_scene, SIGNAL(actionFinished()), this, SLOT(slotUpdateTransitionProperties()));
- connect(m_scene, SIGNAL(doubleClickEvent()), this, SLOT(slotGeometry()));
buttonhcenter->setIcon(KIcon("kdenlive-align-hor"));
buttonhcenter->setToolTip(i18n("Align item horizontally"));
void Geometryval::slotTransparencyChanged(int transp)
{
- int pos = m_timePos.value();
+ int pos = m_timePos.getValue();
Mlt::GeometryItem item;
int error = m_geom->fetch(&item, pos);
if (error || item.key() == false) {
void Geometryval::slotPositionChanged(int pos, bool seek)
{
if (pos == -1) {
- pos = m_timePos.value();
+ pos = m_timePos.getValue();
}
+ kDebug() << "// POS CHANGED: " << pos << ", SEK: " << seek;
if (seek && KdenliveSettings::transitionfollowcursor()) emit seekToPos(pos + m_startPoint);
m_timePos.setValue(pos);
//spinPos->setValue(pos);
+ m_helper->blockSignals(true);
m_helper->setValue(pos);
+ m_helper->blockSignals(false);
Mlt::GeometryItem item;
int error = m_geom->fetch(&item, pos);
if (error || item.key() == false) {
{
// check there is more than one keyframe
Mlt::GeometryItem item;
- int frame = m_timePos.value();
+ int frame = m_timePos.getValue();
if (pos == -1) pos = frame;
int error = m_geom->next_key(&item, pos + 1);
void Geometryval::slotAddFrame(int pos)
{
- int frame = m_timePos.value();
+ int frame = m_timePos.getValue();
if (pos == -1) pos = frame;
Mlt::GeometryItem item;
item.frame(pos);
void Geometryval::slotUpdateTransitionProperties()
{
- int pos = m_timePos.value();
+ int pos = m_timePos.getValue();
Mlt::GeometryItem item;
int error = m_geom->next_key(&item, pos);
if (error || item.frame() != pos) {
bool Geometryval::keyframeSelected()
{
Mlt::GeometryItem item;
- int pos = m_timePos.value();
+ int pos = m_timePos.getValue();
if (m_geom->fetch(&item, pos) || item.key() == false) return false;
return true;
}
m_width = m_profile.width;
m_height = m_profile.height;
kDebug() << "Kdenlive document, init timecode from path: " << path << ", " << m_fps;
- if (m_fps / 1.00 == (int)m_fps) m_timecode.setFormat(m_fps);
- else m_timecode.setFormat(m_fps, true);
+ m_timecode.setFormat(m_fps);
return (current_fps != m_fps);
}
connect(this, SIGNAL(updateThumb()), m_previewTimer, SLOT(start()));
case IMAGE:
case TEXT:
- p = QPixmap::fromImage(KThumb::getFrame(m_producer, m_in->value(), width, 100));
+ p = QPixmap::fromImage(KThumb::getFrame(m_producer, m_in->getValue(), width, 100));
break;
case COLOR:
colour = colour.replace(0, 2, "#");
void MarkerDialog::slotUpdateThumb()
{
m_previewTimer->stop();
- int pos = m_in->value();
+ int pos = m_in->getValue();
int width = 100.0 * m_dar;
if (width % 2 == 1) width++;
QPixmap p = QPixmap::fromImage(KThumb::getFrame(m_producer, pos, width, 100));
void Monitor::slotSeek()
{
- slotSeek(m_timePos->value());
+ slotSeek(m_timePos->getValue());
}
void Monitor::slotSeek(int pos)
void PositionEdit::slotUpdatePosition()
{
m_slider->blockSignals(true);
- m_slider->setValue(m_display->value());
+ m_slider->setValue(m_display->getValue());
m_slider->blockSignals(false);
emit parameterChanged();
}
#include "timecode.h"
-Timecode::Timecode(Formats format, double framesPerSecond, bool dropFrame)
+Timecode::Timecode(Formats format, double framesPerSecond)
{
m_validator = new QRegExpValidator(0);
- setFormat(framesPerSecond, dropFrame, format);
+ setFormat(framesPerSecond, format);
}
Timecode::~Timecode()
{
}
-void Timecode::setFormat(double framesPerSecond, bool dropFrame, Formats format)
+void Timecode::setFormat(double framesPerSecond, Formats format)
{
m_displayedFramesPerSecond = (int)(framesPerSecond + 0.5);
- m_dropFrameTimecode = dropFrame;
+ m_dropFrameTimecode = (framesPerSecond / 1.00 != (int)framesPerSecond) ;
m_format = format;
m_realFps = framesPerSecond;
- if (dropFrame) {
+ if (m_dropFrameTimecode) {
m_dropFrames = round(m_realFps * .066666); //Number of frames to drop on the minute marks is the nearest integer to 6% of the framerate
m_framesPer10Minutes = round(m_realFps * 600); //Number of frames per ten minutes
}
const QString Timecode::getTimecodeHH_MM_SS_FF(const GenTime & time) const
{
- if (m_dropFrameTimecode)
+ if (m_dropFrameTimecode) {
return getTimecodeDropFrame(time);
-
+ }
return getTimecodeHH_MM_SS_FF((int) time.frames(m_realFps));
}
return text;
}
-QString Timecode::getTimecodeHH_MM_SS_HH(const GenTime & time) const
+const QString Timecode::getTimecodeHH_MM_SS_HH(const GenTime & time) const
{
int hundredths = (int)(time.seconds() * 100);
int seconds = hundredths / 100;
return text;
}
-QString Timecode::getTimecodeFrames(const GenTime & time) const
+const QString Timecode::getTimecodeFrames(const GenTime & time) const
{
return QString::number(time.frames(m_realFps));
}
-QString Timecode::getTimecodeSeconds(const GenTime & time) const
+const QString Timecode::getTimecodeSeconds(const GenTime & time) const
{
return QString::number(time.seconds());
}
-QString Timecode::getTimecodeDropFrame(const GenTime & time) const
+const QString Timecode::getTimecodeDropFrame(const GenTime & time) const
{
return getTimecodeDropFrame((int)time.frames(m_realFps));
}
-QString Timecode::getTimecodeDropFrame(int framenumber) const
+const QString Timecode::getTimecodeDropFrame(int framenumber) const
{
//CONVERT A FRAME NUMBER TO DROP FRAME TIMECODE
//Based on code by David Heidelberger, adapted from Andrew Duncan
int d = floor(framenumber / m_framesPer10Minutes);
int m = framenumber % m_framesPer10Minutes;
- if (m > 1) {
- framenumber = framenumber + (m_dropFrames * 9 * d) + m_dropFrames * (floor((m - m_dropFrames) / (round(m_realFps * 60) - m_dropFrames)));
+ int framesPerMinute = round(m_realFps * 60) - m_dropFrames; //Number of frames per minute is the round of the framerate * 60 minus the number of dropped frames
+
+ if (m > m_dropFrames) {
+ framenumber += (m_dropFrames * 9 * d) + m_dropFrames * (floor((m - m_dropFrames) / (round(m_realFps * 60) - m_dropFrames)));
} else {
- framenumber = framenumber + m_dropFrames * 9 * d;
+ framenumber += m_dropFrames * 9 * d;
}
int frames = framenumber % m_displayedFramesPerSecond;
public:
enum Formats { HH_MM_SS_FF, HH_MM_SS_HH, Frames, Seconds };
- explicit Timecode(Formats format = HH_MM_SS_FF, double framesPerSecond = 25,
- bool dropFrame = false);
+ explicit Timecode(Formats format = HH_MM_SS_FF, double framesPerSecond = 25);
/**
* Set the current timecode format; this is the output format for this timecode.
*/
- void setFormat(double framesPerSecond, bool dropFrame = false,
- Formats format = HH_MM_SS_FF);
+ void setFormat(double framesPerSecond, Formats format = HH_MM_SS_FF);
Formats format() const {
return m_format;
const QString getTimecodeHH_MM_SS_FF(const GenTime & time) const;
const QString getTimecodeHH_MM_SS_FF(int frames) const;
- QString getTimecodeHH_MM_SS_HH(const GenTime & time) const;
- QString getTimecodeFrames(const GenTime & time) const;
- QString getTimecodeSeconds(const GenTime & time) const;
- QString getTimecodeDropFrame(const GenTime & time) const;
- QString getTimecodeDropFrame(int framenumber) const;
+ const QString getTimecodeHH_MM_SS_HH(const GenTime & time) const;
+ const QString getTimecodeFrames(const GenTime & time) const;
+ const QString getTimecodeSeconds(const GenTime & time) const;
+ const QString getTimecodeDropFrame(const GenTime & time) const;
+ const QString getTimecodeDropFrame(int framenumber) const;
};
#endif
QFontMetrics fm = lineedit->fontMetrics();
lineedit->setMaximumWidth(fm.width("88:88:88:888"));
setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding);
-
+
setTimeCodeFormat(KdenliveSettings::frametimecode(), true);
connect(uparrow, SIGNAL(clicked()), this, SLOT(slotValueUp()));
void TimecodeDisplay::slotValueUp()
{
- int val = value();
+ int val = getValue();
val++;
setValue(val);
lineedit->clearFocus();
void TimecodeDisplay::slotValueDown()
{
- int val = value();
+ int val = getValue();
val--;
setValue(val);
lineedit->clearFocus();
void TimecodeDisplay::setTimeCodeFormat(bool frametimecode, bool init)
{
if (!init && m_frametimecode == frametimecode) return;
- int val = value();
+ int val = getValue();
m_frametimecode = frametimecode;
if (m_frametimecode) {
QIntValidator *valid = new QIntValidator(lineedit);
return m_minimum;
}
-int TimecodeDisplay::value() const
+int TimecodeDisplay::getValue() const
{
if (m_frametimecode) return lineedit->text().toInt();
else return m_timecode.getFrameCount(lineedit->text());
GenTime TimecodeDisplay::gentime() const
{
- return GenTime(value(), m_timecode.fps());
+ return GenTime(getValue(), m_timecode.fps());
}
Timecode TimecodeDisplay::timecode() const
if (m_maximum > m_minimum && value > m_maximum)
value = m_maximum;
+ if (value == getValue()) return;
downarrow->setEnabled(value > m_minimum);
uparrow->setEnabled(m_maximum < m_minimum || value < m_maximum);
if (m_frametimecode)
lineedit->setText(QString::number(value));
- else
- lineedit->setText(m_timecode.getTimecodeFromFrames(value));
+ else {
+ QString v = m_timecode.getTimecodeFromFrames(value);
+ kDebug() << "// SETTING TO: " << value << " = " << v << "( " << m_timecode.fps();
+ lineedit->setText(v);
+ }
}
void TimecodeDisplay::setValue(GenTime value)
void setRange(int min, int max);
/** @brief Returns the current input in frames. */
- int value() const;
+ int getValue() const;
/** @brief Returns the current input as a GenTime object. */
GenTime gentime() const;