1 // Copyright 2004 "Gilles Degottex"
3 // This file is part of "fmit"
5 // "fmit" is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // "fmit" 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.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #ifndef _MicrotonalView_h_
21 #define _MicrotonalView_h_
30 #include <qpushbutton.h>
32 #include <qfiledialog.h>
40 void load_scala(const QString& file_name);
54 MValue(int n, int d) : is_ratio(true), num(n), den(d), ratio(float(num)/den) {}
55 MValue(float c) : is_ratio(false), cents(c) {}
58 QString getName() {return m_name;}
59 QString getPath() {return m_path;}
61 enum FileType {AUTO,SCALA};
62 MScale(const QString& name);
63 MScale(const QString& file_name, FileType type);
67 bool operator != (const MScale& scale);
70 class QRoot : public QPushButton
78 void rootClicked(int);
81 QRoot(MicrotonalView* view, int ht);
88 class MicrotonalView : public QFrame, public View
92 QPopupMenu ui_scale_menu;
97 void load_default_scales();
99 vector<QRoot*> m_roots;
100 struct QScaleLabel : QLabel
102 MicrotonalView* ui_view;
104 QScaleLabel(MicrotonalView* view);
105 virtual void drawContents(QPainter* p);
106 virtual ~QScaleLabel(){}
109 struct QRatiosLabel : QLabel
111 MicrotonalView* ui_view;
112 void drawTicks(QPainter* p, float r, int h);
113 QRatiosLabel(MicrotonalView* view);
114 virtual void drawContents(QPainter* p);
115 virtual ~QRatiosLabel(){}
118 virtual void mouseReleaseEvent(QMouseEvent* e);
120 struct ScalePreview : QLabel, QFilePreview
122 ScalePreview(QWidget* parent);
123 virtual void previewUrl(const QUrl& url);
127 int getOctaveShift();
130 void refreshScaleList();
132 void selectScale(int index);
133 // void octaveChanged(int value);
134 void emitTuningFreqChanged();
137 MicrotonalView(QWidget* parent);
139 float getTuningFreq() {return m_tuningFreq;}
140 bool hasTuningFreqSelected() {return m_selected_jivalue!=NULL;}
141 QString getTuningNoteName();
142 MScale::MValue* m_selected_jivalue;
144 int getIndex(MScale* scale);
149 QSpinBox* setting_octave;
150 QAction* setting_keepRootToLeft;
151 int setting_selectedRoot;
152 QAction* setting_loadScale;
153 vector<MScale*> setting_scales;
154 MScale* setting_selectedScale;
155 QString setting_lastScalesDirectory;
158 virtual void clearSettings();
161 void setAFreq(float AFreq);
162 void selectScale(const QString& name);
163 void selectRoot(int ht);
164 void updateCursor(float freq);
165 void notesNameChanged();
166 void keepRootToLeft(bool keep);
169 void tuningFreqChanged(float freq);
172 #endif // _MicrotonalView_h_