comparison base/View.cpp @ 29:8460b3bf8f04

* Implement play mute, level and pan controls and a layer visibility control * Handle swapping the buffers in AudioCallbackPlaySource more gracefully, so that in many cases it can be done inaudibly. Still gets it wrong when playing in a noncontiguous selection. * Fix to SV file save for non-2d sparse models * Fixes to LED button drawing and AudioDial mouse functionality * Add progress bar for Ogg file import * Reshuffle PropertyContainer and its subclasses so it can be a QObject * Add layer dormancy (invisible layer permitted to free its cache space) * Optimisations to SpectrogramLayer, removing locks when reading/writing individual pixels in the cache (should be unnecessary there) -- there's still an issue here as we need a lock when reading from the model in case the model is replaced, and we don't currently have one * Several munlock() calls to make it harder to exhaust real memory if running in an RT mode with mlockall() active
author Chris Cannam
date Fri, 17 Feb 2006 18:04:26 +0000
parents 7dad8a310963
children 4afaf0df4d51
comparison
equal deleted inserted replaced
28:4b16526b011b 29:8460b3bf8f04
42 m_cacheCentreFrame(0), 42 m_cacheCentreFrame(0),
43 m_cacheZoomLevel(1024), 43 m_cacheZoomLevel(1024),
44 m_selectionCached(false), 44 m_selectionCached(false),
45 m_deleting(false), 45 m_deleting(false),
46 m_haveSelectedLayer(false), 46 m_haveSelectedLayer(false),
47 m_manager(0) 47 m_manager(0),
48 m_propertyContainer(new ViewPropertyContainer(this))
48 { 49 {
49 // QWidget::setAttribute(Qt::WA_PaintOnScreen); 50 // QWidget::setAttribute(Qt::WA_PaintOnScreen);
50 } 51 }
51 52
52 View::~View() 53 View::~View()
54 m_deleting = true; 55 m_deleting = true;
55 56
56 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { 57 for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
57 delete *i; 58 delete *i;
58 } 59 }
60
61 delete m_propertyContainer;
59 } 62 }
60 63
61 PropertyContainer::PropertyList 64 PropertyContainer::PropertyList
62 View::getProperties() const 65 View::getProperties() const
63 { 66 {
64 PropertyList list; 67 PropertyContainer::PropertyList list;
65 list.push_back(tr("Global Scroll")); 68 list.push_back(tr("Global Scroll"));
66 list.push_back(tr("Global Zoom")); 69 list.push_back(tr("Global Zoom"));
67 list.push_back(tr("Follow Playback")); 70 list.push_back(tr("Follow Playback"));
68 return list; 71 return list;
69 } 72 }
70 73
71 PropertyContainer::PropertyType 74 PropertyContainer::PropertyType
72 View::getPropertyType(const PropertyName &name) const 75 View::getPropertyType(const PropertyContainer::PropertyName &name) const
73 { 76 {
74 if (name == tr("Global Scroll")) return ToggleProperty; 77 if (name == tr("Global Scroll")) return PropertyContainer::ToggleProperty;
75 if (name == tr("Global Zoom")) return ToggleProperty; 78 if (name == tr("Global Zoom")) return PropertyContainer::ToggleProperty;
76 if (name == tr("Follow Playback")) return ValueProperty; 79 if (name == tr("Follow Playback")) return PropertyContainer::ValueProperty;
77 return InvalidProperty; 80 return PropertyContainer::InvalidProperty;
78 } 81 }
79 82
80 int 83 int
81 View::getPropertyRangeAndValue(const PropertyName &name, 84 View::getPropertyRangeAndValue(const PropertyContainer::PropertyName &name,
82 int *min, int *max) const 85 int *min, int *max) const
83 { 86 {
84 if (name == tr("Global Scroll")) return m_followPan; 87 if (name == tr("Global Scroll")) return m_followPan;
85 if (name == tr("Global Zoom")) return m_followZoom; 88 if (name == tr("Global Zoom")) return m_followZoom;
86 if (name == tr("Follow Playback")) { *min = 0; *max = 2; return int(m_followPlay); } 89 if (name == tr("Follow Playback")) {
87 return PropertyContainer::getPropertyRangeAndValue(name, min, max); 90 if (min) *min = 0;
91 if (max) *max = 2;
92 return int(m_followPlay);
93 }
94 if (min) *min = 0;
95 if (max) *max = 0;
96 return 0;
88 } 97 }
89 98
90 QString 99 QString
91 View::getPropertyValueLabel(const PropertyName &name, 100 View::getPropertyValueLabel(const PropertyContainer::PropertyName &name,
92 int value) const 101 int value) const
93 { 102 {
94 if (name == tr("Follow Playback")) { 103 if (name == tr("Follow Playback")) {
95 switch (value) { 104 switch (value) {
96 default: 105 default:
97 case 0: return tr("Scroll"); 106 case 0: return tr("Scroll");
101 } 110 }
102 return tr("<unknown>"); 111 return tr("<unknown>");
103 } 112 }
104 113
105 void 114 void
106 View::setProperty(const PropertyName &name, int value) 115 View::setProperty(const PropertyContainer::PropertyName &name, int value)
107 { 116 {
108 if (name == tr("Global Scroll")) { 117 if (name == tr("Global Scroll")) {
109 setFollowGlobalPan(value != 0); 118 setFollowGlobalPan(value != 0);
110 } else if (name == tr("Global Zoom")) { 119 } else if (name == tr("Global Zoom")) {
111 setFollowGlobalZoom(value != 0); 120 setFollowGlobalZoom(value != 0);
133 } 142 }
134 143
135 PropertyContainer * 144 PropertyContainer *
136 View::getPropertyContainer(size_t i) 145 View::getPropertyContainer(size_t i)
137 { 146 {
138 if (i == 0) return this; 147 if (i == 0) return m_propertyContainer;
139 return m_layers[i-1]; 148 return m_layers[i-1];
140 } 149 }
141 150
142 void 151 void
143 View::propertyContainerSelected(PropertyContainer *pc) 152 View::propertyContainerSelected(PropertyContainer *pc)
144 { 153 {
145 if (pc == this) { 154 if (pc == m_propertyContainer) {
146 if (m_haveSelectedLayer) { 155 if (m_haveSelectedLayer) {
147 m_haveSelectedLayer = false; 156 m_haveSelectedLayer = false;
148 update(); 157 update();
149 } 158 }
150 return; 159 return;
378 387
379 void 388 void
380 View::setFollowGlobalPan(bool f) 389 View::setFollowGlobalPan(bool f)
381 { 390 {
382 m_followPan = f; 391 m_followPan = f;
383 emit propertyContainerPropertyChanged(this); 392 emit propertyContainerPropertyChanged(m_propertyContainer);
384 } 393 }
385 394
386 void 395 void
387 View::setFollowGlobalZoom(bool f) 396 View::setFollowGlobalZoom(bool f)
388 { 397 {
389 m_followZoom = f; 398 m_followZoom = f;
390 emit propertyContainerPropertyChanged(this); 399 emit propertyContainerPropertyChanged(m_propertyContainer);
391 } 400 }
392 401
393 void 402 void
394 View::setPlaybackFollow(PlaybackFollowMode m) 403 View::setPlaybackFollow(PlaybackFollowMode m)
395 { 404 {
396 m_followPlay = m; 405 m_followPlay = m;
397 emit propertyContainerPropertyChanged(this); 406 emit propertyContainerPropertyChanged(m_propertyContainer);
398 } 407 }
399 408
400 void 409 void
401 View::modelChanged() 410 View::modelChanged()
402 { 411 {
690 { 699 {
691 changed = false; 700 changed = false;
692 701
693 LayerList scrollables; 702 LayerList scrollables;
694 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { 703 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
704 if ((*i)->isLayerDormant()) continue;
695 if ((*i)->isLayerScrollable()) scrollables.push_back(*i); 705 if ((*i)->isLayerScrollable()) scrollables.push_back(*i);
696 else { 706 else {
697 if (scrollables != m_lastScrollableBackLayers) { 707 if (scrollables != m_lastScrollableBackLayers) {
698 m_lastScrollableBackLayers = scrollables; 708 m_lastScrollableBackLayers = scrollables;
699 changed = true; 709 changed = true;
728 // Everything in front of the first non-scrollable from the back 738 // Everything in front of the first non-scrollable from the back
729 // should also be considered non-scrollable 739 // should also be considered non-scrollable
730 740
731 size_t count = 0; 741 size_t count = 0;
732 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) { 742 for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
743 if ((*i)->isLayerDormant()) continue;
733 if (count < scrollables.size()) { 744 if (count < scrollables.size()) {
734 ++count; 745 ++count;
735 continue; 746 continue;
736 } 747 }
737 nonScrollables.push_back(*i); 748 nonScrollables.push_back(*i);
1232 s += indent + "</view>\n"; 1243 s += indent + "</view>\n";
1233 1244
1234 return s; 1245 return s;
1235 } 1246 }
1236 1247
1248 ViewPropertyContainer::ViewPropertyContainer(View *v) :
1249 m_v(v)
1250 {
1251 connect(m_v, SIGNAL(propertyChanged(PropertyName)),
1252 this, SIGNAL(propertyChanged(PropertyName)));
1253 }
1237 1254
1238 #ifdef INCLUDE_MOCFILES 1255 #ifdef INCLUDE_MOCFILES
1239 #include "View.moc.cpp" 1256 #include "View.moc.cpp"
1240 #endif 1257 #endif
1241 1258