-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implements #2635: Draws a transparent rectangle in the loop area (plus CSS exposure) #2657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michaelgregorius
merged 14 commits into
LMMS:master
from
michaelgregorius:2635-loop-area-rectangle
Jun 12, 2016
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
740a6d9
Draws a transparent rectangle in the loop area (plus CSS exposure)
michaelgregorius 92b273a
Enable setting the background of the time line from the stylesheet
michaelgregorius ce20dad
Implements some remarks from code reviews
michaelgregorius 38ff02f
Fix heights of the time line in Automation Editor and Piano Roll
michaelgregorius f41b74b
Implements some remarks from a code review
michaelgregorius cba2305
Draw numbers in the time line more centered
michaelgregorius c856205
Draw the loop rectangle behind everything and use a green color
michaelgregorius 6003bd0
Add more properties for the loop rectangle and remove the old pixmaps
michaelgregorius 20eb51c
Change the order in which the elements of the loop rectangle are drawn
michaelgregorius 069ca95
Bring back the playhead marker
michaelgregorius ca6e8f0
Add a padding property for the loop rectangle / document the style sheet
michaelgregorius e8b8f66
Remove the gradient for the TimeLineWidget in the new default theme
michaelgregorius 81b9302
Remove borders and gradients for the loop rectangle in the default theme
michaelgregorius 8981310
Change color of inactive loop rectangles to #3B424A
michaelgregorius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,13 +48,20 @@ | |
|
|
||
|
|
||
| QPixmap * TimeLineWidget::s_posMarkerPixmap = NULL; | ||
| QPixmap * TimeLineWidget::s_loopPointBeginPixmap = NULL; | ||
| QPixmap * TimeLineWidget::s_loopPointEndPixmap = NULL; | ||
|
|
||
| TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppt, | ||
| Song::PlayPos & pos, const MidiTime & begin, | ||
| QWidget * parent ) : | ||
| QWidget( parent ), | ||
| m_inactiveLoopColor( 52, 63, 53, 64 ), | ||
| m_inactiveLoopBrush( QColor( 255, 255, 255, 32 ) ), | ||
| m_inactiveLoopInnerColor( 255, 255, 255, 32 ), | ||
| m_activeLoopColor( 52, 63, 53, 255 ), | ||
| m_activeLoopBrush( QColor( 55, 141, 89 ) ), | ||
| m_activeLoopInnerColor( 74, 155, 100, 255 ), | ||
| m_loopRectangleVerticalPadding( 1 ), | ||
| m_barLineColor( 192, 192, 192 ), | ||
| m_barNumberColor( m_barLineColor.darker( 120 ) ), | ||
| m_autoScroll( AutoScrollEnabled ), | ||
| m_loopPoints( LoopPointsDisabled ), | ||
| m_behaviourAtStop( BackToZero ), | ||
|
|
@@ -77,20 +84,9 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppt, | |
| s_posMarkerPixmap = new QPixmap( embed::getIconPixmap( | ||
| "playpos_marker" ) ); | ||
| } | ||
| if( s_loopPointBeginPixmap == NULL ) | ||
| { | ||
| s_loopPointBeginPixmap = new QPixmap( embed::getIconPixmap( | ||
| "loop_point_b" ) ); | ||
| } | ||
| if( s_loopPointEndPixmap == NULL ) | ||
| { | ||
| s_loopPointEndPixmap = new QPixmap( embed::getIconPixmap( | ||
| "loop_point_e" ) ); | ||
| } | ||
|
|
||
| setAttribute( Qt::WA_OpaquePaintEvent, true ); | ||
| move( 0, yoff ); | ||
| setFixedHeight( 18 ); | ||
|
|
||
| m_xOffset -= s_posMarkerPixmap->width() / 2; | ||
|
|
||
|
|
@@ -224,55 +220,71 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) | |
| { | ||
| QPainter p( this ); | ||
|
|
||
| QColor bg_color = QApplication::palette().color( QPalette::Active, | ||
| QPalette::Background ); | ||
| QLinearGradient g( 0, 0, 0, height() ); | ||
| g.setColorAt( 0, bg_color.lighter( 150 ) ); | ||
| g.setColorAt( 1, bg_color.darker( 150 ) ); | ||
| p.fillRect( 0, 0, width(), height(), g ); | ||
| // Draw background | ||
| p.fillRect( 0, 0, width(), height(), p.background() ); | ||
|
|
||
| // Clip so that we only draw everything starting from the offset | ||
| p.setClipRect( m_xOffset, 0, width() - m_xOffset, height() ); | ||
| p.setPen( QColor( 0, 0, 0 ) ); | ||
|
|
||
| p.setOpacity( loopPointsEnabled() ? 0.9 : 0.2 ); | ||
| p.drawPixmap( markerX( loopBegin() )+2, 2, *s_loopPointBeginPixmap ); | ||
| p.drawPixmap( markerX( loopEnd() )+2, 2, *s_loopPointEndPixmap ); | ||
| p.setOpacity( 1.0 ); | ||
|
|
||
| // Draw the loop rectangle | ||
| int const & loopRectMargin = getLoopRectangleVerticalPadding(); | ||
| int const loopRectHeight = this->height() - 2 * loopRectMargin; | ||
| int const loopStart = markerX( loopBegin() ) + 8; | ||
| int const loopEndR = markerX( loopEnd() ) + 9; | ||
| int const loopRectWidth = loopEndR - loopStart; | ||
|
|
||
| tact_t tact_num = m_begin.getTact(); | ||
| int x = m_xOffset + s_posMarkerPixmap->width() / 2 - | ||
| ( ( static_cast<int>( m_begin * m_ppt ) / MidiTime::ticksPerTact() ) % static_cast<int>( m_ppt ) ); | ||
| bool const loopPointsActive = loopPointsEnabled(); | ||
|
|
||
| QColor lineColor( 192, 192, 192 ); | ||
| QColor tactColor( lineColor.darker( 120 ) ); | ||
| // Draw the main rectangle (inner fill only) | ||
| QRect outerRectangle( loopStart, loopRectMargin, loopRectWidth - 1, loopRectHeight - 1 ); | ||
| p.fillRect( outerRectangle, loopPointsActive ? getActiveLoopBrush() : getInactiveLoopBrush()); | ||
|
|
||
| // Set font to half of the widgets size (in pixels) | ||
| // Draw the bar lines and numbers | ||
| // Activate hinting on the font | ||
| QFont font = p.font(); | ||
| font.setPixelSize( this->height() * 0.5 ); | ||
| p.setFont( font ); | ||
| font.setHintingPreference( QFont::PreferFullHinting ); | ||
| p.setFont(font); | ||
| int const fontAscent = p.fontMetrics().ascent(); | ||
| int const fontHeight = p.fontMetrics().height(); | ||
|
|
||
| QColor const & barLineColor = getBarLineColor(); | ||
| QColor const & barNumberColor = getBarNumberColor(); | ||
|
|
||
| tact_t barNumber = m_begin.getTact(); | ||
| int const x = m_xOffset + s_posMarkerPixmap->width() / 2 - | ||
| ( ( static_cast<int>( m_begin * m_ppt ) / MidiTime::ticksPerTact() ) % static_cast<int>( m_ppt ) ); | ||
|
|
||
| for( int i = 0; x + i * m_ppt < width(); ++i ) | ||
| { | ||
| const int cx = x + qRound( i * m_ppt ); | ||
| p.setPen( lineColor ); | ||
| p.drawLine( cx, 5, cx, height() - 6 ); | ||
| ++tact_num; | ||
| if( ( tact_num - 1 ) % | ||
| ++barNumber; | ||
| if( ( barNumber - 1 ) % | ||
| qMax( 1, qRound( 1.0f / 3.0f * | ||
| MidiTime::ticksPerTact() / m_ppt ) ) == 0 ) | ||
| { | ||
| const QString s = QString::number( tact_num ); | ||
| p.setPen( tactColor ); | ||
| p.drawText( cx + qRound( ( m_ppt - p.fontMetrics(). | ||
| width( s ) ) / 2 ), | ||
| height() - p.fontMetrics().ascent() / 2, s ); | ||
| const int cx = x + qRound( i * m_ppt ); | ||
| p.setPen( barLineColor ); | ||
| p.drawLine( cx, 5, cx, height() - 6 ); | ||
|
|
||
| const QString s = QString::number( barNumber ); | ||
| p.setPen( barNumberColor ); | ||
| p.drawText( cx + 5, ((height() - fontHeight) / 2) + fontAscent, s ); | ||
| } | ||
| } | ||
|
|
||
| // Draw the main rectangle (outer border) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michaelgregorius you accidentaly removed the playhead marker pixmap here:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| p.setPen( loopPointsActive ? getActiveLoopColor() : getInactiveLoopColor() ); | ||
| p.setBrush( Qt::NoBrush ); | ||
| p.drawRect( outerRectangle ); | ||
|
|
||
| // Draw the inner border outline (no fill) | ||
| QRect innerRectangle = outerRectangle.adjusted( 1, 1, -1, -1 ); | ||
| p.setPen( loopPointsActive ? getActiveLoopInnerColor() : getInactiveLoopInnerColor() ); | ||
| p.setBrush( Qt::NoBrush ); | ||
| p.drawRect( innerRectangle ); | ||
|
|
||
| // Draw the position marker | ||
| p.setOpacity( 0.6 ); | ||
| p.drawPixmap( m_posMarkerX, height() - s_posMarkerPixmap->height(), | ||
| *s_posMarkerPixmap ); | ||
| p.drawPixmap( m_posMarkerX, height() - s_posMarkerPixmap->height(), *s_posMarkerPixmap ); | ||
| } | ||
|
|
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to add this here:
to reinstate the old look.
Also, shouldn't
be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reinstated the old look. I have to admit that I like the flat look better but that's something for theme designers I guess. :)
I have also removed the
TimeLineentry from thestyle.css.