forked from cadencii/cadencii-nt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.hpp
More file actions
206 lines (159 loc) · 6.07 KB
/
Controller.hpp
File metadata and controls
206 lines (159 loc) · 6.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/**
* Controller.hpp
* Copyright © 2012 kbinani
*
* This file is part of cadencii.
*
* cadencii is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2.0 as published by the Free Software Foundation.
*
* cadencii 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.
*/
#ifndef __Controller_hpp__
#define __Controller_hpp__
#include <string>
#include "gui/MainView.hpp"
#include "gui/TrackView.hpp"
#include "gui/ControlChangeView.hpp"
#include "gui/PropertyView.hpp"
#include "gui/SingerListView.hpp"
#include "gui/TrackListView.hpp"
#include "ControllerAdapter.hpp"
#include "vsq/Sequence.hpp"
#include "enum/QuantizeMode.hpp"
#include "sequence/SequenceModel.hpp"
namespace cadencii {
class Controller : public ControllerAdapter {
private:
TrackView *trackView;
MainView *mainView;
ControlChangeView *controlChangeView;
BarCountView *barCountView;
TempoView *tempoView;
TimesigView *timesigView;
PropertyView *propertyView;
SingerListView *singerListView;
TrackListView *trackListView;
SequenceModel model;
VSQ_NS::tick_t songPosition;
int trackIndex;
/**
* @brief 1 tick 時刻を何ピクセルで描画するか
*/
double pixelPerTick;
/**
* @brief 選択されているツールの種類
*/
ToolKind::ToolKindEnum toolKind;
/**
* @brief アイテムの選択状態を管理するマネージャオブジェクト
*/
ItemSelectionManager itemSelectionManager;
public:
explicit Controller();
void openVSQFile(const string &filePath)throw();
void openXVSQFile(const std::string &filePath)throw();
void drawOffsetChanged(void *sender, VSQ_NS::tick_t offset)throw();
/**
* @brief 表示するトラックのインデックスを設定する
* @param トラックのインデックス
*/
void setTrackIndex(void *sender, int index)throw();
VSQ_NS::tick_t getSongPosition()throw();
int getXFromTick(VSQ_NS::tick_t tick)throw();
double getTickFromX(int x)throw();
void moveSongPositionStepped(bool isBackward)throw();
int getPreferredComponentWidth()throw();
void exportAsMusicXml(const std::string &filePath)throw();
void exportAsVSQFile(const string &filePath)throw();
void setToolKind(ToolKind::ToolKindEnum kind)throw();
ToolKind::ToolKindEnum getToolKind()throw();
ItemSelectionManager *getItemSelectionManager()throw();
const VSQ_NS::Sequence *getSequence()throw();
void undo();
void redo();
bool canUndo();
bool canRedo();
void execute(AbstractCommand *command);
void removeEvent(int trackIndex, const VSQ_NS::Event *item);
void removeSelectedItems();
void setApplicationShortcutEnabled(bool enabled);
void notifyItemSelectionChange()throw();
const VSQ_NS::PhoneticSymbolDictionary::Element *attachPhoneticSymbol(const string &word);
/**
* @brief トラックのビューを設定する
* @param[in] trackView ビュー
*/
void setTrackView(TrackView *trackView)throw();
/**
* @brief コントロールチェンジのビューを設定する
* @param [in] controlChangeView ビュー
*/
void setControlChangeView(ControlChangeView *controlChangeView)throw();
/**
* @brief 小節数のビューを設定する
* @param [in] barCountView ビュー
*/
void setBarCountView(BarCountView *barCountView)throw();
/**
* @brief テンポ変更イベントのビューを設定する
* @param [in] tempoView ビュー
*/
void setTempoView(TempoView *tempoView)throw();
/**
* @brief 拍子変更イベントのビューを設定する
* @param [in] timesigView ビュー
*/
void setTimesigView(TimesigView *timesigView)throw();
/**
* @brief メインのビューを設定する
* @param[in] mainView ビュー
*/
void setMainView(MainView *mainView)throw();
/**
* @brief プロパティーのビューを設定する
* @param[in] propertyView ビュー
*/
void setPropertyView(PropertyView *propertyView)throw();
/**
* @brief Set a view of singer list.
* @param singerListView [in] A view instance.
*/
void setSingerListView(SingerListView *singerListView);
/**
* @brief Set a view of track list.
* @param trackListView [in] A view instance.
*/
void setTrackListView(TrackListView *trackListView);
/**
* @brief メインのビューを表示する
*/
void showMainView();
protected:
/**
* @brief tick 単位の時刻を、指定されたクオンタイズモードに応じて丸める
* @todo 三連符かどうかのフラグを渡せるようにする
* @todo テスト
*/
VSQ_NS::tick_t getQuantizedTick(VSQ_NS::tick_t before, QuantizeMode::QuantizeModeEnum mode);
private:
/**
* @brief sequence のインスタンスを置き換えたのち、各コンポーネントに sequence のインスタンスが置き換わったことを通知する
* @param sequence 置き換わるインスタンス
*/
void setupSequence(const VSQ_NS::Sequence &sequence);
/**
* @brief すべてのウィジェットを再描画する
*/
void updateAllWidget();
/**
* @brief ソングポジションを設定する
* @param songPosition ソングポジション
*/
void setSongPosition(VSQ_NS::tick_t songPosition);
};
}
#endif