mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-21 23:50:31 -04:00
* Fix of the issue that switching from songs list to main view after playing and stopping some track resulted in elapsed time counter not being updated until the song is unpaused; * cleanups.
95 lines
3.6 KiB
C++
95 lines
3.6 KiB
C++
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include <application-music-player/presenters/SongsPresenter.hpp>
|
|
#include <AppWindow.hpp>
|
|
#include <TextFixedSize.hpp>
|
|
#include <OptionWindow.hpp>
|
|
#include <module-apps/apps-common/InternalModel.hpp>
|
|
|
|
namespace gui
|
|
{
|
|
class ListView;
|
|
class ImageBox;
|
|
class OptionSettings;
|
|
|
|
/// Start MP app window with possible three internal states:
|
|
/// - init screen
|
|
/// - music library screen
|
|
/// - track preview screen
|
|
class MusicPlayerMainWindow : public OptionWindow, public app::music_player::SongsContract::View
|
|
{
|
|
public:
|
|
/// number of vertical items in track's progress bar
|
|
static constexpr std::uint8_t progressBarSize = 27;
|
|
|
|
/// current view mode (switching with up / down arrow)
|
|
enum class ViewMode
|
|
{
|
|
START = 1, // start screen "press down arrow to choose..."
|
|
TRACK, // track info
|
|
LIBRARY // Music library
|
|
};
|
|
|
|
explicit MusicPlayerMainWindow(app::ApplicationCommon *app,
|
|
std::shared_ptr<app::music_player::SongsContract::Presenter> presenter);
|
|
|
|
void onBeforeShow(ShowMode mode, SwitchData *data) override;
|
|
|
|
void rebuild() override;
|
|
void buildInterface() override;
|
|
void destroyInterface() override;
|
|
bool onInput(const InputEvent &inputEvent) override;
|
|
|
|
void updateSongsState(std::optional<db::multimedia_files::MultimediaFilesRecord> record,
|
|
RecordState state) override;
|
|
void updateSongProgress(float progress) override;
|
|
void refreshWindow() override;
|
|
void setNavBarTemporaryMode(const std::string &text) override;
|
|
void restoreFromNavBarTemporaryMode() override;
|
|
|
|
void changeCurrentMode(ViewMode m);
|
|
|
|
protected:
|
|
void buildInterfaceStartMode();
|
|
void buildInterfaceTrackMode();
|
|
void buildInterfaceLibraryMode();
|
|
|
|
void buildPlayButtonsInterface(VBox *parent);
|
|
void buildSwipeDownInterface(VBox *parent);
|
|
void buildTrackProgressInterface(VBox *parent);
|
|
void buildTrackInfoInterface(VBox *parent);
|
|
void updateVisibleTrackData(RecordState state) noexcept;
|
|
void updateVisibleProgressData(void) noexcept;
|
|
|
|
bool onInputTrackMode(const InputEvent &inputEvent);
|
|
|
|
private:
|
|
ViewMode myViewMode = ViewMode::START;
|
|
|
|
std::shared_ptr<app::music_player::SongsContract::Presenter> presenter;
|
|
Label *titleText = nullptr;
|
|
Label *artistText = nullptr;
|
|
Text *currentTimeText = nullptr;
|
|
Text *totalTimeText = nullptr;
|
|
ImageBox *rewImageBox = nullptr;
|
|
ImageBox *pauseImageBox = nullptr;
|
|
ImageBox *ffImageBox = nullptr;
|
|
ImageBox *stateImageBox = nullptr;
|
|
Label *descriptionText = nullptr;
|
|
Image *progressBarItems[progressBarSize] = {nullptr};
|
|
|
|
float currentProgress = 0.0f;
|
|
std::uint32_t currentTotalTime = 0;
|
|
std::uint8_t currentProgressBarsBlack = 0;
|
|
std::string currentTitle;
|
|
std::string currentArtist;
|
|
std::string currentTimeString;
|
|
std::string currentTotalTimeString;
|
|
bool isPermissionToChangeViewMode = false;
|
|
bool needToDeepRedrawScreen = false;
|
|
};
|
|
} /* namespace gui */
|