annotate view/Pane.cpp @ 1541:b4b5b8dd5fe1

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