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