Mercurial > hg > svcore
changeset 45:b11edc8b8ea0
* Restore proper channel selection support for new layers
* Use binary mode for SV file I/O on Windows
* Commands for selection
author | Chris Cannam |
---|---|
date | Wed, 15 Mar 2006 18:11:23 +0000 |
parents | 701404725897 |
children | 5364a9d338a2 |
files | base/View.cpp base/View.h base/ViewManager.cpp base/ViewManager.h |
diffstat | 4 files changed, 91 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/base/View.cpp Mon Mar 13 17:55:19 2006 +0000 +++ b/base/View.cpp Wed Mar 15 18:11:23 2006 +0000 @@ -55,14 +55,7 @@ { std::cerr << "View::~View(" << this << ")" << std::endl; - //!!! will want to _not_ delete layers - m_deleting = true; -/*!!! - for (LayerList::iterator i = m_layers.begin(); i != m_layers.end(); ++i) { - delete *i; - } -*/ delete m_propertyContainer; } @@ -477,6 +470,12 @@ } void +View::drawVisibleText(int x, int y, QString text, TextStyle style) +{ + //!!! blah. +} + +void View::setPlaybackFollow(PlaybackFollowMode m) { m_followPlay = m;
--- a/base/View.h Mon Mar 13 17:55:19 2006 +0000 +++ b/base/View.h Wed Mar 15 18:11:23 2006 +0000 @@ -43,12 +43,8 @@ public: /** - * Deleting a View deletes all its views. However, it is - * also acceptable for the views to be deleted by other code (in - * which case they will remove themselves from this View - * automatically), or to be removed explicitly without deleting - * using removeLayer. - **!!!!!! + * Deleting a View does not delete any of its layers. They should + * be managed elsewhere (e.g. by the Document). */ virtual ~View(); @@ -169,6 +165,13 @@ virtual void setLightBackground(bool lb) { m_lightBackground = lb; } virtual bool hasLightBackground() const { return m_lightBackground; } + enum TextStyle { + BoxedText, + OutlinedText + }; + + virtual void drawVisibleText(int x, int y, QString text, TextStyle style); + virtual bool shouldIlluminateLocalFeatures(const Layer *, QPoint &) const { return false; }
--- a/base/ViewManager.cpp Mon Mar 13 17:55:19 2006 +0000 +++ b/base/ViewManager.cpp Wed Mar 15 18:11:23 2006 +0000 @@ -10,6 +10,7 @@ #include "ViewManager.h" #include "AudioPlaySource.h" #include "Model.h" +#include "CommandHistory.h" #include <iostream> @@ -120,31 +121,80 @@ void ViewManager::setSelection(const Selection &selection) { - m_selections.setSelection(selection); - emit selectionChanged(); + MultiSelection ms(m_selections); + ms.setSelection(selection); + setSelections(ms); } void ViewManager::addSelection(const Selection &selection) { - m_selections.addSelection(selection); - emit selectionChanged(); + MultiSelection ms(m_selections); + ms.addSelection(selection); + setSelections(ms); } void ViewManager::removeSelection(const Selection &selection) { - m_selections.removeSelection(selection); - emit selectionChanged(); + MultiSelection ms(m_selections); + ms.removeSelection(selection); + setSelections(ms); } void ViewManager::clearSelections() { - m_selections.clearSelections(); + MultiSelection ms(m_selections); + ms.clearSelections(); + setSelections(ms); +} + +void +ViewManager::setSelections(const MultiSelection &ms) +{ + if (m_selections.getSelections() == ms.getSelections()) return; + SetSelectionCommand *command = new SetSelectionCommand(this, ms); + CommandHistory::getInstance()->addCommand(command); +} + +void +ViewManager::signalSelectionChange() +{ emit selectionChanged(); } +ViewManager::SetSelectionCommand::SetSelectionCommand(ViewManager *vm, + const MultiSelection &ms) : + m_vm(vm), + m_oldSelection(vm->m_selections), + m_newSelection(ms) +{ +} + +ViewManager::SetSelectionCommand::~SetSelectionCommand() { } + +void +ViewManager::SetSelectionCommand::execute() +{ + m_vm->m_selections = m_newSelection; + m_vm->signalSelectionChange(); +} + +void +ViewManager::SetSelectionCommand::unexecute() +{ + m_vm->m_selections = m_oldSelection; + m_vm->signalSelectionChange(); +} + +QString +ViewManager::SetSelectionCommand::getName() const +{ + if (m_newSelection.getSelections().empty()) return tr("Clear Selection"); + else return tr("Select"); +} + Selection ViewManager::getContainingSelection(size_t frame, bool defaultToFollowing) const {
--- a/base/ViewManager.h Mon Mar 13 17:55:19 2006 +0000 +++ b/base/ViewManager.h Wed Mar 15 18:11:23 2006 +0000 @@ -16,6 +16,7 @@ #include <map> #include "Selection.h" +#include "Command.h" class AudioPlaySource; class Model; @@ -139,6 +140,24 @@ bool m_playLoopMode; bool m_playSelectionMode; + + void setSelections(const MultiSelection &ms); + void signalSelectionChange(); + + class SetSelectionCommand : public Command + { + public: + SetSelectionCommand(ViewManager *vm, const MultiSelection &ms); + virtual ~SetSelectionCommand(); + virtual void execute(); + virtual void unexecute(); + virtual QString getName() const; + + protected: + ViewManager *m_vm; + MultiSelection m_oldSelection; + MultiSelection m_newSelection; + }; }; #endif