1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-21 00:12:06 +02:00

* Update header-anchors' opacity as you scroll down the page.

This commit is contained in:
Christian Muehlhaeuser 2014-08-20 09:18:39 +02:00
parent 8ad1643a46
commit 13cec067c8
2 changed files with 35 additions and 1 deletions

View File

@ -71,13 +71,13 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
ui->relatedArtists->setAutoResize( true );
ui->relatedArtists->setAutoFitItems( true );
ui->relatedArtists->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
ui->relatedArtists->setItemSize( QSize( 170, 170 + 32 ) );
m_relatedModel = new PlayableModel( ui->relatedArtists );
ui->relatedArtists->setPlayableModel( m_relatedModel );
ui->relatedArtists->proxyModel()->sort( -1 );
ui->relatedArtists->setEmptyTip( tr( "Sorry, we could not find any related artists!" ) );
ui->relatedArtists->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
TomahawkStyle::stylePageFrame( ui->relatedArtists );
TomahawkStyle::stylePageFrame( ui->artistFrame );
@ -199,6 +199,8 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
m_area->setAttribute( Qt::WA_MacShowFocusRect, 0 );
m_stackedWidget->addWidget( m_area );
connect( m_area->verticalScrollBar(), SIGNAL( valueChanged(int ) ), SLOT( onSliderValueChanged( int ) ) );
}
{
ContextView* topHitsFullView = new ContextView( m_stackedWidget );
@ -256,6 +258,7 @@ ArtistInfoWidget::ArtistInfoWidget( const Tomahawk::artist_ptr& artist, QWidget*
mpl->addChildInterface( ui->albums->playlistInterface() );
m_plInterface = playlistinterface_ptr( mpl );
onSliderValueChanged( 0 );
load( artist );
}
@ -505,3 +508,32 @@ ArtistInfoWidget::onRelatedArtistsAnchorClicked()
m_area->verticalScrollBar()->setValue( ui->relatedArtistsLabel->mapTo( m_widget, QPoint( 0, 0 ) ).y() - 32 );
onPageClosed();
}
void
ArtistInfoWidget::onSliderValueChanged( int value )
{
const int midPoint = m_area->viewport()->size().height() / 2;
const bool bio = ( ( ui->biographyLabel->mapTo( m_widget, QPoint( 0, 0 ) ).y() - 32 ) - value ) < midPoint ;
const bool ra = ( ( ui->relatedArtistsLabel->mapTo( m_widget, QPoint( 0, 0 ) ).y() - 32 ) - value ) < midPoint;
const float lowOpacity = 0.7;
if ( ra )
{
uiHeader->anchor3Label->setOpacity( 1 );
uiHeader->anchor1Label->setOpacity( lowOpacity );
uiHeader->anchor2Label->setOpacity( lowOpacity );
}
else if ( bio )
{
uiHeader->anchor2Label->setOpacity( 1 );
uiHeader->anchor1Label->setOpacity( lowOpacity );
uiHeader->anchor3Label->setOpacity( lowOpacity );
}
else
{
uiHeader->anchor1Label->setOpacity( 1 );
uiHeader->anchor2Label->setOpacity( lowOpacity );
uiHeader->anchor3Label->setOpacity( lowOpacity );
}
}

View File

@ -112,6 +112,8 @@ private slots:
void onBioAnchorClicked();
void onRelatedArtistsAnchorClicked();
void onSliderValueChanged( int value );
private:
Ui::ArtistInfoWidget *ui;
Ui::HeaderWidget* uiHeader;