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>
33 #include <q3filedialog.h>
35 #include <qfiledialog.h>
44 void load_scala(const QString& file_name);
58 MValue(int n, int d) : is_ratio(true), num(n), den(d), ratio(float(num)/den) {}
59 MValue(float c) : is_ratio(false), cents(c) {}
62 QString getName() {return m_name;}
63 QString getPath() {return m_path;}
65 enum FileType {AUTO,SCALA};
66 MScale(const QString& name);
67 MScale(const QString& file_name, FileType type);
71 bool operator != (const MScale& scale);
74 class QRoot : public QPushButton
82 void rootClicked(int);
85 QRoot(MicrotonalView* view, int ht);
92 class MicrotonalView : public QFrame, public View
101 void load_default_scales();
103 vector<QRoot*> m_roots;
104 struct QScaleLabel : QLabel
106 MicrotonalView* ui_view;
108 QScaleLabel(MicrotonalView* view);
109 virtual void paintEvent(QPaintEvent* event);
110 virtual ~QScaleLabel(){}
113 struct QRatiosLabel : QLabel
115 MicrotonalView* ui_view;
116 void drawTicks(QPainter* p, float r, int h);
117 QRatiosLabel(MicrotonalView* view);
118 virtual void paintEvent(QPaintEvent* event);
119 virtual ~QRatiosLabel(){}
122 virtual void mouseReleaseEvent(QMouseEvent* e);
125 struct ScalePreview : QLabel, Q3FilePreview
127 ScalePreview(QWidget* parent);
128 virtual void previewUrl(const Q3Url& url);
133 int getOctaveShift();
136 void refreshScaleList();
138 void scaleActionToggled(bool checked);
139 void selectScale(int index);
140 // void octaveChanged(int value);
141 void emitTuningFreqChanged();
144 MicrotonalView(QWidget* parent);
146 float getTuningFreq() {return m_tuningFreq;}
147 bool hasTuningFreqSelected() {return m_selected_jivalue!=NULL;}
148 QString getTuningNoteName();
149 MScale::MValue* m_selected_jivalue;
151 int getIndex(MScale* scale);
156 QSpinBox* setting_octave;
157 QAction* setting_keepRootToLeft;
158 int setting_selectedRoot;
159 QAction* setting_loadScale;
160 vector<MScale*> setting_scales;
161 MScale* setting_selectedScale;
162 QString setting_lastScalesDirectory;
165 virtual void clearSettings();
168 void setAFreq(float AFreq);
169 void selectScale(const QString& name);
170 void selectRoot(int ht);
171 void updateCursor(float freq);
172 void notesNameChanged();
173 void keepRootToLeft(bool keep);
176 void tuningFreqChanged(float freq);
179 #endif // _MicrotonalView_h_