summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-09-14 13:55:37 +0000
committerFlorian Jung <flo@windfisch.org>2011-09-14 13:55:37 +0000
commit539b0f88b82d7f0f9c625165c815cbbe19599b1c (patch)
treeaffc9cf66b206b5dd9eee635c335c839277bfa75 /muse2
parenta8c8fa89d916bded2905e0a5a8c05ac30e159902 (diff)
fixed window->tile
Diffstat (limited to 'muse2')
-rw-r--r--muse2/muse/app.cpp60
-rw-r--r--muse2/muse/app.h1
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp4
3 files changed, 62 insertions, 3 deletions
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index bbe5de22..de35e5bc 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -919,7 +919,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setCentralWidget(mdiArea);
- connect(windowsTileAction, SIGNAL(activated()), mdiArea, SLOT(tileSubWindows()));
+ connect(windowsTileAction, SIGNAL(activated()), this, SLOT(tileSubWindows()));
connect(windowsRowsAction, SIGNAL(activated()), this, SLOT(arrangeSubWindowsRows()));
connect(windowsColumnsAction, SIGNAL(activated()), this, SLOT(arrangeSubWindowsColumns()));
connect(windowsCascadeAction, SIGNAL(activated()), mdiArea, SLOT(cascadeSubWindows()));
@@ -3299,9 +3299,17 @@ list<QMdiSubWindow*> get_all_visible_subwins(QMdiArea* mdiarea)
QList<QMdiSubWindow*> wins = mdiarea->subWindowList();
list<QMdiSubWindow*> result;
+ // always put the arranger at the top of the list, if visible
+
for (QList<QMdiSubWindow*>::iterator it=wins.begin(); it!=wins.end(); it++)
if ((*it)->isVisible() && ((*it)->isMinimized()==false))
- result.push_back(*it);
+ if (dynamic_cast<TopWin*>((*it)->widget())->type()==TopWin::ARRANGER)
+ result.push_back(*it);
+
+ for (QList<QMdiSubWindow*>::iterator it=wins.begin(); it!=wins.end(); it++)
+ if ((*it)->isVisible() && ((*it)->isMinimized()==false))
+ if (dynamic_cast<TopWin*>((*it)->widget())->type()!=TopWin::ARRANGER)
+ result.push_back(*it);
return result;
}
@@ -3376,4 +3384,52 @@ void MusE::arrangeSubWindowsRows()
}
}
+void MusE::tileSubWindows()
+{
+ list<QMdiSubWindow*> wins=get_all_visible_subwins(mdiArea);
+ int n=wins.size();
+
+ if (n==0)
+ return;
+ else if (n==1)
+ (*wins.begin())->showMaximized();
+ else
+ {
+ int nx,ny;
+ nx=ceil(sqrt(n));
+ ny=ceil((double)n/nx);
+
+ int width = mdiArea->width();
+ int height = mdiArea->height();
+ int x_add = (*wins.begin())->frameGeometry().width() - (*wins.begin())->geometry().width();
+ int y_add = (*wins.begin())->frameGeometry().height() - (*wins.begin())->geometry().height();
+ int height_per_win = height/ny;
+ int width_per_win = height/nx;
+
+ if ((x_add >= width_per_win) || (y_add >= height_per_win))
+ {
+ printf("ERROR: tried to tile subwins, but there's too few space.\n");
+ return;
+ }
+
+ int i=0, j=0;
+ for (list<QMdiSubWindow*>::iterator it=wins.begin(); it!=wins.end(); it++, i++)
+ {
+ if (i>=nx)
+ {
+ i=0;
+ j++;
+ }
+
+ int top = (float) height*j/ny;
+ int bottom = (float) height*(j+1.0)/ny;
+ int left = (float) width*i/nx;
+ int right = (float) width*(i+1.0)/nx;
+
+ (*it)->move(left,top);
+ (*it)->resize(right-left-x_add, bottom-top-y_add);
+ }
+ }
+}
+
} //namespace MusEApp
diff --git a/muse2/muse/app.h b/muse2/muse/app.h
index cd18ba4a..3bde68e1 100644
--- a/muse2/muse/app.h
+++ b/muse2/muse/app.h
@@ -325,6 +325,7 @@ class MusE : public QMainWindow
void arrangeSubWindowsRows();
void arrangeSubWindowsColumns();
+ void tileSubWindows();
public slots:
bool saveAs();
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index 06e32c9c..a16a872e 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -4539,7 +4539,9 @@ void ScoreCanvas::add_new_parts(const std::map< Part*, std::set<Part*> >& param)
* from clipboard failed. ignoring this one... ) [ not reproducible ]
*
* CURRENT TODO
- * o TEST pasting in editors!
+ * M o ecanvas: FINDMICH
+ * M o dialog.cpp: FINDMICH
+ * M o TEST pasting in editors!
*
* o ticks-to-quarter spinboxes
*