diff options
author | Florian Jung <flo@windfisch.org> | 2011-08-30 16:25:38 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-08-30 16:25:38 +0000 |
commit | 8c37b557d6f865b4320f7b1168030e7d54adacd0 (patch) | |
tree | 9c567b12dd852423df8056857417067151ff3f95 | |
parent | 9cfbb1578284150b7251e6f58a77c4dc07667deb (diff) |
added "arrange windows in rows" and "in columns" functions
-rw-r--r-- | muse2/muse/app.cpp | 94 | ||||
-rw-r--r-- | muse2/muse/app.h | 5 | ||||
-rw-r--r-- | muse2/muse/midiedit/scoreedit.cpp | 12 |
3 files changed, 100 insertions, 11 deletions
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp index cece85ed..91dbaed8 100644 --- a/muse2/muse/app.cpp +++ b/muse2/muse/app.cpp @@ -542,6 +542,8 @@ MusE::MusE(int argc, char** argv) : QMainWindow() //-------- Windows Actions windowsCascadeAction = new QAction(tr("Cascade"), this); windowsTileAction = new QAction(tr("Tile"), this); + windowsRowsAction = new QAction(tr("In rows"), this); + windowsColumnsAction = new QAction(tr("In columns"), this); //-------- Settings Actions @@ -841,6 +843,8 @@ MusE::MusE(int argc, char** argv) : QMainWindow() menuWindows->addAction(windowsCascadeAction); menuWindows->addAction(windowsTileAction); + menuWindows->addAction(windowsRowsAction); + menuWindows->addAction(windowsColumnsAction); //------------------------------------------------------------- // popup Settings @@ -896,6 +900,8 @@ MusE::MusE(int argc, char** argv) : QMainWindow() mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setCentralWidget(mdiArea); connect(windowsTileAction, SIGNAL(activated()), mdiArea, SLOT(tileSubWindows())); + connect(windowsRowsAction, SIGNAL(activated()), this, SLOT(arrangeSubWindowsRows())); + connect(windowsColumnsAction, SIGNAL(activated()), this, SLOT(arrangeSubWindowsColumns())); connect(windowsCascadeAction, SIGNAL(activated()), mdiArea, SLOT(cascadeSubWindows())); @@ -3202,6 +3208,8 @@ void MusE::updateWindowMenu() menuWindows->addAction(windowsCascadeAction); menuWindows->addAction(windowsTileAction); + menuWindows->addAction(windowsRowsAction); + menuWindows->addAction(windowsColumnsAction); sep=false; for (iToplevel it=toplevels.begin(); it!=toplevels.end(); it++) @@ -3237,6 +3245,8 @@ void MusE::updateWindowMenu() windowsCascadeAction->setEnabled(there_are_subwins); windowsTileAction->setEnabled(there_are_subwins); + windowsRowsAction->setEnabled(there_are_subwins); + windowsColumnsAction->setEnabled(there_are_subwins); } void MusE::bringToFront(QWidget* widget) @@ -3261,3 +3271,87 @@ void MusE::setFullscreen(bool val) else showNormal(); } + + + +list<QMdiSubWindow*> get_all_visible_subwins(QMdiArea* mdiarea) +{ + QList<QMdiSubWindow*> wins = mdiarea->subWindowList(); + list<QMdiSubWindow*> result; + + for (QList<QMdiSubWindow*>::iterator it=wins.begin(); it!=wins.end(); it++) + if ((*it)->isVisible() && ((*it)->isMinimized()==false)) + result.push_back(*it); + + return result; +} + +void MusE::arrangeSubWindowsColumns() +{ + 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 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 width_per_win = width/n; + + if (x_add >= width_per_win) + { + printf("ERROR: tried to arrange subwins in columns, but there's too few space.\n"); + return; + } + + int i=0; + for (list<QMdiSubWindow*>::iterator it=wins.begin(); it!=wins.end(); it++, i++) + { + int left = (float) width*i/n; + int right = (float) width*(i+1.0)/n; + + (*it)->move(left,0); + (*it)->resize(right-left-x_add, height-y_add); + } + } +} + +void MusE::arrangeSubWindowsRows() +{ + 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 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/n; + + if (y_add >= height_per_win) + { + printf("ERROR: tried to arrange subwins in rows, but there's too few space.\n"); + return; + } + + int i=0; + for (list<QMdiSubWindow*>::iterator it=wins.begin(); it!=wins.end(); it++, i++) + { + int top = (float) height*i/n; + int bottom = (float) height*(i+1.0)/n; + + (*it)->move(0,top); + (*it)->resize(width-x_add, bottom-top-y_add); + } + } +} diff --git a/muse2/muse/app.h b/muse2/muse/app.h index 8ff0f72c..83fb70ae 100644 --- a/muse2/muse/app.h +++ b/muse2/muse/app.h @@ -132,6 +132,8 @@ class MusE : public QMainWindow // Window Menu Actions QAction* windowsCascadeAction; QAction* windowsTileAction; + QAction* windowsRowsAction; + QAction* windowsColumnsAction; // Settings Menu Actions QAction *settingsGlobalAction, *settingsShortcutsAction, *settingsMetronomeAction, *settingsMidiSyncAction; @@ -296,6 +298,9 @@ class MusE : public QMainWindow void bringToFront(QWidget* win); void setFullscreen(bool); + + void arrangeSubWindowsRows(); + void arrangeSubWindowsColumns(); public slots: bool saveAs(); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index bf52f94b..eee92a9b 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4450,21 +4450,11 @@ void staff_t::update_part_indices() * * CURRENT TODO * M o remove that ugly "bool initalizing" stuff. it's probably unneeded (watch out for the FINDMICH message) - * m o shortcuts, especially for fullscreen + * M o shortcuts for "pencil" in score editor etc. * o mirror most menus to an additional right-click context menu to avoid the long mouse pointer * journey to the menu bar. try to find a way which does not involve duplicate code! * o implement borland-style maximize: free windows do not cover the main menu, even when maximized * - * o window menu -> "arrange" -> "all in rows" / "all in columns" - * o add everything of the function-menus of the midieditors to - * the arranger; except "move notes": call it "move parts" and - * actually move parts not notes - * how it works: - * there will be extra dialogs for the arranger - * when such a dialog has been executed, the "selected" option - * only controls the set<Part*>, but not the "selected" option - * which is given to the actual function call. the range option - * is kept. * o replace "insert empty measure" by a "global insert"-like operation * o replace "insert" and "paste" by a paste-dialog ("move other notes" or "overwrite notes" or "mix with notes") * skip dialog when there is nothing to erase, move or merge with (i.e., at the end of the song) |