summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-10-04 14:44:09 +0000
committerWerner Schweer <ws.seh.de>2006-10-04 14:44:09 +0000
commit1c7c19e9e172db42cfedafa17b23cb53f6e2395e (patch)
treed158e8a87a06d8b5eb868696c9096fb7ffc47e78
parent1007d8a07a2f9553b79ce0b7c11e795887875ea1 (diff)
misc graphical controller editor fixes
-rw-r--r--muse/muse/arranger/canvas.cpp22
-rw-r--r--muse/muse/arranger/tlswidget.cpp2
-rw-r--r--muse/muse/arranger/tlwidget.cpp5
-rw-r--r--muse/muse/ctrl.cpp47
-rw-r--r--muse/muse/ctrl.h1
-rw-r--r--muse/muse/ctrl/ctrleditor.cpp23
-rw-r--r--muse/muse/gui.h6
-rw-r--r--muse/muse/midictrl.cpp6
-rw-r--r--muse/muse/song.cpp1
-rw-r--r--muse/synti/deicsonze/deicsonze.cpp2
-rw-r--r--muse/synti/fluid/fluid.cpp2
-rw-r--r--muse/synti/vam/vam.cpp4
12 files changed, 80 insertions, 41 deletions
diff --git a/muse/muse/arranger/canvas.cpp b/muse/muse/arranger/canvas.cpp
index 1a0ef232..6a2332e0 100644
--- a/muse/muse/arranger/canvas.cpp
+++ b/muse/muse/arranger/canvas.cpp
@@ -244,17 +244,19 @@ void PartCanvas::paint(QPainter& p, QRect r)
p.restore();
}
- p.setPen(QPen(Qt::lightGray, 1, Qt::SolidLine));
- if (i != tl->begin())
- p.drawLine(from, y-2, to, y-2);
+ if (i != tl->begin()) {
+ p.setPen(QPen(Qt::lightGray, trackSeparator, Qt::SolidLine));
+ p.drawLine(from, y + yTrackOffset, to, y + yTrackOffset);
+ }
for (iArrangerTrack i = t->subtracks.begin(); i != t->subtracks.end(); ++i) {
at = *i;
if (at->tw == 0)
continue;
TLSWidget* tls = (TLSWidget*)(at->tw);
int y = tls->y();
- p.setPen(QPen(Qt::lightGray, 1, Qt::SolidLine));
- p.drawLine(from, y-2, to, y-2);
+ int h = tls->height();
+ p.setPen(QPen(Qt::lightGray, trackSeparator, Qt::SolidLine));
+ p.drawLine(from, y + yTrackOffset, to, y + yTrackOffset);
QPoint off(0, y);
p.translate(off);
tls->paint(p, r);
@@ -263,9 +265,9 @@ void PartCanvas::paint(QPainter& p, QRect r)
}
if (at && at->tw) {
// draw last line
- int y = at->tw->y() + at->tw->height() - 2;
- p.setPen(QPen(Qt::lightGray, 1, Qt::SolidLine));
- p.drawLine(from, y-2, to, y-2);
+ int y = at->tw->y() + at->tw->height() + yTrackOffset;
+ p.setPen(QPen(Qt::lightGray, trackSeparator, Qt::SolidLine));
+ p.drawLine(from, y, to, y);
}
if (state == S_DRAG4 || state == S_DRAG1 || state == S_DRAG2 || state == S_DRAG5) {
p.setBrush(Qt::NoBrush);
@@ -561,7 +563,7 @@ void PartCanvas::mousePress(QMouseEvent* me)
if (hit == HIT_SUBTRACK) {
TLSWidget* w = (TLSWidget*)(at->tw);
- int y = pos.y() - w->y() + 2;
+ int y = wpos.y() + pos.y() - w->y();
w->mousePress(QPoint(pos.x(), y), button);
state = S_SUBTRACK;
return;
@@ -653,7 +655,7 @@ void PartCanvas::mouseMove(QPoint pos)
{
if (state == S_SUBTRACK) {
TLSWidget* w = (TLSWidget*)(at->tw);
- int y = pos.y() - w->y() + 2 - rulerHeight;
+ int y = wpos.y() + pos.y() - w->y() - rulerHeight;
w->mouseMove(QPoint(pos.x(), y));
return;
}
diff --git a/muse/muse/arranger/tlswidget.cpp b/muse/muse/arranger/tlswidget.cpp
index 393e7d1e..6e20c3b4 100644
--- a/muse/muse/arranger/tlswidget.cpp
+++ b/muse/muse/arranger/tlswidget.cpp
@@ -165,7 +165,7 @@ Ctrl* TLSWidget::ctrl() const
int TLSWidget::cheight() const
{
- return at->tw->height() - 4;
+ return at->tw->height() - splitWidth;
}
//---------------------------------------------------------
diff --git a/muse/muse/arranger/tlwidget.cpp b/muse/muse/arranger/tlwidget.cpp
index d72856f2..87212e0b 100644
--- a/muse/muse/arranger/tlwidget.cpp
+++ b/muse/muse/arranger/tlwidget.cpp
@@ -629,16 +629,13 @@ void TLWidget::paintEvent(QPaintEvent* ev)
QColor color(_track->selected() ? selectBgColor : bgColor);
p.fillRect(r, color);
-// does not work if scrolled:
-// if (r==rect()) // only draw on full redraw
- paintHLine(p, r.x(), r.x() + r.width(), height() - splitWidth);
+ paintHLine(p, r.x(), r.x() + r.width(), height() - splitWidth);
QPalette pl = nameEdit->palette();
pl.setColor(QPalette::Window, color);
pl.setColor(QPalette::Base, color);
nameEdit->setPalette(pl);
// The selected track will get a 4 pixel red bar to the left
-// if ( _track->selected() && r==rect() /* only draw on full redraw */) {
if ( _track->selected()) {
QColor color(200,10,10);
QRect qr(0, 0, 4, r.height()-splitWidth);
diff --git a/muse/muse/ctrl.cpp b/muse/muse/ctrl.cpp
index c2eac773..056f4caf 100644
--- a/muse/muse/ctrl.cpp
+++ b/muse/muse/ctrl.cpp
@@ -330,18 +330,18 @@ void Ctrl::write(Xml& xml)
int Ctrl::val2pixelR(CVal val, int maxpixel)
{
+ maxpixel -= 1;
if (_type & INT)
- return maxpixel - ((maxpixel * (val.i - min.i) + (max.i-min.i)/2) / (max.i-min.i));
+ return maxpixel - ((maxpixel * (val.i - min.i) + (max.i-min.i)/2) / (max.i - min.i));
else
- return maxpixel - lrint(float(maxpixel) * (val.f - min.f) / (max.f-min.f));
+ return maxpixel - lrint(double(maxpixel) * (val.f - min.f) / (max.f-min.f));
}
int Ctrl::val2pixelR(int val, int maxpixel)
{
- if (_type & INT)
- return maxpixel - (maxpixel * (val - min.i) / (max.i-min.i));
- else
- return maxpixel - lrint(float(maxpixel) * (val - min.f) / (max.f-min.f));
+ maxpixel -= 1;
+ int range = max.i - min.i;
+ return maxpixel - ((maxpixel * (val - min.i) + range / 2) / range);
}
//---------------------------------------------------------
@@ -350,6 +350,7 @@ int Ctrl::val2pixelR(int val, int maxpixel)
CVal Ctrl::pixel2val(int pixel, int maxpixel)
{
+ maxpixel -= 1;
pixel = maxpixel - pixel;
// printf("pixel2val %d(%d) int %d, min %d, max %d\n",
@@ -363,15 +364,43 @@ CVal Ctrl::pixel2val(int pixel, int maxpixel)
rv.i = max.i;
}
else {
- rv.f = float(pixel) * (max.f - min.f) / float(maxpixel) + min.f;
+ rv.f = double(pixel) * (max.f - min.f) / double(maxpixel) + min.f;
if (rv.f < min.f)
rv.f = min.f;
else if (rv.f > max.f)
rv.f = max.f;
+ if (_type & LOG)
+ rv.f = pow(10.0f, rv.f);
}
+ return rv;
+ }
+
+//---------------------------------------------------------
+// pixel2valR
+//---------------------------------------------------------
- if (_type & LOG)
- rv.f = pow(10.0f, rv.f);
+CVal Ctrl::pixel2valR(int pixel, int maxpixel)
+ {
+ maxpixel -= 1;
+ pixel = maxpixel - pixel;
+
+// printf("pixel2val %d(%d) int %d, min %d, max %d\n",
+// pixel, maxpixel, _type & INT, min.i, max.i);
+ CVal rv;
+ if (_type & INT) {
+ rv.i = (pixel * (max.i - min.i) + (maxpixel+min.i)/2) / maxpixel + min.i;
+ if (rv.i < min.i)
+ rv.i = min.i;
+ else if (rv.i > max.i)
+ rv.i = max.i;
+ }
+ else {
+ rv.f = double(pixel) * (max.f - min.f) / double(maxpixel) + min.f;
+ if (rv.f < min.f)
+ rv.f = min.f;
+ else if (rv.f > max.f)
+ rv.f = max.f;
+ }
return rv;
}
diff --git a/muse/muse/ctrl.h b/muse/muse/ctrl.h
index df4a3b6b..2474db1a 100644
--- a/muse/muse/ctrl.h
+++ b/muse/muse/ctrl.h
@@ -199,6 +199,7 @@ class Ctrl : public CTRL {
int val2pixelR(CVal, int maxpixel);
int val2pixelR(int, int maxpixel);
CVal pixel2val(int pixel, int maxpixel);
+ CVal pixel2valR(int pixel, int maxpixel);
};
//---------------------------------------------------------
diff --git a/muse/muse/ctrl/ctrleditor.cpp b/muse/muse/ctrl/ctrleditor.cpp
index bbab4119..efc94ca3 100644
--- a/muse/muse/ctrl/ctrleditor.cpp
+++ b/muse/muse/ctrl/ctrleditor.cpp
@@ -28,6 +28,7 @@
#include "part.h"
#include "tools.h"
#include "muse.h"
+#include "gui.h"
static const int HANDLE1 = 6;
static const int HANDLE2 = 3;
@@ -42,7 +43,6 @@ CtrlEditor::CtrlEditor()
_drawCtrlName = false;
dragy = -1;
lselected = 0;
- dragy = -1;
singlePitch = -1;
drawRuler = false;
}
@@ -215,17 +215,19 @@ void CtrlEditor::mousePress(const QPoint& pos, int button)
int cid = ctrl()->id();
if (tool == PencilTool) {
- CVal val = ctrl()->pixel2val(y, wh);
- selected = tc()->pix2pos(x);
+ selected = tc()->pix2pos(x);
+ lselected = x;
+ dragy = y;
+ dragx = x;
+ dragYoffset = 0;
if (cid == CTRL_VELOCITY || cid == CTRL_SVELOCITY)
song->startUndo();
else {
+ // add controller:
+ CVal val = ctrl()->pixel2val(dragy, wh);
song->addControllerVal(ctrlTrack(), ctrl(), selected, val);
tc()->widget()->update();
}
- lselected = x;
- dragy = y;
- dragx = x;
}
else if (tool == PointerTool || tool == RubberTool) {
if (cid == CTRL_VELOCITY || cid == CTRL_SVELOCITY) {
@@ -340,8 +342,8 @@ void CtrlEditor::mouseRelease()
CVal val = ctrl()->pixel2val(dragy, wh);
// modify controller:
song->addControllerVal(ctrlTrack(), ctrl(), selected, val);
- dragy = -1;
}
+ dragy = -1;
}
}
@@ -432,8 +434,13 @@ void CtrlEditor::mouseMove(const QPoint& pos)
}
}
}
- if (dragy != -1)
+ if (dragy != -1) {
dragy = pos.y() + dragYoffset;
+ if (dragy < 0)
+ dragy = 0;
+ else if (dragy > cheight())
+ dragy = cheight();
+ }
}
tc()->widget()->update();
}
diff --git a/muse/muse/gui.h b/muse/muse/gui.h
index 3c780bfe..155a8a58 100644
--- a/muse/muse/gui.h
+++ b/muse/muse/gui.h
@@ -34,8 +34,10 @@ static const int splitWidth = 6;
static const int trackRowHeight = 24;
static const int minTrackHeight = trackRowHeight + splitWidth + 1;
static const int defaultTrackHeight = minTrackHeight;
-static const int infoHeight = 20;
-static const int infoWidth = 140;
+static const int infoHeight = 20;
+static const int infoWidth = 140;
+static const int trackSeparator = 1;
+static const int yTrackOffset = -4;
// mixer:
static const int STRIP_WIDTH = 66;
diff --git a/muse/muse/midictrl.cpp b/muse/muse/midictrl.cpp
index af3aacf4..fc6fd665 100644
--- a/muse/muse/midictrl.cpp
+++ b/muse/muse/midictrl.cpp
@@ -79,9 +79,9 @@ static MidiController programCtrl("Program", CTRL_PROGRAM, 0, 0xfff
static MidiController mastervolCtrl("MasterVolume", CTRL_MASTER_VOLUME, 0, 0x3fff, 0x3000);
static MidiController volumeCtrl("MainVolume", CTRL_VOLUME, 0, 127, 100);
static MidiController panCtrl("Pan", CTRL_PANPOT, 0, 127, 64);
-static MidiController reverbCtrl("ReverbSend", CTRL_REVERB_SEND, 0, 127, 0);
-static MidiController chorusCtrl("ChorusSend", CTRL_CHORUS_SEND, 0, 127, 0);
-static MidiController variationCtrl("VariationSend", CTRL_VARIATION_SEND,0, 127, 0);
+static MidiController reverbCtrl("ReverbSend", CTRL_REVERB_SEND, 0, 127, 0);
+static MidiController chorusCtrl("ChorusSend", CTRL_CHORUS_SEND, 0, 127, 0);
+static MidiController variationCtrl("VariationSend",CTRL_VARIATION_SEND,0, 127, 0);
//---------------------------------------------------------
// ctrlType2Int
diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp
index eb131878..41eff98a 100644
--- a/muse/muse/song.cpp
+++ b/muse/muse/song.cpp
@@ -2247,6 +2247,7 @@ void Song::addControllerVal(Track* t, Ctrl* c, const Pos& p, CVal val)
}
else {
CVal oval = c->value(time);
+// printf("change controller %f - %f\n", oval.f, val.f);
startUndo();
undoOp(UndoOp::ModifyCtrl, t, c->id(), time, val, oval);
c->add(time, val);
diff --git a/muse/synti/deicsonze/deicsonze.cpp b/muse/synti/deicsonze/deicsonze.cpp
index 9592e120..b7d6adca 100644
--- a/muse/synti/deicsonze/deicsonze.cpp
+++ b/muse/synti/deicsonze/deicsonze.cpp
@@ -104,8 +104,8 @@ DeicsOnze::DeicsOnze() : Mess(2)
//initialization GUI
_gui = new DeicsOnzeGui(this);
+ _gui->hide(); // to avoid flicker during MusE startup
_gui->setWindowTitle(QString("DeicsOnze"));
- _gui->show();
//Load configuration
QString defaultConf = (QString(getenv("HOME")) + QString("/." DEICSONZESTR ".dco"));
diff --git a/muse/synti/fluid/fluid.cpp b/muse/synti/fluid/fluid.cpp
index 2f67a528..fbd8701c 100644
--- a/muse/synti/fluid/fluid.cpp
+++ b/muse/synti/fluid/fluid.cpp
@@ -513,8 +513,8 @@ bool ISynth::init(const char* name)
}
gui = new FLUIDGui;
+ gui->hide(); // to avoid flicker during MusE startup
gui->setWindowTitle(QString(name));
- gui->show();
return false;
}
diff --git a/muse/synti/vam/vam.cpp b/muse/synti/vam/vam.cpp
index 652599c6..7ee9778f 100644
--- a/muse/synti/vam/vam.cpp
+++ b/muse/synti/vam/vam.cpp
@@ -7,7 +7,7 @@
// Werner Schweer's organ softsynth for MusE.
// The music-dsp source archive.
//
-// (C) Copyright 2002 Jotsif Lindman Hörnlund (jotsif@linux.nu)
+// (C) Copyright 2002 Jotsif Lindman Hönlund (jotsif@linux.nu)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -301,8 +301,8 @@ float *VAM::wave_tbl(int wave)
bool VAM::init(const char* name)
{
gui = new VAMGui;
+ gui->hide(); // to avoid flicker during MusE startup
gui->setWindowTitle(QString(name));
- gui->show();
if (useCount == 0) {
int i;