From a8b0d6330835fe0af611c551b532bd85deb8f8a9 Mon Sep 17 00:00:00 2001 From: Werner Schweer Date: Thu, 12 Jul 2012 15:35:35 +0200 Subject: [PATCH] implement inspector for foto mode --- mscore/CMakeLists.txt | 5 +- mscore/actions.cpp | 8 +-- mscore/fotomode.cpp | 7 ++- mscore/inspector.cpp | 10 +-- mscore/inspectorLasso.cpp | 46 ++++++++++++++ mscore/inspectorLasso.h | 40 ++++++++++++ mscore/inspector_lasso.ui | 125 ++++++++++++++++++++++++++++++++++++++ mscore/musescore.cpp | 32 +++++++--- mscore/musescore.h | 2 +- mscore/scoreview.h | 1 + 10 files changed, 254 insertions(+), 22 deletions(-) create mode 100644 mscore/inspectorLasso.cpp create mode 100644 mscore/inspectorLasso.h create mode 100644 mscore/inspector_lasso.ui diff --git a/mscore/CMakeLists.txt b/mscore/CMakeLists.txt index 735d0f4922..887eeb4a35 100644 --- a/mscore/CMakeLists.txt +++ b/mscore/CMakeLists.txt @@ -59,7 +59,7 @@ QT4_WRAP_UI (ui_headers inspector_articulation.ui inspector_spacer.ui inspector_hbox.ui keysig.ui inspector_segment.ui inspector_beam.ui inspector_note.ui rest.ui inspector_chord.ui omrpanel.ui startdialog.ui masterpalette.ui - inspector_group_element.ui inspector_image.ui stem.ui + inspector_group_element.ui inspector_image.ui stem.ui inspector_lasso.ui ${SCRIPT_UI} ) @@ -89,6 +89,7 @@ QT4_WRAP_CPP (mocs editstringdata.h editraster.h mediadialog.h chordeditor.h chordview.h album.h layer.h webpage.h inspector.h inspectorBase.h inspectorBeam.h masterpalette.h inspectorGroupElement.h inspectorImage.h waveview.h helpBrowser.h + inspectorLasso.h ${OMR_MOCS} ${SCRIPT_MOCS} ) @@ -183,7 +184,7 @@ add_executable ( ${ExecutableName} inspector.cpp dragelement.cpp svggenerator.cpp inspectorBase.cpp inspectorBeam.cpp masterpalette.cpp inspectorGroupElement.cpp dragdrop.cpp inspectorImage.cpp - waveview.cpp musicxmlsupport.cpp helpBrowser.cpp + waveview.cpp musicxmlsupport.cpp helpBrowser.cpp inspectorLasso.cpp ${OMR_FILES} ${AUDIO} ${SCRIPT_FILES} diff --git a/mscore/actions.cpp b/mscore/actions.cpp index 1d427e98f3..6b554b6000 100644 --- a/mscore/actions.cpp +++ b/mscore/actions.cpp @@ -2262,19 +2262,19 @@ Shortcut Shortcut::sc[] = { QT_TRANSLATE_NOOP("action", "Plugin Creator") ), Shortcut( - STATE_NORMAL | STATE_NOTE_ENTRY | STATE_PLAY | STATE_EDIT | STATE_LYRICS_EDIT, + STATE_NORMAL | STATE_NOTE_ENTRY | STATE_PLAY | STATE_EDIT | STATE_LYRICS_EDIT | STATE_FOTO, 0, "inspector", - QT_TRANSLATE_NOOP("action","Show Inspector"), QT_TRANSLATE_NOOP("action","Inspector"), + QT_TRANSLATE_NOOP("action","Show Inspector"), QT_TRANSLATE_NOOP("action","Show inspector") ), Shortcut( STATE_NORMAL | STATE_NOTE_ENTRY | STATE_PLAY | STATE_EDIT | STATE_LYRICS_EDIT, 0, "omr", - QT_TRANSLATE_NOOP("action","Show OMR Panel"), QT_TRANSLATE_NOOP("action","OmrPanel"), + QT_TRANSLATE_NOOP("action","Show OMR Panel"), QT_TRANSLATE_NOOP("action","Show OMR PAnel") ), Shortcut( @@ -2320,8 +2320,8 @@ Shortcut Shortcut::sc[] = { STATE_NORMAL | STATE_NOTE_ENTRY, 0, "masterpalette", - QT_TRANSLATE_NOOP("action","Show master palette"), QT_TRANSLATE_NOOP("action","Master Palette..."), + QT_TRANSLATE_NOOP("action","Show master palette"), QT_TRANSLATE_NOOP("action","Show master palette") ), Shortcut( diff --git a/mscore/fotomode.cpp b/mscore/fotomode.cpp index de7dcaa944..3bb76cd249 100644 --- a/mscore/fotomode.cpp +++ b/mscore/fotomode.cpp @@ -28,6 +28,7 @@ #include "libmscore/image.h" #include "libmscore/mscore.h" #include "svggenerator.h" +#include "inspector.h" //--------------------------------------------------------- // FotoScoreViewDragTransition @@ -327,7 +328,6 @@ void ScoreView::setupFotoMode() s->setInitialState(f1); s->addTransition(new ScoreViewDragTransition(this, f2)); - connect(s, SIGNAL(entered()), mscore, SLOT(setFotomode())); connect(s, SIGNAL(entered()), SLOT(startFotomode())); connect(s, SIGNAL(exited()), SLOT(stopFotomode())); } @@ -355,6 +355,7 @@ void ScoreView::startFotomode() updateGrips(); _score->addRefresh(_foto->abbox()); _score->end(); + mscore->changeState(STATE_FOTO); } //--------------------------------------------------------- @@ -439,6 +440,8 @@ void ScoreView::doFotoDragEdit(QMouseEvent* ev) updateGrips(); startMove = p; _score->end(); + if (mscore->getInspector()) + mscore->getInspector()->setElement(_foto); } //--------------------------------------------------------- @@ -535,6 +538,8 @@ void ScoreView::doDragFotoRect(QMouseEvent* ev) startMove = p; updateGrips(); _score->end(); + if (mscore->getInspector()) + mscore->getInspector()->setElement(_foto); } //--------------------------------------------------------- diff --git a/mscore/inspector.cpp b/mscore/inspector.cpp index 8a4e4ad3fe..8b2ee82096 100644 --- a/mscore/inspector.cpp +++ b/mscore/inspector.cpp @@ -14,6 +14,7 @@ #include "inspector.h" #include "inspectorBeam.h" #include "inspectorImage.h" +#include "inspectorLasso.h" #include "inspectorGroupElement.h" #include "musescore.h" #include "scoreview.h" @@ -46,13 +47,7 @@ void MuseScore::showInspector(bool visible) connect(inspector, SIGNAL(inspectorVisible(bool)), a, SLOT(setChecked(bool))); addDockWidget(Qt::RightDockWidgetArea, inspector); } - if (cs) { - if (state() == STATE_EDIT) { - inspector->setElement(cv->getEditObject()); - } - else - selectionChanged(cs->selection().state()); - } + updateInspector(); } if (inspector) inspector->setVisible(visible); @@ -129,6 +124,7 @@ void Inspector::setElement(Element* e) case CLEF: ie = new InspectorClef(this); break; case BEAM: ie = new InspectorBeam(this); break; case IMAGE: ie = new InspectorImage(this); break; + case LASSO: ie = new InspectorLasso(this); break; default: ie = new InspectorElement(this); break; } layout->insertWidget(0, ie); diff --git a/mscore/inspectorLasso.cpp b/mscore/inspectorLasso.cpp new file mode 100644 index 0000000000..153de28c49 --- /dev/null +++ b/mscore/inspectorLasso.cpp @@ -0,0 +1,46 @@ +//============================================================================= +// MuseScore +// Music Composition & Notation +// $Id:$ +// +// Copyright (C) 2011 Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 +// as published by the Free Software Foundation and appearing in +// the file LICENSE.GPL +//============================================================================= + +#include "inspectorLasso.h" +#include "musescore.h" +#include "libmscore/lasso.h" + +//--------------------------------------------------------- +// InspectorLasso +//--------------------------------------------------------- + +InspectorLasso::InspectorLasso(QWidget* parent) + : InspectorBase(parent) + { + QWidget* w = new QWidget; + b.setupUi(w); + layout->addWidget(w); + } + +//--------------------------------------------------------- +// setElement +//--------------------------------------------------------- + +void InspectorLasso::setElement(Element* e) + { + Lasso* lasso = static_cast(e); + QRectF bb(lasso->rect()); + + b.posX->setValue(bb.x() / MScore::DPMM); + b.posY->setValue(bb.y() / MScore::DPMM); + b.sizeWidth->setValue(bb.width() / MScore::DPMM); + b.sizeHeight->setValue(bb.height() / MScore::DPMM); + + InspectorBase::setElement(e); + } + diff --git a/mscore/inspectorLasso.h b/mscore/inspectorLasso.h new file mode 100644 index 0000000000..e47bb10724 --- /dev/null +++ b/mscore/inspectorLasso.h @@ -0,0 +1,40 @@ +//============================================================================= +// MuseScore +// Music Composition & Notation +// $Id:$ +// +// Copyright (C) 2011 Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 +// as published by the Free Software Foundation and appearing in +// the file LICENSE.GPL +//============================================================================= + +#ifndef __INSPECTOR_LASSO_H__ +#define __INSPECTOR_LASSO_H__ + +#include "inspector.h" +#include "ui_inspector_lasso.h" +#include "libmscore/property.h" + +//--------------------------------------------------------- +// InspectorLasso +//--------------------------------------------------------- + +class InspectorLasso : public InspectorBase { + Q_OBJECT + + Ui::InspectorLasso b; + + protected slots: + + protected: + + public: + InspectorLasso(QWidget* parent); + virtual void setElement(Element*); + }; + +#endif + diff --git a/mscore/inspector_lasso.ui b/mscore/inspector_lasso.ui new file mode 100644 index 0000000000..aaa4263ec7 --- /dev/null +++ b/mscore/inspector_lasso.ui @@ -0,0 +1,125 @@ + + + InspectorLasso + + + + 0 + 0 + 287 + 93 + + + + Form + + + + + + + 75 + true + + + + Lasso + + + Qt::AlignCenter + + + + + + + QFrame::HLine + + + QFrame::Raised + + + 2 + + + + + + + + + Position: + + + + + + + 1 + + + 999999.000000000000000 + + + + + + + + 0 + 0 + + + + 1 + + + 99999.000000000000000 + + + + + + + + 0 + 0 + + + + 1 + + + 99999.000000000000000 + + + 0.000000000000000 + + + + + + + Size + + + + + + + 1 + + + 999999.000000000000000 + + + + + + + + + + + + diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index 0c6a7a3e90..c35e507b1c 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -83,6 +83,7 @@ #include "libmscore/measurebase.h" #include "libmscore/chordlist.h" #include "libmscore/volta.h" +#include "libmscore/lasso.h" #include "msynth/synti.h" @@ -1208,18 +1209,33 @@ void MuseScore::selectionChanged(int selectionState) pianorollEditor->changeSelection(selectionState); if (drumrollEditor) drumrollEditor->changeSelection(selectionState); - if (inspector && (state() != STATE_EDIT)) { - if (cs) { + updateInspector(); + } + +//--------------------------------------------------------- +// updateInspector +//--------------------------------------------------------- + +void MuseScore::updateInspector() + { + if (!inspector) + return; + if (cs) { + if (state() == STATE_EDIT) + inspector->setElement(cv->getEditObject()); + else if (state() == STATE_FOTO) + inspector->setElement(cv->fotoLasso()); + else { if (cs->selection().isSingle()) inspector->setElement(cs->selection().element()); - else if (selectionState == SEL_NONE) + else if (cs->selection().state() == SEL_NONE) inspector->setElement(0); else inspector->setElementList(cs->selection().elements()); } - else - inspector->setElement(0); } + else + inspector->setElement(0); } //--------------------------------------------------------- @@ -2652,14 +2668,15 @@ void MuseScore::changeState(ScoreState val) } menuProfiles->setEnabled(enable); -// foreach (QAction* a, pluginActions) allow for "create score" plugins -// a->setEnabled(true); transportTools->setEnabled(enable && !noSeq); cpitchTools->setEnabled(enable); mag->setEnabled(enable); entryTools->setEnabled(enable); + if (_sstate == STATE_FOTO) + updateInspector(); + switch(val) { case STATE_DISABLED: _modeText->setText(tr("no score")); @@ -2690,6 +2707,7 @@ void MuseScore::changeState(ScoreState val) case STATE_FOTO: _modeText->setText(tr("foto mode")); _modeText->show(); + updateInspector(); break; case STATE_SEARCH: if (searchDialog == 0) { diff --git a/mscore/musescore.h b/mscore/musescore.h index e2af3615f4..ee431bf828 100644 --- a/mscore/musescore.h +++ b/mscore/musescore.h @@ -394,6 +394,7 @@ class MuseScore : public QMainWindow { static void convertCapella(Score*, Capella* cap); void changeScore(int); virtual void resizeEvent(QResizeEvent*); + void updateInspector(); private slots: void cmd(QAction* a, const QString& cmd); @@ -462,7 +463,6 @@ class MuseScore : public QMainWindow { void setNoteEntryState() { changeState(STATE_NOTE_ENTRY); } void setPlayState() { changeState(STATE_PLAY); } void setSearchState() { changeState(STATE_SEARCH); } - void setFotomode() { changeState(STATE_FOTO); } void checkForUpdate(); QMenu* fileMenu() const { return _fileMenu; } void midiNoteReceived(int channel, int pitch, int velo); diff --git a/mscore/scoreview.h b/mscore/scoreview.h index d39c746fdf..e670223ab7 100644 --- a/mscore/scoreview.h +++ b/mscore/scoreview.h @@ -425,6 +425,7 @@ class ScoreView : public QWidget, public MuseScoreView { OmrView* omrView() const { return _omrView; } void setOmrView(OmrView* v) { _omrView = v; } Element* getEditObject() { return editObject; } + Lasso* fotoLasso() const { return _foto; } }; //---------------------------------------------------------