|
From: Tapio V. <aa...@us...> - 2011-01-12 20:39:09
|
Module: editor
Branch: master
Commit: eeafe315792a6446a094ff9d98b778972c0b2388
Author: Tapio Vierros <tap...@gm...>
Date: Wed Jan 12 22:30:22 2011 +0200
Restore note type changing through UI.
---
editorapp.cc | 7 +++----
notelabel.hh | 2 +-
notes.cc | 26 +++++++++++++++++++++++---
notes.hh | 9 ++++++---
4 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index f354fee..c802a36 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -50,7 +50,7 @@ void EditorApp::updateNoteInfo(NoteLabel *note)
ui.valNoteDuration->setText(QString::number(note->width()));
ui.valNote->setText(QString::number(note->y() / NoteGraphWidget::noteYStep));
ui.cmbNoteType->setEnabled(true);
- // FIXME: ui.cmbNoteType->setCurrentIndex(note->note().type);
+ ui.cmbNoteType->setCurrentIndex(note->note().getTypeInt());
ui.chkFloating->setEnabled(true);
ui.chkFloating->setChecked(note->isFloating());
} else {
@@ -209,9 +209,8 @@ void EditorApp::on_actionAbout_triggered()
void EditorApp::on_cmbNoteType_currentIndexChanged(int index)
{
- // FIXME: Fix this
- //if (noteGraph->selectedNote())
- // noteGraph->selectedNote()->setType(index);
+ if (noteGraph->selectedNote())
+ noteGraph->selectedNote()->setType(index);
}
void EditorApp::on_chkFloating_stateChanged(int state)
diff --git a/notelabel.hh b/notelabel.hh
index b02bdbe..c19631d 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -29,7 +29,7 @@ public:
bool isFloating() const { return m_floating; }
void setFloating(bool state) { m_floating = state; createPixmap(size()); }
- void setType(Note::Type newtype) { m_note.type = Note::Type(newtype); createPixmap(size()); }
+ void setType(int newtype) { m_note.type = Note::types[newtype]; createPixmap(size()); }
void startResizing(int dir);
void startDragging(const QPoint& point);
diff --git a/notes.cc b/notes.cc
index ba98255..beb5442 100644
--- a/notes.cc
+++ b/notes.cc
@@ -1,6 +1,7 @@
#include "notes.hh"
#include "util.hh"
+#include <QtGlobal>
#include <cmath>
#include <sstream>
#include <stdexcept>
@@ -54,14 +55,33 @@ double MusicalScale::getNoteOffset(double freq) const {
Duration::Duration(): begin(getNaN()), end(getNaN()) {}
+
+const Note::Type Note::types[] = { NORMAL, GOLDEN, FREESTYLE, SLIDE, SLEEP, TAP, HOLDBEGIN, HOLDEND, ROLL, MINE, LIFT };
+
Note::Note(std::string lyric): syllable(lyric), begin(), end(), phase(getNaN()), type(NORMAL), note(), notePrev(), lineBreak() {}
double Note::diff(double note, double n) { return remainder(n - note, 12.0); }
+int Note::getTypeInt() const {
+ switch (type) {
+ case NORMAL: return 0;
+ case GOLDEN: return 1;
+ case FREESTYLE: return 2;
+ case SLIDE: return 3;
+ case SLEEP: return 4;
+ default: return 255;
+ }
+}
+
std::string Note::typeString() const {
- static const std::string typenames[] = { "Normal", "Bonus", "Freestyle" };
- return typenames[0]; // FIXME: Handle notetypes properly
- //return typenames[type];
+ switch (type) {
+ case NORMAL: return QT_TR_NOOP("Normal");
+ case GOLDEN: return QT_TR_NOOP("Bonus");
+ case FREESTYLE: return QT_TR_NOOP("Freestyle");
+ case SLIDE: return QT_TR_NOOP("Slide");
+ case SLEEP: return QT_TR_NOOP("Sleep");
+ default: return QT_TR_NOOP("Unknown");
+ }
}
diff --git a/notes.hh b/notes.hh
index 601808f..e5f8b9e 100644
--- a/notes.hh
+++ b/notes.hh
@@ -48,13 +48,16 @@ typedef std::map<int, Durations> NoteMap;
/// note read from songfile
struct Note {
Note(std::string lyric = "");
+ /// note type - NOTE! Keep the types array below in sync with the enum!
+ enum Type { FREESTYLE = 'F', NORMAL = ':', GOLDEN = '*', SLIDE = '+', SLEEP = '-',
+ TAP = '1', HOLDBEGIN = '2', HOLDEND = '3', ROLL = '4', MINE = 'M', LIFT = 'L'} type;
+ static const Type types[];
+ int getTypeInt() const;
+
//Duration duration; ///< note begin/end
double begin; // FIXME: Should use duration but it is pain to change everywhere
double end;
double phase; ///< position within a measure, [0, 1)
- /// note type
- enum Type { FREESTYLE = 'F', NORMAL = ':', GOLDEN = '*', SLIDE = '+', SLEEP = '-',
- TAP = '1', HOLDBEGIN = '2', HOLDEND = '3', ROLL = '4', MINE = 'M', LIFT = 'L'} type;
int note; ///< MIDI pitch of the note (at the end for slide notes)
int notePrev; ///< MIDI pitch of the previous note (should be same as note for everything but SLIDE)
std::string syllable; ///< lyrics syllable for that note
|