summaryrefslogtreecommitdiff
path: root/muse/awl
diff options
context:
space:
mode:
Diffstat (limited to 'muse/awl')
-rw-r--r--muse/awl/tcanvas.cpp48
-rw-r--r--muse/awl/tcanvas.h66
2 files changed, 87 insertions, 27 deletions
diff --git a/muse/awl/tcanvas.cpp b/muse/awl/tcanvas.cpp
index f5ce2100..6ec4f68f 100644
--- a/muse/awl/tcanvas.cpp
+++ b/muse/awl/tcanvas.cpp
@@ -423,7 +423,7 @@ bool TimeCanvas::eventFilter(QObject* obj, QEvent* event)
void TimeCanvas::keyPressEvent(QKeyEvent *e)
{
- if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down ||
+ if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down ||
e->key() == Qt::Key_Left || e->key() == Qt::Key_Right)
keyboardNavigate(e);
}
@@ -533,7 +533,7 @@ void TimeCanvas::paintClockRuler(QPainter& p, const QRect& r)
int y = rulerHeight - 16;
p.setPen(Qt::black);
- p.setFont(config.fonts[4]);
+ p.setFont(_font3);
QRect tr(r);
tr.setHeight(12);
@@ -590,12 +590,12 @@ void TimeCanvas::paintClockRuler(QPainter& p, const QRect& r)
int yy;
QString s;
if (sr == 0) {
- p.setFont(config.fonts[3]);
+ p.setFont(_font2);
s.sprintf("%d:00", min);
yy = y;
}
else {
- p.setFont(config.fonts[1]);
+ p.setFont(_font1);
s.sprintf("%02d", sr);
yy = y + 7;
}
@@ -613,7 +613,7 @@ void TimeCanvas::paintClockRuler(QPainter& p, const QRect& r)
int min2 = (sec2+59)/60;
for (int min = min1; min < min2; ++min) {
QString s;
- p.setFont(config.fonts[3]);
+ p.setFont(_font2);
s.sprintf("%d", min);
int xp = pos2pix(AL::Pos(min * AL::sampleRate * 60, AL::FRAMES));
p.setPen(Qt::black);
@@ -665,7 +665,7 @@ void TimeCanvas::paintMetronomRuler(QPainter& p, const QRect& r)
int w = r.width();
int y = rulerHeight - 16;
- p.setFont(config.fonts[4]);
+ p.setFont(_font3);
int h = 14;
int y1 = r.y();
@@ -724,7 +724,7 @@ void TimeCanvas::paintMetronomRuler(QPainter& p, const QRect& r)
for (int bar = bar1; bar <= bar2;) {
AL::Pos stick(bar, 0, 0);
if (metronomeRulerMag) {
- p.setFont(config.fonts[3]);
+ p.setFont(_font2);
int x = pos2pix(stick);
QString s;
s.setNum(bar + 1);
@@ -752,12 +752,12 @@ void TimeCanvas::paintMetronomRuler(QPainter& p, const QRect& r)
if (beat == 0) {
num = bar + 1;
y3 = y + 2;
- p.setFont(config.fonts[3]);
+ p.setFont(_font2);
}
else {
num = beat + 1;
y3 = y + 8;
- p.setFont(config.fonts[1]);
+ p.setFont(_font1);
r.moveTop(r.top() + 1);
}
s.setNum(num);
@@ -999,7 +999,7 @@ void TimeCanvas::setLocatorPos(int idx, const AL::Pos& val, bool follow)
{
if (pos[idx] == val)
return;
- QFontMetrics fm(config.fonts[3]);
+ QFontMetrics fm(_font2);
int fw = fm.width("123") + 2;
int w = qMax(markIcon[idx]->width() + 2, fw);
int h = widget()->height();
@@ -1841,3 +1841,31 @@ void TimeCanvas::setPart(const AL::Pos& p1, const AL::Pos& p2)
widget()->update();
}
+//---------------------------------------------------------
+// setFont1
+//---------------------------------------------------------
+
+void TimeCanvas::setFont1(const QFont& f)
+ {
+ _font1 = f;
+ printf("TimeCanvas::setFont1\n");
+ }
+
+//---------------------------------------------------------
+// setFont2
+//---------------------------------------------------------
+
+void TimeCanvas::setFont2(const QFont& f)
+ {
+ _font2 = f;
+ }
+
+//---------------------------------------------------------
+// setFont3
+//---------------------------------------------------------
+
+void TimeCanvas::setFont3(const QFont& f)
+ {
+ _font3 = f;
+ }
+
diff --git a/muse/awl/tcanvas.h b/muse/awl/tcanvas.h
index 7e3841f2..09b26b1d 100644
--- a/muse/awl/tcanvas.h
+++ b/muse/awl/tcanvas.h
@@ -66,6 +66,23 @@ static const int keyHeight = 13;
class TimeCanvas : public QFrame {
Q_OBJECT
+ Q_PROPERTY(QFont font1 READ font1 WRITE setFont1)
+ Q_PROPERTY(QFont font2 READ font2 WRITE setFont2)
+ Q_PROPERTY(QFont font3 READ font3 WRITE setFont3)
+
+ // I could not find out how to set the size of a font property with
+ // style sheets. As a workaround here are special "size" properties
+ // which could be set with style sheet command
+ // TimeCanvas { qproperty-fontSize1: 6 }
+
+ Q_PROPERTY(int fontSize1 READ fontSize1 WRITE setFontSize1 STORED false)
+ Q_PROPERTY(int fontSize2 READ fontSize2 WRITE setFontSize2 STORED false)
+ Q_PROPERTY(int fontSize3 READ fontSize3 WRITE setFontSize3 STORED false)
+
+ QFont _font1;
+ QFont _font2;
+ QFont _font3;
+
int yRange;
bool _yFit;
AL::Pos pos1; // time scroll range
@@ -141,32 +158,32 @@ class TimeCanvas : public QFrame {
bool eventFilter(QObject*, QEvent*);
virtual void paint(QPainter&, QRect) = 0;
- virtual void mousePress(QMouseEvent*) { printf("mousePress method not overloaded\n"); }
- virtual void mouseMove(QPoint) { printf("mouseMove method not overloaded\n"); }
- virtual void mouseRelease(QMouseEvent*) { printf("mouseRelease method not overloaded\n"); }
- virtual void mouseDoubleClick(QMouseEvent*) { printf("mouseDoubleClick method not overloaded\n"); }
+ virtual void mousePress(QMouseEvent*) {}
+ virtual void mouseMove(QPoint) {}
+ virtual void mouseRelease(QMouseEvent*) {}
+ virtual void mouseDoubleClick(QMouseEvent*) {}
virtual void paintDrumList(QPainter&, QRect) {}
- virtual void layout() { printf("layout method not overloaded\n"); }
- virtual void enterB() { printf("enterB method not overloaded\n"); }
- virtual void leaveB() { printf("leaveB method not overloaded\n"); }
+ virtual void layout() {}
+ virtual void enterB() {}
+ virtual void leaveB() {}
virtual void setCursor();
- virtual void timeTypeChanged() { printf("timeTypeChanged method not overloaded\n");}
- virtual void magChanged() { printf("magChanged method not overloaded\n");}
+ virtual void timeTypeChanged() {}
+ virtual void magChanged() {}
- virtual void paintControllerCanvas(QPainter&, QRect) { printf("paintControllerCanvas method not overloaded\n"); }
- virtual void paintControllerPanel(QPainter&, QRect) { printf("paintControllerPanel method not overloaded\n"); }
+ virtual void paintControllerCanvas(QPainter&, QRect) {}
+ virtual void paintControllerPanel(QPainter&, QRect) {}
- virtual void dragEnter(QDragEnterEvent*) { printf("dragEnter method not overloaded\n"); }
- virtual void drop(QDropEvent*) { printf("drop method not overloaded\n"); }
- virtual void dragMove(QDragMoveEvent*) { printf("dragMove method not overloaded\n"); }
- virtual void dragLeave(QDragLeaveEvent*) { printf("dragLeave method not overloaded\n"); }
+ virtual void dragEnter(QDragEnterEvent*) {}
+ virtual void drop(QDropEvent*) {}
+ virtual void dragMove(QDragMoveEvent*) {}
+ virtual void dragLeave(QDragLeaveEvent*) {}
- virtual void addController() { printf("addController method not overloaded\n"); }
+ virtual void addController() {}
virtual void keyPressEvent(QKeyEvent *e);
- virtual void keyboardNavigate(QKeyEvent *) { printf("keyboardNavigate method not overloaded\n"); }
+ virtual void keyboardNavigate(QKeyEvent *) {}
// map logical coordinates to physical coordinates (pixel)
int mapx(int x) const;
@@ -253,6 +270,21 @@ class TimeCanvas : public QFrame {
void updateCanvasB() { _widget->update(rCanvasB); }
void updateRuler() { _widget->update(rRuler); }
+ QFont font1() const { return _font1; }
+ QFont font2() const { return _font2; }
+ QFont font3() const { return _font3; }
+
+ void setFont1(const QFont& f);
+ void setFont2(const QFont& f);
+ void setFont3(const QFont& f);
+
+ int fontSize1() const { return _font1.pointSize(); }
+ int fontSize2() const { return _font2.pointSize(); }
+ int fontSize3() const { return _font3.pointSize(); }
+ void setFontSize1(int val) { _font1.setPointSize(val); }
+ void setFontSize2(int val) { _font2.setPointSize(val); }
+ void setFontSize3(int val) { _font3.setPointSize(val); }
+
static FollowMode followMode;
friend class CtrlEdit;
};