| 1 |
/* |
| 2 |
* Copyright (C) 2022 Rerrah |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person |
| 5 |
* obtaining a copy of this software and associated documentation |
| 6 |
* files (the "Software"), to deal in the Software without |
| 7 |
* restriction, including without limitation the rights to use, |
| 8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 |
* copies of the Software, and to permit persons to whom the |
| 10 |
* Software is furnished to do so, subject to the following |
| 11 |
* conditions: |
| 12 |
* |
| 13 |
* The above copyright notice and this permission notice shall be |
| 14 |
* included in all copies or substantial portions of the Software. |
| 15 |
* |
| 16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 24 |
*/ |
| 25 |
|
| 26 |
#pragma once |
| 27 |
|
| 28 |
#include <memory> |
| 29 |
#include <QDialog> |
| 30 |
#include "bamboo_tracker.hpp" |
| 31 |
#include "configuration.hpp" |
| 32 |
#include "jamming.hpp" |
| 33 |
#include "gui/color_palette.hpp" |
| 34 |
#include "bamboo_tracker_defs.hpp" |
| 35 |
|
| 36 |
enum class InstrumentType: int; |
| 37 |
|
| 38 |
/** |
| 39 |
* @brief The InstrumentEditor class |
| 40 |
*/ |
| 41 |
class InstrumentEditor : public QDialog |
| 42 |
{ |
| 43 |
Q_OBJECT |
| 44 |
|
| 45 |
public: |
| 46 |
/** |
| 47 |
* @brief Return sound source of instrument related to this dialog. |
| 48 |
* @return Sound source of instrument. |
| 49 |
*/ |
| 50 |
virtual SoundSource getSoundSource() const = 0; |
| 51 |
|
| 52 |
/** |
| 53 |
* @brief Return instrument type of instrument related to this dialog. |
| 54 |
* @return Instrument type of instrument. |
| 55 |
*/ |
| 56 |
virtual InstrumentType getInstrumentType() const = 0; |
| 57 |
|
| 58 |
/** |
| 59 |
* @brief setInstrumentNumber |
| 60 |
* @param num Instrument number. |
| 61 |
*/ |
| 62 |
void setInstrumentNumber(int num); |
| 63 |
|
| 64 |
/** |
| 65 |
* @brief getInstrumentNumber |
| 66 |
* @return Instrument number. |
| 67 |
*/ |
| 68 |
int getInstrumentNumber() const noexcept { return instNum_; } |
| 69 |
|
| 70 |
/** |
| 71 |
* @brief setCore |
| 72 |
* @param core Weak pointer to core. |
| 73 |
*/ |
| 74 |
void setCore(std::weak_ptr<BambooTracker> core); |
| 75 |
|
| 76 |
/** |
| 77 |
* @brief setConfiguration |
| 78 |
* @param config Weak pointer to configuration. |
| 79 |
*/ |
| 80 |
void setConfiguration(std::weak_ptr<Configuration> config); |
| 81 |
|
| 82 |
/** |
| 83 |
* @brief setColorPalette |
| 84 |
* @param palette |
| 85 |
*/ |
| 86 |
void setColorPalette(std::shared_ptr<ColorPalette> palette); |
| 87 |
|
| 88 |
/** |
| 89 |
* @brief updateByConfigurationChange |
| 90 |
*/ |
| 91 |
virtual void updateByConfigurationChange() = 0; |
| 92 |
|
| 93 |
/** |
| 94 |
* @brief updateWindowTitle |
| 95 |
*/ |
| 96 |
void updateWindowTitle(); |
| 97 |
|
| 98 |
signals: |
| 99 |
/** |
| 100 |
* @brief Emitted on jamming key on event. |
| 101 |
* @param key Jamkey |
| 102 |
*/ |
| 103 |
void jamKeyOnEvent(JamKey key); |
| 104 |
|
| 105 |
/** |
| 106 |
* @brief Emitted on jamming key off event. |
| 107 |
* @param key Jamkey |
| 108 |
*/ |
| 109 |
void jamKeyOffEvent(JamKey key); |
| 110 |
|
| 111 |
/** |
| 112 |
* @brief Emitted when something in dialog is edited. |
| 113 |
*/ |
| 114 |
void modified(); |
| 115 |
|
| 116 |
protected: |
| 117 |
// Instrument number |
| 118 |
int instNum_; |
| 119 |
|
| 120 |
// Pointer to core |
| 121 |
std::weak_ptr<BambooTracker> bt_; |
| 122 |
// Pointer to color palette |
| 123 |
std::shared_ptr<ColorPalette> palette_; |
| 124 |
// Pointer to configuration |
| 125 |
std::weak_ptr<Configuration> config_; |
| 126 |
|
| 127 |
// Constructor. |
| 128 |
explicit InstrumentEditor(int num, QWidget* parent = nullptr); |
| 129 |
|
| 130 |
// Instrument specific process called in settiing core / cofiguration / color palette. |
| 131 |
virtual void updateBySettingCore() = 0; |
| 132 |
virtual void updateBySettingConfiguration() = 0; |
| 133 |
virtual void updateBySettingColorPalette() = 0; |
| 134 |
}; |