comparison main/MainWindow.cpp @ 159:c07759e19346

* Fix Zoom to Fit and the scroll area (though I'd prefer scrollbar on the left)
author Chris Cannam
date Mon, 02 Jul 2007 18:57:32 +0000
parents d8ec67a6e3c7
children 10700f059548
comparison
equal deleted inserted replaced
158:d8ec67a6e3c7 159:c07759e19346
159 m_descriptionLabel = new QLabel; 159 m_descriptionLabel = new QLabel;
160 160
161 QScrollArea *scroll = new QScrollArea(frame); 161 QScrollArea *scroll = new QScrollArea(frame);
162 scroll->setWidgetResizable(true); 162 scroll->setWidgetResizable(true);
163 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 163 scroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
164 164 scroll->setFrameShape(QFrame::NoFrame);
165 QFrame *subframe = new QFrame; 165
166 scroll->setWidget(subframe); 166 // QFrame *subframe = new QFrame;
167 167 // scroll->setWidget(subframe);
168 m_paneStack = new PaneStack(subframe, m_viewManager); 168
169 // QGridLayout *sublayout = new QGridLayout;
170 // subframe->setLayout(sublayout);
171
172 // m_paneStack = new PaneStack(subframe, m_viewManager);
173 m_paneStack = new PaneStack(scroll, m_viewManager);
169 connect(m_paneStack, SIGNAL(currentPaneChanged(Pane *)), 174 connect(m_paneStack, SIGNAL(currentPaneChanged(Pane *)),
170 this, SLOT(currentPaneChanged(Pane *))); 175 this, SLOT(currentPaneChanged(Pane *)));
171 connect(m_paneStack, SIGNAL(currentLayerChanged(Pane *, Layer *)), 176 connect(m_paneStack, SIGNAL(currentLayerChanged(Pane *, Layer *)),
172 this, SLOT(currentLayerChanged(Pane *, Layer *))); 177 this, SLOT(currentLayerChanged(Pane *, Layer *)));
173 connect(m_paneStack, SIGNAL(rightButtonMenuRequested(Pane *, QPoint)), 178 connect(m_paneStack, SIGNAL(rightButtonMenuRequested(Pane *, QPoint)),
174 this, SLOT(rightButtonMenuRequested(Pane *, QPoint))); 179 this, SLOT(rightButtonMenuRequested(Pane *, QPoint)));
175 connect(m_paneStack, SIGNAL(propertyStacksResized()), 180 connect(m_paneStack, SIGNAL(propertyStacksResized()),
176 this, SLOT(propertyStacksResized())); 181 this, SLOT(propertyStacksResized()));
177 connect(m_paneStack, SIGNAL(contextHelpChanged(const QString &)), 182 connect(m_paneStack, SIGNAL(contextHelpChanged(const QString &)),
178 this, SLOT(contextHelpChanged(const QString &))); 183 this, SLOT(contextHelpChanged(const QString &)));
184
185 // sublayout->addWidget(m_paneStack, 0, 0);
186 scroll->setWidget(m_paneStack);
179 187
180 m_overview = new Overview(frame); 188 m_overview = new Overview(frame);
181 m_overview->setViewManager(m_viewManager); 189 m_overview->setViewManager(m_viewManager);
182 m_overview->setFixedHeight(40); 190 m_overview->setFixedHeight(40);
183 #ifndef _WIN32 191 #ifndef _WIN32
254 m_playSharpen->setChecked(settings.value("playsharpen", true).toBool()); 262 m_playSharpen->setChecked(settings.value("playsharpen", true).toBool());
255 m_playMono->setChecked(settings.value("playmono", false).toBool()); 263 m_playMono->setChecked(settings.value("playmono", false).toBool());
256 settings.endGroup(); 264 settings.endGroup();
257 265
258 layout->setSpacing(4); 266 layout->setSpacing(4);
259 layout->addWidget(m_paneStack, 0, 0, 1, 5); 267 layout->addWidget(scroll, 0, 0, 1, 5);
260 layout->addWidget(m_overview, 1, 0); 268 layout->addWidget(m_overview, 1, 0);
261 layout->addWidget(m_fader, 1, 1); 269 layout->addWidget(m_fader, 1, 1);
262 layout->addWidget(m_playSpeed, 1, 2); 270 layout->addWidget(m_playSpeed, 1, 2);
263 layout->addWidget(m_playSharpen, 1, 3); 271 layout->addWidget(m_playSharpen, 1, 3);
264 layout->addWidget(m_playMono, 1, 4); 272 layout->addWidget(m_playMono, 1, 4);
3222 if (!model) return; 3230 if (!model) return;
3223 3231
3224 size_t start = model->getStartFrame(); 3232 size_t start = model->getStartFrame();
3225 size_t end = model->getEndFrame(); 3233 size_t end = model->getEndFrame();
3226 size_t pixels = currentPane->width(); 3234 size_t pixels = currentPane->width();
3227 std::cerr << "pixels " << pixels << " -> "; 3235
3228 size_t sw = currentPane->getVerticalScaleWidth(); 3236 size_t sw = currentPane->getVerticalScaleWidth();
3229 if (pixels > sw * 2) pixels -= sw * 2; 3237 if (pixels > sw * 2) pixels -= sw * 2;
3230 else pixels = 1; 3238 else pixels = 1;
3231 std::cerr << pixels << " (sw = " << sw << ")"; 3239 if (pixels > 4) pixels -= 4;
3240
3232 size_t zoomLevel = (end - start) / pixels; 3241 size_t zoomLevel = (end - start) / pixels;
3233 3242
3234 currentPane->setZoomLevel(zoomLevel); 3243 currentPane->setZoomLevel(zoomLevel);
3235 currentPane->setStartFrame(start); 3244 currentPane->setCentreFrame((start + end) / 2);
3236 } 3245 }
3237 3246
3238 void 3247 void
3239 MainWindow::zoomDefault() 3248 MainWindow::zoomDefault()
3240 { 3249 {