Deluge Firmware 1.3.0
Build date: 2026.07.15
Loading...
Searching...
No Matches
favourite_manager.h
1/*
2 * Copyright © 2017-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "definitions_cxx.hpp"
21#include "storage/storage_manager.h"
22#include <cstdint>
23#include <functional>
24#include <string>
25#include <vector>
26
27#include <etl/vector.h>
28
29constexpr size_t kNumFavourites = 16;
30
31class FavouritesManager {
32public:
33 struct Favourite {
34 int position = 0;
35 std::optional<uint8_t> colour;
36 std::string filename;
37 };
38
39public:
40 FavouritesManager();
41 ~FavouritesManager();
42
43 void setCategory(const std::string& category);
44 void selectFavouritesBank(uint8_t bankNumber);
45 void setFavourite(uint8_t position, uint8_t colour, const std::string& filename);
46 void unsetFavourite(uint8_t position);
47 bool isEmpty(uint8_t position) const;
48 Error loadFavouritesFromFile(Deserializer& reader);
49 void close();
50 std::array<std::optional<uint8_t>, kNumFavourites> getFavouriteColours() const;
51 void changeColour(uint8_t position, int32_t offset);
52 const std::string& getFavouriteFilename(uint8_t position);
53 static constexpr uint8_t favouriteDefaultColor = 4;
54
55 uint8_t currentBankNumber = 0;
56 std::optional<uint8_t> currentFavouriteNumber;
57
58private:
59 void resetFavourites();
60 void loadFavouritesBank();
61 void saveFavouriteBank() const;
62
63 std::string getFilenameForSave() const;
64 mutable bool unsavedChanges = false;
65
66 std::string currentCategory;
67 etl::vector<Favourite, kNumFavourites> favourites;
68};
69
70extern FavouritesManager favouritesManager;
Definition storage_manager.h:185
Definition favourite_manager.h:31
Definition favourite_manager.h:33