+/***************************************************************************
+ * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
+ * *
+ * This program 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. *
+ * *
+ * This program 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 this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
#include <QMouseEvent>
#include <QStylePainter>
#define END_LABEL_X 4
#define END_LABEL_Y (END_LABEL_X + LABEL_SIZE - 2)
-#define FRAME_SIZE 90
-
+#include "definitions.h"
const int CustomRuler::comboScale[] =
{ 1, 2, 5, 10, 25, 50, 125, 250, 500, 725, 1500, 3000, 6000,
void CustomRuler::mousePressEvent ( QMouseEvent * event )
{
int pos = event->x();
- slotNewValue( pos );
- kDebug()<<pos;
+ slotMoveCursor( pos, true );
+}
+
+// virtual
+void CustomRuler::mouseMoveEvent ( QMouseEvent * event )
+{
+ int pos = event->x();
+ slotMoveCursor( pos, true );
+}
+
+void CustomRuler::slotMoveRuler(int newPos)
+{
+ int diff = offset() - newPos;
+ KRuler::slotNewOffset(newPos);
+ KRuler::slotNewValue(value() + diff);
}
-void CustomRuler::slotNewValue ( int _value )
+void CustomRuler::slotMoveCursor( int _value, bool emitSignal )
{
- m_cursorPosition = _value / pixelPerMark();
- KRuler::slotNewValue(_value);
+ KRuler::slotNewValue(_value );
+ m_cursorPosition= (_value + offset()) / pixelPerMark();
+ if (emitSignal) emit cursorMoved(m_cursorPosition / FRAME_SIZE);
+}
+
+
+void CustomRuler::slotNewValue ( int _value, bool emitSignal )
+{
+ m_cursorPosition= _value / pixelPerMark();
+ if (emitSignal) emit cursorMoved(m_cursorPosition / FRAME_SIZE);
+ KRuler::slotNewValue(_value * pixelPerMark() - offset());
}
void CustomRuler::setPixelPerMark (double rate)
QStylePainter p(this);
- int value = this->value(),
- minval = minimum(),
- maxval;
- maxval = maximum()
- + offset() - endOffset();
+ int value = this->value();
+ int minval = minimum();
+ int maxval = maximum() + offset() - endOffset();
//ioffsetval = value-offset;
// pixelpm = (int)ppm;
offsetmin=(double)(minval-offset()),
offsetmax=(double)(maxval-offset()),
fontOffset = (((double)minval)>offsetmin)?(double)minval:offsetmin;
-
+ QRect bg = QRect(offsetmin, 0, offsetmax, height());
+
+ QPalette palette;
+ //p.fillRect(bg, palette.light());
// draw labels
QFont font = p.font();
font.setPointSize(LABEL_SIZE);
p.setFont( font );
+ p.setPen(palette.dark().color());
// draw littlemarklabel
// draw mediummarklabel
}*/
// draw pointer
- if (showPointer()) {
+ if (showPointer() && value > 0) {
QPolygon pa(4);
pa.setPoints(3, value-6, 9, value+6, 9, value/*+0*/, 16);
p.setBrush( QBrush(Qt::yellow) );