summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog6
-rw-r--r--muse2/muse/app.cpp2
-rw-r--r--muse2/muse/app.h2
-rw-r--r--muse2/muse/arranger/arranger.cpp1
-rw-r--r--muse2/muse/mixer/amixer.cpp182
-rw-r--r--muse2/muse/mixer/amixer.h24
-rw-r--r--muse2/muse/mixer/astrip.cpp17
-rw-r--r--muse2/muse/mixer/astrip.h1
8 files changed, 200 insertions, 35 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index e856c5a8..ec50b3d2 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,9 @@
+16.11.2010
+ - Fixed mixer maximum and minimum sizes. (Tim)
+ Bit of a tough hack. Is there a better way? Done by sub-classing QScrollArea and catching
+ LayoutRequest events, just before paint events when the window sizes are finally correct.
+ TODO: Still off by a few pixels when mixer first opened, because main window frameSize
+ is not set yet, by the time LayoutRequest is caught.
14.11.2010
- renamed deicsonze2 files and classes with '2' suffixes
- Applied patch by Orcan to convert populateAddSynth(). (Tim)
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index 28c5e545..1bdcee8e 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -860,7 +860,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
watchdogThread = 0;
editInstrument = 0;
routingPopupMenu = 0;
- routingPopupView = 0;
+ //routingPopupView = 0;
appName = QString("MusE");
diff --git a/muse2/muse/app.h b/muse2/muse/app.h
index b13c38a3..55f81f71 100644
--- a/muse2/muse/app.h
+++ b/muse2/muse/app.h
@@ -117,7 +117,7 @@ class MusE : public QMainWindow
// Special 'stay-open' menu for routes.
PopupMenu* routingPopupMenu;
- PopupView* routingPopupView;
+ //PopupView* routingPopupView;
int aid1a, aid1b, aid2, aid3, autoId;
int tr_id, bt_id, mr_id;
diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp
index 422980f1..ac2f1548 100644
--- a/muse2/muse/arranger/arranger.cpp
+++ b/muse2/muse/arranger/arranger.cpp
@@ -331,7 +331,6 @@ Arranger::Arranger(QMainWindow* parent, const char* name)
QGridLayout* egrid = new QGridLayout(editor);
egrid->setColStretch(0, 50);
egrid->setRowStretch(2, 50);
- //egrid->setContentsMargins(0, 0, 0, 0);
egrid->setContentsMargins(0, 0, 0, 0);
egrid->setSpacing(0);
diff --git a/muse2/muse/mixer/amixer.cpp b/muse2/muse/mixer/amixer.cpp
index dccdb53b..7644d532 100644
--- a/muse2/muse/mixer/amixer.cpp
+++ b/muse2/muse/mixer/amixer.cpp
@@ -11,6 +11,8 @@
#include <QApplication>
#include <QMenuBar>
+#include <QResizeEvent>
+#include <QPaintEvent>
//Added by qt3to4:
#include <QHBoxLayout>
#include <QCloseEvent>
@@ -36,6 +38,106 @@ extern void populateAddTrack(QMenu* addTrack);
//typedef std::list<Strip*> StripList;
//static StripList stripList;
+
+/*
+Nov 16, 2010: After making the strips variable width, we need a way to
+ set the maximum size of the main window.
+
+// See help Qt4 "Window Geometry"
+// "On X11, a window does not have a frame until the window manager decorates it.
+// This happens asynchronously at some point in time after calling QWidget::show()
+// and the first paint event the window receives, or it does not happen at all.
+// " ...you cannot make any safe assumption about the decoration frame your window will get."
+// "X11 provides no standard or easy way to get the frame geometry once the window is decorated.
+// Qt solves this problem with nifty heuristics and clever code that works on a wide range of
+// window managers that exist today..."
+//
+
+Sequence of events when mixer is opened, and then when a strip is added:
+
+ViewWidget::event type:68 // Mixer opened:
+Event is QEvent::ChildAdded
+ViewWidget::event type:18
+ViewWidget::event type:27
+ViewWidget::event type:131
+ScrollArea::viewportEvent type:68
+Event is QEvent::ChildAdded
+ViewWidget::event type:21
+ViewWidget::event type:75
+ViewWidget::event type:70
+ScrollArea::viewportEvent type:69
+Event is QEvent::ChildPolished
+child width:100 frame width:100
+ViewWidget::event type:26
+ViewWidget::event type:68
+Event is QEvent::ChildAdded
+ViewWidget::event type:69
+Event is QEvent::ChildPolished
+child width:100 frame width:100 // Size is not correct yet
+AudioMixerApp::updateMixer other
+ScrollArea::viewportEvent type:75
+ScrollArea::viewportEvent type:70
+ScrollArea::viewportEvent type:13
+ScrollArea::viewportEvent type:14
+ViewWidget::event type:70
+ViewWidget::event type:13
+ViewWidget::event type:14
+ViewWidget::event type:17
+ScrollArea::viewportEvent type:17
+ScrollArea::viewportEvent type:26
+ViewWidget::event type:67
+ScrollArea::viewportEvent type:67
+ViewWidget::event type:67
+ScrollArea::viewportEvent type:14
+ViewWidget::event type:14
+ScrollArea::viewportEvent type:74
+ViewWidget::event type:74
+ViewWidget::event type:76
+ScrollArea::viewportEvent type:76 // Layout request:
+Event is QEvent::LayoutRequest
+AudioMixerApp::setSizing width:75 frame width:2
+ScrollArea::viewportEvent type:14
+ViewWidget::event type:14
+ViewWidget::event type:12 // Paint event:
+ViewWidget::paintEvent // By this time the size is correct.
+ScrollArea::viewportEvent type:24 // But to avoid having to do the resizing
+ViewWidget::event type:24 // in every paint event, do it just after
+ScrollArea::viewportEvent type:14 // the layout request, as shown above.
+ViewWidget::event type:14 // Hopefully that is a good time to do it.
+ViewWidget::event type:12
+ViewWidget::paintEvent
+ScrollArea::viewportEvent type:25
+ViewWidget::event type:25
+
+ViewWidget::event type:68 // Strip is added:
+Event is QEvent::ChildAdded
+ViewWidget::event type:69
+Event is QEvent::ChildPolished
+child width:100 frame width:100 // Size not correct yet.
+ViewWidget::event type:70
+AudioMixerApp::updateMixer other
+ViewWidget::event type:67
+ViewWidget::event type:76
+ScrollArea::viewportEvent type:76
+ViewWidget::event type:14
+Event is QEvent::LayoutRequest
+AudioMixerApp::setSizing width:75 frame width:2
+AudioMixerApp::setSizing width:75 frame width:2
+ViewWidget::event type:12 // Size is correct by now.
+ViewWidget::paintEvent
+*/
+
+bool ScrollArea::viewportEvent(QEvent* event)
+{
+ // Let it do the layout now, before we emit.
+ QScrollArea::viewportEvent(event);
+
+ if(event->type() == QEvent::LayoutRequest)
+ emit layoutRequest();
+
+ return false;
+}
+
//---------------------------------------------------------
// AudioMixer
//
@@ -98,7 +200,8 @@ AudioMixerApp::AudioMixerApp(QWidget* parent, MixerConfig* c)
menuView->addActions(actionItems->actions());
- view = new QScrollArea();
+ ///view = new QScrollArea();
+ view = new ScrollArea();
view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setCentralWidget(view);
@@ -110,11 +213,54 @@ AudioMixerApp::AudioMixerApp(QWidget* parent, MixerConfig* c)
view->setWidget(central);
view->setWidgetResizable(true);
+ connect(view, SIGNAL(layoutRequest()), SLOT(setSizing()));
+ ///connect(this, SIGNAL(layoutRequest()), SLOT(setSizing()));
+
connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
connect(muse, SIGNAL(configChanged()), SLOT(configChanged()));
song->update(); // calls update mixer
}
+/*
+bool AudioMixerApp::event(QEvent* event)
+{
+ printf("AudioMixerApp::event type:%d\n", event->type()); // REMOVE Tim.
+
+ // Let it do the layout now, before we emit.
+ QMainWindow::event(event);
+
+ if(event->type() == QEvent::LayoutRequest)
+ emit layoutRequest();
+
+ return false;
+}
+*/
+
+void AudioMixerApp::setSizing()
+{
+ int w = 0;
+ StripList::iterator si = stripList.begin();
+ for (; si != stripList.end(); ++si)
+ {
+ //w += (*si)->frameGeometry().width();
+ //Strip* s = *si;
+ //printf("AudioMixerApp::setSizing width:%d frame width:%d\n", s->width(), s->frameWidth()); // REMOVE Tim
+ //w += s->width() + 2 * (s->frameWidth() + s->lineWidth() + s->midLineWidth());
+ //w += s->width() + 2 * s->frameWidth();
+ w += (*si)->width();
+ }
+
+ //w += 2* style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ // FIXME: When mixer first opened, frameSize is not correct yet, done after main window shown.
+ w += frameSize().width() - width();
+
+ if(w < 40)
+ w = 40;
+ setMaximumWidth(w);
+ if(stripList.size() <= 6)
+ view->setMinimumWidth(w);
+}
+
//---------------------------------------------------------
// addStrip
//---------------------------------------------------------
@@ -166,23 +312,6 @@ void AudioMixerApp::clear()
}
//---------------------------------------------------------
-// computeWidth
-//---------------------------------------------------------
-int AudioMixerApp::computeWidth()
-{
- int w = 0;
- StripList::iterator si = stripList.begin();
- for (; si != stripList.end(); ++si) {
- //w += (*si)->width();
- //w += (*si)->frameGeometry().width();
- Strip* s = *si;
- //w += s->width() + 2 * (s->frameWidth() + s->lineWidth() + s->midLineWidth());
- w += s->width() + 2 * s->frameWidth();
- }
- return w;
-}
-
-//---------------------------------------------------------
// updateMixer
//---------------------------------------------------------
@@ -228,17 +357,8 @@ void AudioMixerApp::updateMixer(UpdateAction action)
stripList.erase(ssi);
}
- // TODO: See help Qt4 "Window Geometry"
- // "On X11, a window does not have a frame until the window manager decorates it.
- // This happens asynchronously at some point in time after calling QWidget::show()
- // and the first paint event the window receives, or it does not happen at all.
- // " ...you cannot make any safe assumption about the decoration frame your window will get."
- // "X11 provides no standard or easy way to get the frame geometry once the window is decorated.
- // Qt solves this problem with nifty heuristics and clever code that works on a wide range of
- // window managers that exist today..."
- //
- // I think I may be seeing these issues here...
- //
+ //printf("AudioMixerApp::updateMixer STRIP_REMOVED\n"); // REMOVE Tim
+
//setMaximumWidth(STRIP_WIDTH * stripList.size() + __WIDTH_COMPENSATION);
/// int w = computeWidth();
/// setMaximumWidth(w);
@@ -288,6 +408,8 @@ void AudioMixerApp::updateMixer(UpdateAction action)
addStrip(*i, idx++);
}
+ //printf("AudioMixerApp::updateMixer UPDATE_MIDI\n"); // REMOVE Tim
+
//setMaximumWidth(STRIP_WIDTH * stripList.size() + __WIDTH_COMPENSATION);
/// int w = computeWidth();
/// setMaximumWidth(w);
@@ -376,6 +498,8 @@ void AudioMixerApp::updateMixer(UpdateAction action)
addStrip(*i, idx++);
}
+ //printf("AudioMixerApp::updateMixer other\n"); // REMOVE Tim
+
//setMaximumWidth(STRIP_WIDTH * idx + __WIDTH_COMPENSATION);
/// int w = computeWidth();
/// setMaximumWidth(w);
diff --git a/muse2/muse/mixer/amixer.h b/muse2/muse/mixer/amixer.h
index abe38626..db966cd6 100644
--- a/muse2/muse/mixer/amixer.h
+++ b/muse2/muse/mixer/amixer.h
@@ -50,6 +50,24 @@ struct MixerConfig;
typedef std::list<Strip*> StripList;
//---------------------------------------------------------
+// ScrollArea
+//---------------------------------------------------------
+
+class ScrollArea : public QScrollArea
+{
+ Q_OBJECT
+
+ signals:
+ void layoutRequest();
+
+ protected:
+ virtual bool viewportEvent(QEvent* event);
+
+ public:
+ ScrollArea(QWidget* parent = 0) : QScrollArea(parent) { }
+};
+
+//---------------------------------------------------------
// AudioMixerApp
//---------------------------------------------------------
@@ -86,15 +104,16 @@ class AudioMixerApp : public QMainWindow {
NO_UPDATE, UPDATE_ALL, UPDATE_MIDI, STRIP_INSERTED, STRIP_REMOVED
};
void updateMixer(UpdateAction);
- int computeWidth();
signals:
void closed();
+ //void layoutRequest();
private slots:
void songChanged(int);
//void configChanged() { songChanged(-1); }
void configChanged();
+ void setSizing();
void toggleRouteDialog();
void routingDialogClosed();
//void showTracksChanged(QAction*);
@@ -107,6 +126,9 @@ class AudioMixerApp : public QMainWindow {
void showAuxTracksChanged(bool);
void showSyntiTracksChanged(bool);
+ //protected:
+ // virtual bool event(QEvent* event);
+
public:
//AudioMixerApp(QWidget* parent);
AudioMixerApp(QWidget* parent, MixerConfig* c);
diff --git a/muse2/muse/mixer/astrip.cpp b/muse2/muse/mixer/astrip.cpp
index 9c42f18c..98707d18 100644
--- a/muse2/muse/mixer/astrip.cpp
+++ b/muse2/muse/mixer/astrip.cpp
@@ -71,7 +71,8 @@ QWidget* MenuTitleItem::createWidget(QWidget *parent)
return l;
}
-/*//---------------------------------------------------------
+/*
+//---------------------------------------------------------
// minimumSizeHint
//---------------------------------------------------------
@@ -79,7 +80,19 @@ QSize AudioStrip::minimumSizeHint () const
{
// We force the width of the size hint to be what we want
//return QWidget::minimumSizeHint();
- return QSize(66,QWidget::minimumSizeHint().height());
+ ///return QSize(66,QWidget::minimumSizeHint().height());
+}
+
+//---------------------------------------------------------
+// sizeHint
+//---------------------------------------------------------
+
+QSize AudioStrip::sizeHint () const
+{
+ // We force the width of the size hint to be what we want
+ //return QWidget::minimumSizeHint();
+ //return QSize(66,QWidget::minimumSizeHint().height());
+ return minimumSizeHint();
}
*/
diff --git a/muse2/muse/mixer/astrip.h b/muse2/muse/mixer/astrip.h
index a60b4dd8..88cef89b 100644
--- a/muse2/muse/mixer/astrip.h
+++ b/muse2/muse/mixer/astrip.h
@@ -92,6 +92,7 @@ class AudioStrip : public Strip {
AudioStrip(QWidget* parent, AudioTrack*);
~AudioStrip();
///virtual QSize minimumSizeHint () const;
+ //virtual QSize sizeHint () const;
};
#endif