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@182
|
7 This file copyright 2006 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@127
|
23 #include "base/CommandHistory.h"
|
Chris@127
|
24 #include "layer/WaveformLayer.h"
|
Chris@127
|
25
|
Chris@127
|
26 #include <QPaintEvent>
|
Chris@127
|
27 #include <QPainter>
|
Chris@127
|
28 #include <iostream>
|
Chris@127
|
29 #include <cmath>
|
Chris@127
|
30
|
Chris@133
|
31 //!!! for HUD -- pull out into a separate class
|
Chris@133
|
32 #include <QFrame>
|
Chris@133
|
33 #include <QGridLayout>
|
Chris@133
|
34 #include <QPushButton>
|
Chris@133
|
35 #include "widgets/Thumbwheel.h"
|
Chris@172
|
36 #include "widgets/Panner.h"
|
Chris@188
|
37 #include "widgets/RangeInputDialog.h"
|
Chris@189
|
38 #include "widgets/NotifyingPushButton.h"
|
Chris@133
|
39
|
Chris@127
|
40 using std::cerr;
|
Chris@127
|
41 using std::endl;
|
Chris@127
|
42
|
Chris@127
|
43 Pane::Pane(QWidget *w) :
|
Chris@127
|
44 View(w, true),
|
Chris@127
|
45 m_identifyFeatures(false),
|
Chris@127
|
46 m_clickedInRange(false),
|
Chris@127
|
47 m_shiftPressed(false),
|
Chris@127
|
48 m_ctrlPressed(false),
|
Chris@127
|
49 m_navigating(false),
|
Chris@127
|
50 m_resizing(false),
|
Chris@133
|
51 m_centreLineVisible(true),
|
Chris@133
|
52 m_headsUpDisplay(0)
|
Chris@127
|
53 {
|
Chris@127
|
54 setObjectName("Pane");
|
Chris@127
|
55 setMouseTracking(true);
|
Chris@133
|
56
|
Chris@133
|
57 updateHeadsUpDisplay();
|
Chris@133
|
58 }
|
Chris@133
|
59
|
Chris@133
|
60 void
|
Chris@133
|
61 Pane::updateHeadsUpDisplay()
|
Chris@133
|
62 {
|
Chris@187
|
63 Profiler profiler("Pane::updateHeadsUpDisplay", true);
|
Chris@187
|
64
|
Chris@132
|
65 /*
|
Chris@132
|
66 int count = 0;
|
Chris@132
|
67 int currentLevel = 1;
|
Chris@132
|
68 int level = 1;
|
Chris@132
|
69 while (true) {
|
Chris@132
|
70 if (getZoomLevel() == level) currentLevel = count;
|
Chris@132
|
71 int newLevel = getZoomConstraintBlockSize(level + 1,
|
Chris@132
|
72 ZoomConstraint::RoundUp);
|
Chris@132
|
73 if (newLevel == level) break;
|
Chris@132
|
74 if (newLevel == 131072) break; //!!! just because
|
Chris@132
|
75 level = newLevel;
|
Chris@132
|
76 ++count;
|
Chris@132
|
77 }
|
Chris@132
|
78
|
Chris@132
|
79 std::cerr << "Have " << count+1 << " zoom levels" << std::endl;
|
Chris@132
|
80 */
|
Chris@133
|
81
|
Chris@188
|
82 Layer *layer = 0;
|
Chris@188
|
83 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@188
|
84
|
Chris@133
|
85 if (!m_headsUpDisplay) {
|
Chris@133
|
86
|
Chris@133
|
87 m_headsUpDisplay = new QFrame(this);
|
Chris@133
|
88
|
Chris@133
|
89 QGridLayout *layout = new QGridLayout;
|
Chris@133
|
90 layout->setMargin(0);
|
Chris@133
|
91 layout->setSpacing(0);
|
Chris@133
|
92 m_headsUpDisplay->setLayout(layout);
|
Chris@133
|
93
|
Chris@133
|
94 m_hthumb = new Thumbwheel(Qt::Horizontal);
|
Chris@187
|
95 m_hthumb->setObjectName(tr("Horizontal Zoom"));
|
Chris@173
|
96 layout->addWidget(m_hthumb, 1, 0, 1, 2);
|
Chris@133
|
97 m_hthumb->setFixedWidth(70);
|
Chris@133
|
98 m_hthumb->setFixedHeight(16);
|
Chris@133
|
99 m_hthumb->setDefaultValue(0);
|
Chris@165
|
100 m_hthumb->setSpeed(0.6);
|
Chris@133
|
101 connect(m_hthumb, SIGNAL(valueChanged(int)), this,
|
Chris@133
|
102 SLOT(horizontalThumbwheelMoved(int)));
|
Chris@189
|
103 connect(m_hthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
104 connect(m_hthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@172
|
105
|
Chris@172
|
106 m_vpan = new Panner;
|
Chris@172
|
107 layout->addWidget(m_vpan, 0, 1);
|
Chris@173
|
108 m_vpan->setFixedWidth(12);
|
Chris@172
|
109 m_vpan->setFixedHeight(70);
|
Chris@174
|
110 m_vpan->setAlpha(80, 130);
|
Chris@174
|
111 connect(m_vpan, SIGNAL(rectExtentsChanged(float, float, float, float)),
|
Chris@174
|
112 this, SLOT(verticalPannerMoved(float, float, float, float)));
|
Chris@188
|
113 connect(m_vpan, SIGNAL(doubleClicked()),
|
Chris@188
|
114 this, SLOT(editVerticalPannerExtents()));
|
Chris@189
|
115 connect(m_vpan, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
116 connect(m_vpan, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@172
|
117
|
Chris@133
|
118 m_vthumb = new Thumbwheel(Qt::Vertical);
|
Chris@187
|
119 m_vthumb->setObjectName(tr("Vertical Zoom"));
|
Chris@172
|
120 layout->addWidget(m_vthumb, 0, 2);
|
Chris@133
|
121 m_vthumb->setFixedWidth(16);
|
Chris@133
|
122 m_vthumb->setFixedHeight(70);
|
Chris@133
|
123 connect(m_vthumb, SIGNAL(valueChanged(int)), this,
|
Chris@133
|
124 SLOT(verticalThumbwheelMoved(int)));
|
Chris@189
|
125 connect(m_vthumb, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
126 connect(m_vthumb, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@133
|
127
|
Chris@188
|
128 if (layer) {
|
Chris@188
|
129 RangeMapper *rm = layer->getNewVerticalZoomRangeMapper();
|
Chris@188
|
130 if (rm) m_vthumb->setRangeMapper(rm);
|
Chris@188
|
131 }
|
Chris@188
|
132
|
Chris@189
|
133 m_reset = new NotifyingPushButton;
|
Chris@189
|
134 m_reset->setFixedHeight(16);
|
Chris@189
|
135 m_reset->setFixedWidth(16);
|
Chris@189
|
136 layout->addWidget(m_reset, 1, 2);
|
Chris@189
|
137 connect(m_reset, SIGNAL(clicked()), m_hthumb, SLOT(resetToDefault()));
|
Chris@189
|
138 connect(m_reset, SIGNAL(clicked()), m_vthumb, SLOT(resetToDefault()));
|
Chris@189
|
139 connect(m_reset, SIGNAL(clicked()), m_vpan, SLOT(resetToDefault()));
|
Chris@189
|
140 connect(m_reset, SIGNAL(mouseEntered()), this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
141 connect(m_reset, SIGNAL(mouseLeft()), this, SLOT(mouseLeftWidget()));
|
Chris@133
|
142 }
|
Chris@133
|
143
|
Chris@133
|
144 int count = 0;
|
Chris@133
|
145 int current = 0;
|
Chris@133
|
146 int level = 1;
|
Chris@133
|
147
|
Chris@137
|
148 //!!! pull out into function (presumably in View)
|
Chris@137
|
149 bool haveConstraint = false;
|
Chris@137
|
150 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end();
|
Chris@137
|
151 ++i) {
|
Chris@137
|
152 if ((*i)->getZoomConstraint() && !(*i)->supportsOtherZoomLevels()) {
|
Chris@137
|
153 haveConstraint = true;
|
Chris@137
|
154 break;
|
Chris@137
|
155 }
|
Chris@137
|
156 }
|
Chris@137
|
157
|
Chris@137
|
158 if (haveConstraint) {
|
Chris@137
|
159 while (true) {
|
Chris@137
|
160 if (getZoomLevel() == level) current = count;
|
Chris@137
|
161 int newLevel = getZoomConstraintBlockSize(level + 1,
|
Chris@137
|
162 ZoomConstraint::RoundUp);
|
Chris@137
|
163 if (newLevel == level) break;
|
Chris@137
|
164 level = newLevel;
|
Chris@137
|
165 if (++count == 50) break;
|
Chris@137
|
166 }
|
Chris@137
|
167 } else {
|
Chris@137
|
168 // if we have no particular constraints, we can really spread out
|
Chris@137
|
169 while (true) {
|
Chris@137
|
170 if (getZoomLevel() >= level) current = count;
|
Chris@137
|
171 int step = level / 10;
|
Chris@137
|
172 int pwr = 0;
|
Chris@137
|
173 while (step > 0) {
|
Chris@137
|
174 ++pwr;
|
Chris@137
|
175 step /= 2;
|
Chris@137
|
176 }
|
Chris@137
|
177 step = 1;
|
Chris@137
|
178 while (pwr > 0) {
|
Chris@137
|
179 step *= 2;
|
Chris@137
|
180 --pwr;
|
Chris@137
|
181 }
|
Chris@154
|
182 // std::cerr << level << std::endl;
|
Chris@137
|
183 level += step;
|
Chris@137
|
184 if (++count == 100 || level > 262144) break;
|
Chris@137
|
185 }
|
Chris@133
|
186 }
|
Chris@133
|
187
|
Chris@133
|
188 // std::cerr << "Have " << count << " zoom levels" << std::endl;
|
Chris@133
|
189
|
Chris@133
|
190 m_hthumb->setMinimumValue(0);
|
Chris@133
|
191 m_hthumb->setMaximumValue(count);
|
Chris@133
|
192 m_hthumb->setValue(count - current);
|
Chris@133
|
193
|
Chris@133
|
194 // std::cerr << "set value to " << count-current << std::endl;
|
Chris@133
|
195
|
Chris@133
|
196 // std::cerr << "default value is " << m_hthumb->getDefaultValue() << std::endl;
|
Chris@133
|
197
|
Chris@133
|
198 if (count != 50 && m_hthumb->getDefaultValue() == 0) {
|
Chris@133
|
199 m_hthumb->setDefaultValue(count - current);
|
Chris@133
|
200 // std::cerr << "set default value to " << m_hthumb->getDefaultValue() << std::endl;
|
Chris@133
|
201 }
|
Chris@133
|
202
|
Chris@133
|
203 if (layer) {
|
Chris@133
|
204 int defaultStep = 0;
|
Chris@133
|
205 int max = layer->getVerticalZoomSteps(defaultStep);
|
Chris@133
|
206 if (max == 0) {
|
Chris@133
|
207 m_vthumb->hide();
|
Chris@133
|
208 } else {
|
Chris@133
|
209 m_vthumb->show();
|
Chris@187
|
210 m_vthumb->blockSignals(true);
|
Chris@133
|
211 m_vthumb->setMinimumValue(0);
|
Chris@133
|
212 m_vthumb->setMaximumValue(max);
|
Chris@133
|
213 m_vthumb->setDefaultValue(defaultStep);
|
Chris@133
|
214 m_vthumb->setValue(layer->getCurrentVerticalZoomStep());
|
Chris@187
|
215 m_vthumb->blockSignals(false);
|
Chris@135
|
216
|
Chris@135
|
217 std::cerr << "Vertical thumbwheel: min 0, max " << max
|
Chris@135
|
218 << ", default " << defaultStep << ", value "
|
Chris@135
|
219 << m_vthumb->getValue() << std::endl;
|
Chris@135
|
220
|
Chris@133
|
221 }
|
Chris@133
|
222 }
|
Chris@133
|
223
|
Chris@174
|
224 updateVerticalPanner();
|
Chris@174
|
225
|
Chris@133
|
226 if (m_manager && m_manager->getZoomWheelsEnabled() &&
|
Chris@133
|
227 width() > 120 && height() > 100) {
|
Chris@165
|
228 if (!m_headsUpDisplay->isVisible()) {
|
Chris@165
|
229 m_headsUpDisplay->show();
|
Chris@165
|
230 connect(m_manager, SIGNAL(zoomLevelChanged()),
|
Chris@165
|
231 this, SLOT(zoomLevelChanged()));
|
Chris@165
|
232 }
|
Chris@133
|
233 if (m_vthumb->isVisible()) {
|
Chris@133
|
234 m_headsUpDisplay->move(width() - 86, height() - 86);
|
Chris@133
|
235 } else {
|
Chris@133
|
236 m_headsUpDisplay->move(width() - 86, height() - 51);
|
Chris@133
|
237 }
|
Chris@133
|
238 } else {
|
Chris@133
|
239 m_headsUpDisplay->hide();
|
Chris@133
|
240 if (m_manager) {
|
Chris@133
|
241 disconnect(m_manager, SIGNAL(zoomLevelChanged()),
|
Chris@133
|
242 this, SLOT(zoomLevelChanged()));
|
Chris@133
|
243 }
|
Chris@133
|
244 }
|
Chris@127
|
245 }
|
Chris@127
|
246
|
Chris@174
|
247 void
|
Chris@174
|
248 Pane::updateVerticalPanner()
|
Chris@174
|
249 {
|
Chris@174
|
250 if (!m_vpan || !m_manager || !m_manager->getZoomWheelsEnabled()) return;
|
Chris@174
|
251
|
Chris@174
|
252 float vmin, vmax, dmin, dmax;
|
Chris@174
|
253 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax) && vmax != vmin) {
|
Chris@174
|
254 float y0 = (dmin - vmin) / (vmax - vmin);
|
Chris@174
|
255 float y1 = (dmax - vmin) / (vmax - vmin);
|
Chris@174
|
256 m_vpan->blockSignals(true);
|
Chris@174
|
257 m_vpan->setRectExtents(0, 1.0 - y1, 1, y1 - y0);
|
Chris@174
|
258 m_vpan->blockSignals(false);
|
Chris@174
|
259 m_vpan->show();
|
Chris@174
|
260 } else {
|
Chris@174
|
261 m_vpan->hide();
|
Chris@174
|
262 }
|
Chris@174
|
263 }
|
Chris@174
|
264
|
Chris@127
|
265 bool
|
Chris@127
|
266 Pane::shouldIlluminateLocalFeatures(const Layer *layer, QPoint &pos) const
|
Chris@127
|
267 {
|
Chris@127
|
268 QPoint discard;
|
Chris@127
|
269 bool b0, b1;
|
Chris@127
|
270
|
Chris@127
|
271 if (layer == getSelectedLayer() &&
|
Chris@127
|
272 !shouldIlluminateLocalSelection(discard, b0, b1)) {
|
Chris@127
|
273
|
Chris@127
|
274 pos = m_identifyPoint;
|
Chris@127
|
275 return m_identifyFeatures;
|
Chris@127
|
276 }
|
Chris@127
|
277
|
Chris@127
|
278 return false;
|
Chris@127
|
279 }
|
Chris@127
|
280
|
Chris@127
|
281 bool
|
Chris@127
|
282 Pane::shouldIlluminateLocalSelection(QPoint &pos,
|
Chris@127
|
283 bool &closeToLeft,
|
Chris@127
|
284 bool &closeToRight) const
|
Chris@127
|
285 {
|
Chris@127
|
286 if (m_identifyFeatures &&
|
Chris@127
|
287 m_manager &&
|
Chris@127
|
288 m_manager->getToolMode() == ViewManager::EditMode &&
|
Chris@127
|
289 !m_manager->getSelections().empty() &&
|
Chris@127
|
290 !selectionIsBeingEdited()) {
|
Chris@127
|
291
|
Chris@127
|
292 Selection s(getSelectionAt(m_identifyPoint.x(),
|
Chris@127
|
293 closeToLeft, closeToRight));
|
Chris@127
|
294
|
Chris@127
|
295 if (!s.isEmpty()) {
|
Chris@127
|
296 if (getSelectedLayer() && getSelectedLayer()->isLayerEditable()) {
|
Chris@127
|
297
|
Chris@127
|
298 pos = m_identifyPoint;
|
Chris@127
|
299 return true;
|
Chris@127
|
300 }
|
Chris@127
|
301 }
|
Chris@127
|
302 }
|
Chris@127
|
303
|
Chris@127
|
304 return false;
|
Chris@127
|
305 }
|
Chris@127
|
306
|
Chris@127
|
307 bool
|
Chris@127
|
308 Pane::selectionIsBeingEdited() const
|
Chris@127
|
309 {
|
Chris@127
|
310 if (!m_editingSelection.isEmpty()) {
|
Chris@127
|
311 if (m_mousePos != m_clickPos &&
|
Chris@127
|
312 getFrameForX(m_mousePos.x()) != getFrameForX(m_clickPos.x())) {
|
Chris@127
|
313 return true;
|
Chris@127
|
314 }
|
Chris@127
|
315 }
|
Chris@127
|
316 return false;
|
Chris@127
|
317 }
|
Chris@127
|
318
|
Chris@127
|
319 void
|
Chris@127
|
320 Pane::setCentreLineVisible(bool visible)
|
Chris@127
|
321 {
|
Chris@127
|
322 m_centreLineVisible = visible;
|
Chris@127
|
323 update();
|
Chris@127
|
324 }
|
Chris@127
|
325
|
Chris@127
|
326 void
|
Chris@127
|
327 Pane::paintEvent(QPaintEvent *e)
|
Chris@127
|
328 {
|
Chris@127
|
329 // Profiler profiler("Pane::paintEvent", true);
|
Chris@127
|
330
|
Chris@127
|
331 QPainter paint;
|
Chris@127
|
332
|
Chris@127
|
333 QRect r(rect());
|
Chris@127
|
334
|
Chris@127
|
335 if (e) {
|
Chris@127
|
336 r = e->rect();
|
Chris@127
|
337 }
|
Chris@127
|
338 /*
|
Chris@127
|
339 paint.begin(this);
|
Chris@127
|
340 paint.setClipRect(r);
|
Chris@127
|
341
|
Chris@127
|
342 if (hasLightBackground()) {
|
Chris@127
|
343 paint.setPen(Qt::white);
|
Chris@127
|
344 paint.setBrush(Qt::white);
|
Chris@127
|
345 } else {
|
Chris@127
|
346 paint.setPen(Qt::black);
|
Chris@127
|
347 paint.setBrush(Qt::black);
|
Chris@127
|
348 }
|
Chris@127
|
349 paint.drawRect(r);
|
Chris@127
|
350
|
Chris@127
|
351 paint.end();
|
Chris@127
|
352 */
|
Chris@127
|
353 View::paintEvent(e);
|
Chris@127
|
354
|
Chris@127
|
355 paint.begin(this);
|
Chris@127
|
356
|
Chris@127
|
357 if (e) {
|
Chris@127
|
358 paint.setClipRect(r);
|
Chris@127
|
359 }
|
Chris@127
|
360
|
Chris@127
|
361 const Model *waveformModel = 0; // just for reporting purposes
|
Chris@127
|
362 int verticalScaleWidth = 0;
|
Chris@127
|
363
|
Chris@127
|
364 int fontHeight = paint.fontMetrics().height();
|
Chris@127
|
365 int fontAscent = paint.fontMetrics().ascent();
|
Chris@127
|
366
|
Chris@127
|
367 if (m_manager &&
|
Chris@127
|
368 !m_manager->isPlaying() &&
|
Chris@127
|
369 m_manager->getToolMode() == ViewManager::SelectMode) {
|
Chris@127
|
370
|
Chris@127
|
371 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
|
Chris@127
|
372 --vi;
|
Chris@127
|
373
|
Chris@127
|
374 std::vector<QRect> crosshairExtents;
|
Chris@127
|
375
|
Chris@127
|
376 if ((*vi)->getCrosshairExtents(this, paint, m_identifyPoint,
|
Chris@127
|
377 crosshairExtents)) {
|
Chris@127
|
378 (*vi)->paintCrosshairs(this, paint, m_identifyPoint);
|
Chris@127
|
379 break;
|
Chris@127
|
380 } else if ((*vi)->isLayerOpaque()) {
|
Chris@127
|
381 break;
|
Chris@127
|
382 }
|
Chris@127
|
383 }
|
Chris@127
|
384 }
|
Chris@127
|
385
|
Chris@127
|
386 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
|
Chris@127
|
387 --vi;
|
Chris@127
|
388
|
Chris@127
|
389 if (dynamic_cast<WaveformLayer *>(*vi)) {
|
Chris@127
|
390 waveformModel = (*vi)->getModel();
|
Chris@127
|
391 }
|
Chris@127
|
392
|
Chris@189
|
393 if (!m_manager || !m_manager->shouldShowVerticalScale()) {
|
Chris@127
|
394 break;
|
Chris@127
|
395 }
|
Chris@127
|
396
|
Chris@127
|
397 verticalScaleWidth = (*vi)->getVerticalScaleWidth(this, paint);
|
Chris@127
|
398
|
Chris@127
|
399 if (verticalScaleWidth > 0 && r.left() < verticalScaleWidth) {
|
Chris@127
|
400
|
Chris@127
|
401 // Profiler profiler("Pane::paintEvent - painting vertical scale", true);
|
Chris@127
|
402
|
Chris@127
|
403 // std::cerr << "Pane::paintEvent: calling paint.save() in vertical scale block" << std::endl;
|
Chris@127
|
404 paint.save();
|
Chris@127
|
405
|
Chris@127
|
406 paint.setPen(Qt::black);
|
Chris@127
|
407 paint.setBrush(Qt::white);
|
Chris@127
|
408 paint.drawRect(0, -1, verticalScaleWidth, height()+1);
|
Chris@127
|
409
|
Chris@127
|
410 paint.setBrush(Qt::NoBrush);
|
Chris@127
|
411 (*vi)->paintVerticalScale
|
Chris@127
|
412 (this, paint, QRect(0, 0, verticalScaleWidth, height()));
|
Chris@127
|
413
|
Chris@127
|
414 paint.restore();
|
Chris@127
|
415 }
|
Chris@127
|
416
|
Chris@127
|
417 if (m_identifyFeatures) {
|
Chris@127
|
418
|
Chris@127
|
419 QPoint pos = m_identifyPoint;
|
Chris@127
|
420 QString desc = (*vi)->getFeatureDescription(this, pos);
|
Chris@127
|
421
|
Chris@127
|
422 if (desc != "") {
|
Chris@127
|
423
|
Chris@127
|
424 paint.save();
|
Chris@127
|
425
|
Chris@127
|
426 int tabStop =
|
Chris@127
|
427 paint.fontMetrics().width(tr("Some lengthy prefix:"));
|
Chris@127
|
428
|
Chris@127
|
429 QRect boundingRect =
|
Chris@127
|
430 paint.fontMetrics().boundingRect
|
Chris@127
|
431 (rect(),
|
Chris@127
|
432 Qt::AlignRight | Qt::AlignTop | Qt::TextExpandTabs,
|
Chris@127
|
433 desc, tabStop);
|
Chris@127
|
434
|
Chris@127
|
435 if (hasLightBackground()) {
|
Chris@127
|
436 paint.setPen(Qt::NoPen);
|
Chris@127
|
437 paint.setBrush(QColor(250, 250, 250, 200));
|
Chris@127
|
438 } else {
|
Chris@127
|
439 paint.setPen(Qt::NoPen);
|
Chris@127
|
440 paint.setBrush(QColor(50, 50, 50, 200));
|
Chris@127
|
441 }
|
Chris@127
|
442
|
Chris@127
|
443 int extra = paint.fontMetrics().descent();
|
Chris@127
|
444 paint.drawRect(width() - boundingRect.width() - 10 - extra,
|
Chris@127
|
445 10 - extra,
|
Chris@127
|
446 boundingRect.width() + 2 * extra,
|
Chris@127
|
447 boundingRect.height() + extra);
|
Chris@127
|
448
|
Chris@127
|
449 if (hasLightBackground()) {
|
Chris@127
|
450 paint.setPen(QColor(150, 20, 0));
|
Chris@127
|
451 } else {
|
Chris@127
|
452 paint.setPen(QColor(255, 150, 100));
|
Chris@127
|
453 }
|
Chris@127
|
454
|
Chris@127
|
455 QTextOption option;
|
Chris@127
|
456 option.setWrapMode(QTextOption::NoWrap);
|
Chris@127
|
457 option.setAlignment(Qt::AlignRight | Qt::AlignTop);
|
Chris@127
|
458 option.setTabStop(tabStop);
|
Chris@127
|
459 paint.drawText(QRectF(width() - boundingRect.width() - 10, 10,
|
Chris@127
|
460 boundingRect.width(),
|
Chris@127
|
461 boundingRect.height()),
|
Chris@127
|
462 desc,
|
Chris@127
|
463 option);
|
Chris@127
|
464
|
Chris@127
|
465 paint.restore();
|
Chris@127
|
466 }
|
Chris@127
|
467 }
|
Chris@127
|
468
|
Chris@127
|
469 break;
|
Chris@127
|
470 }
|
Chris@127
|
471
|
Chris@127
|
472 int sampleRate = getModelsSampleRate();
|
Chris@127
|
473 paint.setBrush(Qt::NoBrush);
|
Chris@127
|
474
|
Chris@189
|
475 if (m_centreLineVisible &&
|
Chris@189
|
476 m_manager &&
|
Chris@189
|
477 m_manager->shouldShowCentreLine()) {
|
Chris@127
|
478
|
Chris@189
|
479 QColor c = QColor(0, 0, 0);
|
Chris@189
|
480 if (!hasLightBackground()) {
|
Chris@189
|
481 c = QColor(240, 240, 240);
|
Chris@189
|
482 }
|
Chris@189
|
483 paint.setPen(c);
|
Chris@189
|
484 int x = width() / 2 + 1;
|
Chris@189
|
485 paint.drawLine(x, 0, x, height() - 1);
|
Chris@189
|
486 paint.drawLine(x-1, 1, x+1, 1);
|
Chris@189
|
487 paint.drawLine(x-2, 0, x+2, 0);
|
Chris@189
|
488 paint.drawLine(x-1, height() - 2, x+1, height() - 2);
|
Chris@189
|
489 paint.drawLine(x-2, height() - 1, x+2, height() - 1);
|
Chris@127
|
490
|
Chris@127
|
491 paint.setPen(QColor(50, 50, 50));
|
Chris@127
|
492
|
Chris@127
|
493 int y = height() - fontHeight
|
Chris@127
|
494 + fontAscent - 6;
|
Chris@127
|
495
|
Chris@127
|
496 LayerList::iterator vi = m_layers.end();
|
Chris@127
|
497
|
Chris@127
|
498 if (vi != m_layers.begin()) {
|
Chris@127
|
499
|
Chris@127
|
500 switch ((*--vi)->getPreferredFrameCountPosition()) {
|
Chris@127
|
501
|
Chris@127
|
502 case Layer::PositionTop:
|
Chris@127
|
503 y = fontAscent + 6;
|
Chris@127
|
504 break;
|
Chris@127
|
505
|
Chris@127
|
506 case Layer::PositionMiddle:
|
Chris@127
|
507 y = (height() - fontHeight) / 2
|
Chris@127
|
508 + fontAscent;
|
Chris@127
|
509 break;
|
Chris@127
|
510
|
Chris@127
|
511 case Layer::PositionBottom:
|
Chris@127
|
512 // y already set correctly
|
Chris@127
|
513 break;
|
Chris@127
|
514 }
|
Chris@127
|
515 }
|
Chris@127
|
516
|
Chris@189
|
517 if (m_manager && m_manager->shouldShowFrameCount()) {
|
Chris@127
|
518
|
Chris@127
|
519 if (sampleRate) {
|
Chris@127
|
520
|
Chris@127
|
521 QString text(QString::fromStdString
|
Chris@127
|
522 (RealTime::frame2RealTime
|
Chris@127
|
523 (m_centreFrame, sampleRate).toText(true)));
|
Chris@127
|
524
|
Chris@127
|
525 int tw = paint.fontMetrics().width(text);
|
Chris@127
|
526 int x = width()/2 - 4 - tw;
|
Chris@127
|
527
|
Chris@127
|
528 drawVisibleText(paint, x, y, text, OutlinedText);
|
Chris@127
|
529 }
|
Chris@127
|
530
|
Chris@127
|
531 QString text = QString("%1").arg(m_centreFrame);
|
Chris@127
|
532
|
Chris@127
|
533 int tw = paint.fontMetrics().width(text);
|
Chris@127
|
534 int x = width()/2 + 4;
|
Chris@127
|
535
|
Chris@127
|
536 drawVisibleText(paint, x, y, text, OutlinedText);
|
Chris@127
|
537 }
|
Chris@127
|
538
|
Chris@127
|
539 } else {
|
Chris@127
|
540
|
Chris@127
|
541 paint.setPen(QColor(50, 50, 50));
|
Chris@127
|
542 }
|
Chris@127
|
543
|
Chris@127
|
544 if (waveformModel &&
|
Chris@127
|
545 m_manager &&
|
Chris@189
|
546 m_manager->shouldShowDuration() &&
|
Chris@127
|
547 r.y() + r.height() >= height() - fontHeight - 6) {
|
Chris@127
|
548
|
Chris@150
|
549 size_t modelRate = waveformModel->getSampleRate();
|
Chris@127
|
550 size_t mainModelRate = m_manager->getMainModelSampleRate();
|
Chris@127
|
551 size_t playbackRate = m_manager->getPlaybackSampleRate();
|
Chris@127
|
552
|
Chris@127
|
553 QString srNote = "";
|
Chris@127
|
554
|
Chris@127
|
555 // Show (R) for waveform models that will be resampled on
|
Chris@127
|
556 // playback, and (X) for waveform models that will be played
|
Chris@127
|
557 // at the wrong rate because their rate differs from that of
|
Chris@127
|
558 // the main model.
|
Chris@127
|
559
|
Chris@150
|
560 if (modelRate == mainModelRate) {
|
Chris@150
|
561 if (modelRate != playbackRate) srNote = " " + tr("(R)");
|
Chris@127
|
562 } else {
|
Chris@150
|
563 // std::cerr << "Sample rate = " << modelRate << ", main model rate = " << mainModelRate << std::endl;
|
Chris@127
|
564 srNote = " " + tr("(X)");
|
Chris@127
|
565 }
|
Chris@127
|
566
|
Chris@127
|
567 QString desc = tr("%1 / %2Hz%3")
|
Chris@127
|
568 .arg(RealTime::frame2RealTime(waveformModel->getEndFrame(),
|
Chris@127
|
569 sampleRate)
|
Chris@127
|
570 .toText(false).c_str())
|
Chris@150
|
571 .arg(modelRate)
|
Chris@127
|
572 .arg(srNote);
|
Chris@127
|
573
|
Chris@127
|
574 if (r.x() < verticalScaleWidth + 5 + paint.fontMetrics().width(desc)) {
|
Chris@127
|
575 drawVisibleText(paint, verticalScaleWidth + 5,
|
Chris@127
|
576 height() - fontHeight + fontAscent - 6,
|
Chris@127
|
577 desc, OutlinedText);
|
Chris@127
|
578 }
|
Chris@127
|
579 }
|
Chris@127
|
580
|
Chris@127
|
581 if (m_manager &&
|
Chris@189
|
582 m_manager->shouldShowLayerNames() &&
|
Chris@127
|
583 r.y() + r.height() >= height() - m_layers.size() * fontHeight - 6) {
|
Chris@127
|
584
|
Chris@127
|
585 std::vector<QString> texts;
|
Chris@127
|
586 int maxTextWidth = 0;
|
Chris@127
|
587
|
Chris@127
|
588 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
|
Chris@127
|
589
|
Chris@127
|
590 QString text = (*i)->getLayerPresentationName();
|
Chris@127
|
591 int tw = paint.fontMetrics().width(text);
|
Chris@127
|
592 bool reduced = false;
|
Chris@127
|
593 while (tw > width() / 3 && text.length() > 4) {
|
Chris@127
|
594 if (!reduced && text.length() > 8) {
|
Chris@127
|
595 text = text.left(text.length() - 4);
|
Chris@127
|
596 } else {
|
Chris@127
|
597 text = text.left(text.length() - 2);
|
Chris@127
|
598 }
|
Chris@127
|
599 reduced = true;
|
Chris@127
|
600 tw = paint.fontMetrics().width(text + "...");
|
Chris@127
|
601 }
|
Chris@127
|
602 if (reduced) {
|
Chris@127
|
603 texts.push_back(text + "...");
|
Chris@127
|
604 } else {
|
Chris@127
|
605 texts.push_back(text);
|
Chris@127
|
606 }
|
Chris@127
|
607 if (tw > maxTextWidth) maxTextWidth = tw;
|
Chris@127
|
608 }
|
Chris@127
|
609
|
Chris@127
|
610 int lly = height() - 6;
|
Chris@133
|
611 int llx = width() - maxTextWidth - 5;
|
Chris@127
|
612
|
Chris@133
|
613 if (m_manager->getZoomWheelsEnabled()) {
|
Chris@133
|
614 lly -= 20;
|
Chris@173
|
615 llx -= 36;
|
Chris@133
|
616 }
|
Chris@133
|
617
|
Chris@133
|
618 if (r.x() + r.width() >= llx) {
|
Chris@127
|
619
|
Chris@127
|
620 for (int i = 0; i < texts.size(); ++i) {
|
Chris@127
|
621
|
Chris@127
|
622 if (i == texts.size() - 1) {
|
Chris@127
|
623 paint.setPen(Qt::black);
|
Chris@127
|
624 }
|
Chris@127
|
625
|
Chris@133
|
626 drawVisibleText(paint, llx,
|
Chris@127
|
627 lly - fontHeight + fontAscent,
|
Chris@127
|
628 texts[i], OutlinedText);
|
Chris@127
|
629
|
Chris@127
|
630 lly -= fontHeight;
|
Chris@127
|
631 }
|
Chris@127
|
632 }
|
Chris@127
|
633 }
|
Chris@127
|
634
|
Chris@127
|
635 if (m_clickedInRange && m_shiftPressed) {
|
Chris@127
|
636 if (m_manager && (m_manager->getToolMode() == ViewManager::NavigateMode)) {
|
Chris@127
|
637 //!!! be nice if this looked a bit more in keeping with the
|
Chris@127
|
638 //selection block
|
Chris@127
|
639 paint.setPen(Qt::blue);
|
Chris@127
|
640 paint.drawRect(m_clickPos.x(), m_clickPos.y(),
|
Chris@127
|
641 m_mousePos.x() - m_clickPos.x(),
|
Chris@127
|
642 m_mousePos.y() - m_clickPos.y());
|
Chris@127
|
643 }
|
Chris@127
|
644 }
|
Chris@127
|
645
|
Chris@127
|
646 if (selectionIsBeingEdited()) {
|
Chris@127
|
647
|
Chris@127
|
648 int offset = m_mousePos.x() - m_clickPos.x();
|
Chris@127
|
649 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset;
|
Chris@127
|
650 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset;
|
Chris@127
|
651
|
Chris@127
|
652 if (m_editingSelectionEdge < 0) {
|
Chris@127
|
653 p1 = getXForFrame(m_editingSelection.getEndFrame());
|
Chris@127
|
654 } else if (m_editingSelectionEdge > 0) {
|
Chris@127
|
655 p0 = getXForFrame(m_editingSelection.getStartFrame());
|
Chris@127
|
656 }
|
Chris@127
|
657
|
Chris@127
|
658 paint.save();
|
Chris@127
|
659 if (hasLightBackground()) {
|
Chris@127
|
660 paint.setPen(QPen(Qt::black, 2));
|
Chris@127
|
661 } else {
|
Chris@127
|
662 paint.setPen(QPen(Qt::white, 2));
|
Chris@127
|
663 }
|
Chris@127
|
664
|
Chris@127
|
665 //!!! duplicating display policy with View::drawSelections
|
Chris@127
|
666
|
Chris@127
|
667 if (m_editingSelectionEdge < 0) {
|
Chris@127
|
668 paint.drawLine(p0, 1, p1, 1);
|
Chris@127
|
669 paint.drawLine(p0, 0, p0, height());
|
Chris@127
|
670 paint.drawLine(p0, height() - 1, p1, height() - 1);
|
Chris@127
|
671 } else if (m_editingSelectionEdge > 0) {
|
Chris@127
|
672 paint.drawLine(p0, 1, p1, 1);
|
Chris@127
|
673 paint.drawLine(p1, 0, p1, height());
|
Chris@127
|
674 paint.drawLine(p0, height() - 1, p1, height() - 1);
|
Chris@127
|
675 } else {
|
Chris@127
|
676 paint.setBrush(Qt::NoBrush);
|
Chris@127
|
677 paint.drawRect(p0, 1, p1 - p0, height() - 2);
|
Chris@127
|
678 }
|
Chris@127
|
679 paint.restore();
|
Chris@127
|
680 }
|
Chris@127
|
681
|
Chris@127
|
682 paint.end();
|
Chris@127
|
683 }
|
Chris@127
|
684
|
Chris@127
|
685 Selection
|
Chris@127
|
686 Pane::getSelectionAt(int x, bool &closeToLeftEdge, bool &closeToRightEdge) const
|
Chris@127
|
687 {
|
Chris@127
|
688 closeToLeftEdge = closeToRightEdge = false;
|
Chris@127
|
689
|
Chris@127
|
690 if (!m_manager) return Selection();
|
Chris@127
|
691
|
Chris@127
|
692 long testFrame = getFrameForX(x - 5);
|
Chris@127
|
693 if (testFrame < 0) {
|
Chris@127
|
694 testFrame = getFrameForX(x);
|
Chris@127
|
695 if (testFrame < 0) return Selection();
|
Chris@127
|
696 }
|
Chris@127
|
697
|
Chris@127
|
698 Selection selection = m_manager->getContainingSelection(testFrame, true);
|
Chris@127
|
699 if (selection.isEmpty()) return selection;
|
Chris@127
|
700
|
Chris@127
|
701 int lx = getXForFrame(selection.getStartFrame());
|
Chris@127
|
702 int rx = getXForFrame(selection.getEndFrame());
|
Chris@127
|
703
|
Chris@127
|
704 int fuzz = 2;
|
Chris@127
|
705 if (x < lx - fuzz || x > rx + fuzz) return Selection();
|
Chris@127
|
706
|
Chris@127
|
707 int width = rx - lx;
|
Chris@127
|
708 fuzz = 3;
|
Chris@127
|
709 if (width < 12) fuzz = width / 4;
|
Chris@127
|
710 if (fuzz < 1) fuzz = 1;
|
Chris@127
|
711
|
Chris@127
|
712 if (x < lx + fuzz) closeToLeftEdge = true;
|
Chris@127
|
713 if (x > rx - fuzz) closeToRightEdge = true;
|
Chris@127
|
714
|
Chris@127
|
715 return selection;
|
Chris@127
|
716 }
|
Chris@127
|
717
|
Chris@174
|
718 bool
|
Chris@174
|
719 Pane::canTopLayerMoveVertical()
|
Chris@174
|
720 {
|
Chris@174
|
721 float vmin, vmax, dmin, dmax;
|
Chris@174
|
722 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return false;
|
Chris@174
|
723 if (dmin <= vmin && dmax >= vmax) return false;
|
Chris@174
|
724 return true;
|
Chris@174
|
725 }
|
Chris@174
|
726
|
Chris@174
|
727 bool
|
Chris@174
|
728 Pane::getTopLayerDisplayExtents(float &vmin, float &vmax,
|
Chris@188
|
729 float &dmin, float &dmax,
|
Chris@188
|
730 QString *unit)
|
Chris@174
|
731 {
|
Chris@174
|
732 Layer *layer = 0;
|
Chris@174
|
733 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@174
|
734 if (!layer) return false;
|
Chris@174
|
735 bool vlog;
|
Chris@174
|
736 QString vunit;
|
Chris@188
|
737 bool rv = (layer->getValueExtents(vmin, vmax, vlog, vunit) &&
|
Chris@188
|
738 layer->getDisplayExtents(dmin, dmax));
|
Chris@188
|
739 if (unit) *unit = vunit;
|
Chris@188
|
740 return rv;
|
Chris@174
|
741 }
|
Chris@174
|
742
|
Chris@174
|
743 bool
|
Chris@174
|
744 Pane::setTopLayerDisplayExtents(float dmin, float dmax)
|
Chris@174
|
745 {
|
Chris@174
|
746 Layer *layer = 0;
|
Chris@174
|
747 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@174
|
748 if (!layer) return false;
|
Chris@174
|
749 return layer->setDisplayExtents(dmin, dmax);
|
Chris@174
|
750 }
|
Chris@174
|
751
|
Chris@127
|
752 void
|
Chris@127
|
753 Pane::mousePressEvent(QMouseEvent *e)
|
Chris@127
|
754 {
|
Chris@127
|
755 if (e->buttons() & Qt::RightButton) {
|
Chris@189
|
756 emit contextHelpChanged("");
|
Chris@127
|
757 emit rightButtonMenuRequested(mapToGlobal(e->pos()));
|
Chris@127
|
758 return;
|
Chris@127
|
759 }
|
Chris@127
|
760
|
Chris@127
|
761 m_clickPos = e->pos();
|
Chris@127
|
762 m_clickedInRange = true;
|
Chris@127
|
763 m_editingSelection = Selection();
|
Chris@127
|
764 m_editingSelectionEdge = 0;
|
Chris@127
|
765 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier);
|
Chris@127
|
766 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier);
|
Chris@150
|
767 m_dragMode = UnresolvedDrag;
|
Chris@127
|
768
|
Chris@127
|
769 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
770 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
771
|
Chris@127
|
772 m_navigating = false;
|
Chris@127
|
773
|
Chris@127
|
774 if (mode == ViewManager::NavigateMode || (e->buttons() & Qt::MidButton)) {
|
Chris@127
|
775
|
Chris@127
|
776 if (mode != ViewManager::NavigateMode) {
|
Chris@127
|
777 setCursor(Qt::PointingHandCursor);
|
Chris@127
|
778 }
|
Chris@127
|
779
|
Chris@127
|
780 m_navigating = true;
|
Chris@127
|
781 m_dragCentreFrame = m_centreFrame;
|
Chris@136
|
782 m_dragStartMinValue = 0;
|
Chris@174
|
783
|
Chris@174
|
784 float vmin, vmax, dmin, dmax;
|
Chris@174
|
785 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) {
|
Chris@174
|
786 m_dragStartMinValue = dmin;
|
Chris@136
|
787 }
|
Chris@136
|
788
|
Chris@127
|
789 } else if (mode == ViewManager::SelectMode) {
|
Chris@127
|
790
|
Chris@127
|
791 bool closeToLeft = false, closeToRight = false;
|
Chris@127
|
792 Selection selection = getSelectionAt(e->x(), closeToLeft, closeToRight);
|
Chris@127
|
793
|
Chris@127
|
794 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) {
|
Chris@127
|
795
|
Chris@127
|
796 m_manager->removeSelection(selection);
|
Chris@127
|
797
|
Chris@127
|
798 if (closeToLeft) {
|
Chris@127
|
799 m_selectionStartFrame = selection.getEndFrame();
|
Chris@127
|
800 } else {
|
Chris@127
|
801 m_selectionStartFrame = selection.getStartFrame();
|
Chris@127
|
802 }
|
Chris@127
|
803
|
Chris@127
|
804 m_manager->setInProgressSelection(selection, false);
|
Chris@127
|
805 m_resizing = true;
|
Chris@127
|
806
|
Chris@127
|
807 } else {
|
Chris@127
|
808
|
Chris@127
|
809 int mouseFrame = getFrameForX(e->x());
|
Chris@127
|
810 size_t resolution = 1;
|
Chris@127
|
811 int snapFrame = mouseFrame;
|
Chris@127
|
812
|
Chris@127
|
813 Layer *layer = getSelectedLayer();
|
Chris@127
|
814 if (layer && !m_shiftPressed) {
|
Chris@127
|
815 layer->snapToFeatureFrame(this, snapFrame,
|
Chris@127
|
816 resolution, Layer::SnapLeft);
|
Chris@127
|
817 }
|
Chris@127
|
818
|
Chris@127
|
819 if (snapFrame < 0) snapFrame = 0;
|
Chris@127
|
820 m_selectionStartFrame = snapFrame;
|
Chris@127
|
821 if (m_manager) {
|
Chris@127
|
822 m_manager->setInProgressSelection(Selection(snapFrame,
|
Chris@127
|
823 snapFrame + resolution),
|
Chris@127
|
824 !m_ctrlPressed);
|
Chris@127
|
825 }
|
Chris@127
|
826
|
Chris@127
|
827 m_resizing = false;
|
Chris@127
|
828 }
|
Chris@127
|
829
|
Chris@127
|
830 update();
|
Chris@127
|
831
|
Chris@127
|
832 } else if (mode == ViewManager::DrawMode) {
|
Chris@127
|
833
|
Chris@127
|
834 Layer *layer = getSelectedLayer();
|
Chris@127
|
835 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
836 layer->drawStart(this, e);
|
Chris@127
|
837 }
|
Chris@127
|
838
|
Chris@127
|
839 } else if (mode == ViewManager::EditMode) {
|
Chris@127
|
840
|
Chris@127
|
841 if (!editSelectionStart(e)) {
|
Chris@127
|
842 Layer *layer = getSelectedLayer();
|
Chris@127
|
843 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
844 layer->editStart(this, e);
|
Chris@127
|
845 }
|
Chris@127
|
846 }
|
Chris@127
|
847 }
|
Chris@127
|
848
|
Chris@127
|
849 emit paneInteractedWith();
|
Chris@127
|
850 }
|
Chris@127
|
851
|
Chris@127
|
852 void
|
Chris@127
|
853 Pane::mouseReleaseEvent(QMouseEvent *e)
|
Chris@127
|
854 {
|
Chris@127
|
855 if (e->buttons() & Qt::RightButton) {
|
Chris@127
|
856 return;
|
Chris@127
|
857 }
|
Chris@127
|
858
|
Chris@127
|
859 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
860 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
861
|
Chris@127
|
862 if (m_clickedInRange) {
|
Chris@127
|
863 mouseMoveEvent(e);
|
Chris@127
|
864 }
|
Chris@127
|
865
|
Chris@127
|
866 if (m_navigating || mode == ViewManager::NavigateMode) {
|
Chris@127
|
867
|
Chris@127
|
868 m_navigating = false;
|
Chris@127
|
869
|
Chris@127
|
870 if (mode != ViewManager::NavigateMode) {
|
Chris@127
|
871 // restore cursor
|
Chris@127
|
872 toolModeChanged();
|
Chris@127
|
873 }
|
Chris@127
|
874
|
Chris@127
|
875 if (m_shiftPressed) {
|
Chris@127
|
876
|
Chris@127
|
877 int x0 = std::min(m_clickPos.x(), m_mousePos.x());
|
Chris@127
|
878 int x1 = std::max(m_clickPos.x(), m_mousePos.x());
|
Chris@127
|
879
|
Chris@127
|
880 int y0 = std::min(m_clickPos.y(), m_mousePos.y());
|
Chris@127
|
881 int y1 = std::max(m_clickPos.y(), m_mousePos.y());
|
Chris@127
|
882
|
Chris@174
|
883 zoomToRegion(x0, y0, x1, y1);
|
Chris@127
|
884 }
|
Chris@127
|
885
|
Chris@127
|
886 } else if (mode == ViewManager::SelectMode) {
|
Chris@127
|
887
|
Chris@127
|
888 if (m_manager && m_manager->haveInProgressSelection()) {
|
Chris@127
|
889
|
Chris@127
|
890 bool exclusive;
|
Chris@127
|
891 Selection selection = m_manager->getInProgressSelection(exclusive);
|
Chris@127
|
892
|
Chris@127
|
893 if (selection.getEndFrame() < selection.getStartFrame() + 2) {
|
Chris@127
|
894 selection = Selection();
|
Chris@127
|
895 }
|
Chris@127
|
896
|
Chris@127
|
897 m_manager->clearInProgressSelection();
|
Chris@127
|
898
|
Chris@127
|
899 if (exclusive) {
|
Chris@127
|
900 m_manager->setSelection(selection);
|
Chris@127
|
901 } else {
|
Chris@127
|
902 m_manager->addSelection(selection);
|
Chris@127
|
903 }
|
Chris@127
|
904 }
|
Chris@127
|
905
|
Chris@127
|
906 update();
|
Chris@127
|
907
|
Chris@127
|
908 } else if (mode == ViewManager::DrawMode) {
|
Chris@127
|
909
|
Chris@127
|
910 Layer *layer = getSelectedLayer();
|
Chris@127
|
911 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
912 layer->drawEnd(this, e);
|
Chris@127
|
913 update();
|
Chris@127
|
914 }
|
Chris@127
|
915
|
Chris@127
|
916 } else if (mode == ViewManager::EditMode) {
|
Chris@127
|
917
|
Chris@127
|
918 if (!editSelectionEnd(e)) {
|
Chris@127
|
919 Layer *layer = getSelectedLayer();
|
Chris@127
|
920 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
921 layer->editEnd(this, e);
|
Chris@127
|
922 update();
|
Chris@127
|
923 }
|
Chris@127
|
924 }
|
Chris@127
|
925 }
|
Chris@127
|
926
|
Chris@127
|
927 m_clickedInRange = false;
|
Chris@127
|
928
|
Chris@127
|
929 emit paneInteractedWith();
|
Chris@127
|
930 }
|
Chris@127
|
931
|
Chris@127
|
932 void
|
Chris@127
|
933 Pane::mouseMoveEvent(QMouseEvent *e)
|
Chris@127
|
934 {
|
Chris@127
|
935 if (e->buttons() & Qt::RightButton) {
|
Chris@127
|
936 return;
|
Chris@127
|
937 }
|
Chris@127
|
938
|
Chris@189
|
939 updateContextHelp(&e->pos());
|
Chris@189
|
940
|
Chris@127
|
941 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
942 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
943
|
Chris@127
|
944 QPoint prevPoint = m_identifyPoint;
|
Chris@127
|
945 m_identifyPoint = e->pos();
|
Chris@127
|
946
|
Chris@127
|
947 if (!m_clickedInRange) {
|
Chris@127
|
948
|
Chris@127
|
949 if (mode == ViewManager::SelectMode) {
|
Chris@127
|
950 bool closeToLeft = false, closeToRight = false;
|
Chris@127
|
951 getSelectionAt(e->x(), closeToLeft, closeToRight);
|
Chris@127
|
952 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) {
|
Chris@127
|
953 setCursor(Qt::SizeHorCursor);
|
Chris@127
|
954 } else {
|
Chris@127
|
955 setCursor(Qt::ArrowCursor);
|
Chris@127
|
956 }
|
Chris@127
|
957 }
|
Chris@127
|
958
|
Chris@127
|
959 if (!m_manager->isPlaying()) {
|
Chris@127
|
960
|
Chris@174
|
961 if (getSelectedLayer()) {
|
Chris@127
|
962
|
Chris@174
|
963 bool previouslyIdentifying = m_identifyFeatures;
|
Chris@174
|
964 m_identifyFeatures = true;
|
Chris@174
|
965
|
Chris@174
|
966 if (m_identifyFeatures != previouslyIdentifying ||
|
Chris@174
|
967 m_identifyPoint != prevPoint) {
|
Chris@174
|
968 update();
|
Chris@174
|
969 }
|
Chris@174
|
970 }
|
Chris@127
|
971 }
|
Chris@127
|
972
|
Chris@127
|
973 return;
|
Chris@127
|
974 }
|
Chris@127
|
975
|
Chris@127
|
976 if (m_navigating || mode == ViewManager::NavigateMode) {
|
Chris@127
|
977
|
Chris@127
|
978 if (m_shiftPressed) {
|
Chris@127
|
979
|
Chris@127
|
980 m_mousePos = e->pos();
|
Chris@127
|
981 update();
|
Chris@127
|
982
|
Chris@127
|
983 } else {
|
Chris@127
|
984
|
Chris@174
|
985 dragTopLayer(e);
|
Chris@150
|
986 }
|
Chris@127
|
987
|
Chris@127
|
988 } else if (mode == ViewManager::SelectMode) {
|
Chris@127
|
989
|
Chris@174
|
990 dragExtendSelection(e);
|
Chris@127
|
991
|
Chris@127
|
992 } else if (mode == ViewManager::DrawMode) {
|
Chris@127
|
993
|
Chris@127
|
994 Layer *layer = getSelectedLayer();
|
Chris@127
|
995 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
996 layer->drawDrag(this, e);
|
Chris@127
|
997 }
|
Chris@127
|
998
|
Chris@127
|
999 } else if (mode == ViewManager::EditMode) {
|
Chris@127
|
1000
|
Chris@127
|
1001 if (!editSelectionDrag(e)) {
|
Chris@127
|
1002 Layer *layer = getSelectedLayer();
|
Chris@127
|
1003 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
1004 layer->editDrag(this, e);
|
Chris@127
|
1005 }
|
Chris@127
|
1006 }
|
Chris@127
|
1007 }
|
Chris@127
|
1008 }
|
Chris@127
|
1009
|
Chris@127
|
1010 void
|
Chris@174
|
1011 Pane::zoomToRegion(int x0, int y0, int x1, int y1)
|
Chris@174
|
1012 {
|
Chris@174
|
1013 int w = x1 - x0;
|
Chris@174
|
1014
|
Chris@174
|
1015 long newStartFrame = getFrameForX(x0);
|
Chris@174
|
1016
|
Chris@174
|
1017 long visibleFrames = getEndFrame() - getStartFrame();
|
Chris@174
|
1018 if (newStartFrame <= -visibleFrames) {
|
Chris@174
|
1019 newStartFrame = -visibleFrames + 1;
|
Chris@174
|
1020 }
|
Chris@174
|
1021
|
Chris@174
|
1022 if (newStartFrame >= long(getModelsEndFrame())) {
|
Chris@174
|
1023 newStartFrame = getModelsEndFrame() - 1;
|
Chris@174
|
1024 }
|
Chris@174
|
1025
|
Chris@174
|
1026 float ratio = float(w) / float(width());
|
Chris@174
|
1027 // std::cerr << "ratio: " << ratio << std::endl;
|
Chris@174
|
1028 size_t newZoomLevel = (size_t)nearbyint(m_zoomLevel * ratio);
|
Chris@174
|
1029 if (newZoomLevel < 1) newZoomLevel = 1;
|
Chris@174
|
1030
|
Chris@174
|
1031 // std::cerr << "start: " << m_startFrame << ", level " << m_zoomLevel << std::endl;
|
Chris@174
|
1032 setZoomLevel(getZoomConstraintBlockSize(newZoomLevel));
|
Chris@174
|
1033 setStartFrame(newStartFrame);
|
Chris@174
|
1034
|
Chris@174
|
1035 QString unit;
|
Chris@174
|
1036 float min, max;
|
Chris@174
|
1037 bool log;
|
Chris@174
|
1038 Layer *layer = 0;
|
Chris@174
|
1039 for (LayerList::const_iterator i = m_layers.begin();
|
Chris@174
|
1040 i != m_layers.end(); ++i) {
|
Chris@174
|
1041 if ((*i)->getValueExtents(min, max, log, unit) &&
|
Chris@174
|
1042 (*i)->getDisplayExtents(min, max)) {
|
Chris@174
|
1043 layer = *i;
|
Chris@174
|
1044 break;
|
Chris@174
|
1045 }
|
Chris@174
|
1046 }
|
Chris@174
|
1047
|
Chris@174
|
1048 if (layer) {
|
Chris@174
|
1049 if (log) {
|
Chris@174
|
1050 min = (min < 0.0) ? -log10f(-min) : (min == 0.0) ? 0.0 : log10f(min);
|
Chris@174
|
1051 max = (max < 0.0) ? -log10f(-max) : (max == 0.0) ? 0.0 : log10f(max);
|
Chris@174
|
1052 }
|
Chris@174
|
1053 float rmin = min + ((max - min) * (height() - y1)) / height();
|
Chris@174
|
1054 float rmax = min + ((max - min) * (height() - y0)) / height();
|
Chris@174
|
1055 std::cerr << "min: " << min << ", max: " << max << ", y0: " << y0 << ", y1: " << y1 << ", h: " << height() << ", rmin: " << rmin << ", rmax: " << rmax << std::endl;
|
Chris@174
|
1056 if (log) {
|
Chris@174
|
1057 rmin = powf(10, rmin);
|
Chris@174
|
1058 rmax = powf(10, rmax);
|
Chris@174
|
1059 }
|
Chris@174
|
1060 std::cerr << "finally: rmin: " << rmin << ", rmax: " << rmax << " " << unit.toStdString() << std::endl;
|
Chris@174
|
1061
|
Chris@174
|
1062 layer->setDisplayExtents(rmin, rmax);
|
Chris@174
|
1063 updateVerticalPanner();
|
Chris@174
|
1064 }
|
Chris@174
|
1065 }
|
Chris@174
|
1066
|
Chris@174
|
1067 void
|
Chris@174
|
1068 Pane::dragTopLayer(QMouseEvent *e)
|
Chris@174
|
1069 {
|
Chris@174
|
1070 // We need to avoid making it too easy to drag both
|
Chris@174
|
1071 // horizontally and vertically, in the case where the
|
Chris@174
|
1072 // mouse is moved "mostly" in horizontal or vertical axis
|
Chris@174
|
1073 // with only a small variation in the other axis. This is
|
Chris@174
|
1074 // particularly important during playback (when we want to
|
Chris@174
|
1075 // avoid small horizontal motions) or in slow refresh
|
Chris@174
|
1076 // layers like spectrogram (when we want to avoid small
|
Chris@174
|
1077 // vertical motions).
|
Chris@174
|
1078 //
|
Chris@174
|
1079 // To this end we have horizontal and vertical thresholds
|
Chris@174
|
1080 // and a series of states: unresolved, horizontally or
|
Chris@174
|
1081 // vertically constrained, free.
|
Chris@174
|
1082 //
|
Chris@174
|
1083 // When the mouse first moves, we're unresolved: we
|
Chris@174
|
1084 // restrict ourselves to whichever direction seems safest,
|
Chris@174
|
1085 // until the mouse has passed a small threshold distance
|
Chris@174
|
1086 // from the click point. Then we lock in to one of the
|
Chris@174
|
1087 // constrained modes, based on which axis that distance
|
Chris@174
|
1088 // was measured in first. Finally, if it turns out we've
|
Chris@174
|
1089 // also moved more than a certain larger distance in the
|
Chris@174
|
1090 // other direction as well, we may switch into free mode.
|
Chris@174
|
1091 //
|
Chris@174
|
1092 // If the top layer is incapable of being dragged
|
Chris@174
|
1093 // vertically, the logic is short circuited.
|
Chris@174
|
1094
|
Chris@174
|
1095 int xdiff = e->x() - m_clickPos.x();
|
Chris@174
|
1096 int ydiff = e->y() - m_clickPos.y();
|
Chris@174
|
1097 int smallThreshold = 10, bigThreshold = 50;
|
Chris@174
|
1098
|
Chris@174
|
1099 bool canMoveVertical = canTopLayerMoveVertical();
|
Chris@174
|
1100 bool canMoveHorizontal = true;
|
Chris@174
|
1101
|
Chris@174
|
1102 if (!canMoveHorizontal) {
|
Chris@174
|
1103 m_dragMode = HorizontalDrag;
|
Chris@174
|
1104 }
|
Chris@174
|
1105
|
Chris@174
|
1106 if (m_dragMode == UnresolvedDrag) {
|
Chris@174
|
1107
|
Chris@174
|
1108 if (abs(ydiff) > smallThreshold &&
|
Chris@174
|
1109 abs(ydiff) > abs(xdiff) * 2) {
|
Chris@174
|
1110 m_dragMode = VerticalDrag;
|
Chris@174
|
1111 } else if (abs(xdiff) > smallThreshold &&
|
Chris@174
|
1112 abs(xdiff) > abs(ydiff) * 2) {
|
Chris@174
|
1113 m_dragMode = HorizontalDrag;
|
Chris@174
|
1114 } else if (abs(xdiff) > smallThreshold &&
|
Chris@174
|
1115 abs(ydiff) > smallThreshold) {
|
Chris@174
|
1116 m_dragMode = FreeDrag;
|
Chris@174
|
1117 } else {
|
Chris@174
|
1118 // When playing, we don't want to disturb the play
|
Chris@174
|
1119 // position too easily; when not playing, we don't
|
Chris@174
|
1120 // want to move up/down too easily
|
Chris@174
|
1121 if (m_manager && m_manager->isPlaying()) {
|
Chris@174
|
1122 canMoveHorizontal = false;
|
Chris@174
|
1123 } else {
|
Chris@174
|
1124 canMoveVertical = false;
|
Chris@174
|
1125 }
|
Chris@174
|
1126 }
|
Chris@174
|
1127 }
|
Chris@174
|
1128
|
Chris@174
|
1129 if (m_dragMode == VerticalDrag) {
|
Chris@174
|
1130 if (abs(xdiff) > bigThreshold) m_dragMode = FreeDrag;
|
Chris@174
|
1131 else canMoveHorizontal = false;
|
Chris@174
|
1132 }
|
Chris@174
|
1133
|
Chris@174
|
1134 if (m_dragMode == HorizontalDrag && canMoveVertical) {
|
Chris@174
|
1135 if (abs(ydiff) > bigThreshold) m_dragMode = FreeDrag;
|
Chris@174
|
1136 else canMoveVertical = false;
|
Chris@174
|
1137 }
|
Chris@174
|
1138
|
Chris@174
|
1139 if (canMoveHorizontal) {
|
Chris@174
|
1140
|
Chris@174
|
1141 long frameOff = getFrameForX(e->x()) - getFrameForX(m_clickPos.x());
|
Chris@174
|
1142
|
Chris@174
|
1143 size_t newCentreFrame = m_dragCentreFrame;
|
Chris@174
|
1144
|
Chris@174
|
1145 if (frameOff < 0) {
|
Chris@174
|
1146 newCentreFrame -= frameOff;
|
Chris@174
|
1147 } else if (newCentreFrame >= size_t(frameOff)) {
|
Chris@174
|
1148 newCentreFrame -= frameOff;
|
Chris@174
|
1149 } else {
|
Chris@174
|
1150 newCentreFrame = 0;
|
Chris@174
|
1151 }
|
Chris@174
|
1152
|
Chris@174
|
1153 if (newCentreFrame >= getModelsEndFrame()) {
|
Chris@174
|
1154 newCentreFrame = getModelsEndFrame();
|
Chris@174
|
1155 if (newCentreFrame > 0) --newCentreFrame;
|
Chris@174
|
1156 }
|
Chris@174
|
1157
|
Chris@174
|
1158 if (getXForFrame(m_centreFrame) != getXForFrame(newCentreFrame)) {
|
Chris@174
|
1159 setCentreFrame(newCentreFrame);
|
Chris@174
|
1160 }
|
Chris@174
|
1161 }
|
Chris@174
|
1162
|
Chris@174
|
1163 if (canMoveVertical) {
|
Chris@174
|
1164
|
Chris@174
|
1165 float vmin = 0.f, vmax = 0.f;
|
Chris@174
|
1166 float dmin = 0.f, dmax = 0.f;
|
Chris@174
|
1167
|
Chris@174
|
1168 if (getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) {
|
Chris@174
|
1169
|
Chris@174
|
1170 std::cerr << "ydiff = " << ydiff << std::endl;
|
Chris@174
|
1171
|
Chris@174
|
1172 float perpix = (dmax - dmin) / height();
|
Chris@174
|
1173 float valdiff = ydiff * perpix;
|
Chris@174
|
1174 std::cerr << "valdiff = " << valdiff << std::endl;
|
Chris@174
|
1175
|
Chris@174
|
1176 float newmin = m_dragStartMinValue + valdiff;
|
Chris@174
|
1177 float newmax = m_dragStartMinValue + (dmax - dmin) + valdiff;
|
Chris@174
|
1178 if (newmin < vmin) {
|
Chris@174
|
1179 newmax += vmin - newmin;
|
Chris@174
|
1180 newmin += vmin - newmin;
|
Chris@174
|
1181 }
|
Chris@174
|
1182 if (newmax > vmax) {
|
Chris@174
|
1183 newmin -= newmax - vmax;
|
Chris@174
|
1184 newmax -= newmax - vmax;
|
Chris@174
|
1185 }
|
Chris@174
|
1186 std::cerr << "(" << dmin << ", " << dmax << ") -> ("
|
Chris@174
|
1187 << newmin << ", " << newmax << ") (drag start " << m_dragStartMinValue << ")" << std::endl;
|
Chris@174
|
1188
|
Chris@174
|
1189 setTopLayerDisplayExtents(newmin, newmax);
|
Chris@174
|
1190 updateVerticalPanner();
|
Chris@174
|
1191 }
|
Chris@174
|
1192 }
|
Chris@174
|
1193 }
|
Chris@174
|
1194
|
Chris@174
|
1195 void
|
Chris@174
|
1196 Pane::dragExtendSelection(QMouseEvent *e)
|
Chris@174
|
1197 {
|
Chris@174
|
1198 int mouseFrame = getFrameForX(e->x());
|
Chris@174
|
1199 size_t resolution = 1;
|
Chris@174
|
1200 int snapFrameLeft = mouseFrame;
|
Chris@174
|
1201 int snapFrameRight = mouseFrame;
|
Chris@174
|
1202
|
Chris@174
|
1203 Layer *layer = getSelectedLayer();
|
Chris@174
|
1204 if (layer && !m_shiftPressed) {
|
Chris@174
|
1205 layer->snapToFeatureFrame(this, snapFrameLeft,
|
Chris@174
|
1206 resolution, Layer::SnapLeft);
|
Chris@174
|
1207 layer->snapToFeatureFrame(this, snapFrameRight,
|
Chris@174
|
1208 resolution, Layer::SnapRight);
|
Chris@174
|
1209 }
|
Chris@174
|
1210
|
Chris@174
|
1211 // std::cerr << "snap: frame = " << mouseFrame << ", start frame = " << m_selectionStartFrame << ", left = " << snapFrameLeft << ", right = " << snapFrameRight << std::endl;
|
Chris@174
|
1212
|
Chris@174
|
1213 if (snapFrameLeft < 0) snapFrameLeft = 0;
|
Chris@174
|
1214 if (snapFrameRight < 0) snapFrameRight = 0;
|
Chris@174
|
1215
|
Chris@174
|
1216 size_t min, max;
|
Chris@174
|
1217
|
Chris@174
|
1218 if (m_selectionStartFrame > snapFrameLeft) {
|
Chris@174
|
1219 min = snapFrameLeft;
|
Chris@174
|
1220 max = m_selectionStartFrame;
|
Chris@174
|
1221 } else if (snapFrameRight > m_selectionStartFrame) {
|
Chris@174
|
1222 min = m_selectionStartFrame;
|
Chris@174
|
1223 max = snapFrameRight;
|
Chris@174
|
1224 } else {
|
Chris@174
|
1225 min = snapFrameLeft;
|
Chris@174
|
1226 max = snapFrameRight;
|
Chris@174
|
1227 }
|
Chris@174
|
1228
|
Chris@174
|
1229 if (m_manager) {
|
Chris@174
|
1230 m_manager->setInProgressSelection(Selection(min, max),
|
Chris@174
|
1231 !m_resizing && !m_ctrlPressed);
|
Chris@174
|
1232 }
|
Chris@174
|
1233
|
Chris@174
|
1234 bool doScroll = false;
|
Chris@174
|
1235 if (!m_manager) doScroll = true;
|
Chris@174
|
1236 if (!m_manager->isPlaying()) doScroll = true;
|
Chris@174
|
1237 if (m_followPlay != PlaybackScrollContinuous) doScroll = true;
|
Chris@174
|
1238
|
Chris@174
|
1239 if (doScroll) {
|
Chris@174
|
1240 int offset = mouseFrame - getStartFrame();
|
Chris@174
|
1241 int available = getEndFrame() - getStartFrame();
|
Chris@174
|
1242 if (offset >= available * 0.95) {
|
Chris@174
|
1243 int move = int(offset - available * 0.95) + 1;
|
Chris@174
|
1244 setCentreFrame(m_centreFrame + move);
|
Chris@174
|
1245 } else if (offset <= available * 0.10) {
|
Chris@174
|
1246 int move = int(available * 0.10 - offset) + 1;
|
Chris@174
|
1247 if (m_centreFrame > move) {
|
Chris@174
|
1248 setCentreFrame(m_centreFrame - move);
|
Chris@174
|
1249 } else {
|
Chris@174
|
1250 setCentreFrame(0);
|
Chris@174
|
1251 }
|
Chris@174
|
1252 }
|
Chris@174
|
1253 }
|
Chris@174
|
1254
|
Chris@174
|
1255 update();
|
Chris@174
|
1256 }
|
Chris@174
|
1257
|
Chris@174
|
1258 void
|
Chris@127
|
1259 Pane::mouseDoubleClickEvent(QMouseEvent *e)
|
Chris@127
|
1260 {
|
Chris@127
|
1261 if (e->buttons() & Qt::RightButton) {
|
Chris@127
|
1262 return;
|
Chris@127
|
1263 }
|
Chris@127
|
1264
|
Chris@127
|
1265 // std::cerr << "mouseDoubleClickEvent" << std::endl;
|
Chris@127
|
1266
|
Chris@127
|
1267 m_clickPos = e->pos();
|
Chris@127
|
1268 m_clickedInRange = true;
|
Chris@127
|
1269 m_shiftPressed = (e->modifiers() & Qt::ShiftModifier);
|
Chris@127
|
1270 m_ctrlPressed = (e->modifiers() & Qt::ControlModifier);
|
Chris@127
|
1271
|
Chris@127
|
1272 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@127
|
1273 if (m_manager) mode = m_manager->getToolMode();
|
Chris@127
|
1274
|
Chris@127
|
1275 if (mode == ViewManager::NavigateMode ||
|
Chris@127
|
1276 mode == ViewManager::EditMode) {
|
Chris@127
|
1277
|
Chris@127
|
1278 Layer *layer = getSelectedLayer();
|
Chris@127
|
1279 if (layer && layer->isLayerEditable()) {
|
Chris@127
|
1280 layer->editOpen(this, e);
|
Chris@127
|
1281 }
|
Chris@127
|
1282 }
|
Chris@127
|
1283 }
|
Chris@127
|
1284
|
Chris@127
|
1285 void
|
Chris@127
|
1286 Pane::leaveEvent(QEvent *)
|
Chris@127
|
1287 {
|
Chris@127
|
1288 bool previouslyIdentifying = m_identifyFeatures;
|
Chris@127
|
1289 m_identifyFeatures = false;
|
Chris@127
|
1290 if (previouslyIdentifying) update();
|
Chris@189
|
1291 emit contextHelpChanged("");
|
Chris@127
|
1292 }
|
Chris@127
|
1293
|
Chris@127
|
1294 void
|
Chris@133
|
1295 Pane::resizeEvent(QResizeEvent *)
|
Chris@133
|
1296 {
|
Chris@133
|
1297 updateHeadsUpDisplay();
|
Chris@133
|
1298 }
|
Chris@133
|
1299
|
Chris@133
|
1300 void
|
Chris@127
|
1301 Pane::wheelEvent(QWheelEvent *e)
|
Chris@127
|
1302 {
|
Chris@127
|
1303 //std::cerr << "wheelEvent, delta " << e->delta() << std::endl;
|
Chris@127
|
1304
|
Chris@127
|
1305 int count = e->delta();
|
Chris@127
|
1306
|
Chris@127
|
1307 if (count > 0) {
|
Chris@127
|
1308 if (count >= 120) count /= 120;
|
Chris@127
|
1309 else count = 1;
|
Chris@127
|
1310 }
|
Chris@127
|
1311
|
Chris@127
|
1312 if (count < 0) {
|
Chris@127
|
1313 if (count <= -120) count /= 120;
|
Chris@127
|
1314 else count = -1;
|
Chris@127
|
1315 }
|
Chris@127
|
1316
|
Chris@127
|
1317 if (e->modifiers() & Qt::ControlModifier) {
|
Chris@127
|
1318
|
Chris@127
|
1319 // Scroll left or right, rapidly
|
Chris@127
|
1320
|
Chris@127
|
1321 if (getStartFrame() < 0 &&
|
Chris@127
|
1322 getEndFrame() >= getModelsEndFrame()) return;
|
Chris@127
|
1323
|
Chris@127
|
1324 long delta = ((width() / 2) * count * m_zoomLevel);
|
Chris@127
|
1325
|
Chris@127
|
1326 if (int(m_centreFrame) < delta) {
|
Chris@127
|
1327 setCentreFrame(0);
|
Chris@127
|
1328 } else if (int(m_centreFrame) - delta >= int(getModelsEndFrame())) {
|
Chris@127
|
1329 setCentreFrame(getModelsEndFrame());
|
Chris@127
|
1330 } else {
|
Chris@127
|
1331 setCentreFrame(m_centreFrame - delta);
|
Chris@127
|
1332 }
|
Chris@127
|
1333
|
Chris@127
|
1334 } else {
|
Chris@127
|
1335
|
Chris@127
|
1336 // Zoom in or out
|
Chris@127
|
1337
|
Chris@127
|
1338 int newZoomLevel = m_zoomLevel;
|
Chris@127
|
1339
|
Chris@127
|
1340 while (count > 0) {
|
Chris@127
|
1341 if (newZoomLevel <= 2) {
|
Chris@127
|
1342 newZoomLevel = 1;
|
Chris@127
|
1343 break;
|
Chris@127
|
1344 }
|
Chris@127
|
1345 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel - 1,
|
Chris@127
|
1346 ZoomConstraint::RoundDown);
|
Chris@127
|
1347 --count;
|
Chris@127
|
1348 }
|
Chris@127
|
1349
|
Chris@127
|
1350 while (count < 0) {
|
Chris@127
|
1351 newZoomLevel = getZoomConstraintBlockSize(newZoomLevel + 1,
|
Chris@127
|
1352 ZoomConstraint::RoundUp);
|
Chris@127
|
1353 ++count;
|
Chris@127
|
1354 }
|
Chris@127
|
1355
|
Chris@127
|
1356 if (newZoomLevel != m_zoomLevel) {
|
Chris@127
|
1357 setZoomLevel(newZoomLevel);
|
Chris@127
|
1358 }
|
Chris@127
|
1359 }
|
Chris@127
|
1360
|
Chris@127
|
1361 emit paneInteractedWith();
|
Chris@127
|
1362 }
|
Chris@127
|
1363
|
Chris@132
|
1364 void
|
Chris@132
|
1365 Pane::horizontalThumbwheelMoved(int value)
|
Chris@132
|
1366 {
|
Chris@137
|
1367 //!!! dupe with updateHeadsUpDisplay
|
Chris@137
|
1368
|
Chris@132
|
1369 int count = 0;
|
Chris@132
|
1370 int level = 1;
|
Chris@137
|
1371
|
Chris@137
|
1372
|
Chris@137
|
1373 //!!! pull out into function (presumably in View)
|
Chris@137
|
1374 bool haveConstraint = false;
|
Chris@137
|
1375 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end();
|
Chris@137
|
1376 ++i) {
|
Chris@137
|
1377 if ((*i)->getZoomConstraint() && !(*i)->supportsOtherZoomLevels()) {
|
Chris@137
|
1378 haveConstraint = true;
|
Chris@137
|
1379 break;
|
Chris@137
|
1380 }
|
Chris@132
|
1381 }
|
Chris@132
|
1382
|
Chris@137
|
1383 if (haveConstraint) {
|
Chris@137
|
1384 while (true) {
|
Chris@137
|
1385 if (m_hthumb->getMaximumValue() - value == count) break;
|
Chris@137
|
1386 int newLevel = getZoomConstraintBlockSize(level + 1,
|
Chris@137
|
1387 ZoomConstraint::RoundUp);
|
Chris@137
|
1388 if (newLevel == level) break;
|
Chris@137
|
1389 level = newLevel;
|
Chris@137
|
1390 if (++count == 50) break;
|
Chris@137
|
1391 }
|
Chris@137
|
1392 } else {
|
Chris@137
|
1393 while (true) {
|
Chris@137
|
1394 if (m_hthumb->getMaximumValue() - value == count) break;
|
Chris@137
|
1395 int step = level / 10;
|
Chris@137
|
1396 int pwr = 0;
|
Chris@137
|
1397 while (step > 0) {
|
Chris@137
|
1398 ++pwr;
|
Chris@137
|
1399 step /= 2;
|
Chris@137
|
1400 }
|
Chris@137
|
1401 step = 1;
|
Chris@137
|
1402 while (pwr > 0) {
|
Chris@137
|
1403 step *= 2;
|
Chris@137
|
1404 --pwr;
|
Chris@137
|
1405 }
|
Chris@137
|
1406 // std::cerr << level << std::endl;
|
Chris@137
|
1407 level += step;
|
Chris@137
|
1408 if (++count == 100 || level > 262144) break;
|
Chris@137
|
1409 }
|
Chris@137
|
1410 }
|
Chris@137
|
1411
|
Chris@137
|
1412 std::cerr << "new level is " << level << std::endl;
|
Chris@132
|
1413 setZoomLevel(level);
|
Chris@132
|
1414 }
|
Chris@132
|
1415
|
Chris@132
|
1416 void
|
Chris@132
|
1417 Pane::verticalThumbwheelMoved(int value)
|
Chris@132
|
1418 {
|
Chris@133
|
1419 Layer *layer = 0;
|
Chris@133
|
1420 if (getLayerCount() > 0) layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
1421 if (layer) {
|
Chris@133
|
1422 int defaultStep = 0;
|
Chris@133
|
1423 int max = layer->getVerticalZoomSteps(defaultStep);
|
Chris@133
|
1424 if (max == 0) {
|
Chris@133
|
1425 updateHeadsUpDisplay();
|
Chris@133
|
1426 return;
|
Chris@133
|
1427 }
|
Chris@133
|
1428 if (value > max) {
|
Chris@133
|
1429 value = max;
|
Chris@133
|
1430 }
|
Chris@133
|
1431 layer->setVerticalZoomStep(value);
|
Chris@174
|
1432 updateVerticalPanner();
|
Chris@133
|
1433 }
|
Chris@132
|
1434 }
|
Chris@132
|
1435
|
Chris@174
|
1436 void
|
Chris@174
|
1437 Pane::verticalPannerMoved(float x0, float y0, float w, float h)
|
Chris@174
|
1438 {
|
Chris@174
|
1439 float vmin, vmax, dmin, dmax;
|
Chris@174
|
1440 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax)) return;
|
Chris@174
|
1441 float y1 = y0 + h;
|
Chris@174
|
1442 float newmax = vmin + ((1.0 - y0) * (vmax - vmin));
|
Chris@174
|
1443 float newmin = vmin + ((1.0 - y1) * (vmax - vmin));
|
Chris@174
|
1444 std::cerr << "verticalPannerMoved: (" << x0 << "," << y0 << "," << w
|
Chris@174
|
1445 << "," << h << ") -> (" << newmin << "," << newmax << ")" << std::endl;
|
Chris@174
|
1446 setTopLayerDisplayExtents(newmin, newmax);
|
Chris@174
|
1447 }
|
Chris@174
|
1448
|
Chris@188
|
1449 void
|
Chris@188
|
1450 Pane::editVerticalPannerExtents()
|
Chris@188
|
1451 {
|
Chris@188
|
1452 if (!m_vpan || !m_manager || !m_manager->getZoomWheelsEnabled()) return;
|
Chris@188
|
1453
|
Chris@188
|
1454 float vmin, vmax, dmin, dmax;
|
Chris@188
|
1455 QString unit;
|
Chris@188
|
1456 if (!getTopLayerDisplayExtents(vmin, vmax, dmin, dmax, &unit)
|
Chris@188
|
1457 || vmax == vmin) {
|
Chris@188
|
1458 return;
|
Chris@188
|
1459 }
|
Chris@188
|
1460
|
Chris@188
|
1461 RangeInputDialog dialog(tr("Enter new range"),
|
Chris@188
|
1462 tr("New vertical display range, from %1 to %2 %4:")
|
Chris@188
|
1463 .arg(vmin).arg(vmax).arg(unit),
|
Chris@188
|
1464 unit, vmin, vmax, this);
|
Chris@188
|
1465 dialog.setRange(dmin, dmax);
|
Chris@188
|
1466
|
Chris@188
|
1467 if (dialog.exec() == QDialog::Accepted) {
|
Chris@188
|
1468 dialog.getRange(dmin, dmax);
|
Chris@188
|
1469 setTopLayerDisplayExtents(dmin, dmax);
|
Chris@188
|
1470 updateVerticalPanner();
|
Chris@188
|
1471 }
|
Chris@188
|
1472 }
|
Chris@188
|
1473
|
Chris@127
|
1474 bool
|
Chris@127
|
1475 Pane::editSelectionStart(QMouseEvent *e)
|
Chris@127
|
1476 {
|
Chris@127
|
1477 if (!m_identifyFeatures ||
|
Chris@127
|
1478 !m_manager ||
|
Chris@127
|
1479 m_manager->getToolMode() != ViewManager::EditMode) {
|
Chris@127
|
1480 return false;
|
Chris@127
|
1481 }
|
Chris@127
|
1482
|
Chris@127
|
1483 bool closeToLeft, closeToRight;
|
Chris@127
|
1484 Selection s(getSelectionAt(e->x(), closeToLeft, closeToRight));
|
Chris@127
|
1485 if (s.isEmpty()) return false;
|
Chris@127
|
1486 m_editingSelection = s;
|
Chris@127
|
1487 m_editingSelectionEdge = (closeToLeft ? -1 : closeToRight ? 1 : 0);
|
Chris@127
|
1488 m_mousePos = e->pos();
|
Chris@127
|
1489 return true;
|
Chris@127
|
1490 }
|
Chris@127
|
1491
|
Chris@127
|
1492 bool
|
Chris@127
|
1493 Pane::editSelectionDrag(QMouseEvent *e)
|
Chris@127
|
1494 {
|
Chris@127
|
1495 if (m_editingSelection.isEmpty()) return false;
|
Chris@127
|
1496 m_mousePos = e->pos();
|
Chris@127
|
1497 update();
|
Chris@127
|
1498 return true;
|
Chris@127
|
1499 }
|
Chris@127
|
1500
|
Chris@127
|
1501 bool
|
Chris@127
|
1502 Pane::editSelectionEnd(QMouseEvent *e)
|
Chris@127
|
1503 {
|
Chris@127
|
1504 if (m_editingSelection.isEmpty()) return false;
|
Chris@127
|
1505
|
Chris@127
|
1506 int offset = m_mousePos.x() - m_clickPos.x();
|
Chris@127
|
1507 Layer *layer = getSelectedLayer();
|
Chris@127
|
1508
|
Chris@127
|
1509 if (offset == 0 || !layer) {
|
Chris@127
|
1510 m_editingSelection = Selection();
|
Chris@127
|
1511 return true;
|
Chris@127
|
1512 }
|
Chris@127
|
1513
|
Chris@127
|
1514 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset;
|
Chris@127
|
1515 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset;
|
Chris@127
|
1516
|
Chris@127
|
1517 long f0 = getFrameForX(p0);
|
Chris@127
|
1518 long f1 = getFrameForX(p1);
|
Chris@127
|
1519
|
Chris@127
|
1520 Selection newSelection(f0, f1);
|
Chris@127
|
1521
|
Chris@127
|
1522 if (m_editingSelectionEdge == 0) {
|
Chris@127
|
1523
|
Chris@127
|
1524 CommandHistory::getInstance()->startCompoundOperation
|
Chris@127
|
1525 (tr("Drag Selection"), true);
|
Chris@127
|
1526
|
Chris@127
|
1527 layer->moveSelection(m_editingSelection, f0);
|
Chris@127
|
1528
|
Chris@127
|
1529 } else {
|
Chris@127
|
1530
|
Chris@127
|
1531 CommandHistory::getInstance()->startCompoundOperation
|
Chris@127
|
1532 (tr("Resize Selection"), true);
|
Chris@127
|
1533
|
Chris@127
|
1534 if (m_editingSelectionEdge < 0) {
|
Chris@127
|
1535 f1 = m_editingSelection.getEndFrame();
|
Chris@127
|
1536 } else {
|
Chris@127
|
1537 f0 = m_editingSelection.getStartFrame();
|
Chris@127
|
1538 }
|
Chris@127
|
1539
|
Chris@127
|
1540 newSelection = Selection(f0, f1);
|
Chris@127
|
1541 layer->resizeSelection(m_editingSelection, newSelection);
|
Chris@127
|
1542 }
|
Chris@127
|
1543
|
Chris@127
|
1544 m_manager->removeSelection(m_editingSelection);
|
Chris@127
|
1545 m_manager->addSelection(newSelection);
|
Chris@127
|
1546
|
Chris@127
|
1547 CommandHistory::getInstance()->endCompoundOperation();
|
Chris@127
|
1548
|
Chris@127
|
1549 m_editingSelection = Selection();
|
Chris@127
|
1550 return true;
|
Chris@127
|
1551 }
|
Chris@127
|
1552
|
Chris@127
|
1553 void
|
Chris@127
|
1554 Pane::toolModeChanged()
|
Chris@127
|
1555 {
|
Chris@127
|
1556 ViewManager::ToolMode mode = m_manager->getToolMode();
|
Chris@127
|
1557 // std::cerr << "Pane::toolModeChanged(" << mode << ")" << std::endl;
|
Chris@127
|
1558
|
Chris@127
|
1559 switch (mode) {
|
Chris@127
|
1560
|
Chris@127
|
1561 case ViewManager::NavigateMode:
|
Chris@127
|
1562 setCursor(Qt::PointingHandCursor);
|
Chris@127
|
1563 break;
|
Chris@127
|
1564
|
Chris@127
|
1565 case ViewManager::SelectMode:
|
Chris@127
|
1566 setCursor(Qt::ArrowCursor);
|
Chris@127
|
1567 break;
|
Chris@127
|
1568
|
Chris@127
|
1569 case ViewManager::EditMode:
|
Chris@127
|
1570 setCursor(Qt::UpArrowCursor);
|
Chris@127
|
1571 break;
|
Chris@127
|
1572
|
Chris@127
|
1573 case ViewManager::DrawMode:
|
Chris@127
|
1574 setCursor(Qt::CrossCursor);
|
Chris@127
|
1575 break;
|
Chris@127
|
1576 /*
|
Chris@127
|
1577 case ViewManager::TextMode:
|
Chris@127
|
1578 setCursor(Qt::IBeamCursor);
|
Chris@127
|
1579 break;
|
Chris@127
|
1580 */
|
Chris@127
|
1581 }
|
Chris@127
|
1582 }
|
Chris@127
|
1583
|
Chris@133
|
1584 void
|
Chris@133
|
1585 Pane::zoomWheelsEnabledChanged()
|
Chris@133
|
1586 {
|
Chris@133
|
1587 updateHeadsUpDisplay();
|
Chris@133
|
1588 update();
|
Chris@133
|
1589 }
|
Chris@133
|
1590
|
Chris@133
|
1591 void
|
Chris@133
|
1592 Pane::zoomLevelChanged()
|
Chris@133
|
1593 {
|
Chris@133
|
1594 if (m_manager && m_manager->getZoomWheelsEnabled()) {
|
Chris@133
|
1595 updateHeadsUpDisplay();
|
Chris@133
|
1596 }
|
Chris@133
|
1597 }
|
Chris@133
|
1598
|
Chris@133
|
1599 void
|
Chris@133
|
1600 Pane::propertyContainerSelected(View *v, PropertyContainer *pc)
|
Chris@133
|
1601 {
|
Chris@133
|
1602 Layer *layer = 0;
|
Chris@133
|
1603
|
Chris@133
|
1604 if (getLayerCount() > 0) {
|
Chris@133
|
1605 layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
1606 disconnect(layer, SIGNAL(verticalZoomChanged()),
|
Chris@133
|
1607 this, SLOT(verticalZoomChanged()));
|
Chris@133
|
1608 }
|
Chris@133
|
1609
|
Chris@133
|
1610 View::propertyContainerSelected(v, pc);
|
Chris@133
|
1611 updateHeadsUpDisplay();
|
Chris@133
|
1612
|
Chris@187
|
1613 if (m_vthumb) {
|
Chris@187
|
1614 RangeMapper *rm = 0;
|
Chris@187
|
1615 if (layer) rm = layer->getNewVerticalZoomRangeMapper();
|
Chris@187
|
1616 if (rm) m_vthumb->setRangeMapper(rm);
|
Chris@187
|
1617 }
|
Chris@187
|
1618
|
Chris@133
|
1619 if (getLayerCount() > 0) {
|
Chris@133
|
1620 layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
1621 connect(layer, SIGNAL(verticalZoomChanged()),
|
Chris@133
|
1622 this, SLOT(verticalZoomChanged()));
|
Chris@133
|
1623 }
|
Chris@133
|
1624 }
|
Chris@133
|
1625
|
Chris@133
|
1626 void
|
Chris@133
|
1627 Pane::verticalZoomChanged()
|
Chris@133
|
1628 {
|
Chris@133
|
1629 Layer *layer = 0;
|
Chris@133
|
1630
|
Chris@133
|
1631 if (getLayerCount() > 0) {
|
Chris@133
|
1632
|
Chris@133
|
1633 layer = getLayer(getLayerCount() - 1);
|
Chris@133
|
1634
|
Chris@133
|
1635 if (m_vthumb && m_vthumb->isVisible()) {
|
Chris@133
|
1636 m_vthumb->setValue(layer->getCurrentVerticalZoomStep());
|
Chris@133
|
1637 }
|
Chris@133
|
1638 }
|
Chris@133
|
1639 }
|
Chris@133
|
1640
|
Chris@189
|
1641 void
|
Chris@189
|
1642 Pane::updateContextHelp(const QPoint *pos)
|
Chris@189
|
1643 {
|
Chris@189
|
1644 QString help = "";
|
Chris@189
|
1645
|
Chris@189
|
1646 if (m_clickedInRange) {
|
Chris@189
|
1647 emit contextHelpChanged("");
|
Chris@189
|
1648 return;
|
Chris@189
|
1649 }
|
Chris@189
|
1650
|
Chris@189
|
1651 ViewManager::ToolMode mode = ViewManager::NavigateMode;
|
Chris@189
|
1652 if (m_manager) mode = m_manager->getToolMode();
|
Chris@189
|
1653
|
Chris@189
|
1654 bool editable = false;
|
Chris@189
|
1655 Layer *layer = getSelectedLayer();
|
Chris@189
|
1656 if (layer && layer->isLayerEditable()) {
|
Chris@189
|
1657 editable = true;
|
Chris@189
|
1658 }
|
Chris@189
|
1659
|
Chris@189
|
1660 if (mode == ViewManager::NavigateMode) {
|
Chris@189
|
1661
|
Chris@189
|
1662 help = tr("Click and drag to navigate");
|
Chris@189
|
1663
|
Chris@189
|
1664 } else if (mode == ViewManager::SelectMode) {
|
Chris@189
|
1665
|
Chris@189
|
1666 bool haveSelection = (m_manager && !m_manager->getSelections().empty());
|
Chris@189
|
1667
|
Chris@189
|
1668 if (haveSelection) {
|
Chris@189
|
1669 if (editable) {
|
Chris@189
|
1670 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
|
1671 } else {
|
Chris@189
|
1672 help = tr("Click and drag to select a range; hold Ctrl for multi-select; middle-click and drag to navigate");
|
Chris@189
|
1673 }
|
Chris@189
|
1674
|
Chris@189
|
1675 if (pos) {
|
Chris@189
|
1676 bool closeToLeft = false, closeToRight = false;
|
Chris@189
|
1677 Selection selection = getSelectionAt(pos->x(), closeToLeft, closeToRight);
|
Chris@189
|
1678 if ((closeToLeft || closeToRight) && !(closeToLeft && closeToRight)) {
|
Chris@189
|
1679
|
Chris@189
|
1680 help = tr("Click and drag to move the selection boundary");
|
Chris@189
|
1681 }
|
Chris@189
|
1682 }
|
Chris@189
|
1683 } else {
|
Chris@189
|
1684 if (editable) {
|
Chris@189
|
1685 help = tr("Click and drag to select a range; hold Shift to avoid snapping to items; middle-click to navigate");
|
Chris@189
|
1686 } else {
|
Chris@189
|
1687 help = tr("Click and drag to select a range; middle-click and drag to navigate");
|
Chris@189
|
1688 }
|
Chris@189
|
1689 }
|
Chris@189
|
1690
|
Chris@189
|
1691 } else if (mode == ViewManager::DrawMode) {
|
Chris@189
|
1692
|
Chris@189
|
1693 //!!! could call through to a layer function to find out exact meaning
|
Chris@189
|
1694 if (editable) {
|
Chris@189
|
1695 help = tr("Click to add a new item in the active layer");
|
Chris@189
|
1696 }
|
Chris@189
|
1697
|
Chris@189
|
1698 } else if (mode == ViewManager::EditMode) {
|
Chris@189
|
1699
|
Chris@189
|
1700 //!!! could call through to layer
|
Chris@189
|
1701 if (editable) {
|
Chris@189
|
1702 help = tr("Click and drag an item in the active layer to move it");
|
Chris@189
|
1703 if (pos) {
|
Chris@189
|
1704 bool closeToLeft = false, closeToRight = false;
|
Chris@189
|
1705 Selection selection = getSelectionAt(pos->x(), closeToLeft, closeToRight);
|
Chris@189
|
1706 if (!selection.isEmpty()) {
|
Chris@189
|
1707 help = tr("Click and drag to move all items in the selected range");
|
Chris@189
|
1708 }
|
Chris@189
|
1709 }
|
Chris@189
|
1710 }
|
Chris@189
|
1711 }
|
Chris@189
|
1712
|
Chris@189
|
1713 emit contextHelpChanged(help);
|
Chris@189
|
1714 }
|
Chris@189
|
1715
|
Chris@189
|
1716 void
|
Chris@189
|
1717 Pane::mouseEnteredWidget()
|
Chris@189
|
1718 {
|
Chris@189
|
1719 QWidget *w = dynamic_cast<QWidget *>(sender());
|
Chris@189
|
1720 if (!w) return;
|
Chris@189
|
1721
|
Chris@189
|
1722 if (w == m_vpan) {
|
Chris@189
|
1723 emit contextHelpChanged(tr("Click and drag to adjust the visible range of the vertical scale"));
|
Chris@189
|
1724 } else if (w == m_vthumb) {
|
Chris@189
|
1725 emit contextHelpChanged(tr("Click and drag to adjust the vertical zoom level"));
|
Chris@189
|
1726 } else if (w == m_hthumb) {
|
Chris@189
|
1727 emit contextHelpChanged(tr("Click and drag to adjust the horizontal zoom level"));
|
Chris@189
|
1728 } else if (w == m_reset) {
|
Chris@189
|
1729 emit contextHelpChanged(tr("Reset horizontal and vertical zoom levels to their defaults"));
|
Chris@189
|
1730 }
|
Chris@189
|
1731 }
|
Chris@189
|
1732
|
Chris@189
|
1733 void
|
Chris@189
|
1734 Pane::mouseLeftWidget()
|
Chris@189
|
1735 {
|
Chris@189
|
1736 emit contextHelpChanged("");
|
Chris@189
|
1737 }
|
Chris@189
|
1738
|
Chris@127
|
1739 QString
|
Chris@127
|
1740 Pane::toXmlString(QString indent, QString extraAttributes) const
|
Chris@127
|
1741 {
|
Chris@127
|
1742 return View::toXmlString
|
Chris@127
|
1743 (indent,
|
Chris@127
|
1744 QString("type=\"pane\" centreLineVisible=\"%1\" height=\"%2\" %3")
|
Chris@127
|
1745 .arg(m_centreLineVisible).arg(height()).arg(extraAttributes));
|
Chris@127
|
1746 }
|
Chris@127
|
1747
|
Chris@127
|
1748
|
Chris@127
|
1749 #ifdef INCLUDE_MOCFILES
|
Chris@127
|
1750 #include "Pane.moc.cpp"
|
Chris@127
|
1751 #endif
|
Chris@127
|
1752
|