| 1 |
/* |
| 2 |
* Copyright (C) 2018-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 |
#ifndef PATTERN_EDITOR_HPP |
| 27 |
#define PATTERN_EDITOR_HPP |
| 28 |
|
| 29 |
#include <QFrame> |
| 30 |
#include <QUndoStack> |
| 31 |
#include <QEvent> |
| 32 |
#include <memory> |
| 33 |
#include "bamboo_tracker.hpp" |
| 34 |
#include "configuration.hpp" |
| 35 |
#include "gui/color_palette.hpp" |
| 36 |
|
| 37 |
namespace Ui { |
| 38 |
class PatternEditor; |
| 39 |
} |
| 40 |
|
| 41 |
class PatternEditor : public QFrame |
| 42 |
{ |
| 43 |
Q_OBJECT |
| 44 |
|
| 45 |
public: |
| 46 |
explicit PatternEditor(QWidget *parent = nullptr); |
| 47 |
~PatternEditor() override; |
| 48 |
void setCore(std::shared_ptr<BambooTracker> core); |
| 49 |
void setCommandStack(std::weak_ptr<QUndoStack> stack); |
| 50 |
void setConfiguration(std::shared_ptr<Configuration> config); |
| 51 |
void setColorPallete(std::shared_ptr<ColorPalette> palette); |
| 52 |
void addActionToPanel(QAction* action); |
| 53 |
|
| 54 |
void changeEditable(); |
| 55 |
void updatePositionByStepUpdate(bool isFirstUpdate); |
| 56 |
void updatepositionByPositionJump(bool trackChanged = false); |
| 57 |
void changeMarker(); |
| 58 |
|
| 59 |
void copySelectedCells(); |
| 60 |
void cutSelectedCells(); |
| 61 |
|
| 62 |
void freeze(); |
| 63 |
void unfreeze(); |
| 64 |
|
| 65 |
QFont getHeaderFont() const; |
| 66 |
QFont getRowsFont() const; |
| 67 |
QFont getDefaultHeaderFont() const; |
| 68 |
QFont getDefaultRowsFont() const; |
| 69 |
void setFonts(const QFont& headerFont, const QFont& rowsFont); |
| 70 |
|
| 71 |
void setHorizontalScrollMode(bool cellBased, bool refresh = true); |
| 72 |
void setVisibleTracks(std::vector<int> tracks); |
| 73 |
std::vector<int> getVisibleTracks() const; |
| 74 |
|
| 75 |
signals: |
| 76 |
void currentTrackChanged(int idx); |
| 77 |
void currentOrderChanged(int num, int max); |
| 78 |
|
| 79 |
void focusIn(); |
| 80 |
void focusOut(); |
| 81 |
void selected(bool isSelected); |
| 82 |
void instrumentEntered(int num); |
| 83 |
void volumeEntered(int volume); |
| 84 |
void effectEntered(QString text); |
| 85 |
|
| 86 |
protected: |
| 87 |
bool eventFilter(QObject *watched, QEvent *event) override; |
| 88 |
void resizeEvent(QResizeEvent*) override; |
| 89 |
|
| 90 |
public slots: |
| 91 |
void onOrderListCurrentTrackChanged(int idx); |
| 92 |
void onOrderListCrrentOrderChanged(int num); |
| 93 |
|
| 94 |
void onOrderListEdited(); |
| 95 |
void onDefaultPatternSizeChanged(); |
| 96 |
void onShortcutUpdated(); |
| 97 |
|
| 98 |
void onPatternDataGlobalChanged(); |
| 99 |
|
| 100 |
void setPatternHighlight1Count(int count); |
| 101 |
void setPatternHighlight2Count(int count); |
| 102 |
void setEditableStep(int n); |
| 103 |
|
| 104 |
void onSongLoaded(); |
| 105 |
|
| 106 |
void onDeletePressed(); |
| 107 |
void onPastePressed(); |
| 108 |
void onPasteMixPressed(); |
| 109 |
void onPasteInsertPressed(); |
| 110 |
void onPasteOverwritePressed(); |
| 111 |
/// 0: None |
| 112 |
/// 1: All |
| 113 |
/// 2: Row |
| 114 |
/// 3: Column |
| 115 |
/// 4: Pattern |
| 116 |
/// 5: Order |
| 117 |
void onSelectPressed(int type); |
| 118 |
void onTransposePressed(bool isOctave, bool isIncreased); |
| 119 |
void onChangeValuesPressed(bool isCoarse, bool isIncreased); |
| 120 |
void onToggleTrackPressed(); |
| 121 |
void onSoloTrackPressed(); |
| 122 |
void onExpandPressed(); |
| 123 |
void onShrinkPressed(); |
| 124 |
void onInterpolatePressed(); |
| 125 |
void onReversePressed(); |
| 126 |
void onReplaceInstrumentPressed(); |
| 127 |
void onFollowModeChanged(); |
| 128 |
void onStoppedPlaySong(); |
| 129 |
void onDuplicateInstrumentsRemoved(); |
| 130 |
void onPlayStepPressed(); |
| 131 |
|
| 132 |
private: |
| 133 |
Ui::PatternEditor *ui; |
| 134 |
std::shared_ptr<BambooTracker> bt_; |
| 135 |
|
| 136 |
bool freezed_; |
| 137 |
bool songLoaded_; |
| 138 |
|
| 139 |
bool hScrollCellMove_; |
| 140 |
void updateHorizontalSliderMaximum(); |
| 141 |
}; |
| 142 |
|
| 143 |
#endif // PATTERN_EDITOR_HPP |