Newer
Older
Kevin Whitaker
committed
/*
* Copyright (C) 2017 Kevin Whitaker <eyecreate@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#include "TrackDetails.h"
Kevin Whitaker
committed
#include <Wt/WLength>
Kevin Whitaker
committed
#include <Wt/WCssDecorationStyle>
Kevin Whitaker
committed
TrackDetails::TrackDetails()
{
Kevin Whitaker
committed
this->setMaximumSize(Wt::WLength(600, Wt::WLength::Pixel),Wt::WLength(200, Wt::WLength::Pixel));
this->decorationStyle().setBorder(Wt::WBorder::Ridge);
this->decorationStyle().setBackgroundColor(Wt::WColor("#6FFF6F"));
Kevin Whitaker
committed
mainLayout = new Wt::WHBoxLayout();
this->setLayout(mainLayout);
metaLayout = new Wt::WVBoxLayout();
coverData = new Wt::WMemoryResource();
albumCover = new Wt::WImage();
albumCover->setMinimumSize(Wt::WLength(100,Wt::WLength::Pixel),Wt::WLength(100,Wt::WLength::Pixel));
albumCover->setMaximumSize(Wt::WLength(200,Wt::WLength::Pixel),Wt::WLength(200,Wt::WLength::Pixel));
mainLayout->addWidget(albumCover);
Kevin Whitaker
committed
mainLayout->addSpacing(Wt::WLength(20, Wt::WLength::Pixel));
mainLayout->addLayout(metaLayout);
Kevin Whitaker
committed
trackTitle = new Wt::WText();
Kevin Whitaker
committed
trackTitle->decorationStyle().setTextDecoration(Wt::WCssDecorationStyle::Underline);
trackTitle->decorationStyle().font().setSize(Wt::WFont::Size::Large);
trackTitle->decorationStyle().font().setWeight(Wt::WFont::Weight::Bold);
Kevin Whitaker
committed
trackArtist = new Wt::WText();
trackAlbum = new Wt::WText();
Kevin Whitaker
committed
metaLayout->addWidget(trackTitle,2);
metaLayout->addWidget(trackAlbum,1,Wt::AlignmentFlag::AlignBottom);
metaLayout->addWidget(trackArtist,1,Wt::AlignmentFlag::AlignBottom);
Kevin Whitaker
committed
}
void TrackDetails::updateWithTrackDetails(AudioTrack track)
{
this->animateHide(Wt::WAnimation(Wt::WAnimation::Fade));
Kevin Whitaker
committed
trackTitle->setText(track.trackName);
trackArtist->setText(track.trackArtistName);
trackAlbum->setText(track.trackAlbumName);
//Set image to data from track obj.
coverData = new Wt::WMemoryResource(track.coverMimeType);
coverData->setData((unsigned char*)track.coverArt.data(),std::stoi(std::to_string(track.coverArt.size())));
albumCover->setResource(coverData);
this->animateShow(Wt::WAnimation(Wt::WAnimation::Fade,Wt::WAnimation::TimingFunction::EaseIn, 500));