[Jahshaka-cvs] jah/jahwidgets/src/qt3/widgets timecodeLabel.h, NONE, 1.1 timelineSlider.cpp, 1.4, 1
Status: Beta
Brought to you by:
jahshaka
From: tim <tim...@us...> - 2006-07-19 11:06:47
|
Update of /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv27949/widgets Modified Files: timelineSlider.cpp timelineSlider.h valueFormatters.cpp valueFormatters.h widgets.cpp widgets.pri widgets.pro Added Files: timecodeLabel.h Log Message: - added timecodeLabel - some tab/space cleanup Index: widgets.cpp =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets/widgets.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- widgets.cpp 3 Jul 2006 14:41:00 -0000 1.9 +++ widgets.cpp 19 Jul 2006 11:06:42 -0000 1.10 @@ -1,4 +1,4 @@ - +/* -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ #include "widgets.h" @@ -17,6 +17,7 @@ #include "pushbutton.h" #include "slider.h" #include "progress.h" +#include "timecodeLabel.h" /// \todo move widget keys to widgets themselves... static const QString TIMELINE_SLIDER_KEY( "jahwidgets::qt3::TimelineSlider" ); @@ -24,6 +25,7 @@ static const QString PUSHBUTTON_KEY( "jahwidgets::qt3::Pushbutton" ); static const QString SLIDER_KEY( "jahwidgets::qt3::Slider" ); static const QString PROGRESS_KEY( "jahwidgets::qt3::Progress" ); +static const QString TIMECODE_LABEL_KEY( "jahwidgets::qt3::TimecodeLabel" ); static const QString JAHSHAKA_GROUP_KEY( "Jahshaka" ); namespace jahwidgets { namespace qt3 { @@ -39,6 +41,7 @@ keys_ << PUSHBUTTON_KEY; keys_ << SLIDER_KEY; keys_ << PROGRESS_KEY; + keys_ << TIMECODE_LABEL_KEY; return keys_; } @@ -46,23 +49,27 @@ { if ( classname == TIMELINE_SLIDER_KEY ) { - return new TimelineSlider( parent, name ); + return new TimelineSlider( parent, name ); } if ( classname == PLAYER_KEY ) { - return new delegator< Player >( parent, name ); + return new delegator< Player >( parent, name ); } if ( classname == PUSHBUTTON_KEY ) { - return new Pushbutton( parent, name ); + return new Pushbutton( parent, name ); } if ( classname == SLIDER_KEY ) { - return new Slider( parent, name ); + return new Slider( parent, name ); } if ( classname == PROGRESS_KEY ) { - return new Progress( parent, name ); + return new Progress( parent, name ); + } + if ( classname == TIMECODE_LABEL_KEY ) + { + return new TimecodeLabel( parent, name ); } return NULL; @@ -82,23 +89,27 @@ { if ( key == TIMELINE_SLIDER_KEY ) { - return "timelineSlider.h"; + return "timelineSlider.h"; } if ( key == PLAYER_KEY ) { - return "player.h"; + return "player.h"; } if ( key == PUSHBUTTON_KEY ) { - return "pushbutton.h"; + return "pushbutton.h"; } if ( key == SLIDER_KEY ) { - return "slider.h"; + return "slider.h"; } if ( key == PROGRESS_KEY ) { - return "progress.h"; + return "progress.h"; + } + if ( key == TIMECODE_LABEL_KEY ) + { + return "timecodeLabel.h"; } return QString(); @@ -108,23 +119,27 @@ { if ( key == TIMELINE_SLIDER_KEY ) { - return tr( "a basic timeline slider" ); + return tr( "a basic timeline slider" ); } if ( key == PLAYER_KEY ) { - return tr( "a video playing widget" ); + return tr( "a video playing widget" ); } if ( key == PUSHBUTTON_KEY ) { - return tr( "a pushbutton" ); + return tr( "a pushbutton" ); } if ( key == SLIDER_KEY ) { - return tr( "a slider" ); + return tr( "a slider" ); } if ( key == PROGRESS_KEY ) { - return tr( "a progresss bar capable of handling doubles" ); + return tr( "a progresss bar capable of handling doubles" ); + } + if ( key == TIMECODE_LABEL_KEY ) + { + return tr( "a label displaying a frame count as a timecode" ); } return QString(); --- NEW FILE: timecodeLabel.h --- /* -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ #ifndef TIMECODE_LABEL_H #define TIMECODE_LABEL_H // qt #include <qlabel.h> // local #include "valueFormatters.h" namespace jahwidgets { namespace qt3 { class TimecodeLabel : public QLabel { Q_OBJECT Q_PROPERTY( int fps READ fps WRITE setFPS ) Q_PROPERTY( int value READ value WRITE setValue ) public: TimecodeLabel( QWidget* parent = NULL, const char* name = NULL ) : QLabel( parent, name ), m_value( 0 ) { setFPS( 30 ); setValue( m_value ); } void setFPS( int fps, bool drop = true ) { m_formatter.setFPS( fps, drop ); emit pcosNotification(); } int fps() const { return m_formatter.fps(); } int value() const { return m_value; } signals: void pcosNotification(); public slots: void setValue( int v ) { m_value = v; QLabel::setText( m_formatter.convert( v ) ); emit pcosNotification(); } virtual void setText( const QString& s ) { setValue( s.toInt() ); emit pcosNotification(); } private: int m_value; TimecodeValueFormatter m_formatter; }; } } #endif // TIMECODE_LABEL_H Index: valueFormatters.cpp =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets/valueFormatters.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- valueFormatters.cpp 22 Jun 2006 09:44:36 -0000 1.2 +++ valueFormatters.cpp 19 Jul 2006 11:06:42 -0000 1.3 @@ -1,4 +1,4 @@ - +/* -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ #include "valueFormatters.h" // qt @@ -26,6 +26,11 @@ m_dropFrame = drop; } +int TimecodeValueFormatter::fps() const +{ + return m_fps; +} + int TimecodeValueFormatter::correct( int frame ) const { // rather clumsy... @@ -35,22 +40,22 @@ // Would be better to have properly bound properties. if ( m_dropFrame && m_fps == 30 && frame < 300000 ) { - // Courtesy of Mark McGrath - added by Charles Yates - const int min = m_fps * 60; - const int ten = m_fps * 600; - int prev_val = frame; - int prev_adj = 0; - - do - { - prev_val = frame; - int mins = frame / min; - int tens = frame / ten; - int adj = 2 * ( mins - tens ); - frame += adj - prev_adj; - prev_adj = adj; - } - while( frame != prev_val ); + // Courtesy of Mark McGrath - added by Charles Yates + const int min = m_fps * 60; + const int ten = m_fps * 600; + int prev_val = frame; + int prev_adj = 0; + + do + { + prev_val = frame; + int mins = frame / min; + int tens = frame / ten; + int adj = 2 * ( mins - tens ); + frame += adj - prev_adj; + prev_adj = adj; + } + while( frame != prev_val ); } return frame; } Index: timelineSlider.h =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets/timelineSlider.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- timelineSlider.h 18 Jul 2006 19:24:06 -0000 1.6 +++ timelineSlider.h 19 Jul 2006 11:06:42 -0000 1.7 @@ -1,4 +1,4 @@ - +/* -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ #ifndef TIMELINE_SLIDER_H #define TIMELINE_SLIDER_H @@ -16,66 +16,68 @@ /// timeline based slider class WIDGETS_DECLSPEC TimelineSlider : public QWidget { - Q_OBJECT - Q_PROPERTY( int value READ value WRITE setValue ) - Q_PROPERTY( int minimum READ minValue WRITE setMinValue ) - Q_PROPERTY( int maximum READ maxValue WRITE setMaxValue ) - Q_PROPERTY( bool pressed READ pressed ) + Q_OBJECT + Q_PROPERTY( int value READ value WRITE setValue ) + Q_PROPERTY( int minimum READ minValue WRITE setMinValue ) + Q_PROPERTY( int maximum READ maxValue WRITE setMaxValue ) + Q_PROPERTY( bool pressed READ pressed ) + Q_PROPERTY( int fps READ fps WRITE setFPS ) public: - TimelineSlider( QWidget* parent = 0, const char* name = 0 ); - ~TimelineSlider(); + TimelineSlider( QWidget* parent = 0, const char* name = 0 ); + ~TimelineSlider(); - /// maintain interface with SlickSlider - void setRange ( int minval, int maxval ); - void setMinValue ( int val ); - void setMaxValue ( int val ); - int minValue() const; - int maxValue() const; - int value() const; + /// maintain interface with SlickSlider + void setRange ( int minval, int maxval ); + void setMinValue ( int val ); + void setMaxValue ( int val ); + int minValue() const; + int maxValue() const; + int value() const; - void setFPS( int, bool drop = true ); + void setFPS( int, bool drop = true ); + int fps() const; - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; + virtual QSize sizeHint() const; + virtual QSize minimumSizeHint() const; bool pressed() const { return m_pressed; } public slots: - void setValue ( int val ); + void setValue ( int val ); signals: - void sliderPressed(); - void sliderReleased(); - void sliderMoved( int ); - void valueChanged( int ); - void minChanged( int ); - void maxChanged( int ); + void sliderPressed(); + void sliderReleased(); + void sliderMoved( int ); + void valueChanged( int ); + void minChanged( int ); + void maxChanged( int ); - void pcosNotification(); + void pcosNotification(); protected: - virtual void mousePressEvent( QMouseEvent *e ); - virtual void mouseReleaseEvent( QMouseEvent *e ); - virtual void mouseMoveEvent( QMouseEvent *e ); - virtual void paintEvent( QPaintEvent* ); - virtual void resizeEvent( QResizeEvent* ); + virtual void mousePressEvent( QMouseEvent *e ); + virtual void mouseReleaseEvent( QMouseEvent *e ); + virtual void mouseMoveEvent( QMouseEvent *e ); + virtual void paintEvent( QPaintEvent* ); + virtual void resizeEvent( QResizeEvent* ); private slots: - void onSliderPressed() - { + void onSliderPressed() + { m_pressed = true; emit pcosNotification(); - } + } - void onSliderReleased() - { + void onSliderReleased() + { m_pressed = false; emit pcosNotification(); - } + } private: - struct PrivateTimelineSlider; - std::auto_ptr< PrivateTimelineSlider > m_impl; + struct PrivateTimelineSlider; + std::auto_ptr< PrivateTimelineSlider > m_impl; bool m_pressed; }; Index: valueFormatters.h =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets/valueFormatters.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- valueFormatters.h 22 Jun 2006 09:44:36 -0000 1.2 +++ valueFormatters.h 19 Jul 2006 11:06:42 -0000 1.3 @@ -1,3 +1,4 @@ +/* -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ /******************************************************************************* ** ** The header file for the Jahshaka widget module @@ -18,29 +19,30 @@ class IntValueFormatter { public: - virtual ~IntValueFormatter() {} + virtual ~IntValueFormatter() {} - virtual QString convert( int ) const = 0; - virtual IntValueFormatter* clone() const = 0; + virtual QString convert( int ) const = 0; + virtual IntValueFormatter* clone() const = 0; }; //! A formatting object to convert a frame count into a timecode class TimecodeValueFormatter : public IntValueFormatter { public: - TimecodeValueFormatter(); - TimecodeValueFormatter( int fps, bool drop = true ); + TimecodeValueFormatter(); + TimecodeValueFormatter( int fps, bool drop = true ); - void setFPS( int fps, bool drop ); + void setFPS( int fps, bool drop ); + int fps() const; - virtual QString convert( int ) const; - virtual IntValueFormatter* clone() const; + virtual QString convert( int ) const; + virtual IntValueFormatter* clone() const; private: - int correct( int ) const; + int correct( int ) const; - int m_fps; - bool m_dropFrame; + int m_fps; + bool m_dropFrame; }; } } Index: widgets.pri =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets/widgets.pri,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- widgets.pri 3 Jul 2006 14:41:00 -0000 1.10 +++ widgets.pri 19 Jul 2006 11:06:42 -0000 1.11 @@ -2,11 +2,11 @@ VPATH += ../widgets INCLUDEPATH += ../ SOURCES += widgets.cpp \ - timelineSlider.cpp \ - valueFormatters.cpp \ - player.cpp \ - mediaPtr.cpp \ - scribbler.cpp + timelineSlider.cpp \ + valueFormatters.cpp \ + player.cpp \ + mediaPtr.cpp \ + scribbler.cpp HEADERS += widgets.h \ timelineSlider.h \ @@ -21,7 +21,8 @@ pushbutton.h \ scribbler.h \ slider.h \ - progress.h + progress.h \ + timecodeLabel.h Index: timelineSlider.cpp =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets/timelineSlider.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- timelineSlider.cpp 18 Jul 2006 19:24:06 -0000 1.4 +++ timelineSlider.cpp 19 Jul 2006 11:06:42 -0000 1.5 @@ -1,4 +1,4 @@ - +/* -*- mode: C; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ #include "timelineSlider.h" // local @@ -21,109 +21,109 @@ struct TimelineSlider::PrivateTimelineSlider { - PrivateTimelineSlider( TimelineSlider* p ) - : parent( p ), - min( 0 ), - max( 1000 ), - v( 0 ), - fps( 30 ), - drop( true ), - shouldTrack( false ), - fontDirty( true ), - requestedHeight( 0 ) - {} + PrivateTimelineSlider( TimelineSlider* p ) + : parent( p ), + min( 0 ), + max( 1000 ), + v( 0 ), + fps( 30 ), + drop( true ), + shouldTrack( false ), + fontDirty( true ), + requestedHeight( 0 ) + {} - void updateValue() - { - // ensure min and max are the right way around... - if ( min > max ) - { - std::swap( min, max ); - } + void updateValue() + { + // ensure min and max are the right way around... + if ( min > max ) + { + std::swap( min, max ); + } - // clamp value to range - int nv = std::max( std::min( v, max ), min ); - if ( nv != v ) - { - v = nv; - emit parent->valueChanged( v ); - emit parent->pcosNotification(); - } - } + // clamp value to range + int nv = std::max( std::min( v, max ), min ); + if ( nv != v ) + { + v = nv; + emit parent->valueChanged( v ); + emit parent->pcosNotification(); + } + } - int convertToValue( int val, int range ) const - { - return (int)( min + ( (double)val/range ) * ( max - min ) ); - } + int convertToValue( int val, int range ) const + { + return (int)( min + ( (double)val/range ) * ( max - min ) ); + } - int convertToPixel( int val, int range ) const - { - return (int)( range * ( val - min ) / (double)(max - min ) ); - } + int convertToPixel( int val, int range ) const + { + return (int)( range * ( val - min ) / (double)(max - min ) ); + } - QRect currentMarkerRect() const - { - return QRect( convertToPixel( v, parent->width() ) - parent->height(), 0, 2*parent->height(), parent->height() ); - } + QRect currentMarkerRect() const + { + return QRect( convertToPixel( v, parent->width() ) - parent->height(), 0, 2*parent->height(), parent->height() ); + } - QFont getFontForHeight( int h ) - { - if ( h < 5 ) - { - return font; - } + QFont getFontForHeight( int h ) + { + if ( h < 5 ) + { + return font; + } - if ( fontDirty || h != requestedHeight ) - { - QSize s; - QFont f( parent->font() ); - f.setPointSize( 1 ); + if ( fontDirty || h != requestedHeight ) + { + QSize s; + QFont f( parent->font() ); + f.setPointSize( 1 ); - while ( s.height() < h ) - { - f.setPointSize( f.pointSize() + 1 ); - QFontMetrics fm( f ); - s = fm.size( Qt::AlignLeft, "00" ); - } + while ( s.height() < h ) + { + f.setPointSize( f.pointSize() + 1 ); + QFontMetrics fm( f ); + s = fm.size( Qt::AlignLeft, "00" ); + } - // and back off one notch - font = f; - font.setPointSize( font.pointSize() - 1 ); + // and back off one notch + font = f; + font.setPointSize( font.pointSize() - 1 ); - requestedHeight = h; - fontDirty = false; - } + requestedHeight = h; + fontDirty = false; + } - return font; - } - + return font; + } + - TimelineSlider* parent; + TimelineSlider* parent; - // min, max, v are all in frames - int min; - int max; - int v; + // min, max, v are all in frames + int min; + int max; + int v; - int fps; - bool drop; + int fps; + bool drop; - // mouse tracking - bool shouldTrack; + // mouse tracking + bool shouldTrack; - // font calculations - bool fontDirty; - int requestedHeight; - QFont font; + // font calculations + bool fontDirty; + int requestedHeight; + QFont font; }; TimelineSlider::TimelineSlider( QWidget* parent, const char* name ) - : QWidget( parent, name ), - m_impl( new PrivateTimelineSlider( this ) ), + : QWidget( parent, name ), + m_impl( new PrivateTimelineSlider( this ) ), m_pressed( false ) { - setBackgroundMode( Qt::NoBackground ); - setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + setBackgroundMode( Qt::NoBackground ); + setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); connect( this, SIGNAL( sliderPressed() ), this, SLOT( onSliderPressed() ) ); connect( this, SIGNAL( sliderReleased() ), this, SLOT( onSliderReleased() ) ); } @@ -133,223 +133,229 @@ void TimelineSlider::setRange ( int minval, int maxval ) { - setMinValue( minval ); - setMaxValue( maxval ); + setMinValue( minval ); + setMaxValue( maxval ); } void TimelineSlider::setMinValue( int val ) { - if ( val > m_impl->max ) - { - m_impl->max = val; - } + if ( val > m_impl->max ) + { + m_impl->max = val; + } - m_impl->min = val; - m_impl->updateValue(); - emit minChanged( m_impl->min ); - emit pcosNotification(); - update(); + m_impl->min = val; + m_impl->updateValue(); + emit minChanged( m_impl->min ); + emit pcosNotification(); + update(); } void TimelineSlider::setMaxValue( int val ) { - if ( val < m_impl->min ) - { - m_impl->min = val; - } + if ( val < m_impl->min ) + { + m_impl->min = val; + } - m_impl->max = val; - m_impl->updateValue(); - emit maxChanged( m_impl->max ); - emit pcosNotification(); - update(); + m_impl->max = val; + m_impl->updateValue(); + emit maxChanged( m_impl->max ); + emit pcosNotification(); + update(); } int TimelineSlider::minValue() const { - return m_impl->min; + return m_impl->min; } int TimelineSlider::maxValue() const { - return m_impl->max; + return m_impl->max; } int TimelineSlider::value() const { - return m_impl->v; + return m_impl->v; } void TimelineSlider::setFPS( int fps, bool drop ) { - m_impl->fps = fps; - m_impl->drop = drop; - update(); + m_impl->fps = fps; + m_impl->drop = drop; + emit pcosNotification(); + update(); +} + +int TimelineSlider::fps() const +{ + return m_impl->fps; } QSize TimelineSlider::sizeHint() const { - return minimumSizeHint(); + return minimumSizeHint(); } QSize TimelineSlider::minimumSizeHint() const { - return QSize( 100, 25 ); + return QSize( 100, 25 ); } void TimelineSlider::setValue( int val ) { - if ( val == m_impl->v ) - { - return; - } + if ( val == m_impl->v ) + { + return; + } - m_impl->v = val; - m_impl->updateValue(); + m_impl->v = val; + m_impl->updateValue(); - if ( m_impl->shouldTrack ) - { - repaint(); - } - else - { - update(); - } + if ( m_impl->shouldTrack ) + { + repaint(); + } + else + { + update(); + } - emit valueChanged( m_impl->v ); - emit pcosNotification(); + emit valueChanged( m_impl->v ); + emit pcosNotification(); } void TimelineSlider::mousePressEvent( QMouseEvent* e ) { - emit sliderPressed(); - - QRect marker( m_impl->currentMarkerRect() ); - m_impl->shouldTrack = marker.contains( e->pos() ); + emit sliderPressed(); + + QRect marker( m_impl->currentMarkerRect() ); + m_impl->shouldTrack = marker.contains( e->pos() ); - e->accept(); + e->accept(); } void TimelineSlider::mouseReleaseEvent( QMouseEvent* e ) { - emit sliderReleased(); + emit sliderReleased(); - if ( m_impl->shouldTrack ) - setValue( m_impl->convertToValue( e->pos().x(), width() ) ); + if ( m_impl->shouldTrack ) + setValue( m_impl->convertToValue( e->pos().x(), width() ) ); - m_impl->shouldTrack = false; - e->accept(); + m_impl->shouldTrack = false; + e->accept(); } void TimelineSlider::mouseMoveEvent( QMouseEvent* e ) -{ - if ( e->state() & Qt::LeftButton && m_impl->shouldTrack ) - { - setValue( m_impl->convertToValue( e->pos().x(), width() ) ); - e->accept(); - emit sliderMoved( m_impl->v ); - } +{ + if ( e->state() & Qt::LeftButton && m_impl->shouldTrack ) + { + setValue( m_impl->convertToValue( e->pos().x(), width() ) ); + e->accept(); + emit sliderMoved( m_impl->v ); + } } static int findNiceInterval( int s, int fps ) { - // align to s - while ( s % fps ) - { - ++s; - } + // align to s + while ( s % fps ) + { + ++s; + } - return s; + return s; } void TimelineSlider::paintEvent ( QPaintEvent* e ) { - QWidget::paintEvent( e ); - - QPixmap buffer( width(), height() ); - QPainter p( &buffer ); + QWidget::paintEvent( e ); + + QPixmap buffer( width(), height() ); + QPainter p( &buffer ); - static const int PADDING = height() / 20; - static const int HALF_HEIGHT = height() / 2; + static const int PADDING = height() / 20; + static const int HALF_HEIGHT = height() / 2; - // use a fixed font size - QFont f( m_impl->getFontForHeight( HALF_HEIGHT - 2*PADDING ) ); - p.setFont( f ); + // use a fixed font size + QFont f( m_impl->getFontForHeight( HALF_HEIGHT - 2*PADDING ) ); + p.setFont( f ); - // fill the background - p.setBrush( colorGroup().button().light() ); - p.setPen( colorGroup().shadow() ); - p.drawRect( 0, 0, width(), height() ); + // fill the background + p.setBrush( colorGroup().button().light() ); + p.setPen( colorGroup().shadow() ); + p.drawRect( 0, 0, width(), height() ); - // split the timeline vertically, draw timecodes in the lower half - TimecodeValueFormatter fmt( m_impl->fps, m_impl->drop ); - QFontMetrics fm( p.fontMetrics() ); + // split the timeline vertically, draw timecodes in the lower half + TimecodeValueFormatter fmt( m_impl->fps, m_impl->drop ); + QFontMetrics fm( p.fontMetrics() ); - // find the minimum spacing: two timecodes - QSize fontSize = fm.size( Qt::AlignLeft, fmt.convert( 0 ) ); - int spacing = m_impl->convertToValue( 2 * fontSize.width(), width() ); + // find the minimum spacing: two timecodes + QSize fontSize = fm.size( Qt::AlignLeft, fmt.convert( 0 ) ); + int spacing = m_impl->convertToValue( 2 * fontSize.width(), width() ); - // round up to next nice value - spacing = std::max( spacing, m_impl->fps ); - spacing = findNiceInterval( spacing, m_impl->fps ); + // round up to next nice value + spacing = std::max( spacing, m_impl->fps ); + spacing = findNiceInterval( spacing, m_impl->fps ); - // draw timecodes - p.setBrush( colorGroup().button() ); - p.setPen( QPen::NoPen ); + // draw timecodes + p.setBrush( colorGroup().button() ); + p.setPen( QPen::NoPen ); - QRect lower( 1, HALF_HEIGHT, width() - 2, HALF_HEIGHT ); - p.drawRect( lower ); - - int t = findNiceInterval( m_impl->min, m_impl->fps ); + QRect lower( 1, HALF_HEIGHT, width() - 2, HALF_HEIGHT ); + p.drawRect( lower ); + + int t = findNiceInterval( m_impl->min, m_impl->fps ); - p.setPen( colorGroup().text() ); - while ( t < m_impl->max ) - { - int pos = m_impl->convertToPixel( t, width() ); - p.drawLine( pos, 1, pos, height() - 1 ); - fontSize = fm.size( Qt::AlignLeft, fmt.convert( t ) ); - p.drawText( pos + PADDING, - height() - PADDING - fontSize.height(), - fontSize.width(), - fontSize.height(), - Qt::AlignLeft, fmt.convert( t ) ); + p.setPen( colorGroup().text() ); + while ( t < m_impl->max ) + { + int pos = m_impl->convertToPixel( t, width() ); + p.drawLine( pos, 1, pos, height() - 1 ); + fontSize = fm.size( Qt::AlignLeft, fmt.convert( t ) ); + p.drawText( pos + PADDING, + height() - PADDING - fontSize.height(), + fontSize.width(), + fontSize.height(), + Qt::AlignLeft, fmt.convert( t ) ); - t += spacing; - } + t += spacing; + } - // draw marker - const int HALF_MARKER_WIDTH = HALF_HEIGHT/2; - QPointArray marker( 5 ); - marker.putPoints( 0, 5, - HALF_MARKER_WIDTH, 1, - HALF_MARKER_WIDTH, HALF_MARKER_WIDTH, - 0, HALF_HEIGHT, - -HALF_MARKER_WIDTH, HALF_MARKER_WIDTH, - -HALF_MARKER_WIDTH, 1 ); - - p.setPen( QColor( 150, 0, 50 ) ); - p.setBrush( QColor( 150, 0, 50 ) ); + // draw marker + const int HALF_MARKER_WIDTH = HALF_HEIGHT/2; + QPointArray marker( 5 ); + marker.putPoints( 0, 5, + HALF_MARKER_WIDTH, 1, + HALF_MARKER_WIDTH, HALF_MARKER_WIDTH, + 0, HALF_HEIGHT, + -HALF_MARKER_WIDTH, HALF_MARKER_WIDTH, + -HALF_MARKER_WIDTH, 1 ); + + p.setPen( QColor( 150, 0, 50 ) ); + p.setBrush( QColor( 150, 0, 50 ) ); - const int markerPos = m_impl->convertToPixel( m_impl->v, width() ); - p.translate( markerPos, 0 ); - p.drawPolygon( marker ); - p.drawLine( 0, 1, 0, height() - 1 ); - fontSize = fm.size( Qt::AlignLeft, fmt.convert( m_impl->v ) ); - p.drawText( HALF_MARKER_WIDTH + PADDING, - 0, - fontSize.width(), - fontSize.height(), - Qt::AlignLeft, fmt.convert( m_impl->v ) ); + const int markerPos = m_impl->convertToPixel( m_impl->v, width() ); + p.translate( markerPos, 0 ); + p.drawPolygon( marker ); + p.drawLine( 0, 1, 0, height() - 1 ); + fontSize = fm.size( Qt::AlignLeft, fmt.convert( m_impl->v ) ); + p.drawText( HALF_MARKER_WIDTH + PADDING, + 0, + fontSize.width(), + fontSize.height(), + Qt::AlignLeft, fmt.convert( m_impl->v ) ); - bitBlt( this, 0, 0, - &buffer, 0, 0, width(), height(), - Qt::CopyROP ); + bitBlt( this, 0, 0, + &buffer, 0, 0, width(), height(), + Qt::CopyROP ); } void TimelineSlider::resizeEvent( QResizeEvent* ) { - m_impl->fontDirty = true; + m_impl->fontDirty = true; } } } Index: widgets.pro =================================================================== RCS file: /cvsroot/jahshaka/jah/jahwidgets/src/qt3/widgets/widgets.pro,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- widgets.pro 3 Jul 2006 14:41:00 -0000 1.11 +++ widgets.pro 19 Jul 2006 11:06:42 -0000 1.12 @@ -55,6 +55,7 @@ pushbutton.h \ slider.h \ progress.h \ + timecodeLabel.h \ drop_delegate.hpp \ key_delegate.hpp \ mouse_delegate.hpp \ |