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@264
|
7 This file copyright 2006-2007 Chris Cannam and QMUL.
|
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@376
|
23 #include "widgets/CommandHistory.h"
|
Chris@376
|
24 #include "widgets/TextAbbrev.h"
|
Chris@338
|
25 #include "base/Preferences.h"
|
Chris@127
|
26 #include "layer/WaveformLayer.h"
|
Chris@127
|
27
|
Chris@326
|
28 //!!! ugh
|
Chris@326
|
29 #include "data/model/WaveFileModel.h"
|
Chris@326
|
30
|
Chris@127
|
31 #include <QPaintEvent>
|
Chris@127
|
32 #include <QPainter>
|
Chris@257
|
33 #include <QBitmap>
|
Chris@312
|
34 #include <QDragEnterEvent>
|
Chris@312
|
35 #include <QDropEvent>
|
Chris@257
|
36 #include <QCursor>
|
Chris@316
|
37 #include <QTextStream>
|
Chris@316
|
38
|
Chris@127
|
39 #include <iostream>
|
Chris@127
|
40 #include <cmath>
|
Chris@127
|
41
|
Chris@133
|
42 //!!! for HUD -- pull out into a separate class
|
Chris@133
|
43 #include <QFrame>
|
Chris@133
|
44 #include <QGridLayout>
|
Chris@133
|
45 #include <QPushButton>
|
Chris@133
|
46 #include "widgets/Thumbwheel.h"
|
Chris@172
|
47 #include "widgets/Panner.h"
|
Chris@188
|
48 #include "widgets/RangeInputDialog.h"
|
Chris@189
|
49 #include "widgets/NotifyingPushButton.h"
|
Chris@133
|
50
|
Chris@282
|
51 #include "widgets/KeyReference.h" //!!! should probably split KeyReference into a data class in base and another that shows the widget
|
Chris@282
|
52
|
Chris@363
|
53 //#define DEBUG_PANE
|
Chris@363
|
54
|
Chris@127
|
55 using std::cerr;
|
Chris@127
|
56 using std::endl;
|
Chris@127
|
57
|
Chris@267
|
58 QCursor *Pane::m_measureCursor1 = 0;
|
Chris@267
|
59 QCursor *Pane::m_measureCursor2 = 0;
|
Chris@262
|
60
|
Chris@127
|
61 Pane::Pane(QWidget *w) :
|
Chris@127
|
62 View(w, true),
|
Chris@127
|
63 m_identifyFeatures(false),
|
Chris@127
|
64 m_clickedInRange(false),
|
Chris@127
|
65 m_shiftPressed(false),
|
Chris@127
|
66 m_ctrlPressed(false),
|
Chris@127
|
67 m_navigating(false),
|
Chris@127
|
68 m_resizing(false),
|
Chris@343
|
69 m_editing(false),
|
Chris@343
|
70 m_releasing(false),
|
Chris@133
|
71 m_centreLineVisible(true),
|
Chris@222
|
72 m_scaleWidth(0),
|
Chris@237
|
73 m_headsUpDisplay(0),
|
Chris@237
|
74 m_vpan(0),
|
Chris@237
|
75 m_hthumb(0),
|
Chris@237
|
76 m_vthumb(0),
|
Chris@290
|
77 m_reset(0),
|
Chris@290
|
78 m_mouseInWidget(false)
|
Chris@127
|
79 {
|
Chris@127
|
80 setObjectName("Pane");
|
Chris@127
|
81 setMouseTracking(true);
|
Chris@312
|
82 setAcceptDrops(true);
|
Chris@133
|
83
|
Chris@133
|
84 updateHeadsUpDisplay();
|
Chris@456
|
85
|
Chris@456
|
86
|
Chris@460
|
87 // std::cerr << "Pane::Pane(" << this << ") returning" << std::endl;
|
Chris@133
|
88 }
|
Chris@133
|
89
|
Chris@133
|
90 void
|
Chris@133
|
91 Pane::updateHeadsUpDisplay()
|
Chris@133
|
92 {
|
Chris@382
|
93 Profiler profiler("Pane::updateHeadsUpDisplay");
|
Chris@187
|
94
|
Chris@192
|
95 if (!isVisible()) return;
|
Chris@192
|
96
|
Chris@132
|
97 /*
|
Chris@132
|
98 int count = 0;
|
Chris@132
|
99 int currentLevel = 1;
|
Chris@132
|
100 int level = 1;
|
Chris@132
|
101 while (true) {
|
Chris@132
|
102 if (getZoomLevel() == level) currentLevel = count;
|
Chris@132
|
103 int newLevel = getZoomConstraintBlockSize(level + 1,
|
Chris@132
|
104 ZoomConstraint::RoundUp);
|
Chris@132
|
105 if (newLevel == level) break;
|
Chris@132
|
106 if (newLevel == 131072) break; //!!! just because
|
Chris@132
|
107 level = newLevel;
|
Chris@132
|
108 ++count;
|
Chris@132
|
109 }
|
Chris@132
|
110
|
Chris@132
|
111 std::cerr << "Have " << count+1 << " zoom levels" << std::endl;
|
Chris@132
|
112 */
|
Chris@133
|
113
|
Chris@188
|
114 Layer *layer = 0;
|
Chris@188
|
115 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@188
|
116
|
Chris@133
|
117 if (!m_headsUpDisplay) {
|
Chris@133
|
118
|
Chris@133
|
119 m_headsUpDisplay = new QFrame(this);
|
Chris@133
|
120
|
Chris@133
|
121 QGridLayout *layout = new QGridLayout;
|
Chris@133
|
122 layout->setMargin(0);
|
Chris@133
|
123 layout->setSpacing(0);
|
Chris@133
|
124 m_headsUpDisplay->setLayout(layout);
|
Chris@133
|
125
|
Chris@133
|
126 m_hthumb = new Thumbwheel(Qt::Horizontal);
|
Chris@187
|
127 m_hthumb->setObjectName(tr("Horizontal Zoom"));
|
Chris@260
|
128 m_hthumb->setCursor(Qt::ArrowCursor);
|
Chris@173
|
129 layout->addWidget(m_hthumb, 1, 0, 1, 2);
|
Chris@133
|
130 m_hthumb->setFixedWidth(70);
|
Chris@133
|
131 m_hthumb->setFixedHeight(16);
|
Chris@133
|
132 m_hthumb->setDefaultValue(0);
|
Chris@165
|
133 m_hthumb->setSpeed(0.6);
|
Chris@133
|
134 connect(m_hthumb, SIGNAL(valueChanged(int)), this,
|
Chris@133
|
135 SLOT(horizontalThumbwheelMoved(int)));
|
Chris@189
|
136 connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
137 connect(m_hthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@172
|
138
|
Chris@172
|
139 m_vpan = new Panner;
|
Chris@260
|
140 m_vpan->setCursor(Qt::ArrowCursor);
|
Chris@172
|
141 layout->addWidget(m_vpan, 0, 1);
|
Chris@173
|
142 m_vpan->setFixedWidth(12);
|
Chris@172
|
143 m_vpan->setFixedHeight(70);
|
Chris@174
|
144 m_vpan->setAlpha(80, 130);
|
Chris@174
|
145 connect(m_vpan, SIGNAL(rectExtentsChanged(float, float, float, float)),
|
Chris@174
|
146 this, SLOT(verticalPannerMoved(float, float, float, float)));
|
Chris@188
|
147 connect(m_vpan, SIGNAL(doubleClicked()),
|
Chris@188
|
148 this, SLOT(editVerticalPannerExtents()));
|
Chris@189
|
149 connect(m_vpan, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
150 connect(m_vpan, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@172
|
151
|
Chris@133
|
152 m_vthumb = new Thumbwheel(Qt::Vertical);
|
Chris@187
|
153 m_vthumb->setObjectName(tr("Vertical Zoom"));
|
Chris@260
|
154 m_vthumb->setCursor(Qt::ArrowCursor);
|
Chris@172
|
155 layout->addWidget(m_vthumb, 0, 2);
|
Chris@133
|
156 m_vthumb->setFixedWidth(16);
|
Chris@133
|
157 m_vthumb->setFixedHeight(70);
|
Chris@133
|
158 connect(m_vthumb, SIGNAL(valueChanged(int)), this,
|
Chris@133
|
159 SLOT(verticalThumbwheelMoved(int)));
|
Chris@189
|
160 connect(m_vthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
161 connect(m_vthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@133
|
162
|
Chris@188
|
163 if (layer) {
|
Chris@188
|
164 RangeMapper *rm = layer->getNewVerticalZoomRangeMapper();
|
Chris@188
|
165 if (rm) m_vthumb->setRangeMapper(rm);
|
Chris@188
|
166 }
|
Chris@188
|
167
|
Chris@189
|
168 m_reset = new NotifyingPushButton;
|
Chris@498
|
169 m_reset->setFlat(true);
|
Chris@260
|
170 m_reset->setCursor(Qt::ArrowCursor);
|
Chris@189
|
171 m_reset->setFixedHeight(16);
|
Chris@189
|
172 m_reset->setFixedWidth(16);
|
Chris@189
|
173 layout->addWidget(m_reset, 1, 2);
|
Chris@492
|
174
|
Chris@492
|
175 layout->setColumnStretch(0, 20);
|
Chris@492
|
176
|
Chris@189
|
177 connect(m_reset, SIGNAL(clicked()), m_hthumb, SLOT(resetToDefault()));
|
Chris@189
|
178 connect(m_reset, SIGNAL(clicked()), m_vthumb, SLOT(resetToDefault()));
|
Chris@189
|
179 connect(m_reset, SIGNAL(clicked()), m_vpan, SLOT(resetToDefault()));
|
Chris@189
|
180 connect(m_reset, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
181 connect(m_reset, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@133
|
182 }
|
Chris@133
|
183
|
Chris@133
|
184 int count = 0;
|
Chris@133
|
185 int current = 0;
|
Chris@133
|
186 int level = 1;
|
Chris@133
|
187
|
Chris@137
|
188 //!!! pull out into function (presumably in View)
|
Chris@137
|
189 bool haveConstraint = false;
|
Chris@137
|
190 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end();
|
Chris@137
|
191 ++i) {
|
Chris@137
|
192 if ((*i)->getZoomConstraint() && !(*i)->supportsOtherZoomLevels()) {
|
Chris@137
|
193 haveConstraint = true;
|
Chris@137
|
194 break;
|
Chris@137
|
195 }
|
Chris@137
|
196 }
|
Chris@137
|
197
|
Chris@137
|
198 if (haveConstraint) {
|
Chris@137
|
199 while (true) {
|
Chris@137
|
200 if (getZoomLevel() == level) current = count;
|
Chris@137
|
201 int newLevel = getZoomConstraintBlockSize(level + 1,
|
Chris@137
|
202 ZoomConstraint::RoundUp);
|
Chris@137
|
203 if (newLevel == level) break;
|
Chris@137
|
204 level = newLevel;
|
Chris@137
|
205 if (++count == 50) break;
|
Chris@137
|
206 }
|
Chris@137
|
207 } else {
|
Chris@137
|
208 // if we have no particular constraints, we can really spread out
|
Chris@137
|
209 while (true) {
|
Chris@137
|
210 if (getZoomLevel() >= level) current = count;
|
Chris@137
|
211 int step = level / 10;
|
Chris@137
|
212 int pwr = 0;
|
Chris@137
|
213 while (step > 0) {
|
Chris@137
|
214 ++pwr;
|
Chris@137
|
215 step /= 2;
|
Chris@137
|
216 }
|
Chris@137
|
217 step = 1;
|
Chris@137
|
218 while (pwr > 0) {
|
Chris@137
|
219 step *= 2;
|
Chris@137
|
220 --pwr;
|
Chris@137
|
221 }
|
Chris@154
|
222 // std::cerr << level << std::endl;
|
Chris@137
|
223 level += step;
|
Chris@137
|
224 if (++count == 100 || level > 262144) break;
|
Chris@137
|
225 }
|
Chris@133
|
226 }
|
Chris@133
|
227
|
Chris@133
|
228 // std::cerr << "Have " << count << " zoom levels" << std::endl;
|
Chris@133
|
229
|
Chris@133
|
230 m_hthumb->setMinimumValue(0);
|
Chris@133
|
231 m_hthumb->setMaximumValue(count);
|
Chris@133
|
232 m_hthumb->setValue(count - current);
|
Chris@133
|
233
|
Chris@133
|
234 // std::cerr << "set value to " << count-current << std::endl;
|
Chris@133
|
235
|
Chris@133
|
236 // std::cerr << "default value is " << m_hthumb->getDefaultValue() << std::endl;
|
Chris@133
|
237
|
Chris@133
|
238 if (count != 50 && m_hthumb->getDefaultValue() == 0) {
|
Chris@133
|
239 m_hthumb->setDefaultValue(count - current);
|
Chris@133
|
240 // std::cerr << "set default value to " << m_hthumb->getDefaultValue() << std::endl;
|
Chris@133
|
241 }
|
Chris@133
|
242
|
Chris@204
|
243 bool haveVThumb = false;
|
Chris@204
|
244
|
Chris@133
|
245 if (layer) {
|
Chris@133
|
246 int defaultStep = 0;
|
Chris@133
|
247 int max = layer->getVerticalZoomSteps(defaultStep);
|
Chris@133
|
248 if (max == 0) {
|
Chris@133
|
249 m_vthumb->hide();
|
Chris@133
|
250 } else {
|
Chris@204
|
251 haveVThumb = true;
|
Chris@133
|
252 m_vthumb->show();
|
Chris@187
|
253 m_vthumb->blockSignals(true);
|
Chris@133
|
254 m_vthumb->setMinimumValue(0);
|
Chris@133
|
255 m_vthumb->setMaximumValue(max);
|
Chris@133
|
256 m_vthumb->setDefaultValue(defaultStep);
|
Chris@133
|
257 m_vthumb->setValue(layer->getCurrentVerticalZoomStep());
|
Chris@187
|
258 m_vthumb->blockSignals(false);
|
Chris@135
|
259
|
Chris@205
|
260 // std::cerr << "Vertical thumbwheel: min 0, max " << max
|
Chris@205
|
261 // << ", default " << defaultStep << ", value "
|
Chris@205
|
262 // << m_vthumb->getValue() << std::endl;
|
Chris@135
|
263
|
Chris@133
|
264 }
|
Chris@133
|
265 }
|
Chris@133
|
266
|
Chris@174
|
267 updateVerticalPanner();
|
Chris@174
|
268
|
Chris@133
|
269 if (m_manager && m_manager->getZoomWheelsEnabled() &&
|
Chris@133
|
270 width() > 120 && height() > 100) {
|
Chris@165
|
271 if (!m_headsUpDisplay->isVisible()) {
|
Chris@165
|
272 m_headsUpDisplay->show();
|
Chris@165
|
273 }
|
Chris@204
|
274 if (haveVThumb) {
|
Chris@204
|
275 m_headsUpDisplay->setFixedHeight(m_vthumb->height() + m_hthumb->height());
|
Chris@133
|
276 m_headsUpDisplay->move(width() - 86, height() - 86);
|
Chris@133
|
277 } else {
|
Chris@204
|
278 m_headsUpDisplay->setFixedHeight(m_hthumb->height());
|
Chris@204
|
279 m_headsUpDisplay->move(width() - 86, height() - 16);
|
Chris@133
|
280 }
|
Chris@133
|
281 } else {
|
Chris@133
|
282 m_headsUpDisplay->hide();
|
Chris@133
|
283 }
|
Chris@127
|
284 }
|
Chris@127
|
285
|
Chris@174
|
286 void
|
Chris@174
|
287 Pane::updateVerticalPanner()
|
Chris@174
|
288 {
|
Chris@174
|
289 if (!m_vpan || !m_manager || !m_manager->getZoomWheelsEnabled()) return;
|
Chris@174
|
290
|
Chris@208
|
291 // In principle we should show or hide the panner on the basis of
|
Chris@208
|
292 // whether the top layer has adjustable display extents, and we do
|
Chris@208
|
293 // that below. However, we have no basis for layout of the panner
|
Chris@208
|
294 // if the vertical scroll wheel is not also present. So if we
|
Chris@208
|
295 // have no vertical scroll wheel, we should remove the panner as
|
Chris@208
|
296 // well. Ideally any layer that implements display extents should
|
Chris@208
|
297 // implement vertical zoom steps as well, but they don't all at
|
Chris@208
|
298 // the moment.
|
Chris@208
|
299
|
Chris@208
|
300 Layer *layer = 0;
|
Chris@208
|
301 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@208
|
302 int discard;
|
Chris@208
|
303 if (layer && layer->getVerticalZoomSteps(discard) == 0) {
|
Chris@208
|
304 m_vpan->hide();
|
Chris@208
|
305 return;
|
Chris@208
|
306 }
|
Chris@208
|
307
|
Chris@174
|
308 float vmin, vmax, dmin, dmax;
|
Chris@174
|
309 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax) && vmax != vmin) {
|
Chris@174
|
310 float y0 = (dmin - vmin) / (vmax - vmin);
|
Chris@174
|
311 float y1 = (dmax - vmin) / (vmax - vmin);
|
Chris@174
|
312 m_vpan->blockSignals(true);
|
Chris@174
|
313 m_vpan->setRectExtents(0, 1.0 - y1, 1, y1 - y0);
|
Chris@174
|
314 m_vpan->blockSignals(false);
|
Chris@174
|
315 m_vpan->show();
|
Chris@174
|
316 } else {
|
Chris@174
|
317 m_vpan->hide();
|
Chris@174
|
318 }
|
Chris@174
|
319 }
|
Chris@174
|
320
|
Chris@127
|
321 bool
|
Chris@127
|
322 Pane::shouldIlluminateLocalFeatures(const Layer *layer, QPoint &pos) const
|
Chris@127
|
323 {
|
Chris@127
|
324 QPoint discard;
|
Chris@127
|
325 bool b0, b1;
|
Chris@127
|
326
|
Chris@262
|
327 if (m_manager && m_manager->getToolMode() == ViewManager::MeasureMode) {
|
Chris@262
|
328 return false;
|
Chris@262
|
329 }
|
Chris@262
|
330
|
Chris@326
|
331 if (m_manager && !m_manager->shouldIlluminateLocalFeatures()) {
|
Chris@326
|
332 return false;
|
Chris@326
|
333 }
|
Chris@326
|
334
|
Chris@127
|
335 if (layer == getSelectedLayer() &&
|
Chris@127
|
336 !shouldIlluminateLocalSelection(discard, b0, b1)) {
|
Chris@127
|
337
|
Chris@127
|
338 pos = m_identifyPoint;
|
Chris@127
|
339 return m_identifyFeatures;
|
Chris@127
|
340 }
|
Chris@127
|
341
|
Chris@127
|
342 return false;
|
Chris@127
|
343 }
|
Chris@127
|
344
|
Chris@127
|
345 bool
|
Chris@127
|
346 Pane::shouldIlluminateLocalSelection(QPoint &pos,
|
Chris@127
|
347 bool &closeToLeft,
|
Chris@127
|
348 bool &closeToRight) const
|
Chris@127
|
349 {
|
Chris@127
|
350 if (m_identifyFeatures &&
|
Chris@127
|
351 m_manager &&
|
Chris@127
|
352 m_manager->getToolMode() == ViewManager::EditMode &&
|
Chris@127
|
353 !m_manager->getSelections().empty() &&
|
Chris@127
|
354 !selectionIsBeingEdited()) {
|
Chris@127
|
355
|
Chris@127
|
356 Selection s(getSelectionAt(m_identifyPoint.x(),
|
Chris@127
|
357 closeToLeft, closeToRight));
|
Chris@127
|
358
|
Chris@127
|
359 if (!s.isEmpty()) {
|
Chris@127
|
360 if (getSelectedLayer() && getSelectedLayer()->isLayerEditable()) {
|
Chris@127
|
361
|
Chris@127
|
362 pos = m_identifyPoint;
|
Chris@127
|
363 return true;
|
Chris@127
|
364 }
|
Chris@127
|
365 }
|
Chris@127
|
366 }
|
Chris@127
|
367
|
Chris@127
|
368 return false;
|
Chris@127
|
369 }
|
Chris@127
|
370
|
Chris@127
|
371 bool
|
Chris@127
|
372 Pane::selectionIsBeingEdited() const
|
Chris@127
|
373 {
|
Chris@127
|
374 if (!m_editingSelection.isEmpty()) {
|
Chris@127
|
375 if (m_mousePos != m_clickPos &&
|
Chris@127
|
376 getFrameForX(m_mousePos.x()) != getFrameForX(m_clickPos.x())) {
|
Chris@127
|
377 return true;
|
Chris@127
|
378 }
|
Chris@127
|
379 }
|
Chris@127
|
380 return false;
|
Chris@127
|
381 }
|
Chris@127
|
382
|
Chris@127
|
383 void
|
Chris@127
|
384 Pane::setCentreLineVisible(bool visible)
|
Chris@127
|
385 {
|
Chris@127
|
386 m_centreLineVisible = visible;
|
Chris@127
|
387 update();
|
Chris@127
|
388 }
|
Chris@127
|
389
|
Chris@127
|
390 void
|
Chris@127
|
391 Pane::paintEvent(QPaintEvent *e)
|
Chris@127
|
392 {
|
Chris@127
|
393 // Profiler profiler("Pane::paintEvent", true);
|
Chris@127
|
394
|
Chris@127
|
395 QPainter paint;
|
Chris@127
|
396
|
Chris@127
|
397 QRect r(rect());
|
Chris@261
|
398 if (e) r = e->rect();
|
Chris@127
|
399
|
Chris@127
|
400 View::paintEvent(e);
|
Chris@127
|
401
|
Chris@127
|
402 paint.begin(this);
|
Chris@339
|
403 setPaintFont(paint);
|
Chris@338
|
404
|
Chris@261
|
405 if (e) paint.setClipRect(r);
|
Chris@127
|
406
|
Chris@259
|
407 ViewManager::ToolMode toolMode = m_manager->getToolMode();
|
Chris@259
|
408
|
Chris@127
|
409 if (m_manager &&
|
Chris@290
|
410 // !m_manager->isPlaying() &&
|
Chris@290
|
411 m_mouseInWidget &&
|
Chris@259
|
412 toolMode == ViewManager::MeasureMode) {
|
Chris@127
|
413
|
Chris@127
|
414 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
|
Chris@127
|
415 --vi;
|
Chris@127
|
416
|
Chris@127
|
417 std::vector<QRect> crosshairExtents;
|
Chris@127
|
418
|
Chris@127
|
419 if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint,
|
Chris@127
|
420 crosshairExtents)) {
|
Chris@127
|
421 (*vi)->paintCrosshairs(this, paint, m_identifyPoint);
|
Chris@127
|
422 break;
|
Chris@127
|
423 } else if ((*vi)->isLayerOpaque()) {
|
Chris@127
|
424 break;
|
Chris@127
|
425 }
|
Chris@127
|
426 }
|
Chris@127
|
427 }
|
Chris@127
|
428
|
Chris@268
|
429 Layer *topLayer = getTopLayer();
|
Chris@277
|
430 bool haveSomeTimeXAxis = false;
|
Chris@268
|
431
|
Chris@258
|
432 const Model *waveformModel = 0; // just for reporting purposes
|
Chris@326
|
433 const Model *workModel = 0;
|
Chris@326
|
434
|
Chris@127
|
435 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
|
Chris@127
|
436 --vi;
|
Chris@277
|
437 if (!haveSomeTimeXAxis && (*vi)->hasTimeXAxis()) {
|
Chris@277
|
438 haveSomeTimeXAxis = true;
|
Chris@277
|
439 }
|
Chris@127
|
440 if (dynamic_cast<WaveformLayer *>(*vi)) {
|
Chris@127
|
441 waveformModel = (*vi)->getModel();
|
Chris@326
|
442 workModel = waveformModel;
|
Chris@326
|
443 } else {
|
Chris@326
|
444 Model *m = (*vi)->getModel();
|
Chris@326
|
445 if (dynamic_cast<WaveFileModel *>(m)) {
|
Chris@326
|
446 workModel = m;
|
Chris@326
|
447 } else if (m && dynamic_cast<WaveFileModel *>(m->getSourceModel())) {
|
Chris@326
|
448 workModel = m->getSourceModel();
|
Chris@326
|
449 }
|
Chris@127
|
450 }
|
Chris@326
|
451
|
Chris@326
|
452 if (waveformModel && workModel && haveSomeTimeXAxis) break;
|
Chris@258
|
453 }
|
Chris@127
|
454
|
Chris@261
|
455 m_scaleWidth = 0;
|
Chris@261
|
456
|
Chris@261
|
457 if (m_manager && m_manager->shouldShowVerticalScale() && topLayer) {
|
Chris@261
|
458 drawVerticalScale(r, topLayer, paint);
|
Chris@261
|
459 }
|
Chris@261
|
460
|
Chris@326
|
461 if (m_identifyFeatures &&
|
Chris@326
|
462 m_manager && m_manager->shouldIlluminateLocalFeatures() &&
|
Chris@326
|
463 topLayer) {
|
Chris@261
|
464 drawFeatureDescription(topLayer, paint);
|
Chris@261
|
465 }
|
Chris@261
|
466
|
Chris@261
|
467 int sampleRate = getModelsSampleRate();
|
Chris@261
|
468 paint.setBrush(Qt::NoBrush);
|
Chris@261
|
469
|
Chris@261
|
470 if (m_centreLineVisible &&
|
Chris@261
|
471 m_manager &&
|
Chris@261
|
472 m_manager->shouldShowCentreLine()) {
|
Chris@277
|
473 drawCentreLine(sampleRate, paint, !haveSomeTimeXAxis);
|
Chris@261
|
474 }
|
Chris@261
|
475
|
Chris@261
|
476 paint.setPen(QColor(50, 50, 50));
|
Chris@261
|
477
|
Chris@261
|
478 if (waveformModel &&
|
Chris@261
|
479 m_manager &&
|
Chris@261
|
480 m_manager->shouldShowDuration()) {
|
Chris@261
|
481 drawDurationAndRate(r, waveformModel, sampleRate, paint);
|
Chris@261
|
482 }
|
Chris@261
|
483
|
Chris@326
|
484 bool haveWorkTitle = false;
|
Chris@326
|
485
|
Chris@326
|
486 if (workModel &&
|
Chris@326
|
487 m_manager &&
|
Chris@326
|
488 m_manager->shouldShowWorkTitle()) {
|
Chris@326
|
489 drawWorkTitle(r, paint, workModel);
|
Chris@326
|
490 haveWorkTitle = true;
|
Chris@326
|
491 }
|
Chris@326
|
492
|
Chris@326
|
493 if (workModel &&
|
Chris@320
|
494 m_manager &&
|
Chris@320
|
495 m_manager->getAlignMode()) {
|
Chris@326
|
496 drawAlignmentStatus(r, paint, workModel, haveWorkTitle);
|
Chris@320
|
497 }
|
Chris@320
|
498
|
Chris@261
|
499 if (m_manager &&
|
Chris@261
|
500 m_manager->shouldShowLayerNames()) {
|
Chris@261
|
501 drawLayerNames(r, paint);
|
Chris@261
|
502 }
|
Chris@261
|
503
|
Chris@262
|
504 if (m_shiftPressed && m_clickedInRange &&
|
Chris@283
|
505 (toolMode == ViewManager::NavigateMode || m_navigating)) {
|
Chris@261
|
506
|
Chris@261
|
507 //!!! be nice if this looked a bit more in keeping with the
|
Chris@261
|
508 //selection block
|
Chris@262
|
509
|
Chris@262
|
510 paint.setPen(Qt::blue);
|
Chris@262
|
511 //!!! shouldn't use clickPos -- needs to use a clicked frame
|
Chris@262
|
512 paint.drawRect(m_clickPos.x(), m_clickPos.y(),
|
Chris@262
|
513 m_mousePos.x() - m_clickPos.x(),
|
Chris@262
|
514 m_mousePos.y() - m_clickPos.y());
|
Chris@261
|
515
|
Chris@262
|
516 }
|
Chris@261
|
517
|
Chris@266
|
518 if (toolMode == ViewManager::MeasureMode && topLayer) {
|
Chris@272
|
519 bool showFocus = false;
|
Chris@272
|
520 if (!m_manager || !m_manager->isPlaying()) showFocus = true;
|
Chris@272
|
521 topLayer->paintMeasurementRects(this, paint, showFocus, m_identifyPoint);
|
Chris@261
|
522 }
|
Chris@261
|
523
|
Chris@261
|
524 if (selectionIsBeingEdited()) {
|
Chris@261
|
525 drawEditingSelection(paint);
|
Chris@261
|
526 }
|
Chris@261
|
527
|
Chris@261
|
528 paint.end();
|
Chris@261
|
529 }
|
Chris@261
|
530
|
Chris@276
|
531 size_t
|
Chris@276
|
532 Pane::getVerticalScaleWidth() const
|
Chris@276
|
533 {
|
Chris@276
|
534 if (m_scaleWidth > 0) return m_scaleWidth;
|
Chris@276
|
535 else return 0;
|
Chris@276
|
536 }
|
Chris@276
|
537
|
Chris@261
|
538 void
|
Chris@261
|
539 Pane::drawVerticalScale(QRect r, Layer *topLayer, QPainter &paint)
|
Chris@261
|
540 {
|
Chris@258
|
541 Layer *scaleLayer = 0;
|
Chris@258
|
542
|
Chris@261
|
543 float min, max;
|
Chris@261
|
544 bool log;
|
Chris@261
|
545 QString unit;
|
Chris@258
|
546
|
Chris@261
|
547 // If the top layer has no scale and reports no display
|
Chris@261
|
548 // extents, but does report a unit, then the scale should be
|
Chris@261
|
549 // drawn from any underlying layer with a scale and that unit.
|
Chris@261
|
550 // If the top layer has no scale and no value extents at all,
|
Chris@261
|
551 // then the scale should be drawn from any underlying layer
|
Chris@261
|
552 // with a scale regardless of unit.
|
Chris@258
|
553
|
Chris@261
|
554 int sw = topLayer->getVerticalScaleWidth(this, paint);
|
Chris@258
|
555
|
Chris@261
|
556 if (sw > 0) {
|
Chris@261
|
557 scaleLayer = topLayer;
|
Chris@261
|
558 m_scaleWidth = sw;
|
Chris@258
|
559
|
Chris@261
|
560 } else {
|
Chris@258
|
561
|
Chris@261
|
562 bool hasDisplayExtents = topLayer->getDisplayExtents(min, max);
|
Chris@261
|
563 bool hasValueExtents = topLayer->getValueExtents(min, max, log, unit);
|
Chris@261
|
564
|
Chris@261
|
565 if (!hasDisplayExtents) {
|
Chris@258
|
566
|
Chris@261
|
567 if (!hasValueExtents) {
|
Chris@258
|
568
|
Chris@261
|
569 for (LayerList::iterator vi = m_layers.end();
|
Chris@261
|
570 vi != m_layers.begin(); ) {
|
Chris@261
|
571
|
Chris@261
|
572 --vi;
|
Chris@261
|
573
|
Chris@261
|
574 if ((*vi) == topLayer) continue;
|
Chris@261
|
575
|
Chris@261
|
576 sw = (*vi)->getVerticalScaleWidth(this, paint);
|
Chris@261
|
577
|
Chris@261
|
578 if (sw > 0) {
|
Chris@261
|
579 scaleLayer = *vi;
|
Chris@261
|
580 m_scaleWidth = sw;
|
Chris@261
|
581 break;
|
Chris@261
|
582 }
|
Chris@261
|
583 }
|
Chris@261
|
584 } else if (unit != "") { // && hasValueExtents && !hasDisplayExtents
|
Chris@258
|
585
|
Chris@261
|
586 QString requireUnit = unit;
|
Chris@261
|
587
|
Chris@261
|
588 for (LayerList::iterator vi = m_layers.end();
|
Chris@261
|
589 vi != m_layers.begin(); ) {
|
Chris@258
|
590
|
Chris@261
|
591 --vi;
|
Chris@258
|
592
|
Chris@261
|
593 if ((*vi) == topLayer) continue;
|
Chris@258
|
594
|
Chris@261
|
595 if ((*vi)->getDisplayExtents(min, max)) {
|
Chris@261
|
596
|
Chris@261
|
597 // search no further than this: if the
|
Chris@261
|
598 // scale from this layer isn't suitable,
|
Chris@261
|
599 // we'll have to draw no scale (else we'd
|
Chris@261
|
600 // risk ending up with the wrong scale)
|
Chris@261
|
601
|
Chris@261
|
602 if ((*vi)->getValueExtents(min, max, log, unit) &&
|
Chris@261
|
603 unit == requireUnit) {
|
Chris@261
|
604
|
Chris@261
|
605 sw = (*vi)->getVerticalScaleWidth(this, paint);
|
Chris@261
|
606 if (sw > 0) {
|
Chris@261
|
607 scaleLayer = *vi;
|
Chris@261
|
608 m_scaleWidth = sw;
|
Chris@261
|
609 }
|
Chris@258
|
610 }
|
Chris@261
|
611 break;
|
Chris@258
|
612 }
|
Chris@258
|
613 }
|
Chris@258
|
614 }
|
Chris@127
|
615 }
|
Chris@258
|
616 }
|
Chris@127
|
617
|
Chris@258
|
618 if (!scaleLayer) m_scaleWidth = 0;
|
Chris@258
|
619
|
Chris@258
|
620 if (m_scaleWidth > 0 && r.left() < m_scaleWidth) {
|
Chris@127
|
621
|
Chris@127
|
622 // Profiler profiler("Pane::paintEvent - painting vertical scale", true);
|
Chris@127
|
623
|
Chris@127
|
624 // std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl;
|
Chris@258
|
625 paint.save();
|
Chris@258
|
626
|
Chris@287
|
627 paint.setPen(getForeground());
|
Chris@287
|
628 paint.setBrush(getBackground());
|
Chris@258
|
629 paint.drawRect(0, -1, m_scaleWidth, height()+1);
|
Chris@258
|
630
|
Chris@258
|
631 paint.setBrush(Qt::NoBrush);
|
Chris@258
|
632 scaleLayer->paintVerticalScale
|
Chris@258
|
633 (this, paint, QRect(0, 0, m_scaleWidth, height()));
|
Chris@258
|
634
|
Chris@258
|
635 paint.restore();
|
Chris@258
|
636 }
|
Chris@261
|
637 }
|
Chris@261
|
638
|
Chris@261
|
639 void
|
Chris@261
|
640 Pane::drawFeatureDescription(Layer *topLayer, QPainter &paint)
|
Chris@261
|
641 {
|
Chris@261
|
642 QPoint pos = m_identifyPoint;
|
Chris@261
|
643 QString desc = topLayer->getFeatureDescription(this, pos);
|
Chris@261
|
644
|
Chris@261
|
645 if (desc != "") {
|
Chris@261
|
646
|
Chris@261
|
647 paint.save();
|
Chris@261
|
648
|
Chris@261
|
649 int tabStop =
|
Chris@261
|
650 paint.fontMetrics().width(tr("Some lengthy prefix:"));
|
Chris@261
|
651
|
Chris@261
|
652 QRect boundingRect =
|
Chris@261
|
653 paint.fontMetrics().boundingRect
|
Chris@261
|
654 (rect(),
|
Chris@261
|
655 Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs,
|
Chris@261
|
656 desc, tabStop);
|
Chris@261
|
657
|
Chris@261
|
658 if (hasLightBackground()) {
|
Chris@261
|
659 paint.setPen(Qt::NoPen);
|
Chris@261
|
660 paint.setBrush(QColor(250, 250, 250, 200));
|
Chris@261
|
661 } else {
|
Chris@261
|
662 paint.setPen(Qt::NoPen);
|
Chris@261
|
663 paint.setBrush(QColor(50, 50, 50, 200));
|
Chris@261
|
664 }
|
Chris@261
|
665
|
Chris@261
|
666 int extra = paint.fontMetrics().descent();
|
Chris@261
|
667 paint.drawRect(width() - boundingRect.width() - 10 - extra,
|
Chris@261
|
668 10 - extra,
|
Chris@261
|
669 boundingRect.width() + 2 * extra,
|
Chris@261
|
670 boundingRect.height() + extra);
|
Chris@261
|
671
|
Chris@261
|
672 if (hasLightBackground()) {
|
Chris@261
|
673 paint.setPen(QColor(150, 20, 0));
|
Chris@261
|
674 } else {
|
Chris@261
|
675 paint.setPen(QColor(255, 150, 100));
|
Chris@261
|
676 }
|
Chris@261
|
677
|
Chris@261
|
678 QTextOption option;
|
Chris@261
|
679 option.setWrapMode(QTextOption::NoWrap);
|
Chris@261
|
680 option.setAlignment(Qt::AlignRight | Qt::AlignTop);
|
Chris@261
|
681 option.setTabStop(tabStop);
|
Chris@261
|
682 paint.drawText(QRectF(width() - boundingRect.width() - 10, 10,
|
Chris@261
|
683 boundingRect.width(),
|
Chris@261
|
684 boundingRect.height()),
|
Chris@261
|
685 desc,
|
Chris@261
|
686 option);
|
Chris@261
|
687
|
Chris@261
|
688 paint.restore();
|
Chris@261
|
689 }
|
Chris@261
|
690 }
|
Chris@258
|
691
|
Chris@261
|
692 void
|
Chris@277
|
693 Pane::drawCentreLine(int sampleRate, QPainter &paint, bool omitLine)
|
Chris@261
|
694 {
|
Chris@261
|
695 int fontHeight = paint.fontMetrics().height();
|
Chris@261
|
696 int fontAscent = paint.fontMetrics().ascent();
|
Chris@261
|
697
|
Chris@261
|
698 QColor c = QColor(0, 0, 0);
|
Chris@261
|
699 if (!hasLightBackground()) {
|
Chris@261
|
700 c = QColor(240, 240, 240);
|
Chris@261
|
701 }
|
Chris@277
|
702
|
Chris@261
|
703 paint.setPen(c);
|
Chris@274
|
704 int x = width() / 2;
|
Chris@277
|
705
|
Chris@277
|
706 if (!omitLine) {
|
Chris@277
|
707 paint.drawLine(x, 0, x, height() - 1);
|
Chris@277
|
708 paint.drawLine(x-1, 1, x+1, 1);
|
Chris@277
|
709 paint.drawLine(x-2, 0, x+2, 0);
|
Chris@277
|
710 paint.drawLine(x-1, height() - 2, x+1, height() - 2);
|
Chris@277
|
711 paint.drawLine(x-2, height() - 1, x+2, height() - 1);
|
Chris@277
|
712 }
|
Chris@261
|
713
|
Chris@261
|
714 paint.setPen(QColor(50, 50, 50));
|
Chris@261
|
715
|
Chris@261
|
716 int y = height() - fontHeight + fontAscent - 6;
|
Chris@261
|
717
|
Chris@261
|
718 LayerList::iterator vi = m_layers.end();
|
Chris@261
|
719
|
Chris@261
|
720 if (vi != m_layers.begin()) {
|
Chris@261
|
721
|
Chris@261
|
722 switch ((*--vi)->getPreferredFrameCountPosition()) {
|
Chris@258
|
723
|
Chris@261
|
724 case Layer::PositionTop:
|
Chris@261
|
725 y = fontAscent + 6;
|
Chris@261
|
726 break;
|
Chris@258
|
727
|
Chris@261
|
728 case Layer::PositionMiddle:
|
Chris@261
|
729 y = (height() - fontHeight) / 2
|
Chris@261
|
730 + fontAscent;
|
Chris@261
|
731 break;
|
Chris@127
|
732
|
Chris@261
|
733 case Layer::PositionBottom:
|
Chris@261
|
734 // y already set correctly
|
Chris@261
|
735 break;
|
Chris@127
|
736 }
|
Chris@127
|
737 }
|
Chris@127
|
738
|
Chris@261
|
739 if (m_manager && m_manager->shouldShowFrameCount()) {
|
Chris@261
|
740
|
Chris@261
|
741 if (sampleRate) {
|
Chris@127
|
742
|
Chris@261
|
743 QString text(QString::fromStdString
|
Chris@261
|
744 (RealTime::frame2RealTime
|
Chris@261
|
745 (m_centreFrame, sampleRate).toText(true)));
|
Chris@127
|
746
|
Chris@261
|
747 int tw = paint.fontMetrics().width(text);
|
Chris@261
|
748 int x = width()/2 - 4 - tw;
|
Chris@127
|
749
|
Chris@127
|
750 drawVisibleText(paint, x, y, text, OutlinedText);
|
Chris@127
|
751 }
|
Chris@261
|
752
|
Chris@261
|
753 QString text = QString("%1").arg(m_centreFrame);
|
Chris@261
|
754
|
Chris@261
|
755 int x = width()/2 + 4;
|
Chris@261
|
756
|
Chris@261
|
757 drawVisibleText(paint, x, y, text, OutlinedText);
|
Chris@261
|
758 }
|
Chris@261
|
759 }
|
Chris@127
|
760
|
Chris@261
|
761 void
|
Chris@326
|
762 Pane::drawAlignmentStatus(QRect r, QPainter &paint, const Model *model,
|
Chris@326
|
763 bool down)
|
Chris@320
|
764 {
|
Chris@320
|
765 const Model *reference = model->getAlignmentReference();
|
Chris@320
|
766 /*
|
Chris@320
|
767 if (!reference) {
|
Chris@320
|
768 std::cerr << "Pane[" << this << "]::drawAlignmentStatus: No reference" << std::endl;
|
Chris@320
|
769 } else if (reference == model) {
|
Chris@320
|
770 std::cerr << "Pane[" << this << "]::drawAlignmentStatus: This is the reference model" << std::endl;
|
Chris@320
|
771 } else {
|
Chris@320
|
772 std::cerr << "Pane[" << this << "]::drawAlignmentStatus: This is not the reference" << std::endl;
|
Chris@320
|
773 }
|
Chris@320
|
774 */
|
Chris@320
|
775 QString text;
|
Chris@320
|
776 int completion = 100;
|
Chris@320
|
777
|
Chris@320
|
778 if (reference == model) {
|
Chris@320
|
779 text = tr("Reference");
|
Chris@320
|
780 } else if (!reference) {
|
Chris@320
|
781 text = tr("Unaligned");
|
Chris@320
|
782 } else {
|
Chris@320
|
783 completion = model->getAlignmentCompletion();
|
Chris@320
|
784 if (completion == 0) {
|
Chris@320
|
785 text = tr("Unaligned");
|
Chris@320
|
786 } else if (completion < 100) {
|
Chris@320
|
787 text = tr("Aligning: %1%").arg(completion);
|
Chris@320
|
788 } else {
|
Chris@320
|
789 text = tr("Aligned");
|
Chris@320
|
790 }
|
Chris@320
|
791 }
|
Chris@320
|
792
|
Chris@320
|
793 paint.save();
|
Chris@320
|
794 QFont font(paint.font());
|
Chris@320
|
795 font.setBold(true);
|
Chris@320
|
796 paint.setFont(font);
|
Chris@326
|
797 if (completion < 100) paint.setBrush(Qt::red);
|
Chris@326
|
798
|
Chris@326
|
799 int y = 5;
|
Chris@326
|
800 if (down) y += paint.fontMetrics().height();
|
Chris@326
|
801 int w = paint.fontMetrics().width(text);
|
Chris@326
|
802 int h = paint.fontMetrics().height();
|
Chris@326
|
803 if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) {
|
Chris@326
|
804 paint.restore();
|
Chris@326
|
805 return;
|
Chris@326
|
806 }
|
Chris@320
|
807
|
Chris@320
|
808 drawVisibleText(paint, m_scaleWidth + 5,
|
Chris@326
|
809 paint.fontMetrics().ascent() + y, text, OutlinedText);
|
Chris@320
|
810
|
Chris@320
|
811 paint.restore();
|
Chris@320
|
812 }
|
Chris@320
|
813
|
Chris@320
|
814 void
|
Chris@320
|
815 Pane::modelAlignmentCompletionChanged()
|
Chris@320
|
816 {
|
Chris@320
|
817 View::modelAlignmentCompletionChanged();
|
Chris@320
|
818 update(QRect(0, 0, 300, 100));
|
Chris@320
|
819 }
|
Chris@320
|
820
|
Chris@320
|
821 void
|
Chris@326
|
822 Pane::drawWorkTitle(QRect r, QPainter &paint, const Model *model)
|
Chris@326
|
823 {
|
Chris@326
|
824 QString title = model->getTitle();
|
Chris@326
|
825 QString maker = model->getMaker();
|
Chris@327
|
826 //std::cerr << "Pane::drawWorkTitle: title=\"" << title.toStdString()
|
Chris@327
|
827 //<< "\", maker=\"" << maker.toStdString() << "\"" << std::endl;
|
Chris@326
|
828 if (title == "") return;
|
Chris@326
|
829
|
Chris@326
|
830 QString text = title;
|
Chris@326
|
831 if (maker != "") {
|
Chris@326
|
832 text = tr("%1 - %2").arg(title).arg(maker);
|
Chris@326
|
833 }
|
Chris@326
|
834
|
Chris@326
|
835 paint.save();
|
Chris@326
|
836 QFont font(paint.font());
|
Chris@326
|
837 font.setItalic(true);
|
Chris@326
|
838 paint.setFont(font);
|
Chris@326
|
839
|
Chris@326
|
840 int y = 5;
|
Chris@326
|
841 int w = paint.fontMetrics().width(text);
|
Chris@326
|
842 int h = paint.fontMetrics().height();
|
Chris@326
|
843 if (r.top() > h + y || r.left() > w + m_scaleWidth + 5) {
|
Chris@326
|
844 paint.restore();
|
Chris@326
|
845 return;
|
Chris@326
|
846 }
|
Chris@326
|
847
|
Chris@326
|
848 drawVisibleText(paint, m_scaleWidth + 5,
|
Chris@326
|
849 paint.fontMetrics().ascent() + y, text, OutlinedText);
|
Chris@326
|
850
|
Chris@326
|
851 paint.restore();
|
Chris@326
|
852 }
|
Chris@326
|
853
|
Chris@326
|
854 void
|
Chris@261
|
855 Pane::drawLayerNames(QRect r, QPainter &paint)
|
Chris@261
|
856 {
|
Chris@261
|
857 int fontHeight = paint.fontMetrics().height();
|
Chris@261
|
858 int fontAscent = paint.fontMetrics().ascent();
|
Chris@127
|
859
|
Chris@300
|
860 int lly = height() - 6;
|
Chris@300
|
861 if (m_manager->getZoomWheelsEnabled()) {
|
Chris@300
|
862 lly -= 20;
|
Chris@300
|
863 }
|
Chris@300
|
864
|
Chris@300
|
865 if (r.y() + r.height() < lly - int(m_layers.size()) * fontHeight) {
|
Chris@261
|
866 return;
|
Chris@127
|
867 }
|
Chris@127
|
868
|
Chris@294
|
869 QStringList texts;
|
Chris@299
|
870 std::vector<QPixmap> pixmaps;
|
Chris@294
|
871 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
|
Chris@294
|
872 texts.push_back((*i)->getLayerPresentationName());
|
Chris@299
|
873 // std::cerr << "Pane " << this << ": Layer presentation name for " << *i << ": "
|
Chris@299
|
874 // << texts[texts.size()-1].toStdString() << std::endl;
|
Chris@299
|
875 pixmaps.push_back((*i)->getLayerPresentationPixmap
|
Chris@299
|
876 (QSize(fontAscent, fontAscent)));
|
Chris@294
|
877 }
|
Chris@127
|
878
|
Chris@294
|
879 int maxTextWidth = width() / 3;
|
Chris@294
|
880 texts = TextAbbrev::abbreviate(texts, paint.fontMetrics(), maxTextWidth);
|
Chris@294
|
881
|
Chris@261
|
882 int llx = width() - maxTextWidth - 5;
|
Chris@261
|
883 if (m_manager->getZoomWheelsEnabled()) {
|
Chris@261
|
884 llx -= 36;
|
Chris@261
|
885 }
|
Chris@261
|
886
|
Chris@300
|
887 if (r.x() + r.width() >= llx - fontAscent - 3) {
|
Chris@261
|
888
|
Chris@261
|
889 for (size_t i = 0; i < texts.size(); ++i) {
|
Chris@299
|
890
|
Chris@299
|
891 // std::cerr << "Pane "<< this << ": text " << i << ": " << texts[i].toStdString() << std::endl;
|
Chris@261
|
892
|
Chris@261
|
893 if (i + 1 == texts.size()) {
|
Chris@287
|
894 paint.setPen(getForeground());
|
Chris@261
|
895 }
|
Chris@261
|
896
|
Chris@261
|
897 drawVisibleText(paint, llx,
|
Chris@261
|
898 lly - fontHeight + fontAscent,
|
Chris@261
|
899 texts[i], OutlinedText);
|
Chris@299
|
900
|
Chris@299
|
901 if (!pixmaps[i].isNull()) {
|
Chris@299
|
902 paint.drawPixmap(llx - fontAscent - 3,
|
Chris@299
|
903 lly - fontHeight + (fontHeight-fontAscent)/2,
|
Chris@299
|
904 pixmaps[i]);
|
Chris@299
|
905 }
|
Chris@261
|
906
|
Chris@261
|
907 lly -= fontHeight;
|
Chris@261
|
908 }
|
Chris@261
|
909 }
|
Chris@261
|
910 }
|
Chris@127
|
911
|
Chris@261
|
912 void
|
Chris@261
|
913 Pane::drawEditingSelection(QPainter &paint)
|
Chris@261
|
914 {
|
Chris@261
|
915 int offset = m_mousePos.x() - m_clickPos.x();
|
Chris@261
|
916 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset;
|
Chris@261
|
917 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset;
|
Chris@261
|
918
|
Chris@261
|
919 if (m_editingSelectionEdge < 0) {
|
Chris@261
|
920 p1 = getXForFrame(m_editingSelection.getEndFrame());
|
Chris@261
|
921 } else if (m_editingSelectionEdge > 0) {
|
Chris@261
|
922 p0 = getXForFrame(m_editingSelection.getStartFrame());
|
Chris@127
|
923 }
|
Chris@127
|
924
|
Chris@261
|
925 paint.save();
|
Chris@287
|
926 paint.setPen(QPen(getForeground(), 2));
|
Chris@261
|
927
|
Chris@261
|
928 //!!! duplicating display policy with View::drawSelections
|
Chris@261
|
929
|
Chris@261
|
930 if (m_editingSelectionEdge < 0) {
|
Chris@261
|
931 paint.drawLine(p0, 1, p1, 1);
|
Chris@261
|
932 paint.drawLine(p0, 0, p0, height());
|
Chris@261
|
933 paint.drawLine(p0, height() - 1, p1, height() - 1);
|
Chris@261
|
934 } else if (m_editingSelectionEdge > 0) {
|
Chris@261
|
935 paint.drawLine(p0, 1, p1, 1);
|
Chris@261
|
936 paint.drawLine(p1, 0, p1, height());
|
Chris@261
|
937 paint.drawLine(p0, height() - 1, p1, height() - 1);
|
Chris@261
|
938 } else {
|
Chris@261
|
939 paint.setBrush(Qt::NoBrush);
|
Chris@261
|
940 paint.drawRect(p0, 1, p1 - p0, height() - 2);
|
Chris@261
|
941 }
|
Chris@261
|
942 paint.restore();
|
Chris@261
|
943 }
|
Chris@127
|
944
|
Chris@261
|
945 void
|
Chris@261
|
946 Pane::drawDurationAndRate(QRect r, const Model *waveformModel,
|
Chris@261
|
947 int sampleRate, QPainter &paint)
|
Chris@261
|
948 {
|
Chris@261
|
949 int fontHeight = paint.fontMetrics().height();
|
Chris@261
|
950 int fontAscent = paint.fontMetrics().ascent();
|
Chris@127
|
951
|
Chris@261
|
952 if (r.y() + r.height() < height() - fontHeight - 6) return;
|
Chris@127
|
953
|
Chris@261
|
954 size_t modelRate = waveformModel->getSampleRate();
|
Chris@301
|
955 size_t nativeRate = waveformModel->getNativeRate();
|
Chris@261
|
956 size_t playbackRate = m_manager->getPlaybackSampleRate();
|
Chris@261
|
957 size_t outputRate = m_manager->getOutputSampleRate();
|
Chris@261
|
958
|
Chris@261
|
959 QString srNote = "";
|
Chris@127
|
960
|
Chris@301
|
961 // Show (R) for waveform models that have been resampled or will
|
Chris@301
|
962 // be resampled on playback, and (X) for waveform models that will
|
Chris@301
|
963 // be played at the wrong rate because their rate differs from the
|
Chris@261
|
964 // current playback rate (which is not necessarily that of the
|
Chris@261
|
965 // main model).
|
Chris@127
|
966
|
Chris@261
|
967 if (playbackRate != 0) {
|
Chris@261
|
968 if (modelRate == playbackRate) {
|
Chris@301
|
969 if (modelRate != outputRate || modelRate != nativeRate) {
|
Chris@301
|
970 srNote = " " + tr("(R)");
|
Chris@301
|
971 }
|
Chris@261
|
972 } else {
|
Chris@261
|
973 srNote = " " + tr("(X)");
|
Chris@261
|
974 }
|
Chris@127
|
975 }
|
Chris@127
|
976
|
Chris@261
|
977 QString desc = tr("%1 / %2Hz%3")
|
Chris@261
|
978 .arg(RealTime::frame2RealTime(waveformModel->getEndFrame(),
|
Chris@261
|
979 sampleRate)
|
Chris@261
|
980 .toText(false).c_str())
|
Chris@301
|
981 .arg(nativeRate)
|
Chris@261
|
982 .arg(srNote);
|
Chris@261
|
983
|
Chris@384
|
984 int x = m_scaleWidth + 5;
|
Chris@384
|
985 int pbw = getProgressBarWidth();
|
Chris@384
|
986 if (x < pbw + 5) x = pbw + 5;
|
Chris@384
|
987
|
Chris@384
|
988 if (r.x() < x + paint.fontMetrics().width(desc)) {
|
Chris@384
|
989 drawVisibleText(paint, x,
|
Chris@261
|
990 height() - fontHeight + fontAscent - 6,
|
Chris@261
|
991 desc, OutlinedText);
|
Chris@261
|
992 }
|
Chris@127
|
993 }
|
Chris@127
|
994
|
Chris@227
|
995 bool
|
Chris@229
|
996 Pane::render(QPainter &paint, int xorigin, size_t f0, size_t f1)
|
Chris@227
|
997 {
|
Chris@229
|
998 if (!View::render(paint, xorigin + m_scaleWidth, f0, f1)) {
|
Chris@227
|
999 return false;
|
Chris@227
|
1000 }
|
Chris@227
|
1001
|
Chris@227
|
1002 if (m_scaleWidth > 0) {
|
Chris@227
|
1003
|
Chris@227
|
1004 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
|
Chris@227
|
1005 --vi;
|
Chris@227
|
1006
|
Chris@227
|
1007 paint.save();
|
Chris@227
|
1008
|
Chris@287
|
1009 paint.setPen(getForeground());
|
Chris@287
|
1010 paint.setBrush(getBackground());
|
Chris@229
|
1011 paint.drawRect(xorigin, -1, m_scaleWidth, height()+1);
|
Chris@227
|
1012
|
Chris@227
|
1013 paint.setBrush(Qt::NoBrush);
|
Chris@227
|
1014 (*vi)->paintVerticalScale
|
Chris@229
|
1015 (this, paint, QRect(xorigin, 0, m_scaleWidth, height()));
|
Chris@227
|
1016
|
Chris@227
|
1017 paint.restore();
|
Chris@227
|
1018 break;
|
Chris@227
|
1019 }
|
Chris@227
|
1020 }
|
Chris@227
|
1021
|
Chris@227
|
1022 return true;
|
Chris@227
|
1023 }
|
Chris@227
|
1024
|
Chris@227
|
1025 QImage *
|
Chris@229
|
1026 Pane::toNewImage(size_t f0, size_t f1)
|
Chris@227
|
1027 {
|
Chris@227
|
1028 size_t x0 = f0 / getZoomLevel();
|
Chris@227
|
1029 size_t x1 = f1 / getZoomLevel();
|
Chris@227
|
1030
|
Chris@227
|
1031 QImage *image = new QImage(x1 - x0 + m_scaleWidth,
|
Chris@227
|
1032 height(), QImage::Format_RGB32);
|
Chris@227
|
1033
|
Chris@227
|
1034 int formerScaleWidth = m_scaleWidth;
|
Chris@227
|
1035
|
Chris@227
|
1036 if (m_manager && m_manager->shouldShowVerticalScale()) {
|
Chris@227
|
1037 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
|
Chris@227
|
1038 --vi;
|
Chris@227
|
1039 QPainter paint(image);
|
Chris@227
|
1040 m_scaleWidth = (*vi)->getVerticalScaleWidth(this, paint);
|
Chris@227
|
1041 break;
|
Chris@227
|
1042 }
|
Chris@227
|
1043 } else {
|
Chris@227
|
1044 m_scaleWidth = 0;
|
Chris@227
|
1045 }
|
Chris@227
|
1046
|
Chris@227
|
1047 if (m_scaleWidth != formerScaleWidth) {
|
Chris@227
|
1048 delete image;
|
Chris@227
|
1049 image = new QImage(x1 - x0 + m_scaleWidth,
|
Chris@227
|
1050 height(), QImage::Format_RGB32);
|
Chris@227
|
1051 }
|
Chris@227
|
1052
|
Chris@227
|
1053 QPainter *paint = new QPainter(image);
|
Chris@229
|
1054 if (!render(*paint, 0, f0, f1)) {
|
Chris@227
|
1055 delete paint;
|
Chris@227
|
1056 delete image;
|
Chris@227
|
1057 return 0;
|
Chris@227
|
1058 } else {
|
Chris@227
|
1059 delete paint;
|
Chris@227
|
1060 return image;
|
Chris@227
|
1061 }
|
Chris@227
|
1062 }
|
Chris@227
|
1063
|
Chris@229
|
1064 QSize
|
Chris@229
|
1065 Pane::getImageSize(size_t f0, size_t f1)
|
Chris@229
|
1066 {
|
Chris@229
|
1067 QSize s = View::getImageSize(f0, f1);
|
Chris@229
|
1068 QImage *image = new QImage(100, 100, QImage::Format_RGB32);
|
Chris@229
|
1069 QPainter paint(image);
|
Chris@229
|
1070
|
Chris@229
|
1071 int sw = 0;
|
Chris@229
|
1072 if (m_manager && m_manager->shouldShowVerticalScale()) {
|
Chris@229
|
1073 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
|
Chris@229
|
1074 --vi;
|
Chris@229
|
1075 QPainter paint(image);
|
Chris@229
|
1076 sw = (*vi)->getVerticalScaleWidth(this, paint);
|
Chris@229
|
1077 break;
|
Chris@229
|
1078 }
|
Chris@229
|
1079 }
|
Chris@229
|
1080
|
Chris@229
|
1081 return QSize(sw + s.width(), s.height());
|
Chris@229
|
1082 }
|
Chris@229
|
1083
|
Chris@222
|
1084 size_t
|
Chris@222
|
1085 Pane::getFirstVisibleFrame() const
|
Chris@222
|
1086 {
|
Chris@222
|
1087 long f0 = getFrameForX(m_scaleWidth);
|
Chris@222
|
1088 size_t f = View::getFirstVisibleFrame();
|
Chris@222
|
1089 if (f0 < 0 || f0 < long(f)) return f;
|
Chris@222
|
1090 return f0;
|
Chris@222
|
1091 }
|
Chris@222
|
1092
|
Chris@127
|
1093 Selection
|
Chris@127
|
1094 Pane::getSelectionAt(int x, bool &closeToLeftEdge, bool &closeToRightEdge) const
|
Chris@127
|
1095 {
|
Chris@127
|
1096 closeToLeftEdge = closeToRightEdge = false;
|
Chris@127
|
1097
|
Chris@127
|
1098 if (!m_manager) return Selection();
|
Chris@127
|
1099
|
Chris@127
|
1100 long testFrame = getFrameForX(x - 5);
|
Chris@127
|
1101 if (testFrame < 0) {
|
Chris@127
|
1102 testFrame = getFrameForX(x);
|
Chris@127
|
1103 if (testFrame < 0) return Selection();
|
Chris@127
|
1104 }
|
Chris@127
|
1105
|
Chris@127
|
1106 Selection selection = m_manager->getContainingSelection(testFrame, true);
|
Chris@127
|
1107 if (selection.isEmpty()) return selection;
|
Chris@127
|
1108
|
Chris@127
|
1109 int lx = getXForFrame(selection.getStartFrame());
|
Chris@127
|
1110 int rx = getXForFrame(selection.getEndFrame());
|
Chris@127
|
1111
|
Chris@127
|
1112 int fuzz = 2;
|
Chris@127
|
1113 if (x < lx - fuzz || x > rx + fuzz) return Selection();
|
Chris@127
|
1114
|
Chris@127
|
1115 int width = rx - lx;
|
Chris@127
|
1116 fuzz = 3;
|
Chris@127
|
1117 if (width < 12) fuzz = width / 4;
|
Chris@127
|
1118 if (fuzz < 1) fuzz = 1;
|
Chris@127
|
1119
|
Chris@127
|
1120 if (x < lx + fuzz) closeToLeftEdge = true;
|
Chris@127
|
1121 if (x > rx - fuzz) closeToRightEdge = true;
|
Chris@127
|
1122
|
Chris@127
|
1123 return selection;
|
Chris@127
|
1124 }
|
Chris@127
|
1125
|
Chris@174
|
1126 bool
|
Chris@174
|
1127 Pane::canTopLayerMoveVertical()
|
Chris@174
|
1128 {
|
Chris@174
|
1129 float vmin, vmax, dmin, dmax;
|
Chris@174
|
1130 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return false;
|
Chris@174
|
1131 if (dmin <= vmin && dmax >= vmax) return false;
|
Chris@174
|
1132 return true;
|
Chris@174
|
1133 }
|
Chris@174
|
1134
|
Chris@174
|
1135 bool
|
Chris@174
|
1136 Pane::getTopLayerDisplayExtents(float &vmin, float &vmax,
|
Chris@188
|
1137 float &dmin, float &dmax,
|
Chris@188
|
1138 QString *unit)
|
Chris@174
|
1139 {
|
Chris@268
|
1140 Layer *layer = getTopLayer();
|
Chris@174
|
1141 if (!layer) return false;
|
Chris@174
|
1142 bool vlog;
|
Chris@174
|
1143 QString vunit;
|
Chris@188
|
1144 bool rv = (layer->getValueExtents(vmin, vmax, vlog, vunit) &&
|
Chris@188
|
1145 layer->getDisplayExtents(dmin, dmax));
|
Chris@188
|
1146 if (unit) *unit = vunit;
|
Chris@188
|
1147 return rv;
|
Chris@174
|
1148 }
|
Chris@174
|
1149
|
Chris@174
|
1150 bool
|
Chris@174
|
1151 Pane::setTopLayerDisplayExtents(float dmin, float dmax)
|
Chris@174
|
1152 {
|
Chris@268
|
1153 Layer *layer = getTopLayer();
|
Chris@174
|
1154 if (!layer) return false;
|
Chris@174
|
1155 return layer->setDisplayExtents(dmin, dmax);
|
Chris@174
|
1156 }
|
Chris@174
|
1157
|
Chris@127
|
1158 void
|
Chris@282
|
1159 Pane::registerShortcuts(KeyReference &kr)
|
Chris@282
|
1160 {
|
Chris@282
|
1161 kr.setCategory(tr("Zoom"));
|
Chris@282
|
1162 kr.registerAlternativeShortcut(tr("Zoom In"), tr("Wheel Up"));
|
Chris@282
|
1163 kr.registerAlternativeShortcut(tr("Zoom Out"), tr("Wheel Down"));
|
Chris@282
|
1164
|
Chris@282
|
1165 kr.setCategory(tr("General Pane Mouse Actions"));
|
Chris@282
|
1166
|
Chris@282
|
1167 kr.registerShortcut(tr("Zoom"), tr("Wheel"),
|
Chris@282
|
1168 tr("Zoom in or out in time axis"));
|
Chris@408
|
1169 kr.registerShortcut(tr("Scroll"), tr("Ctrl+Wheel"),
|
Chris@282
|
1170 tr("Scroll rapidly left or right in time axis"));
|
Chris@282
|
1171 kr.registerShortcut(tr("Zoom Vertically"), tr("Shift+Wheel"),
|
Chris@282
|
1172 tr("Zoom in or out in the vertical axis"));
|
Chris@282
|
1173 kr.registerShortcut(tr("Scroll Vertically"), tr("Alt+Wheel"),
|
Chris@282
|
1174 tr("Scroll up or down in the vertical axis"));
|
Chris@282
|
1175 kr.registerShortcut(tr("Navigate"), tr("Middle"),
|
Chris@282
|
1176 tr("Click middle button and drag to navigate with any tool"));
|
Chris@282
|
1177 kr.registerShortcut(tr("Relocate"), tr("Double-Click Middle"),
|
Chris@282
|
1178 tr("Double-click middle button to relocate with any tool"));
|
Chris@282
|
1179 kr.registerShortcut(tr("Menu"), tr("Right"),
|
Chris@282
|
1180 tr("Show pane context menu"));
|
Chris@282
|
1181
|
Chris@282
|
1182 kr.setCategory(tr("Navigate Tool Mouse Actions"));
|
Chris@282
|
1183
|
Chris@282
|
1184 kr.registerShortcut(tr("Navigate"), tr("Left"),
|
Chris@282
|
1185 tr("Click left button and drag to move around"));
|
Chris@282
|
1186 kr.registerShortcut(tr("Zoom to Area"), tr("Shift+Left"),
|
Chris@282
|
1187 tr("Shift-click left button and drag to zoom to a rectangular area"));
|
Chris@282
|
1188 kr.registerShortcut(tr("Relocate"), tr("Double-Click Left"),
|
Chris@282
|
1189 tr("Double-click left button to jump to clicked location"));
|
Chris@282
|
1190 kr.registerShortcut(tr("Edit"), tr("Double-Click Left"),
|
Chris@282
|
1191 tr("Double-click left button on an item to edit it"));
|
Chris@282
|
1192
|
Chris@282
|
1193 kr.setCategory(tr("Select Tool Mouse Actions"));
|
Chris@282
|
1194 kr.registerShortcut(tr("Select"), tr("Left"),
|
Chris@282
|
1195 tr("Click left button and drag to select region; drag region edge to resize"));
|
Chris@282
|
1196 kr.registerShortcut(tr("Multi Select"), tr("Ctrl+Left"),
|
Chris@282
|
1197 tr("Ctrl-click left button and drag to select an additional region"));
|
Chris@283
|
1198 kr.registerShortcut(tr("Fine Select"), tr("Shift+Left"),
|
Chris@283
|
1199 tr("Shift-click left button and drag to select without snapping to items or grid"));
|
Chris@282
|
1200
|
Chris@282
|
1201 kr.setCategory(tr("Edit Tool Mouse Actions"));
|
Chris@282
|
1202 kr.registerShortcut(tr("Move"), tr("Left"),
|
Chris@282
|
1203 tr("Click left button on an item or selected region and drag to move"));
|
Chris@282
|
1204 kr.registerShortcut(tr("Edit"), tr("Double-Click Left"),
|
Chris@282
|
1205 tr("Double-click left button on an item to edit it"));
|
Chris@282
|
1206
|
Chris@282
|
1207 kr.setCategory(tr("Draw Tool Mouse Actions"));
|
Chris@282
|
1208 kr.registerShortcut(tr("Draw"), tr("Left"),
|
Chris@282
|
1209 tr("Click left button and drag to create new item"));
|
Chris@282
|
1210
|
Chris@282
|
1211 kr.setCategory(tr("Measure Tool Mouse Actions"));
|
Chris@282
|
1212 kr.registerShortcut(tr("Measure Area"), tr("Left"),
|
Chris@282
|
1213 tr("Click left button and drag to measure a rectangular area"));
|
Chris@282
|
1214 kr.registerShortcut(tr("Measure Item"), tr("Double-Click Left"),
|
Chris@282
|
1215 tr("Click left button and drag to measure extents of an item or shape"));
|
Chris@283
|
1216 kr.registerShortcut(tr("Zoom to Area"), tr("Shift+Left"),
|
Chris@283
|
1217 tr("Shift-click left button and drag to zoom to a rectangular area"));
|
Chris@282
|
1218 }
|
Chris@282
|
1219
|
Chris@282
|
1220 void
|
Chris@127
|
1221 Pane::mousePressEvent(QMouseEvent *e)
|
Chris@127
|
1222 {
|
Chris@127
|
1223 if (e->buttons() & Qt::RightButton) {
|
Chris@189
|
1224 emit contextHelpChanged("");
|
Chris@127
|
1225 emit rightButtonMenuRequested(mapToGlobal(e->pos()));
|
Chris@127
|
1226 return;
|
Chris@127
|
1227 }
|
Chris@127
|
1228
|
Chris@343
|
1229 // std::cerr << "mousePressEvent" << std::endl;
|
Chris@341
|
1230
|
Chris@127
|
1231 m_clickPos = e->pos();
|
Chris@262
|
1232 m_mousePos = m_clickPos;
|
Chris@127
|
1233 m_clickedInRange = true;
|
Chris@127
|
1234 m_editingSelection = Selection();
|
Chris@127
|
1235 m_editingSelectionEdge = 0;
|
Chris@127
|
1236 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier);
|
Chris@127
|
1237 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier);
|
Chris@150
|
1238 m_dragMode = UnresolvedDrag;
|
Chris@127
|
1239
|
Chris@127
|
1240 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
1241 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
1242
|
Chris@127
|
1243 m_navigating = false;
|
Chris@343
|
1244 m_resizing = false;
|
Chris@343
|
1245 m_editing = false;
|
Chris@343
|
1246 m_releasing = false;
|
Chris@127
|
1247
|
Chris@283
|
1248 if (mode == ViewManager::NavigateMode ||
|
Chris@283
|
1249 (e->buttons() & Qt::MidButton) ||
|
Chris@283
|
1250 (mode == ViewManager::MeasureMode &&
|
Chris@283
|
1251 (e->buttons() & Qt::LeftButton) && m_shiftPressed)) {
|
Chris@127
|
1252
|
Chris@127
|
1253 if (mode != ViewManager::NavigateMode) {
|
Chris@127
|
1254 setCursor(Qt::PointingHandCursor);
|
Chris@127
|
1255 }
|
Chris@127
|
1256
|
Chris@127
|
1257 m_navigating = true;
|
Chris@127
|
1258 m_dragCentreFrame = m_centreFrame;
|
Chris@136
|
1259 m_dragStartMinValue = 0;
|
Chris@174
|
1260
|
Chris@174
|
1261 float vmin, vmax, dmin, dmax;
|
Chris@174
|
1262 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) {
|
Chris@174
|
1263 m_dragStartMinValue = dmin;
|
Chris@136
|
1264 }
|
Chris@136
|
1265
|
Chris@127
|
1266 } else if (mode == ViewManager::SelectMode) {
|
Chris@127
|
1267
|
Chris@217
|
1268 if (!hasTopLayerTimeXAxis()) return;
|
Chris@217
|
1269
|
Chris@127
|
1270 bool closeToLeft = false, closeToRight = false;
|
Chris@127
|
1271 Selection selection = getSelectionAt(e->x(), closeToLeft, closeToRight);
|
Chris@127
|
1272
|
Chris@127
|
1273 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) {
|
Chris@127
|
1274
|
Chris@127
|
1275 m_manager->removeSelection(selection);
|
Chris@127
|
1276
|
Chris@127
|
1277 if (closeToLeft) {
|
Chris@127
|
1278 m_selectionStartFrame = selection.getEndFrame();
|
Chris@127
|
1279 } else {
|
Chris@127
|
1280 m_selectionStartFrame = selection.getStartFrame();
|
Chris@127
|
1281 }
|
Chris@127
|
1282
|
Chris@127
|
1283 m_manager->setInProgressSelection(selection, false);
|
Chris@127
|
1284 m_resizing = true;
|
Chris@127
|
1285
|
Chris@127
|
1286 } else {
|
Chris@127
|
1287
|
Chris@127
|
1288 int mouseFrame = getFrameForX(e->x());
|
Chris@127
|
1289 size_t resolution = 1;
|
Chris@127
|
1290 int snapFrame = mouseFrame;
|
Chris@127
|
1291
|
Chris@127
|
1292 Layer *layer = getSelectedLayer();
|
Chris@127
|
1293 if (layer && !m_shiftPressed) {
|
Chris@127
|
1294 layer->snapToFeatureFrame(this, snapFrame,
|
Chris@127
|
1295 resolution, Layer::SnapLeft);
|
Chris@127
|
1296 }
|
Chris@127
|
1297
|
Chris@127
|
1298 if (snapFrame < 0) snapFrame = 0;
|
Chris@127
|
1299 m_selectionStartFrame = snapFrame;
|
Chris@127
|
1300 if (m_manager) {
|
Chris@333
|
1301 m_manager->setInProgressSelection
|
Chris@333
|
1302 (Selection(alignToReference(snapFrame),
|
Chris@333
|
1303 alignToReference(snapFrame + resolution)),
|
Chris@333
|
1304 !m_ctrlPressed);
|
Chris@127
|
1305 }
|
Chris@127
|
1306
|
Chris@127
|
1307 m_resizing = false;
|
Chris@127
|
1308 }
|
Chris@127
|
1309
|
Chris@127
|
1310 update();
|
Chris@127
|
1311
|
Chris@127
|
1312 } else if (mode == ViewManager::DrawMode) {
|
Chris@127
|
1313
|
Chris@127
|
1314 Layer *layer = getSelectedLayer();
|
Chris@127
|
1315 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
1316 layer->drawStart(this, e);
|
Chris@127
|
1317 }
|
Chris@127
|
1318
|
Chris@335
|
1319 } else if (mode == ViewManager::EraseMode) {
|
Chris@335
|
1320
|
Chris@335
|
1321 Layer *layer = getSelectedLayer();
|
Chris@335
|
1322 if (layer && layer->isLayerEditable()) {
|
Chris@335
|
1323 layer->eraseStart(this, e);
|
Chris@335
|
1324 }
|
Chris@335
|
1325
|
Chris@127
|
1326 } else if (mode == ViewManager::EditMode) {
|
Chris@127
|
1327
|
Chris@343
|
1328 // Do nothing here -- we'll do it in mouseMoveEvent when the
|
Chris@343
|
1329 // drag threshold has been passed
|
Chris@262
|
1330
|
Chris@262
|
1331 } else if (mode == ViewManager::MeasureMode) {
|
Chris@262
|
1332
|
Chris@268
|
1333 Layer *layer = getTopLayer();
|
Chris@267
|
1334 if (layer) layer->measureStart(this, e);
|
Chris@262
|
1335 update();
|
Chris@127
|
1336 }
|
Chris@127
|
1337
|
Chris@127
|
1338 emit paneInteractedWith();
|
Chris@127
|
1339 }
|
Chris@127
|
1340
|
Chris@127
|
1341 void
|
Chris@127
|
1342 Pane::mouseReleaseEvent(QMouseEvent *e)
|
Chris@127
|
1343 {
|
Chris@127
|
1344 if (e->buttons() & Qt::RightButton) {
|
Chris@127
|
1345 return;
|
Chris@127
|
1346 }
|
Chris@127
|
1347
|
Chris@343
|
1348 // std::cerr << "mouseReleaseEvent" << std::endl;
|
Chris@341
|
1349
|
Chris@127
|
1350 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
1351 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
1352
|
Chris@343
|
1353 m_releasing = true;
|
Chris@343
|
1354
|
Chris@127
|
1355 if (m_clickedInRange) {
|
Chris@127
|
1356 mouseMoveEvent(e);
|
Chris@127
|
1357 }
|
Chris@127
|
1358
|
Chris@127
|
1359 if (m_navigating || mode == ViewManager::NavigateMode) {
|
Chris@127
|
1360
|
Chris@127
|
1361 m_navigating = false;
|
Chris@127
|
1362
|
Chris@127
|
1363 if (mode != ViewManager::NavigateMode) {
|
Chris@127
|
1364 // restore cursor
|
Chris@127
|
1365 toolModeChanged();
|
Chris@127
|
1366 }
|
Chris@127
|
1367
|
Chris@127
|
1368 if (m_shiftPressed) {
|
Chris@127
|
1369
|
Chris@127
|
1370 int x0 = std::min(m_clickPos.x(), m_mousePos.x());
|
Chris@127
|
1371 int x1 = std::max(m_clickPos.x(), m_mousePos.x());
|
Chris@127
|
1372
|
Chris@127
|
1373 int y0 = std::min(m_clickPos.y(), m_mousePos.y());
|
Chris@127
|
1374 int y1 = std::max(m_clickPos.y(), m_mousePos.y());
|
Chris@127
|
1375
|
Chris@174
|
1376 zoomToRegion(x0, y0, x1, y1);
|
Chris@127
|
1377 }
|
Chris@127
|
1378
|
Chris@127
|
1379 } else if (mode == ViewManager::SelectMode) {
|
Chris@127
|
1380
|
Chris@343
|
1381 if (!hasTopLayerTimeXAxis()) {
|
Chris@343
|
1382 m_releasing = false;
|
Chris@343
|
1383 return;
|
Chris@343
|
1384 }
|
Chris@217
|
1385
|
Chris@127
|
1386 if (m_manager && m_manager->haveInProgressSelection()) {
|
Chris@127
|
1387
|
Chris@127
|
1388 bool exclusive;
|
Chris@127
|
1389 Selection selection = m_manager->getInProgressSelection(exclusive);
|
Chris@127
|
1390
|
Chris@127
|
1391 if (selection.getEndFrame() < selection.getStartFrame() + 2) {
|
Chris@127
|
1392 selection = Selection();
|
Chris@127
|
1393 }
|
Chris@127
|
1394
|
Chris@127
|
1395 m_manager->clearInProgressSelection();
|
Chris@127
|
1396
|
Chris@127
|
1397 if (exclusive) {
|
Chris@127
|
1398 m_manager->setSelection(selection);
|
Chris@127
|
1399 } else {
|
Chris@127
|
1400 m_manager->addSelection(selection);
|
Chris@127
|
1401 }
|
Chris@127
|
1402 }
|
Chris@127
|
1403
|
Chris@127
|
1404 update();
|
Chris@127
|
1405
|
Chris@127
|
1406 } else if (mode == ViewManager::DrawMode) {
|
Chris@127
|
1407
|
Chris@127
|
1408 Layer *layer = getSelectedLayer();
|
Chris@127
|
1409 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
1410 layer->drawEnd(this, e);
|
Chris@127
|
1411 update();
|
Chris@127
|
1412 }
|
Chris@127
|
1413
|
Chris@335
|
1414 } else if (mode == ViewManager::EraseMode) {
|
Chris@335
|
1415
|
Chris@335
|
1416 Layer *layer = getSelectedLayer();
|
Chris@335
|
1417 if (layer && layer->isLayerEditable()) {
|
Chris@335
|
1418 layer->eraseEnd(this, e);
|
Chris@335
|
1419 update();
|
Chris@335
|
1420 }
|
Chris@335
|
1421
|
Chris@127
|
1422 } else if (mode == ViewManager::EditMode) {
|
Chris@127
|
1423
|
Chris@343
|
1424 if (m_editing) {
|
Chris@343
|
1425 if (!editSelectionEnd(e)) {
|
Chris@343
|
1426 Layer *layer = getSelectedLayer();
|
Chris@343
|
1427 if (layer && layer->isLayerEditable()) {
|
Chris@343
|
1428 layer->editEnd(this, e);
|
Chris@343
|
1429 update();
|
Chris@343
|
1430 }
|
Chris@343
|
1431 }
|
Chris@343
|
1432 }
|
Chris@262
|
1433
|
Chris@262
|
1434 } else if (mode == ViewManager::MeasureMode) {
|
Chris@262
|
1435
|
Chris@268
|
1436 Layer *layer = getTopLayer();
|
Chris@267
|
1437 if (layer) layer->measureEnd(this, e);
|
Chris@267
|
1438 if (m_measureCursor1) setCursor(*m_measureCursor1);
|
Chris@267
|
1439 update();
|
Chris@127
|
1440 }
|
Chris@127
|
1441
|
Chris@127
|
1442 m_clickedInRange = false;
|
Chris@343
|
1443 m_releasing = false;
|
Chris@127
|
1444
|
Chris@127
|
1445 emit paneInteractedWith();
|
Chris@127
|
1446 }
|
Chris@127
|
1447
|
Chris@127
|
1448 void
|
Chris@127
|
1449 Pane::mouseMoveEvent(QMouseEvent *e)
|
Chris@127
|
1450 {
|
Chris@127
|
1451 if (e->buttons() & Qt::RightButton) {
|
Chris@127
|
1452 return;
|
Chris@127
|
1453 }
|
Chris@127
|
1454
|
Chris@343
|
1455 // std::cerr << "mouseMoveEvent" << std::endl;
|
Chris@341
|
1456
|
Chris@189
|
1457 updateContextHelp(&e->pos());
|
Chris@189
|
1458
|
Chris@343
|
1459 if (m_navigating && m_clickedInRange && !m_releasing) {
|
Chris@343
|
1460
|
Chris@343
|
1461 // if no buttons pressed, and not called from
|
Chris@343
|
1462 // mouseReleaseEvent, we want to reset clicked-ness (to avoid
|
Chris@343
|
1463 // annoying continual drags when we moved the mouse outside
|
Chris@343
|
1464 // the window after pressing button first time).
|
Chris@343
|
1465
|
Chris@343
|
1466 if (!(e->buttons() & Qt::LeftButton) &&
|
Chris@343
|
1467 !(e->buttons() & Qt::MidButton)) {
|
Chris@343
|
1468 m_clickedInRange = false;
|
Chris@343
|
1469 return;
|
Chris@343
|
1470 }
|
Chris@343
|
1471 }
|
Chris@343
|
1472
|
Chris@127
|
1473 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
1474 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
1475
|
Chris@127
|
1476 QPoint prevPoint = m_identifyPoint;
|
Chris@127
|
1477 m_identifyPoint = e->pos();
|
Chris@127
|
1478
|
Chris@127
|
1479 if (!m_clickedInRange) {
|
Chris@127
|
1480
|
Chris@217
|
1481 if (mode == ViewManager::SelectMode && hasTopLayerTimeXAxis()) {
|
Chris@127
|
1482 bool closeToLeft = false, closeToRight = false;
|
Chris@127
|
1483 getSelectionAt(e->x(), closeToLeft, closeToRight);
|
Chris@127
|
1484 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) {
|
Chris@127
|
1485 setCursor(Qt::SizeHorCursor);
|
Chris@127
|
1486 } else {
|
Chris@127
|
1487 setCursor(Qt::ArrowCursor);
|
Chris@127
|
1488 }
|
Chris@127
|
1489 }
|
Chris@127
|
1490
|
Chris@127
|
1491 if (!m_manager->isPlaying()) {
|
Chris@127
|
1492
|
Chris@272
|
1493 bool updating = false;
|
Chris@272
|
1494
|
Chris@326
|
1495 if (getSelectedLayer() &&
|
Chris@326
|
1496 m_manager->shouldIlluminateLocalFeatures()) {
|
Chris@127
|
1497
|
Chris@174
|
1498 bool previouslyIdentifying = m_identifyFeatures;
|
Chris@174
|
1499 m_identifyFeatures = true;
|
Chris@174
|
1500
|
Chris@174
|
1501 if (m_identifyFeatures != previouslyIdentifying ||
|
Chris@174
|
1502 m_identifyPoint != prevPoint) {
|
Chris@174
|
1503 update();
|
Chris@272
|
1504 updating = true;
|
Chris@272
|
1505 }
|
Chris@272
|
1506 }
|
Chris@272
|
1507
|
Chris@272
|
1508 if (!updating && mode == ViewManager::MeasureMode &&
|
Chris@272
|
1509 m_manager && !m_manager->isPlaying()) {
|
Chris@272
|
1510
|
Chris@272
|
1511 Layer *layer = getTopLayer();
|
Chris@272
|
1512 if (layer && layer->nearestMeasurementRectChanged
|
Chris@272
|
1513 (this, prevPoint, m_identifyPoint)) {
|
Chris@272
|
1514 update();
|
Chris@174
|
1515 }
|
Chris@174
|
1516 }
|
Chris@127
|
1517 }
|
Chris@127
|
1518
|
Chris@127
|
1519 return;
|
Chris@127
|
1520 }
|
Chris@127
|
1521
|
Chris@127
|
1522 if (m_navigating || mode == ViewManager::NavigateMode) {
|
Chris@127
|
1523
|
Chris@127
|
1524 if (m_shiftPressed) {
|
Chris@127
|
1525
|
Chris@127
|
1526 m_mousePos = e->pos();
|
Chris@127
|
1527 update();
|
Chris@127
|
1528
|
Chris@127
|
1529 } else {
|
Chris@127
|
1530
|
Chris@174
|
1531 dragTopLayer(e);
|
Chris@150
|
1532 }
|
Chris@127
|
1533
|
Chris@127
|
1534 } else if (mode == ViewManager::SelectMode) {
|
Chris@127
|
1535
|
Chris@217
|
1536 if (!hasTopLayerTimeXAxis()) return;
|
Chris@217
|
1537
|
Chris@174
|
1538 dragExtendSelection(e);
|
Chris@127
|
1539
|
Chris@127
|
1540 } else if (mode == ViewManager::DrawMode) {
|
Chris@127
|
1541
|
Chris@127
|
1542 Layer *layer = getSelectedLayer();
|
Chris@127
|
1543 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
1544 layer->drawDrag(this, e);
|
Chris@127
|
1545 }
|
Chris@127
|
1546
|
Chris@335
|
1547 } else if (mode == ViewManager::EraseMode) {
|
Chris@335
|
1548
|
Chris@335
|
1549 Layer *layer = getSelectedLayer();
|
Chris@335
|
1550 if (layer && layer->isLayerEditable()) {
|
Chris@335
|
1551 layer->eraseDrag(this, e);
|
Chris@335
|
1552 }
|
Chris@335
|
1553
|
Chris@127
|
1554 } else if (mode == ViewManager::EditMode) {
|
Chris@127
|
1555
|
Chris@343
|
1556 if (m_editing) {
|
Chris@343
|
1557 if (!editSelectionDrag(e)) {
|
Chris@343
|
1558 Layer *layer = getSelectedLayer();
|
Chris@343
|
1559 if (layer && layer->isLayerEditable()) {
|
Chris@343
|
1560 layer->editDrag(this, e);
|
Chris@343
|
1561 }
|
Chris@343
|
1562 }
|
Chris@343
|
1563 }
|
Chris@343
|
1564
|
Chris@343
|
1565 if (!m_editing) {
|
Chris@343
|
1566
|
Chris@387
|
1567 bool resist = true;
|
Chris@387
|
1568
|
Chris@387
|
1569 if ((e->modifiers() & Qt::ShiftModifier)) {
|
Chris@387
|
1570 m_shiftPressed = true;
|
Chris@387
|
1571 // ... but don't set it false if shift has been
|
Chris@387
|
1572 // released -- we want the state when we started
|
Chris@387
|
1573 // dragging to be used most of the time
|
Chris@387
|
1574 }
|
Chris@387
|
1575
|
Chris@387
|
1576 if (m_shiftPressed) resist = false;
|
Chris@387
|
1577
|
Chris@343
|
1578 DragMode newDragMode = updateDragMode
|
Chris@343
|
1579 (m_dragMode,
|
Chris@343
|
1580 m_clickPos,
|
Chris@343
|
1581 e->pos(),
|
Chris@387
|
1582 true, // can move horiz
|
Chris@387
|
1583 true, // can move vert
|
Chris@387
|
1584 resist, // resist horiz
|
Chris@387
|
1585 resist); // resist vert
|
Chris@343
|
1586
|
Chris@343
|
1587 if (newDragMode != UnresolvedDrag) {
|
Chris@343
|
1588
|
Chris@343
|
1589 m_editing = true;
|
Chris@343
|
1590
|
Chris@343
|
1591 QMouseEvent clickEvent(QEvent::MouseButtonPress,
|
Chris@343
|
1592 m_clickPos,
|
Chris@343
|
1593 Qt::NoButton,
|
Chris@343
|
1594 e->buttons(),
|
Chris@343
|
1595 e->modifiers());
|
Chris@343
|
1596
|
Chris@343
|
1597 if (!editSelectionStart(&clickEvent)) {
|
Chris@343
|
1598 Layer *layer = getSelectedLayer();
|
Chris@343
|
1599 if (layer && layer->isLayerEditable()) {
|
Chris@343
|
1600 layer->editStart(this, &clickEvent);
|
Chris@343
|
1601 }
|
Chris@343
|
1602 }
|
Chris@343
|
1603 }
|
Chris@343
|
1604 }
|
Chris@259
|
1605
|
Chris@259
|
1606 } else if (mode == ViewManager::MeasureMode) {
|
Chris@259
|
1607
|
Chris@267
|
1608 if (m_measureCursor2) setCursor(*m_measureCursor2);
|
Chris@266
|
1609
|
Chris@268
|
1610 Layer *layer = getTopLayer();
|
Chris@290
|
1611 if (layer) {
|
Chris@290
|
1612 layer->measureDrag(this, e);
|
Chris@290
|
1613 if (layer->hasTimeXAxis()) edgeScrollMaybe(e->x());
|
Chris@290
|
1614 }
|
Chris@267
|
1615
|
Chris@267
|
1616 update();
|
Chris@127
|
1617 }
|
Chris@127
|
1618 }
|
Chris@127
|
1619
|
Chris@127
|
1620 void
|
Chris@174
|
1621 Pane::zoomToRegion(int x0, int y0, int x1, int y1)
|
Chris@174
|
1622 {
|
Chris@174
|
1623 int w = x1 - x0;
|
Chris@174
|
1624
|
Chris@174
|
1625 long newStartFrame = getFrameForX(x0);
|
Chris@174
|
1626
|
Chris@174
|
1627 long visibleFrames = getEndFrame() - getStartFrame();
|
Chris@174
|
1628 if (newStartFrame <= -visibleFrames) {
|
Chris@174
|
1629 newStartFrame = -visibleFrames + 1;
|
Chris@174
|
1630 }
|
Chris@174
|
1631
|
Chris@174
|
1632 if (newStartFrame >= long(getModelsEndFrame())) {
|
Chris@174
|
1633 newStartFrame = getModelsEndFrame() - 1;
|
Chris@174
|
1634 }
|
Chris@174
|
1635
|
Chris@174
|
1636 float ratio = float(w) / float(width());
|
Chris@174
|
1637 // std::cerr << "ratio: " << ratio << std::endl;
|
Chris@174
|
1638 size_t newZoomLevel = (size_t)nearbyint(m_zoomLevel * ratio);
|
Chris@174
|
1639 if (newZoomLevel < 1) newZoomLevel = 1;
|
Chris@174
|
1640
|
Chris@174
|
1641 // std::cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << std::endl;
|
Chris@174
|
1642 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel));
|
Chris@174
|
1643 setStartFrame(newStartFrame);
|
Chris@174
|
1644
|
Chris@174
|
1645 QString unit;
|
Chris@174
|
1646 float min, max;
|
Chris@174
|
1647 bool log;
|
Chris@174
|
1648 Layer *layer = 0;
|
Chris@174
|
1649 for (LayerList::const_iterator i = m_layers.begin();
|
Chris@174
|
1650 i != m_layers.end(); ++i) {
|
Chris@174
|
1651 if ((*i)->getValueExtents(min, max, log, unit) &&
|
Chris@174
|
1652 (*i)->getDisplayExtents(min, max)) {
|
Chris@174
|
1653 layer = *i;
|
Chris@174
|
1654 break;
|
Chris@174
|
1655 }
|
Chris@174
|
1656 }
|
Chris@174
|
1657
|
Chris@174
|
1658 if (layer) {
|
Chris@174
|
1659 if (log) {
|
Chris@174
|
1660 min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min);
|
Chris@174
|
1661 max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max);
|
Chris@174
|
1662 }
|
Chris@174
|
1663 float rmin = min + ((max - min) * (height() - y1)) / height();
|
Chris@174
|
1664 float rmax = min + ((max - min) * (height() - y0)) / height();
|
Chris@174
|
1665 std::cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << std::endl;
|
Chris@174
|
1666 if (log) {
|
Chris@174
|
1667 rmin = powf(10, rmin);
|
Chris@174
|
1668 rmax = powf(10, rmax);
|
Chris@174
|
1669 }
|
Chris@174
|
1670 std::cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit.toStdString() << std::endl;
|
Chris@174
|
1671
|
Chris@174
|
1672 layer->setDisplayExtents(rmin, rmax);
|
Chris@174
|
1673 updateVerticalPanner();
|
Chris@174
|
1674 }
|
Chris@174
|
1675 }
|
Chris@174
|
1676
|
Chris@174
|
1677 void
|
Chris@174
|
1678 Pane::dragTopLayer(QMouseEvent *e)
|
Chris@174
|
1679 {
|
Chris@174
|
1680 // We need to avoid making it too easy to drag both
|
Chris@174
|
1681 // horizontally and vertically, in the case where the
|
Chris@174
|
1682 // mouse is moved "mostly" in horizontal or vertical axis
|
Chris@174
|
1683 // with only a small variation in the other axis. This is
|
Chris@174
|
1684 // particularly important during playback (when we want to
|
Chris@174
|
1685 // avoid small horizontal motions) or in slow refresh
|
Chris@174
|
1686 // layers like spectrogram (when we want to avoid small
|
Chris@174
|
1687 // vertical motions).
|
Chris@174
|
1688 //
|
Chris@174
|
1689 // To this end we have horizontal and vertical thresholds
|
Chris@174
|
1690 // and a series of states: unresolved, horizontally or
|
Chris@174
|
1691 // vertically constrained, free.
|
Chris@174
|
1692 //
|
Chris@174
|
1693 // When the mouse first moves, we're unresolved: we
|
Chris@174
|
1694 // restrict ourselves to whichever direction seems safest,
|
Chris@174
|
1695 // until the mouse has passed a small threshold distance
|
Chris@174
|
1696 // from the click point. Then we lock in to one of the
|
Chris@174
|
1697 // constrained modes, based on which axis that distance
|
Chris@174
|
1698 // was measured in first. Finally, if it turns out we've
|
Chris@174
|
1699 // also moved more than a certain larger distance in the
|
Chris@174
|
1700 // other direction as well, we may switch into free mode.
|
Chris@174
|
1701 //
|
Chris@174
|
1702 // If the top layer is incapable of being dragged
|
Chris@174
|
1703 // vertically, the logic is short circuited.
|
Chris@174
|
1704
|
Chris@343
|
1705 m_dragMode = updateDragMode
|
Chris@343
|
1706 (m_dragMode,
|
Chris@343
|
1707 m_clickPos,
|
Chris@343
|
1708 e->pos(),
|
Chris@343
|
1709 true, // can move horiz
|
Chris@343
|
1710 canTopLayerMoveVertical(), // can move vert
|
Chris@343
|
1711 canTopLayerMoveVertical() || (m_manager && m_manager->isPlaying()), // resist horiz
|
Chris@343
|
1712 !(m_manager && m_manager->isPlaying())); // resist vert
|
Chris@174
|
1713
|
Chris@343
|
1714 if (m_dragMode == HorizontalDrag ||
|
Chris@343
|
1715 m_dragMode == FreeDrag) {
|
Chris@174
|
1716
|
Chris@174
|
1717 long frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x());
|
Chris@174
|
1718
|
Chris@174
|
1719 size_t newCentreFrame = m_dragCentreFrame;
|
Chris@174
|
1720
|
Chris@174
|
1721 if (frameOff < 0) {
|
Chris@174
|
1722 newCentreFrame -= frameOff;
|
Chris@174
|
1723 } else if (newCentreFrame >= size_t(frameOff)) {
|
Chris@174
|
1724 newCentreFrame -= frameOff;
|
Chris@174
|
1725 } else {
|
Chris@174
|
1726 newCentreFrame = 0;
|
Chris@174
|
1727 }
|
Chris@363
|
1728
|
Chris@363
|
1729 #ifdef DEBUG_PANE
|
Chris@339
|
1730 std::cerr << "Pane::dragTopLayer: newCentreFrame = " << newCentreFrame <<
|
Chris@339
|
1731 ", models end frame = " << getModelsEndFrame() << std::endl;
|
Chris@363
|
1732 #endif
|
Chris@339
|
1733
|
Chris@174
|
1734 if (newCentreFrame >= getModelsEndFrame()) {
|
Chris@174
|
1735 newCentreFrame = getModelsEndFrame();
|
Chris@174
|
1736 if (newCentreFrame > 0) --newCentreFrame;
|
Chris@174
|
1737 }
|
Chris@174
|
1738
|
Chris@174
|
1739 if (getXForFrame(m_centreFrame) != getXForFrame(newCentreFrame)) {
|
Chris@174
|
1740 setCentreFrame(newCentreFrame);
|
Chris@174
|
1741 }
|
Chris@174
|
1742 }
|
Chris@174
|
1743
|
Chris@343
|
1744 if (m_dragMode == VerticalDrag ||
|
Chris@343
|
1745 m_dragMode == FreeDrag) {
|
Chris@174
|
1746
|
Chris@174
|
1747 float vmin = 0.f, vmax = 0.f;
|
Chris@174
|
1748 float dmin = 0.f, dmax = 0.f;
|
Chris@174
|
1749
|
Chris@174
|
1750 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) {
|
Chris@174
|
1751
|
Chris@248
|
1752 // std::cerr << "ydiff = " << ydiff << std::endl;
|
Chris@174
|
1753
|
Chris@343
|
1754 int ydiff = e->y() - m_clickPos.y();
|
Chris@174
|
1755 float perpix = (dmax - dmin) / height();
|
Chris@174
|
1756 float valdiff = ydiff * perpix;
|
Chris@248
|
1757 // std::cerr << "valdiff = " << valdiff << std::endl;
|
Chris@174
|
1758
|
Chris@343
|
1759 if (m_dragMode == UnresolvedDrag && ydiff != 0) {
|
Chris@343
|
1760 m_dragMode = VerticalDrag;
|
Chris@343
|
1761 }
|
Chris@343
|
1762
|
Chris@174
|
1763 float newmin = m_dragStartMinValue + valdiff;
|
Chris@174
|
1764 float newmax = m_dragStartMinValue + (dmax - dmin) + valdiff;
|
Chris@174
|
1765 if (newmin < vmin) {
|
Chris@174
|
1766 newmax += vmin - newmin;
|
Chris@174
|
1767 newmin += vmin - newmin;
|
Chris@174
|
1768 }
|
Chris@174
|
1769 if (newmax > vmax) {
|
Chris@174
|
1770 newmin -= newmax - vmax;
|
Chris@174
|
1771 newmax -= newmax - vmax;
|
Chris@174
|
1772 }
|
Chris@248
|
1773 // std::cerr << "(" << dmin << ", " << dmax << ") -> ("
|
Chris@248
|
1774 // << newmin << ", " << newmax << ") (drag start " << m_dragStartMinValue << ")" << std::endl;
|
Chris@174
|
1775
|
Chris@174
|
1776 setTopLayerDisplayExtents(newmin, newmax);
|
Chris@174
|
1777 updateVerticalPanner();
|
Chris@174
|
1778 }
|
Chris@174
|
1779 }
|
Chris@174
|
1780 }
|
Chris@174
|
1781
|
Chris@343
|
1782 Pane::DragMode
|
Chris@343
|
1783 Pane::updateDragMode(DragMode dragMode,
|
Chris@343
|
1784 QPoint origin,
|
Chris@343
|
1785 QPoint point,
|
Chris@343
|
1786 bool canMoveHorizontal,
|
Chris@343
|
1787 bool canMoveVertical,
|
Chris@343
|
1788 bool resistHorizontal,
|
Chris@343
|
1789 bool resistVertical)
|
Chris@343
|
1790 {
|
Chris@343
|
1791 int xdiff = point.x() - origin.x();
|
Chris@343
|
1792 int ydiff = point.y() - origin.y();
|
Chris@343
|
1793
|
Chris@343
|
1794 int smallThreshold = 10, bigThreshold = 80;
|
Chris@343
|
1795
|
Chris@343
|
1796 // std::cerr << "Pane::updateDragMode: xdiff = " << xdiff << ", ydiff = "
|
Chris@343
|
1797 // << ydiff << ", canMoveVertical = " << canMoveVertical << ", drag mode = " << m_dragMode << std::endl;
|
Chris@343
|
1798
|
Chris@343
|
1799 if (dragMode == UnresolvedDrag) {
|
Chris@343
|
1800
|
Chris@343
|
1801 if (abs(ydiff) > smallThreshold &&
|
Chris@343
|
1802 abs(ydiff) > abs(xdiff) * 2 &&
|
Chris@343
|
1803 canMoveVertical) {
|
Chris@343
|
1804 // std::cerr << "Pane::updateDragMode: passed vertical threshold" << std::endl;
|
Chris@343
|
1805 dragMode = VerticalDrag;
|
Chris@343
|
1806 } else if (abs(xdiff) > smallThreshold &&
|
Chris@343
|
1807 abs(xdiff) > abs(ydiff) * 2 &&
|
Chris@343
|
1808 canMoveHorizontal) {
|
Chris@343
|
1809 // std::cerr << "Pane::updateDragMode: passed horizontal threshold" << std::endl;
|
Chris@343
|
1810 dragMode = HorizontalDrag;
|
Chris@343
|
1811 } else if (abs(xdiff) > smallThreshold &&
|
Chris@343
|
1812 abs(ydiff) > smallThreshold &&
|
Chris@343
|
1813 canMoveVertical &&
|
Chris@343
|
1814 canMoveHorizontal) {
|
Chris@343
|
1815 // std::cerr << "Pane::updateDragMode: passed both thresholds" << std::endl;
|
Chris@343
|
1816 dragMode = FreeDrag;
|
Chris@343
|
1817 }
|
Chris@343
|
1818 }
|
Chris@343
|
1819
|
Chris@343
|
1820 if (dragMode == VerticalDrag && canMoveHorizontal) {
|
Chris@343
|
1821 if (abs(xdiff) > bigThreshold) dragMode = FreeDrag;
|
Chris@343
|
1822 }
|
Chris@343
|
1823
|
Chris@343
|
1824 if (dragMode == HorizontalDrag && canMoveVertical) {
|
Chris@343
|
1825 if (abs(ydiff) > bigThreshold) dragMode = FreeDrag;
|
Chris@343
|
1826 }
|
Chris@343
|
1827
|
Chris@343
|
1828 if (dragMode == UnresolvedDrag) {
|
Chris@343
|
1829 if (!resistHorizontal && xdiff != 0) {
|
Chris@343
|
1830 dragMode = HorizontalDrag;
|
Chris@343
|
1831 }
|
Chris@343
|
1832 if (!resistVertical && ydiff != 0) {
|
Chris@343
|
1833 if (dragMode == HorizontalDrag) dragMode = FreeDrag;
|
Chris@343
|
1834 else dragMode = VerticalDrag;
|
Chris@343
|
1835 }
|
Chris@343
|
1836 }
|
Chris@343
|
1837
|
Chris@343
|
1838 return dragMode;
|
Chris@343
|
1839 }
|
Chris@343
|
1840
|
Chris@174
|
1841 void
|
Chris@174
|
1842 Pane::dragExtendSelection(QMouseEvent *e)
|
Chris@174
|
1843 {
|
Chris@174
|
1844 int mouseFrame = getFrameForX(e->x());
|
Chris@174
|
1845 size_t resolution = 1;
|
Chris@174
|
1846 int snapFrameLeft = mouseFrame;
|
Chris@174
|
1847 int snapFrameRight = mouseFrame;
|
Chris@174
|
1848
|
Chris@174
|
1849 Layer *layer = getSelectedLayer();
|
Chris@174
|
1850 if (layer && !m_shiftPressed) {
|
Chris@174
|
1851 layer->snapToFeatureFrame(this, snapFrameLeft,
|
Chris@174
|
1852 resolution, Layer::SnapLeft);
|
Chris@174
|
1853 layer->snapToFeatureFrame(this, snapFrameRight,
|
Chris@174
|
1854 resolution, Layer::SnapRight);
|
Chris@174
|
1855 }
|
Chris@174
|
1856
|
Chris@174
|
1857 // std::cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << std::endl;
|
Chris@174
|
1858
|
Chris@174
|
1859 if (snapFrameLeft < 0) snapFrameLeft = 0;
|
Chris@174
|
1860 if (snapFrameRight < 0) snapFrameRight = 0;
|
Chris@174
|
1861
|
Chris@174
|
1862 size_t min, max;
|
Chris@174
|
1863
|
Chris@248
|
1864 if (m_selectionStartFrame > size_t(snapFrameLeft)) {
|
Chris@174
|
1865 min = snapFrameLeft;
|
Chris@174
|
1866 max = m_selectionStartFrame;
|
Chris@248
|
1867 } else if (size_t(snapFrameRight) > m_selectionStartFrame) {
|
Chris@174
|
1868 min = m_selectionStartFrame;
|
Chris@174
|
1869 max = snapFrameRight;
|
Chris@174
|
1870 } else {
|
Chris@174
|
1871 min = snapFrameLeft;
|
Chris@174
|
1872 max = snapFrameRight;
|
Chris@174
|
1873 }
|
Chris@174
|
1874
|
Chris@174
|
1875 if (m_manager) {
|
Chris@333
|
1876 m_manager->setInProgressSelection(Selection(alignToReference(min),
|
Chris@333
|
1877 alignToReference(max)),
|
Chris@174
|
1878 !m_resizing && !m_ctrlPressed);
|
Chris@174
|
1879 }
|
Chris@174
|
1880
|
Chris@259
|
1881 edgeScrollMaybe(e->x());
|
Chris@259
|
1882
|
Chris@259
|
1883 update();
|
Chris@259
|
1884 }
|
Chris@259
|
1885
|
Chris@259
|
1886 void
|
Chris@259
|
1887 Pane::edgeScrollMaybe(int x)
|
Chris@259
|
1888 {
|
Chris@259
|
1889 int mouseFrame = getFrameForX(x);
|
Chris@259
|
1890
|
Chris@174
|
1891 bool doScroll = false;
|
Chris@174
|
1892 if (!m_manager) doScroll = true;
|
Chris@174
|
1893 if (!m_manager->isPlaying()) doScroll = true;
|
Chris@174
|
1894 if (m_followPlay != PlaybackScrollContinuous) doScroll = true;
|
Chris@174
|
1895
|
Chris@174
|
1896 if (doScroll) {
|
Chris@174
|
1897 int offset = mouseFrame - getStartFrame();
|
Chris@174
|
1898 int available = getEndFrame() - getStartFrame();
|
Chris@259
|
1899 int move = 0;
|
Chris@174
|
1900 if (offset >= available * 0.95) {
|
Chris@259
|
1901 move = int(offset - available * 0.95) + 1;
|
Chris@259
|
1902 } else if (offset <= available * 0.10) {
|
Chris@259
|
1903 move = int(available * 0.10 - offset) + 1;
|
Chris@259
|
1904 move = -move;
|
Chris@259
|
1905 }
|
Chris@259
|
1906 if (move != 0) {
|
Chris@174
|
1907 setCentreFrame(m_centreFrame + move);
|
Chris@259
|
1908 update();
|
Chris@174
|
1909 }
|
Chris@174
|
1910 }
|
Chris@174
|
1911 }
|
Chris@174
|
1912
|
Chris@174
|
1913 void
|
Chris@127
|
1914 Pane::mouseDoubleClickEvent(QMouseEvent *e)
|
Chris@127
|
1915 {
|
Chris@127
|
1916 if (e->buttons() & Qt::RightButton) {
|
Chris@127
|
1917 return;
|
Chris@127
|
1918 }
|
Chris@127
|
1919
|
Chris@343
|
1920 // std::cerr << "mouseDoubleClickEvent" << std::endl;
|
Chris@127
|
1921
|
Chris@127
|
1922 m_clickPos = e->pos();
|
Chris@127
|
1923 m_clickedInRange = true;
|
Chris@127
|
1924 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier);
|
Chris@127
|
1925 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier);
|
Chris@127
|
1926
|
Chris@127
|
1927 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
1928 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
1929
|
Chris@255
|
1930 bool relocate = (mode == ViewManager::NavigateMode ||
|
Chris@255
|
1931 (e->buttons() & Qt::MidButton));
|
Chris@255
|
1932
|
Chris@127
|
1933 if (mode == ViewManager::NavigateMode ||
|
Chris@127
|
1934 mode == ViewManager::EditMode) {
|
Chris@127
|
1935
|
Chris@127
|
1936 Layer *layer = getSelectedLayer();
|
Chris@127
|
1937 if (layer && layer->isLayerEditable()) {
|
Chris@255
|
1938 if (layer->editOpen(this, e)) relocate = false;
|
Chris@127
|
1939 }
|
Chris@280
|
1940
|
Chris@280
|
1941 } else if (mode == ViewManager::MeasureMode) {
|
Chris@280
|
1942
|
Chris@280
|
1943 Layer *layer = getTopLayer();
|
Chris@280
|
1944 if (layer) layer->measureDoubleClick(this, e);
|
Chris@280
|
1945 update();
|
Chris@127
|
1946 }
|
Chris@255
|
1947
|
Chris@255
|
1948 if (relocate) {
|
Chris@255
|
1949
|
Chris@255
|
1950 long f = getFrameForX(e->x());
|
Chris@255
|
1951
|
Chris@255
|
1952 setCentreFrame(f);
|
Chris@255
|
1953
|
Chris@255
|
1954 m_dragCentreFrame = f;
|
Chris@255
|
1955 m_dragStartMinValue = 0;
|
Chris@255
|
1956 m_dragMode = UnresolvedDrag;
|
Chris@255
|
1957
|
Chris@255
|
1958 float vmin, vmax, dmin, dmax;
|
Chris@255
|
1959 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) {
|
Chris@255
|
1960 m_dragStartMinValue = dmin;
|
Chris@255
|
1961 }
|
Chris@255
|
1962 }
|
Chris@127
|
1963 }
|
Chris@127
|
1964
|
Chris@127
|
1965 void
|
Chris@290
|
1966 Pane::enterEvent(QEvent *)
|
Chris@290
|
1967 {
|
Chris@290
|
1968 m_mouseInWidget = true;
|
Chris@290
|
1969 }
|
Chris@290
|
1970
|
Chris@290
|
1971 void
|
Chris@127
|
1972 Pane::leaveEvent(QEvent *)
|
Chris@127
|
1973 {
|
Chris@290
|
1974 m_mouseInWidget = false;
|
Chris@127
|
1975 bool previouslyIdentifying = m_identifyFeatures;
|
Chris@127
|
1976 m_identifyFeatures = false;
|
Chris@127
|
1977 if (previouslyIdentifying) update();
|
Chris@189
|
1978 emit contextHelpChanged("");
|
Chris@127
|
1979 }
|
Chris@127
|
1980
|
Chris@127
|
1981 void
|
Chris@133
|
1982 Pane::resizeEvent(QResizeEvent *)
|
Chris@133
|
1983 {
|
Chris@133
|
1984 updateHeadsUpDisplay();
|
Chris@133
|
1985 }
|
Chris@133
|
1986
|
Chris@133
|
1987 void
|
Chris@127
|
1988 Pane::wheelEvent(QWheelEvent *e)
|
Chris@127
|
1989 {
|
Chris@127
|
1990 //std::cerr << "wheelEvent, delta " << e->delta() << std::endl;
|
Chris@127
|
1991
|
Chris@127
|
1992 int count = e->delta();
|
Chris@127
|
1993
|
Chris@127
|
1994 if (count > 0) {
|
Chris@127
|
1995 if (count >= 120) count /= 120;
|
Chris@127
|
1996 else count = 1;
|
Chris@127
|
1997 }
|
Chris@127
|
1998
|
Chris@127
|
1999 if (count < 0) {
|
Chris@127
|
2000 if (count <= -120) count /= 120;
|
Chris@127
|
2001 else count = -1;
|
Chris@127
|
2002 }
|
Chris@127
|
2003
|
Chris@127
|
2004 if (e->modifiers() & Qt::ControlModifier) {
|
Chris@127
|
2005
|
Chris@127
|
2006 // Scroll left or right, rapidly
|
Chris@127
|
2007
|
Chris@127
|
2008 if (getStartFrame() < 0 &&
|
Chris@127
|
2009 getEndFrame() >= getModelsEndFrame()) return;
|
Chris@127
|
2010
|
Chris@127
|
2011 long delta = ((width() / 2) * count * m_zoomLevel);
|
Chris@127
|
2012
|
Chris@127
|
2013 if (int(m_centreFrame) < delta) {
|
Chris@127
|
2014 setCentreFrame(0);
|
Chris@127
|
2015 } else if (int(m_centreFrame) - delta >= int(getModelsEndFrame())) {
|
Chris@127
|
2016 setCentreFrame(getModelsEndFrame());
|
Chris@127
|
2017 } else {
|
Chris@127
|
2018 setCentreFrame(m_centreFrame - delta);
|
Chris@127
|
2019 }
|
Chris@127
|
2020
|
Chris@256
|
2021 } else if (e->modifiers() & Qt::ShiftModifier) {
|
Chris@256
|
2022
|
Chris@256
|
2023 // Zoom vertically
|
Chris@256
|
2024
|
Chris@256
|
2025 if (m_vpan) {
|
Chris@256
|
2026 m_vpan->scroll(e->delta() > 0);
|
Chris@256
|
2027 }
|
Chris@256
|
2028
|
Chris@256
|
2029 } else if (e->modifiers() & Qt::AltModifier) {
|
Chris@256
|
2030
|
Chris@256
|
2031 // Zoom vertically
|
Chris@256
|
2032
|
Chris@256
|
2033 if (m_vthumb) {
|
Chris@256
|
2034 m_vthumb->scroll(e->delta() > 0);
|
Chris@256
|
2035 }
|
Chris@256
|
2036
|
Chris@127
|
2037 } else {
|
Chris@127
|
2038
|
Chris@127
|
2039 // Zoom in or out
|
Chris@127
|
2040
|
Chris@127
|
2041 int newZoomLevel = m_zoomLevel;
|
Chris@127
|
2042
|
Chris@127
|
2043 while (count > 0) {
|
Chris@127
|
2044 if (newZoomLevel <= 2) {
|
Chris@127
|
2045 newZoomLevel = 1;
|
Chris@127
|
2046 break;
|
Chris@127
|
2047 }
|
Chris@127
|
2048 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1,
|
Chris@127
|
2049 ZoomConstraint::RoundDown);
|
Chris@127
|
2050 --count;
|
Chris@127
|
2051 }
|
Chris@127
|
2052
|
Chris@127
|
2053 while (count < 0) {
|
Chris@127
|
2054 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1,
|
Chris@127
|
2055 ZoomConstraint::RoundUp);
|
Chris@127
|
2056 ++count;
|
Chris@127
|
2057 }
|
Chris@127
|
2058
|
Chris@127
|
2059 if (newZoomLevel != m_zoomLevel) {
|
Chris@127
|
2060 setZoomLevel(newZoomLevel);
|
Chris@127
|
2061 }
|
Chris@127
|
2062 }
|
Chris@127
|
2063
|
Chris@127
|
2064 emit paneInteractedWith();
|
Chris@127
|
2065 }
|
Chris@127
|
2066
|
Chris@132
|
2067 void
|
Chris@132
|
2068 Pane::horizontalThumbwheelMoved(int value)
|
Chris@132
|
2069 {
|
Chris@137
|
2070 //!!! dupe with updateHeadsUpDisplay
|
Chris@137
|
2071
|
Chris@132
|
2072 int count = 0;
|
Chris@132
|
2073 int level = 1;
|
Chris@137
|
2074
|
Chris@137
|
2075
|
Chris@137
|
2076 //!!! pull out into function (presumably in View)
|
Chris@137
|
2077 bool haveConstraint = false;
|
Chris@137
|
2078 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end();
|
Chris@137
|
2079 ++i) {
|
Chris@137
|
2080 if ((*i)->getZoomConstraint() && !(*i)->supportsOtherZoomLevels()) {
|
Chris@137
|
2081 haveConstraint = true;
|
Chris@137
|
2082 break;
|
Chris@137
|
2083 }
|
Chris@132
|
2084 }
|
Chris@132
|
2085
|
Chris@137
|
2086 if (haveConstraint) {
|
Chris@137
|
2087 while (true) {
|
Chris@137
|
2088 if (m_hthumb->getMaximumValue() - value == count) break;
|
Chris@137
|
2089 int newLevel = getZoomConstraintBlockSize(level + 1,
|
Chris@137
|
2090 ZoomConstraint::RoundUp);
|
Chris@137
|
2091 if (newLevel == level) break;
|
Chris@137
|
2092 level = newLevel;
|
Chris@137
|
2093 if (++count == 50) break;
|
Chris@137
|
2094 }
|
Chris@137
|
2095 } else {
|
Chris@137
|
2096 while (true) {
|
Chris@137
|
2097 if (m_hthumb->getMaximumValue() - value == count) break;
|
Chris@137
|
2098 int step = level / 10;
|
Chris@137
|
2099 int pwr = 0;
|
Chris@137
|
2100 while (step > 0) {
|
Chris@137
|
2101 ++pwr;
|
Chris@137
|
2102 step /= 2;
|
Chris@137
|
2103 }
|
Chris@137
|
2104 step = 1;
|
Chris@137
|
2105 while (pwr > 0) {
|
Chris@137
|
2106 step *= 2;
|
Chris@137
|
2107 --pwr;
|
Chris@137
|
2108 }
|
Chris@137
|
2109 // std::cerr << level << std::endl;
|
Chris@137
|
2110 level += step;
|
Chris@137
|
2111 if (++count == 100 || level > 262144) break;
|
Chris@137
|
2112 }
|
Chris@137
|
2113 }
|
Chris@137
|
2114
|
Chris@244
|
2115 // std::cerr << "new level is " << level << std::endl;
|
Chris@132
|
2116 setZoomLevel(level);
|
Chris@132
|
2117 }
|
Chris@132
|
2118
|
Chris@132
|
2119 void
|
Chris@132
|
2120 Pane::verticalThumbwheelMoved(int value)
|
Chris@132
|
2121 {
|
Chris@133
|
2122 Layer *layer = 0;
|
Chris@133
|
2123 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
2124 if (layer) {
|
Chris@133
|
2125 int defaultStep = 0;
|
Chris@133
|
2126 int max = layer->getVerticalZoomSteps(defaultStep);
|
Chris@133
|
2127 if (max == 0) {
|
Chris@133
|
2128 updateHeadsUpDisplay();
|
Chris@133
|
2129 return;
|
Chris@133
|
2130 }
|
Chris@133
|
2131 if (value > max) {
|
Chris@133
|
2132 value = max;
|
Chris@133
|
2133 }
|
Chris@133
|
2134 layer->setVerticalZoomStep(value);
|
Chris@174
|
2135 updateVerticalPanner();
|
Chris@133
|
2136 }
|
Chris@132
|
2137 }
|
Chris@132
|
2138
|
Chris@174
|
2139 void
|
Chris@174
|
2140 Pane::verticalPannerMoved(float x0, float y0, float w, float h)
|
Chris@174
|
2141 {
|
Chris@174
|
2142 float vmin, vmax, dmin, dmax;
|
Chris@174
|
2143 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return;
|
Chris@174
|
2144 float y1 = y0 + h;
|
Chris@174
|
2145 float newmax = vmin + ((1.0 - y0) * (vmax - vmin));
|
Chris@174
|
2146 float newmin = vmin + ((1.0 - y1) * (vmax - vmin));
|
Chris@438
|
2147 // std::cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w
|
Chris@438
|
2148 // << "," << h << ") -> (" << newmin << "," << newmax << ")" << std::endl;
|
Chris@174
|
2149 setTopLayerDisplayExtents(newmin, newmax);
|
Chris@174
|
2150 }
|
Chris@174
|
2151
|
Chris@188
|
2152 void
|
Chris@188
|
2153 Pane::editVerticalPannerExtents()
|
Chris@188
|
2154 {
|
Chris@188
|
2155 if (!m_vpan || !m_manager || !m_manager->getZoomWheelsEnabled()) return;
|
Chris@188
|
2156
|
Chris@188
|
2157 float vmin, vmax, dmin, dmax;
|
Chris@188
|
2158 QString unit;
|
Chris@188
|
2159 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax, &unit)
|
Chris@188
|
2160 || vmax == vmin) {
|
Chris@188
|
2161 return;
|
Chris@188
|
2162 }
|
Chris@188
|
2163
|
Chris@188
|
2164 RangeInputDialog dialog(tr("Enter new range"),
|
Chris@188
|
2165 tr("New vertical display range, from %1 to %2 %4:")
|
Chris@188
|
2166 .arg(vmin).arg(vmax).arg(unit),
|
Chris@188
|
2167 unit, vmin, vmax, this);
|
Chris@188
|
2168 dialog.setRange(dmin, dmax);
|
Chris@188
|
2169
|
Chris@188
|
2170 if (dialog.exec() == QDialog::Accepted) {
|
Chris@188
|
2171 dialog.getRange(dmin, dmax);
|
Chris@188
|
2172 setTopLayerDisplayExtents(dmin, dmax);
|
Chris@188
|
2173 updateVerticalPanner();
|
Chris@188
|
2174 }
|
Chris@188
|
2175 }
|
Chris@188
|
2176
|
Chris@312
|
2177 void
|
Chris@437
|
2178 Pane::layerParametersChanged()
|
Chris@437
|
2179 {
|
Chris@437
|
2180 View::layerParametersChanged();
|
Chris@437
|
2181 updateHeadsUpDisplay();
|
Chris@437
|
2182 }
|
Chris@437
|
2183
|
Chris@437
|
2184 void
|
Chris@312
|
2185 Pane::dragEnterEvent(QDragEnterEvent *e)
|
Chris@312
|
2186 {
|
Chris@312
|
2187 QStringList formats(e->mimeData()->formats());
|
Chris@312
|
2188 std::cerr << "dragEnterEvent: format: "
|
Chris@312
|
2189 << formats.join(",").toStdString()
|
Chris@312
|
2190 << ", possibleActions: " << e->possibleActions()
|
Chris@312
|
2191 << ", proposedAction: " << e->proposedAction() << std::endl;
|
Chris@312
|
2192
|
Chris@312
|
2193 if (e->provides("text/uri-list") || e->provides("text/plain")) {
|
Chris@312
|
2194
|
Chris@312
|
2195 if (e->proposedAction() & Qt::CopyAction) {
|
Chris@312
|
2196 e->acceptProposedAction();
|
Chris@312
|
2197 } else {
|
Chris@312
|
2198 e->setDropAction(Qt::CopyAction);
|
Chris@312
|
2199 e->accept();
|
Chris@312
|
2200 }
|
Chris@312
|
2201 }
|
Chris@312
|
2202 }
|
Chris@312
|
2203
|
Chris@312
|
2204 void
|
Chris@312
|
2205 Pane::dropEvent(QDropEvent *e)
|
Chris@312
|
2206 {
|
Chris@312
|
2207 std::cerr << "dropEvent: text: \"" << e->mimeData()->text().toStdString()
|
Chris@312
|
2208 << "\"" << std::endl;
|
Chris@312
|
2209
|
Chris@312
|
2210 if (e->provides("text/uri-list") || e->provides("text/plain")) {
|
Chris@312
|
2211
|
Chris@312
|
2212 if (e->proposedAction() & Qt::CopyAction) {
|
Chris@312
|
2213 e->acceptProposedAction();
|
Chris@312
|
2214 } else {
|
Chris@312
|
2215 e->setDropAction(Qt::CopyAction);
|
Chris@312
|
2216 e->accept();
|
Chris@312
|
2217 }
|
Chris@312
|
2218
|
Chris@312
|
2219 if (e->provides("text/uri-list")) {
|
Chris@312
|
2220
|
Chris@312
|
2221 std::cerr << "accepting... data is \"" << e->encodedData("text/uri-list").data() << "\"" << std::endl;
|
Chris@312
|
2222 emit dropAccepted(QString::fromLocal8Bit
|
Chris@312
|
2223 (e->encodedData("text/uri-list").data())
|
Chris@312
|
2224 .split(QRegExp("[\\r\\n]+"),
|
Chris@312
|
2225 QString::SkipEmptyParts));
|
Chris@312
|
2226 } else {
|
Chris@312
|
2227 emit dropAccepted(QString::fromLocal8Bit
|
Chris@312
|
2228 (e->encodedData("text/plain").data()));
|
Chris@312
|
2229 }
|
Chris@312
|
2230 }
|
Chris@312
|
2231 }
|
Chris@312
|
2232
|
Chris@127
|
2233 bool
|
Chris@127
|
2234 Pane::editSelectionStart(QMouseEvent *e)
|
Chris@127
|
2235 {
|
Chris@127
|
2236 if (!m_identifyFeatures ||
|
Chris@127
|
2237 !m_manager ||
|
Chris@127
|
2238 m_manager->getToolMode() != ViewManager::EditMode) {
|
Chris@127
|
2239 return false;
|
Chris@127
|
2240 }
|
Chris@127
|
2241
|
Chris@127
|
2242 bool closeToLeft, closeToRight;
|
Chris@127
|
2243 Selection s(getSelectionAt(e->x(), closeToLeft, closeToRight));
|
Chris@127
|
2244 if (s.isEmpty()) return false;
|
Chris@127
|
2245 m_editingSelection = s;
|
Chris@127
|
2246 m_editingSelectionEdge = (closeToLeft ? -1 : closeToRight ? 1 : 0);
|
Chris@127
|
2247 m_mousePos = e->pos();
|
Chris@127
|
2248 return true;
|
Chris@127
|
2249 }
|
Chris@127
|
2250
|
Chris@127
|
2251 bool
|
Chris@127
|
2252 Pane::editSelectionDrag(QMouseEvent *e)
|
Chris@127
|
2253 {
|
Chris@127
|
2254 if (m_editingSelection.isEmpty()) return false;
|
Chris@127
|
2255 m_mousePos = e->pos();
|
Chris@127
|
2256 update();
|
Chris@127
|
2257 return true;
|
Chris@127
|
2258 }
|
Chris@127
|
2259
|
Chris@127
|
2260 bool
|
Chris@248
|
2261 Pane::editSelectionEnd(QMouseEvent *)
|
Chris@127
|
2262 {
|
Chris@127
|
2263 if (m_editingSelection.isEmpty()) return false;
|
Chris@127
|
2264
|
Chris@127
|
2265 int offset = m_mousePos.x() - m_clickPos.x();
|
Chris@127
|
2266 Layer *layer = getSelectedLayer();
|
Chris@127
|
2267
|
Chris@127
|
2268 if (offset == 0 || !layer) {
|
Chris@127
|
2269 m_editingSelection = Selection();
|
Chris@127
|
2270 return true;
|
Chris@127
|
2271 }
|
Chris@127
|
2272
|
Chris@127
|
2273 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset;
|
Chris@127
|
2274 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset;
|
Chris@127
|
2275
|
Chris@127
|
2276 long f0 = getFrameForX(p0);
|
Chris@127
|
2277 long f1 = getFrameForX(p1);
|
Chris@127
|
2278
|
Chris@127
|
2279 Selection newSelection(f0, f1);
|
Chris@127
|
2280
|
Chris@127
|
2281 if (m_editingSelectionEdge == 0) {
|
Chris@127
|
2282
|
Chris@127
|
2283 CommandHistory::getInstance()->startCompoundOperation
|
Chris@127
|
2284 (tr("Drag Selection"), true);
|
Chris@127
|
2285
|
Chris@127
|
2286 layer->moveSelection(m_editingSelection, f0);
|
Chris@127
|
2287
|
Chris@127
|
2288 } else {
|
Chris@127
|
2289
|
Chris@127
|
2290 CommandHistory::getInstance()->startCompoundOperation
|
Chris@127
|
2291 (tr("Resize Selection"), true);
|
Chris@127
|
2292
|
Chris@127
|
2293 if (m_editingSelectionEdge < 0) {
|
Chris@127
|
2294 f1 = m_editingSelection.getEndFrame();
|
Chris@127
|
2295 } else {
|
Chris@127
|
2296 f0 = m_editingSelection.getStartFrame();
|
Chris@127
|
2297 }
|
Chris@127
|
2298
|
Chris@127
|
2299 newSelection = Selection(f0, f1);
|
Chris@127
|
2300 layer->resizeSelection(m_editingSelection, newSelection);
|
Chris@127
|
2301 }
|
Chris@127
|
2302
|
Chris@127
|
2303 m_manager->removeSelection(m_editingSelection);
|
Chris@127
|
2304 m_manager->addSelection(newSelection);
|
Chris@127
|
2305
|
Chris@127
|
2306 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@127
|
2307
|
Chris@127
|
2308 m_editingSelection = Selection();
|
Chris@127
|
2309 return true;
|
Chris@127
|
2310 }
|
Chris@127
|
2311
|
Chris@127
|
2312 void
|
Chris@127
|
2313 Pane::toolModeChanged()
|
Chris@127
|
2314 {
|
Chris@127
|
2315 ViewManager::ToolMode mode = m_manager->getToolMode();
|
Chris@127
|
2316 // std::cerr << "Pane::toolModeChanged(" << mode << ")" << std::endl;
|
Chris@127
|
2317
|
Chris@267
|
2318 if (mode == ViewManager::MeasureMode && !m_measureCursor1) {
|
Chris@267
|
2319 m_measureCursor1 = new QCursor(QBitmap(":/icons/measure1cursor.xbm"),
|
Chris@267
|
2320 QBitmap(":/icons/measure1mask.xbm"),
|
Chris@267
|
2321 15, 14);
|
Chris@267
|
2322 m_measureCursor2 = new QCursor(QBitmap(":/icons/measure2cursor.xbm"),
|
Chris@267
|
2323 QBitmap(":/icons/measure2mask.xbm"),
|
Chris@267
|
2324 16, 17);
|
Chris@257
|
2325 }
|
Chris@257
|
2326
|
Chris@127
|
2327 switch (mode) {
|
Chris@127
|
2328
|
Chris@127
|
2329 case ViewManager::NavigateMode:
|
Chris@127
|
2330 setCursor(Qt::PointingHandCursor);
|
Chris@127
|
2331 break;
|
Chris@127
|
2332
|
Chris@127
|
2333 case ViewManager::SelectMode:
|
Chris@127
|
2334 setCursor(Qt::ArrowCursor);
|
Chris@127
|
2335 break;
|
Chris@127
|
2336
|
Chris@127
|
2337 case ViewManager::EditMode:
|
Chris@127
|
2338 setCursor(Qt::UpArrowCursor);
|
Chris@127
|
2339 break;
|
Chris@127
|
2340
|
Chris@127
|
2341 case ViewManager::DrawMode:
|
Chris@127
|
2342 setCursor(Qt::CrossCursor);
|
Chris@127
|
2343 break;
|
Chris@335
|
2344
|
Chris@335
|
2345 case ViewManager::EraseMode:
|
Chris@335
|
2346 setCursor(Qt::CrossCursor);
|
Chris@335
|
2347 break;
|
Chris@257
|
2348
|
Chris@257
|
2349 case ViewManager::MeasureMode:
|
Chris@267
|
2350 if (m_measureCursor1) setCursor(*m_measureCursor1);
|
Chris@257
|
2351 break;
|
Chris@257
|
2352
|
Chris@127
|
2353 /*
|
Chris@127
|
2354 case ViewManager::TextMode:
|
Chris@127
|
2355 setCursor(Qt::IBeamCursor);
|
Chris@127
|
2356 break;
|
Chris@127
|
2357 */
|
Chris@127
|
2358 }
|
Chris@127
|
2359 }
|
Chris@127
|
2360
|
Chris@133
|
2361 void
|
Chris@133
|
2362 Pane::zoomWheelsEnabledChanged()
|
Chris@133
|
2363 {
|
Chris@133
|
2364 updateHeadsUpDisplay();
|
Chris@133
|
2365 update();
|
Chris@133
|
2366 }
|
Chris@133
|
2367
|
Chris@133
|
2368 void
|
Chris@224
|
2369 Pane::viewZoomLevelChanged(View *v, unsigned long z, bool locked)
|
Chris@133
|
2370 {
|
Chris@212
|
2371 // std::cerr << "Pane[" << this << "]::zoomLevelChanged (global now "
|
Chris@212
|
2372 // << (m_manager ? m_manager->getGlobalZoom() : 0) << ")" << std::endl;
|
Chris@192
|
2373
|
Chris@224
|
2374 View::viewZoomLevelChanged(v, z, locked);
|
Chris@224
|
2375
|
Chris@232
|
2376 if (m_hthumb && !m_hthumb->isVisible()) return;
|
Chris@224
|
2377
|
Chris@222
|
2378 if (v != this) {
|
Chris@222
|
2379 if (!locked || !m_followZoom) return;
|
Chris@222
|
2380 }
|
Chris@222
|
2381
|
Chris@133
|
2382 if (m_manager && m_manager->getZoomWheelsEnabled()) {
|
Chris@133
|
2383 updateHeadsUpDisplay();
|
Chris@133
|
2384 }
|
Chris@133
|
2385 }
|
Chris@133
|
2386
|
Chris@133
|
2387 void
|
Chris@133
|
2388 Pane::propertyContainerSelected(View *v, PropertyContainer *pc)
|
Chris@133
|
2389 {
|
Chris@133
|
2390 Layer *layer = 0;
|
Chris@133
|
2391
|
Chris@133
|
2392 if (getLayerCount() > 0) {
|
Chris@133
|
2393 layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
2394 disconnect(layer, SIGNAL(verticalZoomChanged()),
|
Chris@133
|
2395 this, SLOT(verticalZoomChanged()));
|
Chris@133
|
2396 }
|
Chris@133
|
2397
|
Chris@133
|
2398 View::propertyContainerSelected(v, pc);
|
Chris@133
|
2399 updateHeadsUpDisplay();
|
Chris@133
|
2400
|
Chris@187
|
2401 if (m_vthumb) {
|
Chris@187
|
2402 RangeMapper *rm = 0;
|
Chris@187
|
2403 if (layer) rm = layer->getNewVerticalZoomRangeMapper();
|
Chris@187
|
2404 if (rm) m_vthumb->setRangeMapper(rm);
|
Chris@187
|
2405 }
|
Chris@187
|
2406
|
Chris@133
|
2407 if (getLayerCount() > 0) {
|
Chris@133
|
2408 layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
2409 connect(layer, SIGNAL(verticalZoomChanged()),
|
Chris@133
|
2410 this, SLOT(verticalZoomChanged()));
|
Chris@133
|
2411 }
|
Chris@133
|
2412 }
|
Chris@133
|
2413
|
Chris@133
|
2414 void
|
Chris@133
|
2415 Pane::verticalZoomChanged()
|
Chris@133
|
2416 {
|
Chris@133
|
2417 Layer *layer = 0;
|
Chris@133
|
2418
|
Chris@133
|
2419 if (getLayerCount() > 0) {
|
Chris@133
|
2420
|
Chris@133
|
2421 layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
2422
|
Chris@133
|
2423 if (m_vthumb && m_vthumb->isVisible()) {
|
Chris@133
|
2424 m_vthumb->setValue(layer->getCurrentVerticalZoomStep());
|
Chris@133
|
2425 }
|
Chris@133
|
2426 }
|
Chris@133
|
2427 }
|
Chris@133
|
2428
|
Chris@189
|
2429 void
|
Chris@189
|
2430 Pane::updateContextHelp(const QPoint *pos)
|
Chris@189
|
2431 {
|
Chris@189
|
2432 QString help = "";
|
Chris@189
|
2433
|
Chris@189
|
2434 if (m_clickedInRange) {
|
Chris@189
|
2435 emit contextHelpChanged("");
|
Chris@189
|
2436 return;
|
Chris@189
|
2437 }
|
Chris@189
|
2438
|
Chris@189
|
2439 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@189
|
2440 if (m_manager) mode = m_manager->getToolMode();
|
Chris@189
|
2441
|
Chris@189
|
2442 bool editable = false;
|
Chris@189
|
2443 Layer *layer = getSelectedLayer();
|
Chris@189
|
2444 if (layer && layer->isLayerEditable()) {
|
Chris@189
|
2445 editable = true;
|
Chris@189
|
2446 }
|
Chris@189
|
2447
|
Chris@189
|
2448 if (mode == ViewManager::NavigateMode) {
|
Chris@189
|
2449
|
Chris@189
|
2450 help = tr("Click and drag to navigate");
|
Chris@189
|
2451
|
Chris@189
|
2452 } else if (mode == ViewManager::SelectMode) {
|
Chris@189
|
2453
|
Chris@217
|
2454 if (!hasTopLayerTimeXAxis()) return;
|
Chris@217
|
2455
|
Chris@189
|
2456 bool haveSelection = (m_manager && !m_manager->getSelections().empty());
|
Chris@189
|
2457
|
Chris@189
|
2458 if (haveSelection) {
|
Chris@189
|
2459 if (editable) {
|
Chris@189
|
2460 help = tr("Click and drag to select a range; hold Shift to avoid snapping to items; hold Ctrl for multi-select; middle-click and drag to navigate");
|
Chris@189
|
2461 } else {
|
Chris@189
|
2462 help = tr("Click and drag to select a range; hold Ctrl for multi-select; middle-click and drag to navigate");
|
Chris@189
|
2463 }
|
Chris@189
|
2464
|
Chris@189
|
2465 if (pos) {
|
Chris@189
|
2466 bool closeToLeft = false, closeToRight = false;
|
Chris@189
|
2467 Selection selection = getSelectionAt(pos->x(), closeToLeft, closeToRight);
|
Chris@189
|
2468 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) {
|
Chris@189
|
2469
|
Chris@189
|
2470 help = tr("Click and drag to move the selection boundary");
|
Chris@189
|
2471 }
|
Chris@189
|
2472 }
|
Chris@189
|
2473 } else {
|
Chris@189
|
2474 if (editable) {
|
Chris@189
|
2475 help = tr("Click and drag to select a range; hold Shift to avoid snapping to items; middle-click to navigate");
|
Chris@189
|
2476 } else {
|
Chris@189
|
2477 help = tr("Click and drag to select a range; middle-click and drag to navigate");
|
Chris@189
|
2478 }
|
Chris@189
|
2479 }
|
Chris@189
|
2480
|
Chris@189
|
2481 } else if (mode == ViewManager::DrawMode) {
|
Chris@189
|
2482
|
Chris@189
|
2483 //!!! could call through to a layer function to find out exact meaning
|
Chris@189
|
2484 if (editable) {
|
Chris@189
|
2485 help = tr("Click to add a new item in the active layer");
|
Chris@189
|
2486 }
|
Chris@335
|
2487
|
Chris@335
|
2488 } else if (mode == ViewManager::EraseMode) {
|
Chris@335
|
2489
|
Chris@335
|
2490 //!!! could call through to a layer function to find out exact meaning
|
Chris@335
|
2491 if (editable) {
|
Chris@335
|
2492 help = tr("Click to erase an item from the active layer");
|
Chris@335
|
2493 }
|
Chris@189
|
2494
|
Chris@189
|
2495 } else if (mode == ViewManager::EditMode) {
|
Chris@189
|
2496
|
Chris@189
|
2497 //!!! could call through to layer
|
Chris@189
|
2498 if (editable) {
|
Chris@189
|
2499 help = tr("Click and drag an item in the active layer to move it");
|
Chris@189
|
2500 if (pos) {
|
Chris@189
|
2501 bool closeToLeft = false, closeToRight = false;
|
Chris@189
|
2502 Selection selection = getSelectionAt(pos->x(), closeToLeft, closeToRight);
|
Chris@189
|
2503 if (!selection.isEmpty()) {
|
Chris@189
|
2504 help = tr("Click and drag to move all items in the selected range");
|
Chris@189
|
2505 }
|
Chris@189
|
2506 }
|
Chris@189
|
2507 }
|
Chris@189
|
2508 }
|
Chris@189
|
2509
|
Chris@189
|
2510 emit contextHelpChanged(help);
|
Chris@189
|
2511 }
|
Chris@189
|
2512
|
Chris@189
|
2513 void
|
Chris@189
|
2514 Pane::mouseEnteredWidget()
|
Chris@189
|
2515 {
|
Chris@189
|
2516 QWidget *w = dynamic_cast<QWidget *>(sender());
|
Chris@189
|
2517 if (!w) return;
|
Chris@189
|
2518
|
Chris@189
|
2519 if (w == m_vpan) {
|
Chris@189
|
2520 emit contextHelpChanged(tr("Click and drag to adjust the visible range of the vertical scale"));
|
Chris@189
|
2521 } else if (w == m_vthumb) {
|
Chris@189
|
2522 emit contextHelpChanged(tr("Click and drag to adjust the vertical zoom level"));
|
Chris@189
|
2523 } else if (w == m_hthumb) {
|
Chris@189
|
2524 emit contextHelpChanged(tr("Click and drag to adjust the horizontal zoom level"));
|
Chris@189
|
2525 } else if (w == m_reset) {
|
Chris@189
|
2526 emit contextHelpChanged(tr("Reset horizontal and vertical zoom levels to their defaults"));
|
Chris@189
|
2527 }
|
Chris@189
|
2528 }
|
Chris@189
|
2529
|
Chris@189
|
2530 void
|
Chris@189
|
2531 Pane::mouseLeftWidget()
|
Chris@189
|
2532 {
|
Chris@189
|
2533 emit contextHelpChanged("");
|
Chris@189
|
2534 }
|
Chris@189
|
2535
|
Chris@316
|
2536 void
|
Chris@316
|
2537 Pane::toXml(QTextStream &stream,
|
Chris@316
|
2538 QString indent, QString extraAttributes) const
|
Chris@127
|
2539 {
|
Chris@316
|
2540 View::toXml
|
Chris@316
|
2541 (stream, indent,
|
Chris@127
|
2542 QString("type=\"pane\" centreLineVisible=\"%1\" height=\"%2\" %3")
|
Chris@127
|
2543 .arg(m_centreLineVisible).arg(height()).arg(extraAttributes));
|
Chris@127
|
2544 }
|
Chris@127
|
2545
|
Chris@127
|
2546
|