-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
WIP: Redesign time display #5118
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
29b0786
Move tempo spin box next to time display
winniehell 6eb774c
Replace QHBoxLayout with QGridLayout in TimeDisplayWidget
winniehell ede9765
Replace major LCD in TimeDisplayWidget with QLabels
winniehell 9e40b2c
Replace minor LCD in TimeDisplayWidget with QLabels
winniehell 52faff6
Replace milliseconds LCD in TimeDisplayWidget with QLabels
winniehell de37efa
Set colors and font sizes for TimeDisplayWidget
winniehell 1cbb7ae
Add margin and padding to TimeDisplayWidget
winniehell 6857333
Add leading zeros and separators to TimeDisplayWidget
winniehell 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
This file contains 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 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 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 |
---|---|---|
|
@@ -34,20 +34,42 @@ | |
|
||
|
||
TimeDisplayWidget::TimeDisplayWidget() : | ||
QWidget(), | ||
QFrame(), | ||
m_displayMode( MinutesSeconds ), | ||
m_spinBoxesLayout( this ), | ||
m_majorLCD( 4, this ), | ||
m_minorLCD( 2, this ), | ||
m_milliSecondsLCD( 3, this ) | ||
m_majorLabel( this ), | ||
m_majorValue( this ), | ||
m_minorLabel( this ), | ||
m_minorValue( this ), | ||
m_milliSecondsLabel( this ), | ||
m_milliSecondsValue( this ) | ||
{ | ||
m_spinBoxesLayout.setSpacing( 0 ); | ||
m_spinBoxesLayout.setMargin( 0 ); | ||
m_spinBoxesLayout.addWidget( &m_majorLCD ); | ||
m_spinBoxesLayout.addWidget( &m_minorLCD ); | ||
m_spinBoxesLayout.addWidget( &m_milliSecondsLCD ); | ||
|
||
setMaximumHeight( 32 ); | ||
m_spinBoxesLayout.addWidget( &m_majorLabel, 0, 0 ); | ||
m_spinBoxesLayout.addWidget( &m_majorValue, 1, 0 ); | ||
m_spinBoxesLayout.addWidget( &m_minorLabel, 0, 1 ); | ||
m_spinBoxesLayout.addWidget( &m_minorValue, 1, 1 ); | ||
m_spinBoxesLayout.addWidget( &m_milliSecondsLabel, 0, 2 ); | ||
m_spinBoxesLayout.addWidget( &m_milliSecondsValue, 1, 2 ); | ||
|
||
this->setStyleSheet( "TimeDisplayWidget { border-radius: 4px; background-color: rgba(0,0,0,70); margin: 8px; padding: 4px; }" ); | ||
|
||
QString labelStyle = "font-size: 10px;"; | ||
QString valueStyle = "color: #0bd556; font-size: 24px;"; | ||
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. This should go in the stylesheet. |
||
|
||
m_majorLabel.setAlignment(Qt::AlignRight); | ||
m_majorLabel.setStyleSheet(labelStyle); | ||
m_majorValue.setAlignment(Qt::AlignRight); | ||
m_majorValue.setStyleSheet(valueStyle); | ||
m_minorLabel.setAlignment(Qt::AlignRight); | ||
m_minorLabel.setStyleSheet(labelStyle); | ||
m_minorValue.setAlignment(Qt::AlignRight); | ||
m_minorValue.setStyleSheet(valueStyle); | ||
m_milliSecondsLabel.setAlignment(Qt::AlignRight); | ||
m_milliSecondsLabel.setStyleSheet(labelStyle); | ||
m_milliSecondsValue.setAlignment(Qt::AlignRight); | ||
m_milliSecondsValue.setStyleSheet(valueStyle); | ||
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. This repetition deserves its own widget. |
||
|
||
ToolTip::add( this, tr( "Time units" ) ); | ||
|
||
|
@@ -65,15 +87,15 @@ void TimeDisplayWidget::setDisplayMode( DisplayMode displayMode ) | |
switch( m_displayMode ) | ||
{ | ||
case MinutesSeconds: | ||
m_majorLCD.setLabel( tr( "MIN" ) ); | ||
m_minorLCD.setLabel( tr( "SEC" ) ); | ||
m_milliSecondsLCD.setLabel( tr( "MSEC" ) ); | ||
m_majorLabel.setText( tr( "MIN" ) ); | ||
m_minorLabel.setText( tr( "SEC" ) ); | ||
m_milliSecondsLabel.setText( tr( "MSEC" ) ); | ||
break; | ||
|
||
case BarsTicks: | ||
m_majorLCD.setLabel( tr( "BAR" ) ); | ||
m_minorLCD.setLabel( tr( "BEAT" ) ); | ||
m_milliSecondsLCD.setLabel( tr( "TICK" ) ); | ||
m_majorLabel.setText( tr( "BAR" ) ); | ||
m_minorLabel.setText( tr( "BEAT" ) ); | ||
m_milliSecondsLabel.setText( tr( "TICK" ) ); | ||
break; | ||
|
||
default: break; | ||
|
@@ -87,28 +109,36 @@ void TimeDisplayWidget::updateTime() | |
{ | ||
Song* s = Engine::getSong(); | ||
|
||
int major = 0; | ||
int minor = 0; | ||
int milliSeconds = 0; | ||
|
||
switch( m_displayMode ) | ||
{ | ||
case MinutesSeconds: | ||
int msec; | ||
msec = s->getMilliseconds(); | ||
m_majorLCD.setValue(msec / 60000); | ||
m_minorLCD.setValue((msec / 1000) % 60); | ||
m_milliSecondsLCD.setValue(msec % 1000); | ||
major = msec / 60000; | ||
minor = (msec / 1000) % 60; | ||
milliSeconds = msec % 1000; | ||
break; | ||
|
||
case BarsTicks: | ||
int tick; | ||
tick = s->getPlayPos().getTicks(); | ||
m_majorLCD.setValue((int)(tick / s->ticksPerTact()) + 1); | ||
m_minorLCD.setValue((tick % s->ticksPerTact()) / | ||
(s->ticksPerTact() / s->getTimeSigModel().getNumerator() ) +1); | ||
m_milliSecondsLCD.setValue((tick % s->ticksPerTact()) % | ||
(s->ticksPerTact() / s->getTimeSigModel().getNumerator())); | ||
major = (int)(tick / s->ticksPerTact()) + 1; | ||
minor = (tick % s->ticksPerTact()) / | ||
(s->ticksPerTact() / s->getTimeSigModel().getNumerator()) +1; | ||
milliSeconds = (tick % s->ticksPerTact()) % | ||
(s->ticksPerTact() / s->getTimeSigModel().getNumerator()); | ||
break; | ||
|
||
default: break; | ||
} | ||
|
||
m_majorValue.setText( QString::number( major ).rightJustified( 4, '0' ) ); | ||
m_minorValue.setText( QString::number( minor ).rightJustified( 2, '0' ).prepend( ':' ) ); | ||
m_milliSecondsValue.setText( QString::number( milliSeconds ).rightJustified( 3, '0' ).prepend( '.' ) ); | ||
} | ||
|
||
|
||
|
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.
This should go in the stylesheet.