| 97 | } |
| 98 | |
| 99 | void DocumentSwitcherPlugin::setViewGeometry(Sublime::MainWindow* window) |
| 100 | { |
| 101 | const QSize centralSize = window->centralWidget()->size(); |
| 102 | |
| 103 | // Maximum size of the view is 3/4th of the central widget (the editor area) so the view does not overlap the |
| 104 | // mainwindow since that looks awkward. |
| 105 | const QSize viewMaxSize( centralSize.width() * 3/4, centralSize.height() * 3/4 ); |
| 106 | |
| 107 | // The actual view size should be as big as the columns/rows need it, but smaller than the max-size. This means |
| 108 | // the view will get quite high with many open files but I think that is ok. Otherwise one can easily tweak the |
| 109 | // max size to be only 1/2th of the central widget size |
| 110 | const int rowHeight = view->sizeHintForRow(0); |
| 111 | const int frameWidth = view->frameWidth(); |
| 112 | const QSize viewSize( std::min( view->sizeHintForColumn(0) + 2 * frameWidth + view->verticalScrollBar()->width(), viewMaxSize.width() ), |
| 113 | std::min( std::max( rowHeight * view->model()->rowCount() + 2 * frameWidth, rowHeight * 6 ), viewMaxSize.height() ) ); |
| 114 | |
| 115 | // Position should be central over the editor area, so map to global from parent of central widget since |
| 116 | // the view is positioned in global coords |
| 117 | QPoint centralWidgetPos = window->mapToGlobal( window->centralWidget()->pos() ); |
| 118 | const int xPos = std::max(0, centralWidgetPos.x() + (centralSize.width() - viewSize.width() ) / 2); |
| 119 | const int yPos = std::max(0, centralWidgetPos.y() + (centralSize.height() - viewSize.height() ) / 2); |
| 120 | |
| 121 | view->setFixedSize(viewSize); |
| 122 | view->move(xPos, yPos); |
| 123 | } |
| 124 | |
| 125 | void DocumentSwitcherPlugin::walk(const int from, const int to) |
| 126 | { |