Chris@127
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@127
|
2
|
Chris@127
|
3 /*
|
Chris@127
|
4 Sonic Visualiser
|
Chris@127
|
5 An audio file viewer and annotation editor.
|
Chris@127
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@127
|
7 This file copyright 2006 Chris Cannam.
|
Chris@127
|
8
|
Chris@127
|
9 This program is free software; you can redistribute it and/or
|
Chris@127
|
10 modify it under the terms of the GNU General Public License as
|
Chris@127
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@127
|
12 License, or (at your option) any later version. See the file
|
Chris@127
|
13 COPYING included with this distribution for more information.
|
Chris@127
|
14 */
|
Chris@127
|
15
|
Chris@128
|
16 #include "Pane.h"
|
Chris@128
|
17 #include "layer/Layer.h"
|
Chris@128
|
18 #include "data/model/Model.h"
|
Chris@127
|
19 #include "base/ZoomConstraint.h"
|
Chris@127
|
20 #include "base/RealTime.h"
|
Chris@127
|
21 #include "base/Profiler.h"
|
Chris@128
|
22 #include "ViewManager.h"
|
Chris@127
|
23 #include "base/CommandHistory.h"
|
Chris@127
|
24 #include "layer/WaveformLayer.h"
|
Chris@127
|
25
|
Chris@127
|
26 #include <QPaintEvent>
|
Chris@127
|
27 #include <QPainter>
|
Chris@127
|
28 #include <iostream>
|
Chris@127
|
29 #include <cmath>
|
Chris@127
|
30
|
Chris@133
|
31 //!!! for HUD -- pull out into a separate class
|
Chris@133
|
32 #include <QFrame>
|
Chris@133
|
33 #include <QGridLayout>
|
Chris@133
|
34 #include <QPushButton>
|
Chris@133
|
35 #include "widgets/Thumbwheel.h"
|
Chris@133
|
36
|
Chris@127
|
37 using std::cerr;
|
Chris@127
|
38 using std::endl;
|
Chris@127
|
39
|
Chris@127
|
40 Pane::Pane(QWidget *w) :
|
Chris@127
|
41 View(w, true),
|
Chris@127
|
42 m_identifyFeatures(false),
|
Chris@127
|
43 m_clickedInRange(false),
|
Chris@127
|
44 m_shiftPressed(false),
|
Chris@127
|
45 m_ctrlPressed(false),
|
Chris@127
|
46 m_navigating(false),
|
Chris@127
|
47 m_resizing(false),
|
Chris@133
|
48 m_centreLineVisible(true),
|
Chris@133
|
49 m_headsUpDisplay(0)
|
Chris@127
|
50 {
|
Chris@127
|
51 setObjectName("Pane");
|
Chris@127
|
52 setMouseTracking(true);
|
Chris@133
|
53
|
Chris@133
|
54 updateHeadsUpDisplay();
|
Chris@133
|
55 }
|
Chris@133
|
56
|
Chris@133
|
57 void
|
Chris@133
|
58 Pane::updateHeadsUpDisplay()
|
Chris@133
|
59 {
|
Chris@132
|
60 /*
|
Chris@132
|
61 int count = 0;
|
Chris@132
|
62 int currentLevel = 1;
|
Chris@132
|
63 int level = 1;
|
Chris@132
|
64 while (true) {
|
Chris@132
|
65 if (getZoomLevel() == level) currentLevel = count;
|
Chris@132
|
66 int newLevel = getZoomConstraintBlockSize(level + 1,
|
Chris@132
|
67 ZoomConstraint::RoundUp);
|
Chris@132
|
68 if (newLevel == level) break;
|
Chris@132
|
69 if (newLevel == 131072) break; //!!! just because
|
Chris@132
|
70 level = newLevel;
|
Chris@132
|
71 ++count;
|
Chris@132
|
72 }
|
Chris@132
|
73
|
Chris@132
|
74 std::cerr << "Have " << count+1 << " zoom levels" << std::endl;
|
Chris@132
|
75 */
|
Chris@133
|
76
|
Chris@133
|
77 if (!m_headsUpDisplay) {
|
Chris@133
|
78
|
Chris@133
|
79 m_headsUpDisplay = new QFrame(this);
|
Chris@133
|
80
|
Chris@133
|
81 QGridLayout *layout = new QGridLayout;
|
Chris@133
|
82 layout->setMargin(0);
|
Chris@133
|
83 layout->setSpacing(0);
|
Chris@133
|
84 m_headsUpDisplay->setLayout(layout);
|
Chris@133
|
85
|
Chris@133
|
86 m_hthumb = new Thumbwheel(Qt::Horizontal);
|
Chris@133
|
87 layout->addWidget(m_hthumb, 1, 0);
|
Chris@133
|
88 m_hthumb->setFixedWidth(70);
|
Chris@133
|
89 m_hthumb->setFixedHeight(16);
|
Chris@133
|
90 m_hthumb->setDefaultValue(0);
|
Chris@133
|
91 connect(m_hthumb, SIGNAL(valueChanged(int)), this,
|
Chris@133
|
92 SLOT(horizontalThumbwheelMoved(int)));
|
Chris@133
|
93
|
Chris@133
|
94 m_vthumb = new Thumbwheel(Qt::Vertical);
|
Chris@133
|
95 layout->addWidget(m_vthumb, 0, 1);
|
Chris@133
|
96 m_vthumb->setFixedWidth(16);
|
Chris@133
|
97 m_vthumb->setFixedHeight(70);
|
Chris@133
|
98 connect(m_vthumb, SIGNAL(valueChanged(int)), this,
|
Chris@133
|
99 SLOT(verticalThumbwheelMoved(int)));
|
Chris@133
|
100
|
Chris@133
|
101 QPushButton *reset = new QPushButton;
|
Chris@133
|
102 reset->setFixedHeight(16);
|
Chris@133
|
103 reset->setFixedWidth(16);
|
Chris@133
|
104 layout->addWidget(reset, 1, 1);
|
Chris@133
|
105 connect(reset, SIGNAL(clicked()), m_hthumb, SLOT(resetToDefault()));
|
Chris@133
|
106 connect(reset, SIGNAL(clicked()), m_vthumb, SLOT(resetToDefault()));
|
Chris@133
|
107 }
|
Chris@133
|
108
|
Chris@133
|
109 int count = 0;
|
Chris@133
|
110 int current = 0;
|
Chris@133
|
111 int level = 1;
|
Chris@133
|
112
|
Chris@133
|
113 while (true) {
|
Chris@133
|
114 if (getZoomLevel() == level) current = count;
|
Chris@133
|
115 int newLevel = getZoomConstraintBlockSize(level + 1,
|
Chris@133
|
116 ZoomConstraint::RoundUp);
|
Chris@133
|
117 if (newLevel == level) break;
|
Chris@133
|
118 level = newLevel;
|
Chris@133
|
119 if (++count == 50) break;
|
Chris@133
|
120 }
|
Chris@133
|
121
|
Chris@133
|
122 // std::cerr << "Have " << count << " zoom levels" << std::endl;
|
Chris@133
|
123
|
Chris@133
|
124 m_hthumb->setMinimumValue(0);
|
Chris@133
|
125 m_hthumb->setMaximumValue(count);
|
Chris@133
|
126 m_hthumb->setValue(count - current);
|
Chris@133
|
127
|
Chris@133
|
128 // std::cerr << "set value to " << count-current << std::endl;
|
Chris@133
|
129
|
Chris@133
|
130 // std::cerr << "default value is " << m_hthumb->getDefaultValue() << std::endl;
|
Chris@133
|
131
|
Chris@133
|
132 if (count != 50 && m_hthumb->getDefaultValue() == 0) {
|
Chris@133
|
133 m_hthumb->setDefaultValue(count - current);
|
Chris@133
|
134 // std::cerr << "set default value to " << m_hthumb->getDefaultValue() << std::endl;
|
Chris@133
|
135 }
|
Chris@133
|
136
|
Chris@133
|
137 Layer *layer = 0;
|
Chris@133
|
138 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
139 if (layer) {
|
Chris@133
|
140 int defaultStep = 0;
|
Chris@133
|
141 int max = layer->getVerticalZoomSteps(defaultStep);
|
Chris@133
|
142 if (max == 0) {
|
Chris@133
|
143 m_vthumb->hide();
|
Chris@133
|
144 } else {
|
Chris@133
|
145 m_vthumb->show();
|
Chris@133
|
146 m_vthumb->setMinimumValue(0);
|
Chris@133
|
147 m_vthumb->setMaximumValue(max);
|
Chris@133
|
148 m_vthumb->setDefaultValue(defaultStep);
|
Chris@133
|
149 m_vthumb->setValue(layer->getCurrentVerticalZoomStep());
|
Chris@135
|
150
|
Chris@135
|
151 std::cerr << "Vertical thumbwheel: min 0, max " << max
|
Chris@135
|
152 << ", default " << defaultStep << ", value "
|
Chris@135
|
153 << m_vthumb->getValue() << std::endl;
|
Chris@135
|
154
|
Chris@133
|
155 }
|
Chris@133
|
156 }
|
Chris@133
|
157
|
Chris@133
|
158 if (m_manager && m_manager->getZoomWheelsEnabled() &&
|
Chris@133
|
159 width() > 120 && height() > 100) {
|
Chris@133
|
160 if (m_vthumb->isVisible()) {
|
Chris@133
|
161 m_headsUpDisplay->move(width() - 86, height() - 86);
|
Chris@133
|
162 } else {
|
Chris@133
|
163 m_headsUpDisplay->move(width() - 86, height() - 51);
|
Chris@133
|
164 }
|
Chris@133
|
165 if (!m_headsUpDisplay->isVisible()) {
|
Chris@133
|
166 m_headsUpDisplay->show();
|
Chris@133
|
167 connect(m_manager, SIGNAL(zoomLevelChanged()),
|
Chris@133
|
168 this, SLOT(zoomLevelChanged()));
|
Chris@133
|
169 }
|
Chris@133
|
170 } else {
|
Chris@133
|
171 m_headsUpDisplay->hide();
|
Chris@133
|
172 if (m_manager) {
|
Chris@133
|
173 disconnect(m_manager, SIGNAL(zoomLevelChanged()),
|
Chris@133
|
174 this, SLOT(zoomLevelChanged()));
|
Chris@133
|
175 }
|
Chris@133
|
176 }
|
Chris@127
|
177 }
|
Chris@127
|
178
|
Chris@127
|
179 bool
|
Chris@127
|
180 Pane::shouldIlluminateLocalFeatures(const Layer *layer, QPoint &pos) const
|
Chris@127
|
181 {
|
Chris@127
|
182 QPoint discard;
|
Chris@127
|
183 bool b0, b1;
|
Chris@127
|
184
|
Chris@127
|
185 if (layer == getSelectedLayer() &&
|
Chris@127
|
186 !shouldIlluminateLocalSelection(discard, b0, b1)) {
|
Chris@127
|
187
|
Chris@127
|
188 pos = m_identifyPoint;
|
Chris@127
|
189 return m_identifyFeatures;
|
Chris@127
|
190 }
|
Chris@127
|
191
|
Chris@127
|
192 return false;
|
Chris@127
|
193 }
|
Chris@127
|
194
|
Chris@127
|
195 bool
|
Chris@127
|
196 Pane::shouldIlluminateLocalSelection(QPoint &pos,
|
Chris@127
|
197 bool &closeToLeft,
|
Chris@127
|
198 bool &closeToRight) const
|
Chris@127
|
199 {
|
Chris@127
|
200 if (m_identifyFeatures &&
|
Chris@127
|
201 m_manager &&
|
Chris@127
|
202 m_manager->getToolMode() == ViewManager::EditMode &&
|
Chris@127
|
203 !m_manager->getSelections().empty() &&
|
Chris@127
|
204 !selectionIsBeingEdited()) {
|
Chris@127
|
205
|
Chris@127
|
206 Selection s(getSelectionAt(m_identifyPoint.x(),
|
Chris@127
|
207 closeToLeft, closeToRight));
|
Chris@127
|
208
|
Chris@127
|
209 if (!s.isEmpty()) {
|
Chris@127
|
210 if (getSelectedLayer() && getSelectedLayer()->isLayerEditable()) {
|
Chris@127
|
211
|
Chris@127
|
212 pos = m_identifyPoint;
|
Chris@127
|
213 return true;
|
Chris@127
|
214 }
|
Chris@127
|
215 }
|
Chris@127
|
216 }
|
Chris@127
|
217
|
Chris@127
|
218 return false;
|
Chris@127
|
219 }
|
Chris@127
|
220
|
Chris@127
|
221 bool
|
Chris@127
|
222 Pane::selectionIsBeingEdited() const
|
Chris@127
|
223 {
|
Chris@127
|
224 if (!m_editingSelection.isEmpty()) {
|
Chris@127
|
225 if (m_mousePos != m_clickPos &&
|
Chris@127
|
226 getFrameForX(m_mousePos.x()) != getFrameForX(m_clickPos.x())) {
|
Chris@127
|
227 return true;
|
Chris@127
|
228 }
|
Chris@127
|
229 }
|
Chris@127
|
230 return false;
|
Chris@127
|
231 }
|
Chris@127
|
232
|
Chris@127
|
233 void
|
Chris@127
|
234 Pane::setCentreLineVisible(bool visible)
|
Chris@127
|
235 {
|
Chris@127
|
236 m_centreLineVisible = visible;
|
Chris@127
|
237 update();
|
Chris@127
|
238 }
|
Chris@127
|
239
|
Chris@127
|
240 void
|
Chris@127
|
241 Pane::paintEvent(QPaintEvent *e)
|
Chris@127
|
242 {
|
Chris@127
|
243 // Profiler profiler("Pane::paintEvent", true);
|
Chris@127
|
244
|
Chris@127
|
245 QPainter paint;
|
Chris@127
|
246
|
Chris@127
|
247 QRect r(rect());
|
Chris@127
|
248
|
Chris@127
|
249 if (e) {
|
Chris@127
|
250 r = e->rect();
|
Chris@127
|
251 }
|
Chris@127
|
252 /*
|
Chris@127
|
253 paint.begin(this);
|
Chris@127
|
254 paint.setClipRect(r);
|
Chris@127
|
255
|
Chris@127
|
256 if (hasLightBackground()) {
|
Chris@127
|
257 paint.setPen(Qt::white);
|
Chris@127
|
258 paint.setBrush(Qt::white);
|
Chris@127
|
259 } else {
|
Chris@127
|
260 paint.setPen(Qt::black);
|
Chris@127
|
261 paint.setBrush(Qt::black);
|
Chris@127
|
262 }
|
Chris@127
|
263 paint.drawRect(r);
|
Chris@127
|
264
|
Chris@127
|
265 paint.end();
|
Chris@127
|
266 */
|
Chris@127
|
267 View::paintEvent(e);
|
Chris@127
|
268
|
Chris@127
|
269 paint.begin(this);
|
Chris@127
|
270
|
Chris@127
|
271 if (e) {
|
Chris@127
|
272 paint.setClipRect(r);
|
Chris@127
|
273 }
|
Chris@127
|
274
|
Chris@127
|
275 const Model *waveformModel = 0; // just for reporting purposes
|
Chris@127
|
276 int verticalScaleWidth = 0;
|
Chris@127
|
277
|
Chris@127
|
278 int fontHeight = paint.fontMetrics().height();
|
Chris@127
|
279 int fontAscent = paint.fontMetrics().ascent();
|
Chris@127
|
280
|
Chris@127
|
281 if (m_manager &&
|
Chris@127
|
282 !m_manager->isPlaying() &&
|
Chris@127
|
283 m_manager->getToolMode() == ViewManager::SelectMode) {
|
Chris@127
|
284
|
Chris@127
|
285 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
|
Chris@127
|
286 --vi;
|
Chris@127
|
287
|
Chris@127
|
288 std::vector<QRect> crosshairExtents;
|
Chris@127
|
289
|
Chris@127
|
290 if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint,
|
Chris@127
|
291 crosshairExtents)) {
|
Chris@127
|
292 (*vi)->paintCrosshairs(this, paint, m_identifyPoint);
|
Chris@127
|
293 break;
|
Chris@127
|
294 } else if ((*vi)->isLayerOpaque()) {
|
Chris@127
|
295 break;
|
Chris@127
|
296 }
|
Chris@127
|
297 }
|
Chris@127
|
298 }
|
Chris@127
|
299
|
Chris@127
|
300 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
|
Chris@127
|
301 --vi;
|
Chris@127
|
302
|
Chris@127
|
303 if (dynamic_cast<WaveformLayer *>(*vi)) {
|
Chris@127
|
304 waveformModel = (*vi)->getModel();
|
Chris@127
|
305 }
|
Chris@127
|
306
|
Chris@127
|
307 if (!m_manager ||
|
Chris@127
|
308 m_manager->getOverlayMode() == ViewManager::NoOverlays) {
|
Chris@127
|
309 break;
|
Chris@127
|
310 }
|
Chris@127
|
311
|
Chris@127
|
312 verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint);
|
Chris@127
|
313
|
Chris@127
|
314 if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) {
|
Chris@127
|
315
|
Chris@127
|
316 // Profiler profiler("Pane::paintEvent - painting vertical scale", true);
|
Chris@127
|
317
|
Chris@127
|
318 // std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl;
|
Chris@127
|
319 paint.save();
|
Chris@127
|
320
|
Chris@127
|
321 paint.setPen(Qt::black);
|
Chris@127
|
322 paint.setBrush(Qt::white);
|
Chris@127
|
323 paint.drawRect(0, -1, verticalScaleWidth, height()+1);
|
Chris@127
|
324
|
Chris@127
|
325 paint.setBrush(Qt::NoBrush);
|
Chris@127
|
326 (*vi)->paintVerticalScale
|
Chris@127
|
327 (this, paint, QRect(0, 0, verticalScaleWidth, height()));
|
Chris@127
|
328
|
Chris@127
|
329 paint.restore();
|
Chris@127
|
330 }
|
Chris@127
|
331
|
Chris@127
|
332 if (m_identifyFeatures) {
|
Chris@127
|
333
|
Chris@127
|
334 QPoint pos = m_identifyPoint;
|
Chris@127
|
335 QString desc = (*vi)->getFeatureDescription(this, pos);
|
Chris@127
|
336
|
Chris@127
|
337 if (desc != "") {
|
Chris@127
|
338
|
Chris@127
|
339 paint.save();
|
Chris@127
|
340
|
Chris@127
|
341 int tabStop =
|
Chris@127
|
342 paint.fontMetrics().width(tr("Some lengthy prefix:"));
|
Chris@127
|
343
|
Chris@127
|
344 QRect boundingRect =
|
Chris@127
|
345 paint.fontMetrics().boundingRect
|
Chris@127
|
346 (rect(),
|
Chris@127
|
347 Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs,
|
Chris@127
|
348 desc, tabStop);
|
Chris@127
|
349
|
Chris@127
|
350 if (hasLightBackground()) {
|
Chris@127
|
351 paint.setPen(Qt::NoPen);
|
Chris@127
|
352 paint.setBrush(QColor(250, 250, 250, 200));
|
Chris@127
|
353 } else {
|
Chris@127
|
354 paint.setPen(Qt::NoPen);
|
Chris@127
|
355 paint.setBrush(QColor(50, 50, 50, 200));
|
Chris@127
|
356 }
|
Chris@127
|
357
|
Chris@127
|
358 int extra = paint.fontMetrics().descent();
|
Chris@127
|
359 paint.drawRect(width() - boundingRect.width() - 10 - extra,
|
Chris@127
|
360 10 - extra,
|
Chris@127
|
361 boundingRect.width() + 2 * extra,
|
Chris@127
|
362 boundingRect.height() + extra);
|
Chris@127
|
363
|
Chris@127
|
364 if (hasLightBackground()) {
|
Chris@127
|
365 paint.setPen(QColor(150, 20, 0));
|
Chris@127
|
366 } else {
|
Chris@127
|
367 paint.setPen(QColor(255, 150, 100));
|
Chris@127
|
368 }
|
Chris@127
|
369
|
Chris@127
|
370 QTextOption option;
|
Chris@127
|
371 option.setWrapMode(QTextOption::NoWrap);
|
Chris@127
|
372 option.setAlignment(Qt::AlignRight | Qt::AlignTop);
|
Chris@127
|
373 option.setTabStop(tabStop);
|
Chris@127
|
374 paint.drawText(QRectF(width() - boundingRect.width() - 10, 10,
|
Chris@127
|
375 boundingRect.width(),
|
Chris@127
|
376 boundingRect.height()),
|
Chris@127
|
377 desc,
|
Chris@127
|
378 option);
|
Chris@127
|
379
|
Chris@127
|
380 paint.restore();
|
Chris@127
|
381 }
|
Chris@127
|
382 }
|
Chris@127
|
383
|
Chris@127
|
384 break;
|
Chris@127
|
385 }
|
Chris@127
|
386
|
Chris@127
|
387 int sampleRate = getModelsSampleRate();
|
Chris@127
|
388 paint.setBrush(Qt::NoBrush);
|
Chris@127
|
389
|
Chris@127
|
390 if (m_centreLineVisible) {
|
Chris@127
|
391
|
Chris@127
|
392 if (hasLightBackground()) {
|
Chris@127
|
393 paint.setPen(QColor(50, 50, 50));
|
Chris@127
|
394 } else {
|
Chris@127
|
395 paint.setPen(QColor(200, 200, 200));
|
Chris@127
|
396 }
|
Chris@127
|
397 paint.drawLine(width() / 2, 0, width() / 2, height() - 1);
|
Chris@127
|
398
|
Chris@127
|
399 paint.setPen(QColor(50, 50, 50));
|
Chris@127
|
400
|
Chris@127
|
401 int y = height() - fontHeight
|
Chris@127
|
402 + fontAscent - 6;
|
Chris@127
|
403
|
Chris@127
|
404 LayerList::iterator vi = m_layers.end();
|
Chris@127
|
405
|
Chris@127
|
406 if (vi != m_layers.begin()) {
|
Chris@127
|
407
|
Chris@127
|
408 switch ((*--vi)->getPreferredFrameCountPosition()) {
|
Chris@127
|
409
|
Chris@127
|
410 case Layer::PositionTop:
|
Chris@127
|
411 y = fontAscent + 6;
|
Chris@127
|
412 break;
|
Chris@127
|
413
|
Chris@127
|
414 case Layer::PositionMiddle:
|
Chris@127
|
415 y = (height() - fontHeight) / 2
|
Chris@127
|
416 + fontAscent;
|
Chris@127
|
417 break;
|
Chris@127
|
418
|
Chris@127
|
419 case Layer::PositionBottom:
|
Chris@127
|
420 // y already set correctly
|
Chris@127
|
421 break;
|
Chris@127
|
422 }
|
Chris@127
|
423 }
|
Chris@127
|
424
|
Chris@127
|
425 if (m_manager &&
|
Chris@127
|
426 m_manager->getOverlayMode() != ViewManager::NoOverlays) {
|
Chris@127
|
427
|
Chris@127
|
428 if (sampleRate) {
|
Chris@127
|
429
|
Chris@127
|
430 QString text(QString::fromStdString
|
Chris@127
|
431 (RealTime::frame2RealTime
|
Chris@127
|
432 (m_centreFrame, sampleRate).toText(true)));
|
Chris@127
|
433
|
Chris@127
|
434 int tw = paint.fontMetrics().width(text);
|
Chris@127
|
435 int x = width()/2 - 4 - tw;
|
Chris@127
|
436
|
Chris@127
|
437 drawVisibleText(paint, x, y, text, OutlinedText);
|
Chris@127
|
438 }
|
Chris@127
|
439
|
Chris@127
|
440 QString text = QString("%1").arg(m_centreFrame);
|
Chris@127
|
441
|
Chris@127
|
442 int tw = paint.fontMetrics().width(text);
|
Chris@127
|
443 int x = width()/2 + 4;
|
Chris@127
|
444
|
Chris@127
|
445 drawVisibleText(paint, x, y, text, OutlinedText);
|
Chris@127
|
446 }
|
Chris@127
|
447
|
Chris@127
|
448 } else {
|
Chris@127
|
449
|
Chris@127
|
450 paint.setPen(QColor(50, 50, 50));
|
Chris@127
|
451 }
|
Chris@127
|
452
|
Chris@127
|
453 if (waveformModel &&
|
Chris@127
|
454 m_manager &&
|
Chris@127
|
455 m_manager->getOverlayMode() != ViewManager::NoOverlays &&
|
Chris@127
|
456 r.y() + r.height() >= height() - fontHeight - 6) {
|
Chris@127
|
457
|
Chris@127
|
458 size_t mainModelRate = m_manager->getMainModelSampleRate();
|
Chris@127
|
459 size_t playbackRate = m_manager->getPlaybackSampleRate();
|
Chris@127
|
460
|
Chris@127
|
461 QString srNote = "";
|
Chris@127
|
462
|
Chris@127
|
463 // Show (R) for waveform models that will be resampled on
|
Chris@127
|
464 // playback, and (X) for waveform models that will be played
|
Chris@127
|
465 // at the wrong rate because their rate differs from that of
|
Chris@127
|
466 // the main model.
|
Chris@127
|
467
|
Chris@127
|
468 if (sampleRate == mainModelRate) {
|
Chris@127
|
469 if (sampleRate != playbackRate) srNote = " " + tr("(R)");
|
Chris@127
|
470 } else {
|
Chris@127
|
471 std::cerr << "Sample rate = " << sampleRate << ", main model rate = " << mainModelRate << std::endl;
|
Chris@127
|
472 srNote = " " + tr("(X)");
|
Chris@127
|
473 }
|
Chris@127
|
474
|
Chris@127
|
475 QString desc = tr("%1 / %2Hz%3")
|
Chris@127
|
476 .arg(RealTime::frame2RealTime(waveformModel->getEndFrame(),
|
Chris@127
|
477 sampleRate)
|
Chris@127
|
478 .toText(false).c_str())
|
Chris@127
|
479 .arg(sampleRate)
|
Chris@127
|
480 .arg(srNote);
|
Chris@127
|
481
|
Chris@127
|
482 if (r.x() < verticalScaleWidth + 5 + paint.fontMetrics().width(desc)) {
|
Chris@127
|
483 drawVisibleText(paint, verticalScaleWidth + 5,
|
Chris@127
|
484 height() - fontHeight + fontAscent - 6,
|
Chris@127
|
485 desc, OutlinedText);
|
Chris@127
|
486 }
|
Chris@127
|
487 }
|
Chris@127
|
488
|
Chris@127
|
489 if (m_manager &&
|
Chris@127
|
490 m_manager->getOverlayMode() == ViewManager::AllOverlays &&
|
Chris@127
|
491 r.y() + r.height() >= height() - m_layers.size() * fontHeight - 6) {
|
Chris@127
|
492
|
Chris@127
|
493 std::vector<QString> texts;
|
Chris@127
|
494 int maxTextWidth = 0;
|
Chris@127
|
495
|
Chris@127
|
496 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
|
Chris@127
|
497
|
Chris@127
|
498 QString text = (*i)->getLayerPresentationName();
|
Chris@127
|
499 int tw = paint.fontMetrics().width(text);
|
Chris@127
|
500 bool reduced = false;
|
Chris@127
|
501 while (tw > width() / 3 && text.length() > 4) {
|
Chris@127
|
502 if (!reduced && text.length() > 8) {
|
Chris@127
|
503 text = text.left(text.length() - 4);
|
Chris@127
|
504 } else {
|
Chris@127
|
505 text = text.left(text.length() - 2);
|
Chris@127
|
506 }
|
Chris@127
|
507 reduced = true;
|
Chris@127
|
508 tw = paint.fontMetrics().width(text + "...");
|
Chris@127
|
509 }
|
Chris@127
|
510 if (reduced) {
|
Chris@127
|
511 texts.push_back(text + "...");
|
Chris@127
|
512 } else {
|
Chris@127
|
513 texts.push_back(text);
|
Chris@127
|
514 }
|
Chris@127
|
515 if (tw > maxTextWidth) maxTextWidth = tw;
|
Chris@127
|
516 }
|
Chris@127
|
517
|
Chris@127
|
518 int lly = height() - 6;
|
Chris@133
|
519 int llx = width() - maxTextWidth - 5;
|
Chris@127
|
520
|
Chris@133
|
521 if (m_manager->getZoomWheelsEnabled()) {
|
Chris@133
|
522 lly -= 20;
|
Chris@133
|
523 llx -= 20;
|
Chris@133
|
524 }
|
Chris@133
|
525
|
Chris@133
|
526 if (r.x() + r.width() >= llx) {
|
Chris@127
|
527
|
Chris@127
|
528 for (int i = 0; i < texts.size(); ++i) {
|
Chris@127
|
529
|
Chris@127
|
530 if (i == texts.size() - 1) {
|
Chris@127
|
531 paint.setPen(Qt::black);
|
Chris@127
|
532 }
|
Chris@127
|
533
|
Chris@133
|
534 drawVisibleText(paint, llx,
|
Chris@127
|
535 lly - fontHeight + fontAscent,
|
Chris@127
|
536 texts[i], OutlinedText);
|
Chris@127
|
537
|
Chris@127
|
538 lly -= fontHeight;
|
Chris@127
|
539 }
|
Chris@127
|
540 }
|
Chris@127
|
541 }
|
Chris@127
|
542
|
Chris@127
|
543 if (m_clickedInRange && m_shiftPressed) {
|
Chris@127
|
544 if (m_manager && (m_manager->getToolMode() == ViewManager::NavigateMode)) {
|
Chris@127
|
545 //!!! be nice if this looked a bit more in keeping with the
|
Chris@127
|
546 //selection block
|
Chris@127
|
547 paint.setPen(Qt::blue);
|
Chris@127
|
548 paint.drawRect(m_clickPos.x(), m_clickPos.y(),
|
Chris@127
|
549 m_mousePos.x() - m_clickPos.x(),
|
Chris@127
|
550 m_mousePos.y() - m_clickPos.y());
|
Chris@127
|
551 }
|
Chris@127
|
552 }
|
Chris@127
|
553
|
Chris@127
|
554 if (selectionIsBeingEdited()) {
|
Chris@127
|
555
|
Chris@127
|
556 int offset = m_mousePos.x() - m_clickPos.x();
|
Chris@127
|
557 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset;
|
Chris@127
|
558 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset;
|
Chris@127
|
559
|
Chris@127
|
560 if (m_editingSelectionEdge < 0) {
|
Chris@127
|
561 p1 = getXForFrame(m_editingSelection.getEndFrame());
|
Chris@127
|
562 } else if (m_editingSelectionEdge > 0) {
|
Chris@127
|
563 p0 = getXForFrame(m_editingSelection.getStartFrame());
|
Chris@127
|
564 }
|
Chris@127
|
565
|
Chris@127
|
566 paint.save();
|
Chris@127
|
567 if (hasLightBackground()) {
|
Chris@127
|
568 paint.setPen(QPen(Qt::black, 2));
|
Chris@127
|
569 } else {
|
Chris@127
|
570 paint.setPen(QPen(Qt::white, 2));
|
Chris@127
|
571 }
|
Chris@127
|
572
|
Chris@127
|
573 //!!! duplicating display policy with View::drawSelections
|
Chris@127
|
574
|
Chris@127
|
575 if (m_editingSelectionEdge < 0) {
|
Chris@127
|
576 paint.drawLine(p0, 1, p1, 1);
|
Chris@127
|
577 paint.drawLine(p0, 0, p0, height());
|
Chris@127
|
578 paint.drawLine(p0, height() - 1, p1, height() - 1);
|
Chris@127
|
579 } else if (m_editingSelectionEdge > 0) {
|
Chris@127
|
580 paint.drawLine(p0, 1, p1, 1);
|
Chris@127
|
581 paint.drawLine(p1, 0, p1, height());
|
Chris@127
|
582 paint.drawLine(p0, height() - 1, p1, height() - 1);
|
Chris@127
|
583 } else {
|
Chris@127
|
584 paint.setBrush(Qt::NoBrush);
|
Chris@127
|
585 paint.drawRect(p0, 1, p1 - p0, height() - 2);
|
Chris@127
|
586 }
|
Chris@127
|
587 paint.restore();
|
Chris@127
|
588 }
|
Chris@127
|
589
|
Chris@127
|
590 paint.end();
|
Chris@127
|
591 }
|
Chris@127
|
592
|
Chris@127
|
593 Selection
|
Chris@127
|
594 Pane::getSelectionAt(int x, bool &closeToLeftEdge, bool &closeToRightEdge) const
|
Chris@127
|
595 {
|
Chris@127
|
596 closeToLeftEdge = closeToRightEdge = false;
|
Chris@127
|
597
|
Chris@127
|
598 if (!m_manager) return Selection();
|
Chris@127
|
599
|
Chris@127
|
600 long testFrame = getFrameForX(x - 5);
|
Chris@127
|
601 if (testFrame < 0) {
|
Chris@127
|
602 testFrame = getFrameForX(x);
|
Chris@127
|
603 if (testFrame < 0) return Selection();
|
Chris@127
|
604 }
|
Chris@127
|
605
|
Chris@127
|
606 Selection selection = m_manager->getContainingSelection(testFrame, true);
|
Chris@127
|
607 if (selection.isEmpty()) return selection;
|
Chris@127
|
608
|
Chris@127
|
609 int lx = getXForFrame(selection.getStartFrame());
|
Chris@127
|
610 int rx = getXForFrame(selection.getEndFrame());
|
Chris@127
|
611
|
Chris@127
|
612 int fuzz = 2;
|
Chris@127
|
613 if (x < lx - fuzz || x > rx + fuzz) return Selection();
|
Chris@127
|
614
|
Chris@127
|
615 int width = rx - lx;
|
Chris@127
|
616 fuzz = 3;
|
Chris@127
|
617 if (width < 12) fuzz = width / 4;
|
Chris@127
|
618 if (fuzz < 1) fuzz = 1;
|
Chris@127
|
619
|
Chris@127
|
620 if (x < lx + fuzz) closeToLeftEdge = true;
|
Chris@127
|
621 if (x > rx - fuzz) closeToRightEdge = true;
|
Chris@127
|
622
|
Chris@127
|
623 return selection;
|
Chris@127
|
624 }
|
Chris@127
|
625
|
Chris@127
|
626 void
|
Chris@127
|
627 Pane::mousePressEvent(QMouseEvent *e)
|
Chris@127
|
628 {
|
Chris@127
|
629 if (e->buttons() & Qt::RightButton) {
|
Chris@127
|
630 emit rightButtonMenuRequested(mapToGlobal(e->pos()));
|
Chris@127
|
631 return;
|
Chris@127
|
632 }
|
Chris@127
|
633
|
Chris@127
|
634 m_clickPos = e->pos();
|
Chris@127
|
635 m_clickedInRange = true;
|
Chris@127
|
636 m_editingSelection = Selection();
|
Chris@127
|
637 m_editingSelectionEdge = 0;
|
Chris@127
|
638 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier);
|
Chris@127
|
639 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier);
|
Chris@127
|
640
|
Chris@127
|
641 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
642 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
643
|
Chris@127
|
644 m_navigating = false;
|
Chris@127
|
645
|
Chris@127
|
646 if (mode == ViewManager::NavigateMode || (e->buttons() & Qt::MidButton)) {
|
Chris@127
|
647
|
Chris@127
|
648 if (mode != ViewManager::NavigateMode) {
|
Chris@127
|
649 setCursor(Qt::PointingHandCursor);
|
Chris@127
|
650 }
|
Chris@127
|
651
|
Chris@127
|
652 m_navigating = true;
|
Chris@127
|
653 m_dragCentreFrame = m_centreFrame;
|
Chris@127
|
654
|
Chris@136
|
655 //!!! pull out into function to go with mouse move code
|
Chris@136
|
656
|
Chris@136
|
657 m_dragStartMinValue = 0;
|
Chris@136
|
658
|
Chris@136
|
659 Layer *layer = 0;
|
Chris@136
|
660 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@136
|
661
|
Chris@136
|
662 if (layer) {
|
Chris@136
|
663 float min = 0.f, max = 0.f;
|
Chris@136
|
664 if (layer->getDisplayExtents(min, max)) {
|
Chris@136
|
665 m_dragStartMinValue = min;
|
Chris@136
|
666 }
|
Chris@136
|
667 }
|
Chris@136
|
668
|
Chris@127
|
669 } else if (mode == ViewManager::SelectMode) {
|
Chris@127
|
670
|
Chris@127
|
671 bool closeToLeft = false, closeToRight = false;
|
Chris@127
|
672 Selection selection = getSelectionAt(e->x(), closeToLeft, closeToRight);
|
Chris@127
|
673
|
Chris@127
|
674 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) {
|
Chris@127
|
675
|
Chris@127
|
676 m_manager->removeSelection(selection);
|
Chris@127
|
677
|
Chris@127
|
678 if (closeToLeft) {
|
Chris@127
|
679 m_selectionStartFrame = selection.getEndFrame();
|
Chris@127
|
680 } else {
|
Chris@127
|
681 m_selectionStartFrame = selection.getStartFrame();
|
Chris@127
|
682 }
|
Chris@127
|
683
|
Chris@127
|
684 m_manager->setInProgressSelection(selection, false);
|
Chris@127
|
685 m_resizing = true;
|
Chris@127
|
686
|
Chris@127
|
687 } else {
|
Chris@127
|
688
|
Chris@127
|
689 int mouseFrame = getFrameForX(e->x());
|
Chris@127
|
690 size_t resolution = 1;
|
Chris@127
|
691 int snapFrame = mouseFrame;
|
Chris@127
|
692
|
Chris@127
|
693 Layer *layer = getSelectedLayer();
|
Chris@127
|
694 if (layer && !m_shiftPressed) {
|
Chris@127
|
695 layer->snapToFeatureFrame(this, snapFrame,
|
Chris@127
|
696 resolution, Layer::SnapLeft);
|
Chris@127
|
697 }
|
Chris@127
|
698
|
Chris@127
|
699 if (snapFrame < 0) snapFrame = 0;
|
Chris@127
|
700 m_selectionStartFrame = snapFrame;
|
Chris@127
|
701 if (m_manager) {
|
Chris@127
|
702 m_manager->setInProgressSelection(Selection(snapFrame,
|
Chris@127
|
703 snapFrame + resolution),
|
Chris@127
|
704 !m_ctrlPressed);
|
Chris@127
|
705 }
|
Chris@127
|
706
|
Chris@127
|
707 m_resizing = false;
|
Chris@127
|
708 }
|
Chris@127
|
709
|
Chris@127
|
710 update();
|
Chris@127
|
711
|
Chris@127
|
712 } else if (mode == ViewManager::DrawMode) {
|
Chris@127
|
713
|
Chris@127
|
714 Layer *layer = getSelectedLayer();
|
Chris@127
|
715 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
716 layer->drawStart(this, e);
|
Chris@127
|
717 }
|
Chris@127
|
718
|
Chris@127
|
719 } else if (mode == ViewManager::EditMode) {
|
Chris@127
|
720
|
Chris@127
|
721 if (!editSelectionStart(e)) {
|
Chris@127
|
722 Layer *layer = getSelectedLayer();
|
Chris@127
|
723 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
724 layer->editStart(this, e);
|
Chris@127
|
725 }
|
Chris@127
|
726 }
|
Chris@127
|
727 }
|
Chris@127
|
728
|
Chris@127
|
729 emit paneInteractedWith();
|
Chris@127
|
730 }
|
Chris@127
|
731
|
Chris@127
|
732 void
|
Chris@127
|
733 Pane::mouseReleaseEvent(QMouseEvent *e)
|
Chris@127
|
734 {
|
Chris@127
|
735 if (e->buttons() & Qt::RightButton) {
|
Chris@127
|
736 return;
|
Chris@127
|
737 }
|
Chris@127
|
738
|
Chris@127
|
739 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
740 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
741
|
Chris@127
|
742 if (m_clickedInRange) {
|
Chris@127
|
743 mouseMoveEvent(e);
|
Chris@127
|
744 }
|
Chris@127
|
745
|
Chris@127
|
746 if (m_navigating || mode == ViewManager::NavigateMode) {
|
Chris@127
|
747
|
Chris@127
|
748 m_navigating = false;
|
Chris@127
|
749
|
Chris@127
|
750 if (mode != ViewManager::NavigateMode) {
|
Chris@127
|
751 // restore cursor
|
Chris@127
|
752 toolModeChanged();
|
Chris@127
|
753 }
|
Chris@127
|
754
|
Chris@127
|
755 if (m_shiftPressed) {
|
Chris@127
|
756
|
Chris@127
|
757 int x0 = std::min(m_clickPos.x(), m_mousePos.x());
|
Chris@127
|
758 int x1 = std::max(m_clickPos.x(), m_mousePos.x());
|
Chris@127
|
759 int w = x1 - x0;
|
Chris@127
|
760
|
Chris@127
|
761 int y0 = std::min(m_clickPos.y(), m_mousePos.y());
|
Chris@127
|
762 int y1 = std::max(m_clickPos.y(), m_mousePos.y());
|
Chris@127
|
763 // int h = y1 - y0;
|
Chris@127
|
764
|
Chris@127
|
765 long newStartFrame = getFrameForX(x0);
|
Chris@127
|
766
|
Chris@127
|
767 long visibleFrames = getEndFrame() - getStartFrame();
|
Chris@127
|
768 if (newStartFrame <= -visibleFrames) {
|
Chris@127
|
769 newStartFrame = -visibleFrames + 1;
|
Chris@127
|
770 }
|
Chris@127
|
771
|
Chris@127
|
772 if (newStartFrame >= long(getModelsEndFrame())) {
|
Chris@127
|
773 newStartFrame = getModelsEndFrame() - 1;
|
Chris@127
|
774 }
|
Chris@127
|
775
|
Chris@127
|
776 float ratio = float(w) / float(width());
|
Chris@127
|
777 // std::cerr << "ratio: " << ratio << std::endl;
|
Chris@127
|
778 size_t newZoomLevel = (size_t)nearbyint(m_zoomLevel * ratio);
|
Chris@127
|
779 if (newZoomLevel < 1) newZoomLevel = 1;
|
Chris@127
|
780
|
Chris@127
|
781 // std::cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << std::endl;
|
Chris@127
|
782 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel));
|
Chris@127
|
783 setStartFrame(newStartFrame);
|
Chris@127
|
784
|
Chris@127
|
785 //!!! lots of faff, shouldn't be here
|
Chris@127
|
786
|
Chris@127
|
787 QString unit;
|
Chris@127
|
788 float min, max;
|
Chris@127
|
789 bool log;
|
Chris@127
|
790 Layer *layer = 0;
|
Chris@127
|
791 for (LayerList::const_iterator i = m_layers.begin();
|
Chris@127
|
792 i != m_layers.end(); ++i) {
|
Chris@127
|
793 if ((*i)->getValueExtents(min, max, log, unit) &&
|
Chris@127
|
794 (*i)->getDisplayExtents(min, max)) {
|
Chris@127
|
795 layer = *i;
|
Chris@127
|
796 break;
|
Chris@127
|
797 }
|
Chris@127
|
798 }
|
Chris@127
|
799
|
Chris@127
|
800 if (layer) {
|
Chris@127
|
801 if (log) {
|
Chris@127
|
802 min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min);
|
Chris@127
|
803 max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max);
|
Chris@127
|
804 }
|
Chris@127
|
805 float rmin = min + ((max - min) * (height() - y1)) / height();
|
Chris@127
|
806 float rmax = min + ((max - min) * (height() - y0)) / height();
|
Chris@127
|
807 std::cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << std::endl;
|
Chris@127
|
808 if (log) {
|
Chris@127
|
809 rmin = powf(10, rmin);
|
Chris@127
|
810 rmax = powf(10, rmax);
|
Chris@127
|
811 }
|
Chris@127
|
812 std::cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit.toStdString() << std::endl;
|
Chris@127
|
813
|
Chris@127
|
814 layer->setDisplayExtents(rmin, rmax);
|
Chris@127
|
815 }
|
Chris@127
|
816
|
Chris@127
|
817 //cerr << "mouseReleaseEvent: start frame now " << m_startFrame << endl;
|
Chris@127
|
818 // update();
|
Chris@127
|
819 }
|
Chris@127
|
820
|
Chris@127
|
821 } else if (mode == ViewManager::SelectMode) {
|
Chris@127
|
822
|
Chris@127
|
823 if (m_manager && m_manager->haveInProgressSelection()) {
|
Chris@127
|
824
|
Chris@127
|
825 bool exclusive;
|
Chris@127
|
826 Selection selection = m_manager->getInProgressSelection(exclusive);
|
Chris@127
|
827
|
Chris@127
|
828 if (selection.getEndFrame() < selection.getStartFrame() + 2) {
|
Chris@127
|
829 selection = Selection();
|
Chris@127
|
830 }
|
Chris@127
|
831
|
Chris@127
|
832 m_manager->clearInProgressSelection();
|
Chris@127
|
833
|
Chris@127
|
834 if (exclusive) {
|
Chris@127
|
835 m_manager->setSelection(selection);
|
Chris@127
|
836 } else {
|
Chris@127
|
837 m_manager->addSelection(selection);
|
Chris@127
|
838 }
|
Chris@127
|
839 }
|
Chris@127
|
840
|
Chris@127
|
841 update();
|
Chris@127
|
842
|
Chris@127
|
843 } else if (mode == ViewManager::DrawMode) {
|
Chris@127
|
844
|
Chris@127
|
845 Layer *layer = getSelectedLayer();
|
Chris@127
|
846 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
847 layer->drawEnd(this, e);
|
Chris@127
|
848 update();
|
Chris@127
|
849 }
|
Chris@127
|
850
|
Chris@127
|
851 } else if (mode == ViewManager::EditMode) {
|
Chris@127
|
852
|
Chris@127
|
853 if (!editSelectionEnd(e)) {
|
Chris@127
|
854 Layer *layer = getSelectedLayer();
|
Chris@127
|
855 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
856 layer->editEnd(this, e);
|
Chris@127
|
857 update();
|
Chris@127
|
858 }
|
Chris@127
|
859 }
|
Chris@127
|
860 }
|
Chris@127
|
861
|
Chris@127
|
862 m_clickedInRange = false;
|
Chris@127
|
863
|
Chris@127
|
864 emit paneInteractedWith();
|
Chris@127
|
865 }
|
Chris@127
|
866
|
Chris@127
|
867 void
|
Chris@127
|
868 Pane::mouseMoveEvent(QMouseEvent *e)
|
Chris@127
|
869 {
|
Chris@127
|
870 if (e->buttons() & Qt::RightButton) {
|
Chris@127
|
871 return;
|
Chris@127
|
872 }
|
Chris@127
|
873
|
Chris@127
|
874 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
875 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
876
|
Chris@127
|
877 QPoint prevPoint = m_identifyPoint;
|
Chris@127
|
878 m_identifyPoint = e->pos();
|
Chris@127
|
879
|
Chris@127
|
880 if (!m_clickedInRange) {
|
Chris@127
|
881
|
Chris@127
|
882 if (mode == ViewManager::SelectMode) {
|
Chris@127
|
883 bool closeToLeft = false, closeToRight = false;
|
Chris@127
|
884 getSelectionAt(e->x(), closeToLeft, closeToRight);
|
Chris@127
|
885 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) {
|
Chris@127
|
886 setCursor(Qt::SizeHorCursor);
|
Chris@127
|
887 } else {
|
Chris@127
|
888 setCursor(Qt::ArrowCursor);
|
Chris@127
|
889 }
|
Chris@127
|
890 }
|
Chris@127
|
891
|
Chris@127
|
892 //!!! if (mode != ViewManager::DrawMode) {
|
Chris@127
|
893
|
Chris@127
|
894 if (!m_manager->isPlaying()) {
|
Chris@127
|
895
|
Chris@127
|
896 if (getSelectedLayer()) {
|
Chris@127
|
897
|
Chris@127
|
898 bool previouslyIdentifying = m_identifyFeatures;
|
Chris@127
|
899 m_identifyFeatures = true;
|
Chris@127
|
900
|
Chris@127
|
901 if (m_identifyFeatures != previouslyIdentifying ||
|
Chris@127
|
902 m_identifyPoint != prevPoint) {
|
Chris@127
|
903 update();
|
Chris@127
|
904 }
|
Chris@127
|
905 }
|
Chris@127
|
906
|
Chris@127
|
907 }
|
Chris@127
|
908
|
Chris@127
|
909 // }
|
Chris@127
|
910
|
Chris@127
|
911 return;
|
Chris@127
|
912 }
|
Chris@127
|
913
|
Chris@127
|
914 if (m_navigating || mode == ViewManager::NavigateMode) {
|
Chris@127
|
915
|
Chris@127
|
916 if (m_shiftPressed) {
|
Chris@127
|
917
|
Chris@127
|
918 m_mousePos = e->pos();
|
Chris@127
|
919 update();
|
Chris@127
|
920
|
Chris@127
|
921 } else {
|
Chris@127
|
922
|
Chris@127
|
923 long frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x());
|
Chris@127
|
924
|
Chris@127
|
925 size_t newCentreFrame = m_dragCentreFrame;
|
Chris@127
|
926
|
Chris@127
|
927 if (frameOff < 0) {
|
Chris@127
|
928 newCentreFrame -= frameOff;
|
Chris@127
|
929 } else if (newCentreFrame >= size_t(frameOff)) {
|
Chris@127
|
930 newCentreFrame -= frameOff;
|
Chris@127
|
931 } else {
|
Chris@127
|
932 newCentreFrame = 0;
|
Chris@127
|
933 }
|
Chris@127
|
934
|
Chris@127
|
935 if (newCentreFrame >= getModelsEndFrame()) {
|
Chris@127
|
936 newCentreFrame = getModelsEndFrame();
|
Chris@127
|
937 if (newCentreFrame > 0) --newCentreFrame;
|
Chris@127
|
938 }
|
Chris@127
|
939
|
Chris@127
|
940 if (getXForFrame(m_centreFrame) != getXForFrame(newCentreFrame)) {
|
Chris@127
|
941 setCentreFrame(newCentreFrame);
|
Chris@127
|
942 }
|
Chris@136
|
943
|
Chris@136
|
944 //!!! For drag up/down, we need to: call getValueExtents
|
Chris@136
|
945 //and getDisplayExtents and see whether both return true
|
Chris@136
|
946 //(we can only drag up/down if they do); and check whether
|
Chris@136
|
947 //the ranges returned differ (likewise). Then, we know
|
Chris@136
|
948 //the height of the layer, so...
|
Chris@136
|
949
|
Chris@136
|
950 //!!! this should have its own function
|
Chris@136
|
951
|
Chris@136
|
952 Layer *layer = 0;
|
Chris@136
|
953 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@136
|
954
|
Chris@136
|
955 if (layer) {
|
Chris@136
|
956
|
Chris@136
|
957 float vmin = 0.f, vmax = 0.f;
|
Chris@136
|
958 bool vlog = false;
|
Chris@136
|
959 QString vunit;
|
Chris@136
|
960
|
Chris@136
|
961 float dmin = 0.f, dmax = 0.f;
|
Chris@136
|
962
|
Chris@136
|
963 if (layer->getValueExtents(vmin, vmax, vlog, vunit) &&
|
Chris@136
|
964 layer->getDisplayExtents(dmin, dmax) &&
|
Chris@136
|
965 (dmin > vmin || dmax < vmax)) {
|
Chris@136
|
966
|
Chris@136
|
967 int ydiff = e->y() - m_clickPos.y();
|
Chris@136
|
968 std::cerr << "ydiff = " << ydiff << std::endl;
|
Chris@136
|
969
|
Chris@136
|
970 float perpix = (dmax - dmin) / height();
|
Chris@136
|
971 float valdiff = ydiff * perpix;
|
Chris@136
|
972 std::cerr << "valdiff = " << valdiff << std::endl;
|
Chris@136
|
973
|
Chris@136
|
974 float newmin = m_dragStartMinValue + valdiff;
|
Chris@136
|
975 float newmax = m_dragStartMinValue + (dmax - dmin) + valdiff;
|
Chris@136
|
976 if (newmin < vmin) {
|
Chris@136
|
977 newmax += vmin - newmin;
|
Chris@136
|
978 newmin += vmin - newmin;
|
Chris@136
|
979 }
|
Chris@136
|
980 if (newmax > vmax) {
|
Chris@136
|
981 newmin -= newmax - vmax;
|
Chris@136
|
982 newmax -= newmax - vmax;
|
Chris@136
|
983 }
|
Chris@136
|
984 std::cerr << "(" << dmin << ", " << dmax << ") -> ("
|
Chris@136
|
985 << newmin << ", " << newmax << ") (drag start " << m_dragStartMinValue << ")" << std::endl;
|
Chris@136
|
986 layer->setDisplayExtents(newmin, newmax);
|
Chris@136
|
987 }
|
Chris@136
|
988 }
|
Chris@127
|
989 }
|
Chris@127
|
990
|
Chris@127
|
991 } else if (mode == ViewManager::SelectMode) {
|
Chris@127
|
992
|
Chris@127
|
993 int mouseFrame = getFrameForX(e->x());
|
Chris@127
|
994 size_t resolution = 1;
|
Chris@127
|
995 int snapFrameLeft = mouseFrame;
|
Chris@127
|
996 int snapFrameRight = mouseFrame;
|
Chris@127
|
997
|
Chris@127
|
998 Layer *layer = getSelectedLayer();
|
Chris@127
|
999 if (layer && !m_shiftPressed) {
|
Chris@127
|
1000 layer->snapToFeatureFrame(this, snapFrameLeft,
|
Chris@127
|
1001 resolution, Layer::SnapLeft);
|
Chris@127
|
1002 layer->snapToFeatureFrame(this, snapFrameRight,
|
Chris@127
|
1003 resolution, Layer::SnapRight);
|
Chris@127
|
1004 }
|
Chris@127
|
1005
|
Chris@127
|
1006 // std::cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << std::endl;
|
Chris@127
|
1007
|
Chris@127
|
1008 if (snapFrameLeft < 0) snapFrameLeft = 0;
|
Chris@127
|
1009 if (snapFrameRight < 0) snapFrameRight = 0;
|
Chris@127
|
1010
|
Chris@127
|
1011 size_t min, max;
|
Chris@127
|
1012
|
Chris@127
|
1013 if (m_selectionStartFrame > snapFrameLeft) {
|
Chris@127
|
1014 min = snapFrameLeft;
|
Chris@127
|
1015 max = m_selectionStartFrame;
|
Chris@127
|
1016 } else if (snapFrameRight > m_selectionStartFrame) {
|
Chris@127
|
1017 min = m_selectionStartFrame;
|
Chris@127
|
1018 max = snapFrameRight;
|
Chris@127
|
1019 } else {
|
Chris@127
|
1020 min = snapFrameLeft;
|
Chris@127
|
1021 max = snapFrameRight;
|
Chris@127
|
1022 }
|
Chris@127
|
1023
|
Chris@127
|
1024 if (m_manager) {
|
Chris@127
|
1025 m_manager->setInProgressSelection(Selection(min, max),
|
Chris@127
|
1026 !m_resizing && !m_ctrlPressed);
|
Chris@127
|
1027 }
|
Chris@127
|
1028
|
Chris@127
|
1029 bool doScroll = false;
|
Chris@127
|
1030 if (!m_manager) doScroll = true;
|
Chris@127
|
1031 if (!m_manager->isPlaying()) doScroll = true;
|
Chris@127
|
1032 if (m_followPlay != PlaybackScrollContinuous) doScroll = true;
|
Chris@127
|
1033
|
Chris@127
|
1034 if (doScroll) {
|
Chris@127
|
1035 int offset = mouseFrame - getStartFrame();
|
Chris@127
|
1036 int available = getEndFrame() - getStartFrame();
|
Chris@127
|
1037 if (offset >= available * 0.95) {
|
Chris@127
|
1038 int move = int(offset - available * 0.95) + 1;
|
Chris@127
|
1039 setCentreFrame(m_centreFrame + move);
|
Chris@127
|
1040 } else if (offset <= available * 0.10) {
|
Chris@127
|
1041 int move = int(available * 0.10 - offset) + 1;
|
Chris@127
|
1042 if (m_centreFrame > move) {
|
Chris@127
|
1043 setCentreFrame(m_centreFrame - move);
|
Chris@127
|
1044 } else {
|
Chris@127
|
1045 setCentreFrame(0);
|
Chris@127
|
1046 }
|
Chris@127
|
1047 }
|
Chris@127
|
1048 }
|
Chris@127
|
1049
|
Chris@127
|
1050 update();
|
Chris@127
|
1051
|
Chris@127
|
1052 } else if (mode == ViewManager::DrawMode) {
|
Chris@127
|
1053
|
Chris@127
|
1054 Layer *layer = getSelectedLayer();
|
Chris@127
|
1055 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
1056 layer->drawDrag(this, e);
|
Chris@127
|
1057 }
|
Chris@127
|
1058
|
Chris@127
|
1059 } else if (mode == ViewManager::EditMode) {
|
Chris@127
|
1060
|
Chris@127
|
1061 if (!editSelectionDrag(e)) {
|
Chris@127
|
1062 Layer *layer = getSelectedLayer();
|
Chris@127
|
1063 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
1064 layer->editDrag(this, e);
|
Chris@127
|
1065 }
|
Chris@127
|
1066 }
|
Chris@127
|
1067 }
|
Chris@127
|
1068 }
|
Chris@127
|
1069
|
Chris@127
|
1070 void
|
Chris@127
|
1071 Pane::mouseDoubleClickEvent(QMouseEvent *e)
|
Chris@127
|
1072 {
|
Chris@127
|
1073 if (e->buttons() & Qt::RightButton) {
|
Chris@127
|
1074 return;
|
Chris@127
|
1075 }
|
Chris@127
|
1076
|
Chris@127
|
1077 // std::cerr << "mouseDoubleClickEvent" << std::endl;
|
Chris@127
|
1078
|
Chris@127
|
1079 m_clickPos = e->pos();
|
Chris@127
|
1080 m_clickedInRange = true;
|
Chris@127
|
1081 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier);
|
Chris@127
|
1082 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier);
|
Chris@127
|
1083
|
Chris@127
|
1084 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
1085 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
1086
|
Chris@127
|
1087 if (mode == ViewManager::NavigateMode ||
|
Chris@127
|
1088 mode == ViewManager::EditMode) {
|
Chris@127
|
1089
|
Chris@127
|
1090 Layer *layer = getSelectedLayer();
|
Chris@127
|
1091 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
1092 layer->editOpen(this, e);
|
Chris@127
|
1093 }
|
Chris@127
|
1094 }
|
Chris@127
|
1095 }
|
Chris@127
|
1096
|
Chris@127
|
1097 void
|
Chris@127
|
1098 Pane::leaveEvent(QEvent *)
|
Chris@127
|
1099 {
|
Chris@127
|
1100 bool previouslyIdentifying = m_identifyFeatures;
|
Chris@127
|
1101 m_identifyFeatures = false;
|
Chris@127
|
1102 if (previouslyIdentifying) update();
|
Chris@127
|
1103 }
|
Chris@127
|
1104
|
Chris@127
|
1105 void
|
Chris@133
|
1106 Pane::resizeEvent(QResizeEvent *)
|
Chris@133
|
1107 {
|
Chris@133
|
1108 updateHeadsUpDisplay();
|
Chris@133
|
1109 }
|
Chris@133
|
1110
|
Chris@133
|
1111 void
|
Chris@127
|
1112 Pane::wheelEvent(QWheelEvent *e)
|
Chris@127
|
1113 {
|
Chris@127
|
1114 //std::cerr << "wheelEvent, delta " << e->delta() << std::endl;
|
Chris@127
|
1115
|
Chris@127
|
1116 int count = e->delta();
|
Chris@127
|
1117
|
Chris@127
|
1118 if (count > 0) {
|
Chris@127
|
1119 if (count >= 120) count /= 120;
|
Chris@127
|
1120 else count = 1;
|
Chris@127
|
1121 }
|
Chris@127
|
1122
|
Chris@127
|
1123 if (count < 0) {
|
Chris@127
|
1124 if (count <= -120) count /= 120;
|
Chris@127
|
1125 else count = -1;
|
Chris@127
|
1126 }
|
Chris@127
|
1127
|
Chris@127
|
1128 if (e->modifiers() & Qt::ControlModifier) {
|
Chris@127
|
1129
|
Chris@127
|
1130 // Scroll left or right, rapidly
|
Chris@127
|
1131
|
Chris@127
|
1132 if (getStartFrame() < 0 &&
|
Chris@127
|
1133 getEndFrame() >= getModelsEndFrame()) return;
|
Chris@127
|
1134
|
Chris@127
|
1135 long delta = ((width() / 2) * count * m_zoomLevel);
|
Chris@127
|
1136
|
Chris@127
|
1137 if (int(m_centreFrame) < delta) {
|
Chris@127
|
1138 setCentreFrame(0);
|
Chris@127
|
1139 } else if (int(m_centreFrame) - delta >= int(getModelsEndFrame())) {
|
Chris@127
|
1140 setCentreFrame(getModelsEndFrame());
|
Chris@127
|
1141 } else {
|
Chris@127
|
1142 setCentreFrame(m_centreFrame - delta);
|
Chris@127
|
1143 }
|
Chris@127
|
1144
|
Chris@127
|
1145 } else {
|
Chris@127
|
1146
|
Chris@127
|
1147 // Zoom in or out
|
Chris@127
|
1148
|
Chris@127
|
1149 int newZoomLevel = m_zoomLevel;
|
Chris@127
|
1150
|
Chris@127
|
1151 while (count > 0) {
|
Chris@127
|
1152 if (newZoomLevel <= 2) {
|
Chris@127
|
1153 newZoomLevel = 1;
|
Chris@127
|
1154 break;
|
Chris@127
|
1155 }
|
Chris@127
|
1156 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1,
|
Chris@127
|
1157 ZoomConstraint::RoundDown);
|
Chris@127
|
1158 --count;
|
Chris@127
|
1159 }
|
Chris@127
|
1160
|
Chris@127
|
1161 while (count < 0) {
|
Chris@127
|
1162 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1,
|
Chris@127
|
1163 ZoomConstraint::RoundUp);
|
Chris@127
|
1164 ++count;
|
Chris@127
|
1165 }
|
Chris@127
|
1166
|
Chris@127
|
1167 if (newZoomLevel != m_zoomLevel) {
|
Chris@127
|
1168 setZoomLevel(newZoomLevel);
|
Chris@127
|
1169 }
|
Chris@127
|
1170 }
|
Chris@127
|
1171
|
Chris@127
|
1172 emit paneInteractedWith();
|
Chris@127
|
1173 }
|
Chris@127
|
1174
|
Chris@132
|
1175 void
|
Chris@132
|
1176 Pane::horizontalThumbwheelMoved(int value)
|
Chris@132
|
1177 {
|
Chris@132
|
1178 int count = 0;
|
Chris@132
|
1179 int level = 1;
|
Chris@132
|
1180 while (true) {
|
Chris@133
|
1181 if (m_hthumb->getMaximumValue() - value == count) break;
|
Chris@132
|
1182 int newLevel = getZoomConstraintBlockSize(level + 1,
|
Chris@132
|
1183 ZoomConstraint::RoundUp);
|
Chris@132
|
1184 if (newLevel == level) break;
|
Chris@132
|
1185 level = newLevel;
|
Chris@132
|
1186 ++count;
|
Chris@132
|
1187 }
|
Chris@132
|
1188
|
Chris@133
|
1189 // std::cerr << "new level is " << level << std::endl;
|
Chris@132
|
1190 setZoomLevel(level);
|
Chris@132
|
1191 }
|
Chris@132
|
1192
|
Chris@132
|
1193 void
|
Chris@132
|
1194 Pane::verticalThumbwheelMoved(int value)
|
Chris@132
|
1195 {
|
Chris@133
|
1196 Layer *layer = 0;
|
Chris@133
|
1197 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
1198 if (layer) {
|
Chris@133
|
1199 int defaultStep = 0;
|
Chris@133
|
1200 int max = layer->getVerticalZoomSteps(defaultStep);
|
Chris@133
|
1201 if (max == 0) {
|
Chris@133
|
1202 updateHeadsUpDisplay();
|
Chris@133
|
1203 return;
|
Chris@133
|
1204 }
|
Chris@133
|
1205 if (value > max) {
|
Chris@133
|
1206 value = max;
|
Chris@133
|
1207 }
|
Chris@133
|
1208 layer->setVerticalZoomStep(value);
|
Chris@133
|
1209 }
|
Chris@132
|
1210 }
|
Chris@132
|
1211
|
Chris@127
|
1212 bool
|
Chris@127
|
1213 Pane::editSelectionStart(QMouseEvent *e)
|
Chris@127
|
1214 {
|
Chris@127
|
1215 if (!m_identifyFeatures ||
|
Chris@127
|
1216 !m_manager ||
|
Chris@127
|
1217 m_manager->getToolMode() != ViewManager::EditMode) {
|
Chris@127
|
1218 return false;
|
Chris@127
|
1219 }
|
Chris@127
|
1220
|
Chris@127
|
1221 bool closeToLeft, closeToRight;
|
Chris@127
|
1222 Selection s(getSelectionAt(e->x(), closeToLeft, closeToRight));
|
Chris@127
|
1223 if (s.isEmpty()) return false;
|
Chris@127
|
1224 m_editingSelection = s;
|
Chris@127
|
1225 m_editingSelectionEdge = (closeToLeft ? -1 : closeToRight ? 1 : 0);
|
Chris@127
|
1226 m_mousePos = e->pos();
|
Chris@127
|
1227 return true;
|
Chris@127
|
1228 }
|
Chris@127
|
1229
|
Chris@127
|
1230 bool
|
Chris@127
|
1231 Pane::editSelectionDrag(QMouseEvent *e)
|
Chris@127
|
1232 {
|
Chris@127
|
1233 if (m_editingSelection.isEmpty()) return false;
|
Chris@127
|
1234 m_mousePos = e->pos();
|
Chris@127
|
1235 update();
|
Chris@127
|
1236 return true;
|
Chris@127
|
1237 }
|
Chris@127
|
1238
|
Chris@127
|
1239 bool
|
Chris@127
|
1240 Pane::editSelectionEnd(QMouseEvent *e)
|
Chris@127
|
1241 {
|
Chris@127
|
1242 if (m_editingSelection.isEmpty()) return false;
|
Chris@127
|
1243
|
Chris@127
|
1244 int offset = m_mousePos.x() - m_clickPos.x();
|
Chris@127
|
1245 Layer *layer = getSelectedLayer();
|
Chris@127
|
1246
|
Chris@127
|
1247 if (offset == 0 || !layer) {
|
Chris@127
|
1248 m_editingSelection = Selection();
|
Chris@127
|
1249 return true;
|
Chris@127
|
1250 }
|
Chris@127
|
1251
|
Chris@127
|
1252 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset;
|
Chris@127
|
1253 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset;
|
Chris@127
|
1254
|
Chris@127
|
1255 long f0 = getFrameForX(p0);
|
Chris@127
|
1256 long f1 = getFrameForX(p1);
|
Chris@127
|
1257
|
Chris@127
|
1258 Selection newSelection(f0, f1);
|
Chris@127
|
1259
|
Chris@127
|
1260 if (m_editingSelectionEdge == 0) {
|
Chris@127
|
1261
|
Chris@127
|
1262 CommandHistory::getInstance()->startCompoundOperation
|
Chris@127
|
1263 (tr("Drag Selection"), true);
|
Chris@127
|
1264
|
Chris@127
|
1265 layer->moveSelection(m_editingSelection, f0);
|
Chris@127
|
1266
|
Chris@127
|
1267 } else {
|
Chris@127
|
1268
|
Chris@127
|
1269 CommandHistory::getInstance()->startCompoundOperation
|
Chris@127
|
1270 (tr("Resize Selection"), true);
|
Chris@127
|
1271
|
Chris@127
|
1272 if (m_editingSelectionEdge < 0) {
|
Chris@127
|
1273 f1 = m_editingSelection.getEndFrame();
|
Chris@127
|
1274 } else {
|
Chris@127
|
1275 f0 = m_editingSelection.getStartFrame();
|
Chris@127
|
1276 }
|
Chris@127
|
1277
|
Chris@127
|
1278 newSelection = Selection(f0, f1);
|
Chris@127
|
1279 layer->resizeSelection(m_editingSelection, newSelection);
|
Chris@127
|
1280 }
|
Chris@127
|
1281
|
Chris@127
|
1282 m_manager->removeSelection(m_editingSelection);
|
Chris@127
|
1283 m_manager->addSelection(newSelection);
|
Chris@127
|
1284
|
Chris@127
|
1285 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@127
|
1286
|
Chris@127
|
1287 m_editingSelection = Selection();
|
Chris@127
|
1288 return true;
|
Chris@127
|
1289 }
|
Chris@127
|
1290
|
Chris@127
|
1291 void
|
Chris@127
|
1292 Pane::toolModeChanged()
|
Chris@127
|
1293 {
|
Chris@127
|
1294 ViewManager::ToolMode mode = m_manager->getToolMode();
|
Chris@127
|
1295 // std::cerr << "Pane::toolModeChanged(" << mode << ")" << std::endl;
|
Chris@127
|
1296
|
Chris@127
|
1297 switch (mode) {
|
Chris@127
|
1298
|
Chris@127
|
1299 case ViewManager::NavigateMode:
|
Chris@127
|
1300 setCursor(Qt::PointingHandCursor);
|
Chris@127
|
1301 break;
|
Chris@127
|
1302
|
Chris@127
|
1303 case ViewManager::SelectMode:
|
Chris@127
|
1304 setCursor(Qt::ArrowCursor);
|
Chris@127
|
1305 break;
|
Chris@127
|
1306
|
Chris@127
|
1307 case ViewManager::EditMode:
|
Chris@127
|
1308 setCursor(Qt::UpArrowCursor);
|
Chris@127
|
1309 break;
|
Chris@127
|
1310
|
Chris@127
|
1311 case ViewManager::DrawMode:
|
Chris@127
|
1312 setCursor(Qt::CrossCursor);
|
Chris@127
|
1313 break;
|
Chris@127
|
1314 /*
|
Chris@127
|
1315 case ViewManager::TextMode:
|
Chris@127
|
1316 setCursor(Qt::IBeamCursor);
|
Chris@127
|
1317 break;
|
Chris@127
|
1318 */
|
Chris@127
|
1319 }
|
Chris@127
|
1320 }
|
Chris@127
|
1321
|
Chris@133
|
1322 void
|
Chris@133
|
1323 Pane::zoomWheelsEnabledChanged()
|
Chris@133
|
1324 {
|
Chris@133
|
1325 updateHeadsUpDisplay();
|
Chris@133
|
1326 update();
|
Chris@133
|
1327 }
|
Chris@133
|
1328
|
Chris@133
|
1329 void
|
Chris@133
|
1330 Pane::zoomLevelChanged()
|
Chris@133
|
1331 {
|
Chris@133
|
1332 if (m_manager && m_manager->getZoomWheelsEnabled()) {
|
Chris@133
|
1333 updateHeadsUpDisplay();
|
Chris@133
|
1334 }
|
Chris@133
|
1335 }
|
Chris@133
|
1336
|
Chris@133
|
1337 void
|
Chris@133
|
1338 Pane::propertyContainerSelected(View *v, PropertyContainer *pc)
|
Chris@133
|
1339 {
|
Chris@133
|
1340 Layer *layer = 0;
|
Chris@133
|
1341
|
Chris@133
|
1342 if (getLayerCount() > 0) {
|
Chris@133
|
1343 layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
1344 disconnect(layer, SIGNAL(verticalZoomChanged()),
|
Chris@133
|
1345 this, SLOT(verticalZoomChanged()));
|
Chris@133
|
1346 }
|
Chris@133
|
1347
|
Chris@133
|
1348 View::propertyContainerSelected(v, pc);
|
Chris@133
|
1349 updateHeadsUpDisplay();
|
Chris@133
|
1350
|
Chris@133
|
1351 if (getLayerCount() > 0) {
|
Chris@133
|
1352 layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
1353 connect(layer, SIGNAL(verticalZoomChanged()),
|
Chris@133
|
1354 this, SLOT(verticalZoomChanged()));
|
Chris@133
|
1355 }
|
Chris@133
|
1356 }
|
Chris@133
|
1357
|
Chris@133
|
1358 void
|
Chris@133
|
1359 Pane::verticalZoomChanged()
|
Chris@133
|
1360 {
|
Chris@133
|
1361 Layer *layer = 0;
|
Chris@133
|
1362
|
Chris@133
|
1363 if (getLayerCount() > 0) {
|
Chris@133
|
1364
|
Chris@133
|
1365 layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
1366
|
Chris@133
|
1367 if (m_vthumb && m_vthumb->isVisible()) {
|
Chris@133
|
1368 m_vthumb->setValue(layer->getCurrentVerticalZoomStep());
|
Chris@133
|
1369 }
|
Chris@133
|
1370 }
|
Chris@133
|
1371 }
|
Chris@133
|
1372
|
Chris@127
|
1373 QString
|
Chris@127
|
1374 Pane::toXmlString(QString indent, QString extraAttributes) const
|
Chris@127
|
1375 {
|
Chris@127
|
1376 return View::toXmlString
|
Chris@127
|
1377 (indent,
|
Chris@127
|
1378 QString("type=\"pane\" centreLineVisible=\"%1\" height=\"%2\" %3")
|
Chris@127
|
1379 .arg(m_centreLineVisible).arg(height()).arg(extraAttributes));
|
Chris@127
|
1380 }
|
Chris@127
|
1381
|
Chris@127
|
1382
|
Chris@127
|
1383 #ifdef INCLUDE_MOCFILES
|
Chris@127
|
1384 #include "Pane.moc.cpp"
|
Chris@127
|
1385 #endif
|
Chris@127
|
1386
|