Planeshift
pawsmusicwindow.h
Go to the documentation of this file.
1 /*
2  * pawsmusicwindow.h, Author: Andrea Rizzi <88whacko@gmail.com>
3  *
4  * Copyright (C) 2001-2011 Atomic Blue (info@planeshift.it, http://www.atomicblue.org)
5  *
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation (version 2 of the License)
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */
19 
20 #ifndef PAWS_MUSIC_WINDOW_H
21 #define PAWS_MUSIC_WINDOW_H
22 
23 
24 //====================================================================================
25 // Project Includes
26 //====================================================================================
27 #include <clientsongmngr.h>
28 #include <net/cmdbase.h>
31 
32 //------------------------------------------------------------------------------------
33 // Forward Declarations
34 //------------------------------------------------------------------------------------
35 class Chord;
36 class Measure;
37 class SheetLine;
38 class pawsSheetLine;
39 
45 {
46 public:
47  enum
48  {
53  };
54 
55  enum
56  {
58 
59  // duration buttons
65 
66  // alteration buttons
67  FLAT_BUTTON = 300,
70  };
71 
76 
82  pawsMusicWindow(const pawsMusicWindow* origin);
83 
87  virtual ~pawsMusicWindow();
88 
98  void OnChordSelection(SheetLine* sheetLine, Measure* measure, Chord* chord, int notePosition, bool before);
99 
106  void GetMeter(int &beats, int &beatType);
107 
113  uint GetDivisions();
114 
115  // From iSongManagerListener
116  virtual void OnMainPlayerSongStop();
117 
118  // From iOnMeterEnteredListener
119  virtual void OnMeterEntered(const char* name, csString beats, csString beatType);
120 
121  // From iOnStringEnteredAction
122  //-----------------------------
123  virtual void OnStringEntered(const char* name, int param, const char* value);
124 
125  // From psClientNetSubscriber
126  //----------------------------
127  virtual void HandleMessage(MsgEntry* message);
128 
129  // From pawsWidget
130  //-----------------
131  virtual double CalcFunction(MathEnvironment* env, const char* functionName, const double* params);
132  virtual void Hide();
133  virtual bool PostSetup();
134  virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
135  virtual bool OnScroll(int scrollDirection, pawsScrollBar* widget);
136 
137 private:
138  friend class pawsSheetLine;
139 
140  int fifths;
141  csString beats;
142  csString beatType;
143  uint tempo;
144  uint playedTempo;
145 
146  SheetLine* linesHead;
147  Measure* measuresHead;
148 
149  Chord* selectedChord;
150  Measure* selectedMeasure;
151 
157  SheetLine* selectedSheetLine;
158 
159  int selectedDurButton;
160  int selectedAlterButton;
161 
162  uint32_t currentItemID;
163  bool readOnly;
164  bool edited;
165  bool pendingString;
166  bool editMode;
167  bool insertMode;
168 
169  pawsButton* editButton;
170  pawsButton* playButton;
171  pawsWidget* loadButton;
172  pawsWidget* saveButton;
173  pawsWidget* titleButton;
174 
175  pawsButton* doubleStaffButton;
176  pawsWidget* tonalityButton;
177  pawsWidget* meterButton;
178  pawsWidget* bpmButton;
179  pawsButton* restButton;
180 
181  pawsButton* sixteenthButton;
182  pawsButton* eighthButton;
183  pawsButton* quarterButton;
184  pawsButton* halfButton;
185  pawsButton* wholeButton;
186  pawsButton* dotButton;
187 
188  pawsButton* flatButton;
189  // pawsButton* naturalButton; TODO support natural notes in song stream before use this
190  pawsButton* sharpButton;
191 
192  pawsWidget* deleteChordButton;
193  pawsWidget* deleteMeasureButton;
194  pawsButton* insertNoteButton;
195  pawsWidget* insertMeasureButton;
196 
197  pawsButton* startRepeatButton;
198  pawsButton* endRepeatButton;
199  pawsButton* endingButton;
200 
201  pawsSheetLine* pawsLine1;
202  pawsSheetLine* pawsLine2;
203 
204  pawsScrollBar* scrollBar;
205 
210  static void OnSheetLineCallback(void* object, SheetLine* sheetLine);
211 
215  void Unload();
216 
225  bool LoadXML(csRef<iDocument> sheet);
226 
234  csString ToXML(bool usePlayedTempo);
235 
242  SheetLine* GetSheetLine(int index);
243 
249  SheetLine* GetSelectedSheetLine();
250 
254  void UpdateScrollBar();
255 
262  void UpdateLines(SheetLine* line, bool forceAll);
263 
267  void DisplaySelectedMeasure();
268 
276  pawsButton* GetButton(int buttonID);
277 
281  void DeleteSelectedChord();
282 
286  void DeleteSelectedMeasure();
287 
291  void InsertMeasure();
292 
298  void SetInsertMode(bool toggle);
299 
305  void ToggleEditMode(bool toggle);
306 
310  void PlayStop();
311 
315  void Save();
316 
320  void Load();
321 
325  void ChangeSongTitle();
326 
330  void SwitchDoubleStaff();
331 
335  void ChangeTonality();
336 
340  void ChangeMeter();
341 
345  void ChangeBPM();
346 
350  void SetPlayedBPM();
351 
355  void ChangeChordDuration();
356 
361  void SetEndRepeat();
362 
366  void SetEnding();
367 
373  int GetSelectedDuration();
374 
381  void SetDurationButton(int duration);
382 
388  void SelectDuration(int buttonID);
389 
396  void SelectAlteration(int buttonID);
397 
402  void SetToolbarButtons();
403 
408  void ResetState();
409 
413  void DeleteAll();
414 };
415 
417 
418 #endif // PAWS_MUSIC_WINDOW_H
virtual void OnStringEntered(const char *name, int param, const char *value)
When the pawsStringPromptWindow is created, a ptr to a class which implements this function is provid...
A measure containing measure elements.
virtual ~pawsMusicWindow()
Destructor.
uint GetDivisions()
Gets the sheet&#39;s number of divisions.
The main base widget that all other widgets should inherit from.
Definition: pawswidget.h:116
void GetMeter(int &beats, int &beatType)
Gets beats and beat type of the song.
A specific MathEnvironment to be used in a MathScript.
Definition: mathscript.h:188
CREATE_PAWS_FACTORY(pawsMusicWindow)
csString name
The name of this widget.
Definition: pawswidget.h:217
Interface implemented by a pawsMeterPromptWindow listener.
The structure of 1 queue entry (pointer to a message)
Definition: message.h:143
virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget *widget)
Called whenever a button is pressed.
pawsMusicWindow()
Constructor.
virtual void Hide()
Makes widget invisible and removes focus if widget has current focus.
virtual double CalcFunction(MathEnvironment *env, const char *functionName, const double *params)
This interface implemets a listener to client song events.
virtual void OnMainPlayerSongStop()
This is called when the main player&#39;s song is stopped.
virtual void HandleMessage(MsgEntry *message)
virtual void OnMeterEntered(const char *name, csString beats, csString beatType)
This function is called when the user input a meter.
A simple scroll bar widget.
Definition: pawscrollbar.h:64
A simple button widget.
Definition: pawsbutton.h:43
virtual bool Load(iDocumentNode *node)
Load a widget based on its <widget></widget> tag.
This interface defines the callback used by pawsStringPromptWindow to notify another window of a supp...
virtual bool PostSetup()
This is called after the widget and all of it&#39;s children have been created.
A window that shows a musical sheet and allows the player to edit it.
virtual bool OnScroll(int scrollDirection, pawsScrollBar *widget)
Called whenever a window is scrolled.
void OnChordSelection(SheetLine *sheetLine, Measure *measure, Chord *chord, int notePosition, bool before)
Handle a click on a chord.
This class draws a musical staff on the widget and creates notes and chords that it can represent on ...