/* * Copyright (C) 2017 Kevin Whitaker * * 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" #include #include TrackDetails::TrackDetails() { 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")); 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); mainLayout->addSpacing(Wt::WLength(20, Wt::WLength::Pixel)); mainLayout->addLayout(metaLayout); trackTitle = new Wt::WText(); trackTitle->decorationStyle().setTextDecoration(Wt::WCssDecorationStyle::Underline); trackTitle->decorationStyle().font().setSize(Wt::WFont::Size::Large); trackTitle->decorationStyle().font().setWeight(Wt::WFont::Weight::Bold); trackArtist = new Wt::WText(); trackAlbum = new Wt::WText(); metaLayout->addWidget(trackTitle,2); metaLayout->addWidget(trackAlbum,1,Wt::AlignmentFlag::AlignBottom); metaLayout->addWidget(trackArtist,1,Wt::AlignmentFlag::AlignBottom); } void TrackDetails::updateWithTrackDetails(AudioTrack track) { this->animateHide(Wt::WAnimation(Wt::WAnimation::Fade)); 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)); }