Radium Engine  1.5.20
Loading...
Searching...
No Matches
TimelineTimeScale.cpp
1#include <Gui/Timeline/TimelineTimeScale.hpp>
2
3#include <QPainter>
4
5#include <Gui/Timeline/TimelineScrollArea.hpp>
6
7namespace Ra::Gui {
8
9TimelineTimeScale::TimelineTimeScale( QWidget* parent ) : QFrame( parent ) {}
10
11void TimelineTimeScale::setScrollArea( TimelineScrollArea* scrollArea ) {
12 m_scrollArea = scrollArea;
13}
14
15void TimelineTimeScale::paintEvent( QPaintEvent* event ) {
16 if ( m_scrollArea == nullptr ) {
17 QFrame::paintEvent( event );
18 return;
19 }
20
21 QPainter painter( this );
22 painter.setRenderHint( QPainter::Antialiasing );
23
24 painter.drawText( 0, 11, "sec" );
25 Scalar pixPerSec = m_scrollArea->getPixPerSec();
26 Scalar step = m_scrollArea->getStep();
27 for ( int i = 1; i < m_scrollArea->getNbInterval(); i++ ) {
28 int x = int( pixPerSec * step * i );
29 QString time = QString::number( double( ( i - 1 ) * step ) );
30 int dec = time.size() * 6 / 2;
31 painter.drawText( x - dec, 11, time );
32 }
33}
34
35} // namespace Ra::Gui