TextLayer.cpp
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #include "TextLayer.h"
17 
18 #include "data/model/Model.h"
19 #include "base/RealTime.h"
20 #include "base/Profiler.h"
21 #include "ColourDatabase.h"
22 #include "view/View.h"
23 
24 #include "data/model/TextModel.h"
25 
26 #include <QPainter>
27 #include <QMouseEvent>
28 #include <QInputDialog>
29 #include <QTextStream>
30 #include <QMessageBox>
31 
32 #include <iostream>
33 #include <cmath>
34 
37  m_editing(false),
38  m_originalPoint(0, 0.0, tr("Empty Label")),
39  m_editingPoint(0, 0.0, tr("Empty Label")),
40  m_editingCommand(nullptr)
41 {
42 
43 }
44 
45 int
47 {
48  auto model = ModelById::get(m_model);
49  if (model) return model->getCompletion();
50  else return 0;
51 }
52 
53 void
54 TextLayer::setModel(ModelId modelId)
55 {
56  auto newModel = ModelById::getAs<TextModel>(modelId);
57 
58  if (!modelId.isNone() && !newModel) {
59  throw std::logic_error("Not a TextModel");
60  }
61 
62  if (m_model == modelId) return;
63  m_model = modelId;
64 
65  if (newModel) {
67  }
68 
69  emit modelReplaced();
70 }
71 
72 Layer::PropertyList
74 {
75  PropertyList list = SingleColourLayer::getProperties();
76  return list;
77 }
78 
79 QString
80 TextLayer::getPropertyLabel(const PropertyName &name) const
81 {
83 }
84 
85 Layer::PropertyType
86 TextLayer::getPropertyType(const PropertyName &name) const
87 {
89 }
90 
91 int
92 TextLayer::getPropertyRangeAndValue(const PropertyName &name,
93  int *min, int *max, int *deflt) const
94 {
95  return SingleColourLayer::getPropertyRangeAndValue(name, min, max, deflt);
96 }
97 
98 QString
99 TextLayer::getPropertyValueLabel(const PropertyName &name,
100  int value) const
101 {
102  return SingleColourLayer::getPropertyValueLabel(name, value);
103 }
104 
105 void
106 TextLayer::setProperty(const PropertyName &name, int value)
107 {
108  SingleColourLayer::setProperty(name, value);
109 }
110 
111 bool
112 TextLayer::getValueExtents(double &, double &, bool &, QString &) const
113 {
114  return false;
115 }
116 
117 bool
119 {
120  QPoint discard;
121  return !v->shouldIlluminateLocalFeatures(this, discard);
122 }
123 
124 EventVector
126 {
127  auto model = ModelById::getAs<TextModel>(m_model);
128  if (!model) return {};
129 
130  int overlap = ViewManager::scalePixelSize(150);
131 
132  sv_frame_t frame0 = v->getFrameForX(-overlap);
133  sv_frame_t frame1 = v->getFrameForX(v->getPaintWidth() + overlap);
134 
135  EventVector points(model->getEventsSpanning(frame0, frame1 - frame0));
136 
137  EventVector rv;
138  QFontMetrics metrics = QFontMetrics(QFont());
139 
140  for (EventVector::iterator i = points.begin(); i != points.end(); ++i) {
141 
142  Event p(*i);
143 
144  int px = v->getXForFrame(p.getFrame());
145  int py = getYForHeight(v, p.getValue());
146 
147  QString label = p.getLabel();
148  if (label == "") {
149  label = tr("<no text>");
150  }
151 
152  QRect rect = metrics.boundingRect
153  (QRect(0, 0, 150, 200),
154  Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, label);
155 
156  if (py + rect.height() > v->getPaintHeight()) {
157  if (rect.height() > v->getPaintHeight()) py = 0;
158  else py = v->getPaintHeight() - rect.height() - 1;
159  }
160 
161  if (x >= px && x < px + rect.width() &&
162  y >= py && y < py + rect.height()) {
163  rv.push_back(p);
164  }
165  }
166 
167  return rv;
168 }
169 
170 bool
171 TextLayer::getPointToDrag(LayerGeometryProvider *v, int x, int y, Event &p) const
172 {
173  auto model = ModelById::getAs<TextModel>(m_model);
174  if (!model) return false;
175 
176  sv_frame_t a = v->getFrameForX(x - ViewManager::scalePixelSize(120));
177  sv_frame_t b = v->getFrameForX(x + ViewManager::scalePixelSize(10));
178  EventVector onPoints = model->getEventsWithin(a, b);
179  if (onPoints.empty()) return false;
180 
181  double nearestDistance = -1;
182 
183  for (EventVector::const_iterator i = onPoints.begin();
184  i != onPoints.end(); ++i) {
185 
186  double yd = getYForHeight(v, i->getValue()) - y;
187  double xd = v->getXForFrame(i->getFrame()) - x;
188  double distance = sqrt(yd*yd + xd*xd);
189 
190  if (nearestDistance == -1 || distance < nearestDistance) {
191  nearestDistance = distance;
192  p = *i;
193  }
194  }
195 
196  return true;
197 }
198 
199 QString
201 {
202  int x = pos.x();
203 
204  auto model = ModelById::getAs<TextModel>(m_model);
205  if (!model || !model->getSampleRate()) return "";
206 
207  EventVector points = getLocalPoints(v, x, pos.y());
208 
209  if (points.empty()) {
210  if (!model->isReady()) {
211  return tr("In progress");
212  } else {
213  return "";
214  }
215  }
216 
217  sv_frame_t useFrame = points.begin()->getFrame();
218 
219  RealTime rt = RealTime::frame2RealTime(useFrame, model->getSampleRate());
220 
221  QString text;
222 
223  if (points.begin()->getLabel() == "") {
224  text = QString(tr("Time:\t%1\nHeight:\t%2\nLabel:\t%3"))
225  .arg(rt.toText(true).c_str())
226  .arg(points.begin()->getValue())
227  .arg(points.begin()->getLabel());
228  }
229 
230  pos = QPoint(v->getXForFrame(useFrame),
231  getYForHeight(v, points.begin()->getValue()));
232  return text;
233 }
234 
235 
237 
238 bool
240  int &resolution,
241  SnapType snap, int ycoord) const
242 {
243  auto model = ModelById::getAs<TextModel>(m_model);
244  if (!model) {
245  return Layer::snapToFeatureFrame(v, frame, resolution, snap, ycoord);
246  }
247 
248  // SnapLeft / SnapRight: return frame of nearest feature in that
249  // direction no matter how far away
250  //
251  // SnapNeighbouring: return frame of feature that would be used in
252  // an editing operation, i.e. closest feature in either direction
253  // but only if it is "close enough"
254 
255  resolution = model->getResolution();
256 
257  if (snap == SnapNeighbouring) {
258  EventVector points = getLocalPoints(v, v->getXForFrame(frame), -1);
259  if (points.empty()) return false;
260  frame = points.begin()->getFrame();
261  return true;
262  }
263 
264  Event e;
265  if (model->getNearestEventMatching
266  (frame,
267  [](Event) { return true; },
268  snap == SnapLeft ? EventSeries::Backward : EventSeries::Forward,
269  e)) {
270  frame = e.getFrame();
271  return true;
272  }
273 
274  return false;
275 }
276 
277 int
279 {
280  int h = v->getPaintHeight();
281  return h - int(height * h);
282 }
283 
284 double
286 {
287  int h = v->getPaintHeight();
288  return double(h - y) / h;
289 }
290 
291 void
292 TextLayer::paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const
293 {
294  auto model = ModelById::getAs<TextModel>(m_model);
295  if (!model || !model->isOK()) return;
296 
297  sv_samplerate_t sampleRate = model->getSampleRate();
298  if (!sampleRate) return;
299 
300 // Profiler profiler("TextLayer::paint", true);
301 
302  int x0 = rect.left();
303  int x1 = x0 + rect.width();
304 
305  int overlap = ViewManager::scalePixelSize(150);
306  sv_frame_t frame0 = v->getFrameForX(x0 - overlap);
307  sv_frame_t frame1 = v->getFrameForX(x1 + overlap);
308 
309  EventVector points(model->getEventsWithin(frame0, frame1 - frame0, 2));
310  if (points.empty()) return;
311 
312  QColor brushColour(getBaseQColor());
313 
314  int h, s, val;
315  brushColour.getHsv(&h, &s, &val);
316  brushColour.setHsv(h, s, 255, 100);
317 
318  QColor penColour;
319  penColour = v->getForeground();
320 
321 // SVDEBUG << "TextLayer::paint: resolution is "
322 // << model->getResolution() << " frames" << endl;
323 
324  QPoint localPos;
325  Event illuminatePoint(0);
326  bool shouldIlluminate = false;
327 
328  if (v->shouldIlluminateLocalFeatures(this, localPos)) {
329  shouldIlluminate = getPointToDrag(v, localPos.x(), localPos.y(),
330  illuminatePoint);
331  }
332 
333  int boxMaxWidth = 150;
334  int boxMaxHeight = 200;
335 
336  paint.save();
337  paint.setClipRect(rect.x(), 0, rect.width() + boxMaxWidth, v->getPaintHeight());
338 
339  for (EventVector::const_iterator i = points.begin();
340  i != points.end(); ++i) {
341 
342  Event p(*i);
343 
344  int x = v->getXForFrame(p.getFrame());
345  int y = getYForHeight(v, p.getValue());
346 
347  if (!shouldIlluminate || illuminatePoint != p) {
348  paint.setPen(penColour);
349  paint.setBrush(brushColour);
350  } else {
351  paint.setBrush(penColour);
352  paint.setPen(v->getBackground());
353  }
354 
355  QString label = p.getLabel();
356  if (label == "") {
357  label = tr("<no text>");
358  }
359 
360  QRect boxRect = paint.fontMetrics().boundingRect
361  (QRect(0, 0, boxMaxWidth, boxMaxHeight),
362  Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, label);
363 
364  QRect textRect = QRect(3, 2, boxRect.width(), boxRect.height());
365  boxRect = QRect(0, 0, boxRect.width() + 6, boxRect.height() + 2);
366 
367  if (y + boxRect.height() > v->getPaintHeight()) {
368  if (boxRect.height() > v->getPaintHeight()) y = 0;
369  else y = v->getPaintHeight() - boxRect.height() - 1;
370  }
371 
372  boxRect = QRect(x, y, boxRect.width(), boxRect.height());
373  textRect = QRect(x + 3, y + 2, textRect.width(), textRect.height());
374 
375 // boxRect = QRect(x, y, boxRect.width(), boxRect.height());
376 // textRect = QRect(x + 3, y + 2, textRect.width(), textRect.height());
377 
378  paint.setRenderHint(QPainter::Antialiasing, false);
379  paint.drawRect(boxRect);
380 
381  paint.setRenderHint(QPainter::Antialiasing, true);
382  paint.drawText(textRect,
383  Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap,
384  label);
385 
389  }
390 
391  paint.restore();
392 
393  // looks like save/restore doesn't deal with this:
394  paint.setRenderHint(QPainter::Antialiasing, false);
395 }
396 
397 void
399 {
400 // SVDEBUG << "TextLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl;
401 
402  auto model = ModelById::getAs<TextModel>(m_model);
403  if (!model) {
404  SVDEBUG << "TextLayer::drawStart: no model" << endl;
405  return;
406  }
407 
408  sv_frame_t frame = v->getFrameForX(e->x());
409  if (frame < 0) frame = 0;
410  frame = frame / model->getResolution() * model->getResolution();
411 
412  double height = getHeightForY(v, e->y());
413 
414  m_editingPoint = Event(frame, float(height), "");
416 
418  m_editingCommand = new ChangeEventsCommand(m_model.untyped, "Add Label");
419  m_editingCommand->add(m_editingPoint);
420 
421  m_editing = true;
422 }
423 
424 void
426 {
427 // SVDEBUG << "TextLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl;
428 
429  auto model = ModelById::getAs<TextModel>(m_model);
430  if (!model || !m_editing) return;
431 
432  sv_frame_t frame = v->getFrameForX(e->x());
433  if (frame < 0) frame = 0;
434  frame = frame / model->getResolution() * model->getResolution();
435 
436  double height = getHeightForY(v, e->y());
437 
440  .withFrame(frame)
441  .withValue(float(height));
443 }
444 
445 void
447 {
448 // SVDEBUG << "TextLayer::drawEnd(" << e->x() << "," << e->y() << ")" << endl;
449  auto model = ModelById::getAs<TextModel>(m_model);
450  if (!model || !m_editing) return;
451 
452  bool ok = false;
453  QString label = QInputDialog::getText(v->getView(), tr("Enter label"),
454  tr("Please enter a new label:"),
455  QLineEdit::Normal, "", &ok);
456 
458 
459  if (ok) {
461  .withLabel(label);
463  }
464 
466  m_editingCommand = nullptr;
467  m_editing = false;
468 }
469 
470 void
472 {
473  auto model = ModelById::getAs<TextModel>(m_model);
474  if (!model) return;
475 
476  if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) return;
477 
478  if (m_editingCommand) {
480  m_editingCommand = nullptr;
481  }
482 
483  m_editing = true;
484 }
485 
486 void
488 {
489 }
490 
491 void
493 {
494  auto model = ModelById::getAs<TextModel>(m_model);
495  if (!model || !m_editing) return;
496 
497  m_editing = false;
498 
499  Event p;
500  if (!getPointToDrag(v, e->x(), e->y(), p)) return;
501  if (p.getFrame() != m_editingPoint.getFrame() ||
502  p.getValue() != m_editingPoint.getValue()) return;
503 
504  m_editingCommand = new ChangeEventsCommand(m_model.untyped, tr("Erase Point"));
507  m_editingCommand = nullptr;
508  m_editing = false;
509 }
510 
511 void
513 {
514 // SVDEBUG << "TextLayer::editStart(" << e->x() << "," << e->y() << ")" << endl;
515 
516  auto model = ModelById::getAs<TextModel>(m_model);
517  if (!model) return;
518 
519  if (!getPointToDrag(v, e->x(), e->y(), m_editingPoint)) {
520  return;
521  }
522 
523  m_editOrigin = e->pos();
525 
526  if (m_editingCommand) {
528  m_editingCommand = nullptr;
529  }
530 
531  m_editing = true;
532 }
533 
534 void
536 {
537  auto model = ModelById::getAs<TextModel>(m_model);
538  if (!model || !m_editing) return;
539 
540  sv_frame_t frameDiff =
541  v->getFrameForX(e->x()) - v->getFrameForX(m_editOrigin.x());
542  double heightDiff =
543  getHeightForY(v, e->y()) - getHeightForY(v, m_editOrigin.y());
544 
545  sv_frame_t frame = m_originalPoint.getFrame() + frameDiff;
546  double height = m_originalPoint.getValue() + heightDiff;
547 
548  if (frame < 0) frame = 0;
549  frame = (frame / model->getResolution()) * model->getResolution();
550 
551  if (!m_editingCommand) {
552  m_editingCommand = new ChangeEventsCommand(m_model.untyped, tr("Drag Label"));
553  }
554 
557  .withFrame(frame)
558  .withValue(float(height));
560 }
561 
562 void
564 {
565 // SVDEBUG << "TextLayer::editEnd(" << e->x() << "," << e->y() << ")" << endl;
566  auto model = ModelById::getAs<TextModel>(m_model);
567  if (!model || !m_editing) return;
568 
569  if (m_editingCommand) {
570 
571  QString newName = m_editingCommand->getName();
572 
573  if (m_editingPoint.getFrame() != m_originalPoint.getFrame()) {
574  if (m_editingPoint.getValue() != m_originalPoint.getValue()) {
575  newName = tr("Move Label");
576  } else {
577  newName = tr("Move Label Horizontally");
578  }
579  } else {
580  newName = tr("Move Label Vertically");
581  }
582 
583  m_editingCommand->setName(newName);
585  }
586 
587  m_editingCommand = nullptr;
588  m_editing = false;
589 }
590 
591 bool
593 {
594  auto model = ModelById::getAs<TextModel>(m_model);
595  if (!model) return false;
596 
597  Event text;
598  if (!getPointToDrag(v, e->x(), e->y(), text)) return false;
599 
600  QString label = text.getLabel();
601 
602  bool ok = false;
603  label = QInputDialog::getText(v->getView(), tr("Enter label"),
604  tr("Please enter a new label:"),
605  QLineEdit::Normal, label, &ok);
606  if (ok && label != text.getLabel()) {
607  ChangeEventsCommand *command =
608  new ChangeEventsCommand(m_model.untyped, tr("Re-Label Point"));
609  command->remove(text);
610  command->add(text.withLabel(label));
611  finish(command);
612  }
613 
614  return true;
615 }
616 
617 void
618 TextLayer::moveSelection(Selection s, sv_frame_t newStartFrame)
619 {
620  auto model = ModelById::getAs<TextModel>(m_model);
621  if (!model) return;
622 
623  ChangeEventsCommand *command =
624  new ChangeEventsCommand(m_model.untyped, tr("Drag Selection"));
625 
626  EventVector points =
627  model->getEventsStartingWithin(s.getStartFrame(), s.getDuration());
628 
629  for (Event p: points) {
630  command->remove(p);
631  Event moved = p.withFrame(p.getFrame() +
632  newStartFrame - s.getStartFrame());
633  command->add(moved);
634  }
635 
636  finish(command);
637 }
638 
639 void
640 TextLayer::resizeSelection(Selection s, Selection newSize)
641 {
642  auto model = ModelById::getAs<TextModel>(m_model);
643  if (!model) return;
644 
645  ChangeEventsCommand *command =
646  new ChangeEventsCommand(m_model.untyped, tr("Resize Selection"));
647 
648  EventVector points =
649  model->getEventsStartingWithin(s.getStartFrame(), s.getDuration());
650 
651  double ratio = double(newSize.getDuration()) / double(s.getDuration());
652  double oldStart = double(s.getStartFrame());
653  double newStart = double(newSize.getStartFrame());
654 
655  for (Event p: points) {
656 
657  double newFrame = (double(p.getFrame()) - oldStart) * ratio + newStart;
658 
659  Event newPoint = p
660  .withFrame(lrint(newFrame));
661  command->remove(p);
662  command->add(newPoint);
663  }
664 
665  finish(command);
666 }
667 
668 void
670 {
671  auto model = ModelById::getAs<TextModel>(m_model);
672  if (!model) return;
673 
674  ChangeEventsCommand *command =
675  new ChangeEventsCommand(m_model.untyped, tr("Delete Selection"));
676 
677  EventVector points =
678  model->getEventsStartingWithin(s.getStartFrame(), s.getDuration());
679 
680  for (Event p: points) {
681  command->remove(p);
682  }
683 
684  finish(command);
685 }
686 
687 void
688 TextLayer::copy(LayerGeometryProvider *v, Selection s, Clipboard &to)
689 {
690  auto model = ModelById::getAs<TextModel>(m_model);
691  if (!model) return;
692 
693  EventVector points =
694  model->getEventsStartingWithin(s.getStartFrame(), s.getDuration());
695 
696  for (Event p: points) {
697  to.addPoint(p.withReferenceFrame(alignToReference(v, p.getFrame())));
698  }
699 }
700 
701 bool
702 TextLayer::paste(LayerGeometryProvider *v, const Clipboard &from,
703  sv_frame_t /* frameOffset */, bool /* interactive */)
704 {
705  auto model = ModelById::getAs<TextModel>(m_model);
706  if (!model) return false;
707 
708  const EventVector &points = from.getPoints();
709 
710  bool realign = false;
711 
712  if (clipboardHasDifferentAlignment(v, from)) {
713 
714  QMessageBox::StandardButton button =
715  QMessageBox::question(v->getView(), tr("Re-align pasted items?"),
716  tr("The items you are pasting came from a layer with different source material from this one. Do you want to re-align them in time, to match the source material for this layer?"),
717  QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel,
718  QMessageBox::Yes);
719 
720  if (button == QMessageBox::Cancel) {
721  return false;
722  }
723 
724  if (button == QMessageBox::Yes) {
725  realign = true;
726  }
727  }
728 
729  ChangeEventsCommand *command =
730  new ChangeEventsCommand(m_model.untyped, tr("Paste"));
731 
732  double valueMin = 0.0, valueMax = 1.0;
733  for (EventVector::const_iterator i = points.begin();
734  i != points.end(); ++i) {
735  if (i->hasValue()) {
736  if (i->getValue() < valueMin) valueMin = i->getValue();
737  if (i->getValue() > valueMax) valueMax = i->getValue();
738  }
739  }
740  if (valueMax < valueMin + 1.0) valueMax = valueMin + 1.0;
741 
742  for (EventVector::const_iterator i = points.begin();
743  i != points.end(); ++i) {
744 
745  sv_frame_t frame = 0;
746 
747  if (!realign) {
748 
749  frame = i->getFrame();
750 
751  } else {
752 
753  if (i->hasReferenceFrame()) {
754  frame = i->getReferenceFrame();
755  frame = alignFromReference(v, frame);
756  } else {
757  frame = i->getFrame();
758  }
759  }
760 
761  Event p = i->withFrame(frame);
762 
763  Event newPoint = p;
764  if (p.hasValue()) {
765  newPoint = newPoint.withValue(float((i->getValue() - valueMin) /
766  (valueMax - valueMin)));
767  } else {
768  newPoint = newPoint.withValue(0.5f);
769  }
770 
771  if (!p.hasLabel()) {
772  if (p.hasValue()) {
773  newPoint = newPoint.withLabel(QString("%1").arg(p.getValue()));
774  } else {
775  newPoint = newPoint.withLabel(tr("New Point"));
776  }
777  }
778 
779  command->add(newPoint);
780  }
781 
782  finish(command);
783  return true;
784 }
785 
786 int
787 TextLayer::getDefaultColourHint(bool darkbg, bool &impose)
788 {
789  impose = false;
791  (QString(darkbg ? "Bright Orange" : "Orange"));
792 }
793 
794 void
795 TextLayer::toXml(QTextStream &stream,
796  QString indent, QString extraAttributes) const
797 {
798  SingleColourLayer::toXml(stream, indent, extraAttributes);
799 }
800 
801 void
802 TextLayer::setProperties(const QXmlAttributes &attributes)
803 {
805 }
806 
void drawDrag(LayerGeometryProvider *v, QMouseEvent *) override
Definition: TextLayer.cpp:425
ModelId m_model
Definition: TextLayer.h:103
virtual bool snapToFeatureFrame(LayerGeometryProvider *, sv_frame_t &, int &resolution, SnapType, int) const
Adjust the given frame to snap to the nearest feature, if possible.
Definition: Layer.h:226
Event m_editingPoint
Definition: TextLayer.h:107
virtual QColor getForeground() const =0
bool getValueExtents(double &min, double &max, bool &logarithmic, QString &unit) const override
Return the minimum and maximum values for the y axis of the model in this layer, as well as whether t...
Definition: TextLayer.cpp:112
void moveSelection(Selection s, sv_frame_t newStartFrame) override
Definition: TextLayer.cpp:618
Event m_originalPoint
Definition: TextLayer.h:106
virtual QColor getBackground() const =0
PropertyList getProperties() const override
virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const =0
static int scalePixelSize(int pixels)
Take a "design pixel" size and scale it for the actual display.
void modelReplaced()
void editEnd(LayerGeometryProvider *v, QMouseEvent *) override
Definition: TextLayer.cpp:563
int getCompletion(LayerGeometryProvider *) const override
Return the proportion of background work complete in drawing this view, as a percentage – in most ca...
Definition: TextLayer.cpp:46
void setModel(ModelId model)
Definition: TextLayer.cpp:54
bool isLayerScrollable(const LayerGeometryProvider *v) const override
This should return true if the layer can safely be scrolled automatically by a given view (simply cop...
Definition: TextLayer.cpp:118
EventVector getLocalPoints(LayerGeometryProvider *v, int x, int y) const
Definition: TextLayer.cpp:125
int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const override
Definition: TextLayer.cpp:92
ChangeEventsCommand * m_editingCommand
Definition: TextLayer.h:108
int getDefaultColourHint(bool dark, bool &impose) override
Definition: TextLayer.cpp:787
virtual sv_frame_t getFrameForX(int x) const =0
Return the closest frame to the given pixel x-coordinate.
bool snapToFeatureFrame(LayerGeometryProvider *v, sv_frame_t &frame, int &resolution, SnapType snap, int ycoord) const override
!! too much overlap with TimeValueLayer/TimeInstantLayer
Definition: TextLayer.cpp:239
virtual QColor getBaseQColor() const
void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const override
bool getPointToDrag(LayerGeometryProvider *v, int x, int y, Event &) const
Definition: TextLayer.cpp:171
Interface for classes that provide geometry information (such as size, start frame, and a large number of other properties) about the disposition of a layer.
void paint(LayerGeometryProvider *v, QPainter &paint, QRect rect) const override
Paint the given rectangle of this layer onto the given view using the given painter, superimposing it on top of any existing material in that view.
Definition: TextLayer.cpp:292
QString getPropertyValueLabel(const PropertyName &, int value) const override
Definition: TextLayer.cpp:99
QPoint m_editOrigin
Definition: TextLayer.h:105
int getColourIndex(QString name) const
Return the index of the colour with the given name, if found in the database.
PropertyType getPropertyType(const PropertyName &) const override
Definition: TextLayer.cpp:86
virtual sv_frame_t alignFromReference(LayerGeometryProvider *v, sv_frame_t frame) const
Definition: Layer.cpp:198
void resizeSelection(Selection s, Selection newSize) override
Definition: TextLayer.cpp:640
void editDrag(LayerGeometryProvider *v, QMouseEvent *) override
Definition: TextLayer.cpp:535
void deleteSelection(Selection s) override
Definition: TextLayer.cpp:669
bool clipboardHasDifferentAlignment(LayerGeometryProvider *v, const Clipboard &clip) const
Definition: Layer.cpp:209
int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const override
void drawEnd(LayerGeometryProvider *v, QMouseEvent *) override
Definition: TextLayer.cpp:446
SnapType
Definition: Layer.h:195
virtual sv_frame_t alignToReference(LayerGeometryProvider *v, sv_frame_t frame) const
Definition: Layer.cpp:187
void eraseEnd(LayerGeometryProvider *v, QMouseEvent *) override
Definition: TextLayer.cpp:492
void connectSignals(ModelId)
Definition: Layer.cpp:49
virtual int getPaintHeight() const
void setProperties(const QXmlAttributes &attributes) override
Set the particular properties of a layer (those specific to the subclass) from a set of XML attribute...
Definition: TextLayer.cpp:802
PropertyType getPropertyType(const PropertyName &) const override
bool editOpen(LayerGeometryProvider *, QMouseEvent *) override
Open an editor on the item under the mouse (e.g.
Definition: TextLayer.cpp:592
int getYForHeight(LayerGeometryProvider *v, double height) const
Definition: TextLayer.cpp:278
void setProperty(const PropertyName &, int value) override
Definition: TextLayer.cpp:106
void setProperties(const QXmlAttributes &attributes) override
Set the particular properties of a layer (those specific to the subclass) from a set of XML attribute...
void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const override
Definition: TextLayer.cpp:795
void drawStart(LayerGeometryProvider *v, QMouseEvent *) override
Definition: TextLayer.cpp:398
QString getPropertyValueLabel(const PropertyName &, int value) const override
bool m_editing
Definition: TextLayer.h:104
void finish(ChangeEventsCommand *command)
Definition: TextLayer.h:110
void editStart(LayerGeometryProvider *v, QMouseEvent *) override
Definition: TextLayer.cpp:512
void eraseStart(LayerGeometryProvider *v, QMouseEvent *) override
Definition: TextLayer.cpp:471
QString getFeatureDescription(LayerGeometryProvider *v, QPoint &) const override
Definition: TextLayer.cpp:200
PropertyList getProperties() const override
Definition: TextLayer.cpp:73
void eraseDrag(LayerGeometryProvider *v, QMouseEvent *) override
Definition: TextLayer.cpp:487
QString getPropertyLabel(const PropertyName &) const override
Definition: TextLayer.cpp:80
bool paste(LayerGeometryProvider *v, const Clipboard &from, sv_frame_t frameOffset, bool interactive) override
Paste from the given clipboard onto the layer at the given frame offset.
Definition: TextLayer.cpp:702
void copy(LayerGeometryProvider *v, Selection s, Clipboard &to) override
Definition: TextLayer.cpp:688
void setProperty(const PropertyName &, int value) override
virtual int getXForFrame(sv_frame_t frame) const =0
Return the pixel x-coordinate corresponding to a given sample frame (which may be negative)...
virtual int getPaintWidth() const
QString getPropertyLabel(const PropertyName &) const override
static ColourDatabase * getInstance()
virtual View * getView()=0
double getHeightForY(LayerGeometryProvider *v, int y) const
Definition: TextLayer.cpp:285