📄 notationview.h
字号:
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: *//* Rosegarden A MIDI and audio sequencer and musical notation editor. This program is Copyright 2000-2007 Guillaume Laurent <glaurent@telegraph-road.org>, Chris Cannam <cannam@all-day-breakfast.com>, Richard Bown <richard.bown@ferventsoftware.com> The moral rights of Guillaume Laurent, Chris Cannam, and Richard Bown to claim authorship of this work have been asserted. Other copyrights also apply to some parts of this work. Please see the AUTHORS file and individual file headers for details. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See the file COPYING included with this distribution for more information.*/#ifndef _RG_NOTATIONVIEW_H_#define _RG_NOTATIONVIEW_H_#include "base/NotationTypes.h"#include "base/Track.h"#include "gui/general/EditView.h"#include "gui/general/LinedStaff.h"#include "gui/general/LinedStaffManager.h"#include "NotationProperties.h"#include "NotationCanvasView.h"#include <string>#include <kprocess.h>#include <ktempfile.h>#include <qmap.h>#include <qsize.h>#include <qstring.h>#include <vector>#include "base/Event.h"#include "gui/general/ClefIndex.h"class QWidget;class QTimer;class QPaintEvent;class QObject;class QMouseEvent;class QLabel;class QCursor;class QCanvasItem;class QCanvas;class KProgress;class KComboBox;class KActionMenu;class KAction;namespace Rosegarden{class Staff;class Segment;class ScrollBoxDialog;class RulerScale;class RosegardenGUIDoc;class RawNoteRuler;class ProgressDialog;class ProgressBar;class NotePixmapFactory;class NotationVLayout;class NotationStaff;class NotationHLayout;class NotationElement;class NoteActionData;class NoteActionDataMap;class MarkActionData;class MarkActionDataMap;class NoteChangeActionData;class NoteChangeActionDataMap;class Key;class EventSelection;class Event;class Clef;class ChordNameRuler;/** * NotationView is a view for one or more Staff objects, each of * which contains the notation data associated with a Segment. * NotationView owns the Staff objects it displays. * * This class manages the relationship between NotationHLayout/ * NotationVLayout and Staff data, as well as using rendering the * actual notes (using NotePixmapFactory to generate the pixmaps). */class NotationView : public EditView, public LinedStaffManager{ friend class NoteInserter; friend class ClefInserter; friend class NotationEraser; friend class NotationSelectionPaster; friend class LilypondExporter; Q_OBJECTpublic: explicit NotationView(RosegardenGUIDoc *doc, std::vector<Segment *> segments, QWidget *parent, bool showProgressive); // update during initial render? /** * Constructor for printing only. If parent is provided, a * progress dialog will be shown -- otherwise not. If another * NotationView is provided, the fonts and other settings used * for printing will be taken from that view. */ explicit NotationView(RosegardenGUIDoc *doc, std::vector<Segment *> segments, QWidget *parent, NotationView *referenceView); ~NotationView();// void initialLayout(); /// constructed successfully? (main reason it might not is user hit Cancel) bool isOK() const { return m_ok; } /** * Return the view-local PropertyName definitions for this view */ const NotationProperties &getProperties() const; /// Return the number of staffs int getStaffCount() { return m_staffs.size(); } /// Return a pointer to the staff at the specified index Staff *getStaff(int i) { return getLinedStaff(i); } /// Return a pointer to the staff corresponding to the given segment Staff *getStaff(const Segment &segment) { return getLinedStaff(segment); } /// Return a pointer to the staff at the specified index LinedStaff *getLinedStaff(int i); /// Return a pointer to the staff corresponding to the given segment LinedStaff *getLinedStaff(const Segment &segment); /// Return a pointer to the staff at the specified index NotationStaff *getNotationStaff(int i) { if (i >= 0 && unsigned(i) < m_staffs.size()) return m_staffs[i]; else return 0; } /// Return a pointer to the staff corresponding to the given segment NotationStaff *getNotationStaff(const Segment &segment); QCanvas* canvas() { return getCanvasView()->canvas(); } void setCanvasCursor(const QCursor &cursor) { getCanvasView()->viewport()->setCursor(cursor); } void setHeightTracking(bool t) { getCanvasView()->setHeightTracking(t); } /** * Returns true if the view is actually for printing */ bool isInPrintMode() { return m_printMode; } /** * Set the note or rest selected by the user from the toolbars */ void setCurrentSelectedNote(const char *pixmapName, bool isRest, Note::Type, int dots = 0); /** * Set the note or rest selected by the user from the toolbars */ void setCurrentSelectedNote(const NoteActionData &); /** * Discover whether chord-mode insertions are enabled (as opposed * to the default melody-mode) */ bool isInChordMode(); /** * Discover whether triplet-mode insertions are enabled */ bool isInTripletMode(); /** * Discover whether annotations are being displayed or not */ bool areAnnotationsVisible() { return m_annotationsVisible; } /** * Discover whether LilyPond directives are being displayed or not */ bool areLilyPondDirectivesVisible() { return m_lilypondDirectivesVisible; } /** * Set the current event selection. * * If preview is true, sound the selection as well. * * If redrawNow is true, recolour the elements on the canvas; * otherwise just line up a refresh for the next paint event. * * (If the selection has changed as part of a modification to a * segment, redrawNow should be unnecessary and undesirable, as a * paint event will occur in the next event loop following the * command invocation anyway.) */ virtual void setCurrentSelection(EventSelection*, bool preview = false, bool redrawNow = false); /** * Set the current event selection to a single event */ void setSingleSelectedEvent(int staffNo, Event *event, bool preview = false, bool redrawNow = false); /** * Set the current event selection to a single event */ void setSingleSelectedEvent(Segment &segment, Event *event, bool preview = false, bool redrawNow = false); /** * Show and sound the given note. The height is used for display, * the pitch for performance, so the two need not correspond (e.g. * under ottava there may be octave differences). */ void showPreviewNote(int staffNo, double layoutX, int pitch, int height, const Note ¬e, int velocity = -1); /// Remove any visible preview note void clearPreviewNote(); /// Sound the given note void playNote(Segment &segment, int pitch, int velocity = -1); /// Switches between page- and linear- layout modes void setPageMode(LinedStaff::PageMode mode); /// Returns the page width according to the layout mode (page/linear) int getPageWidth(); /// Returns the page height according to the layout mode (page/linear) int getPageHeight(); /// Returns the margins within the page (zero if not in MultiPageMode) void getPageMargins(int &left, int &top); /// Scrolls the view such that the given time is centered void scrollToTime(timeT t); NotePixmapFactory *getNotePixmapFactory() const { return m_notePixmapFactory; } virtual void refreshSegment(Segment *segment, timeT startTime = 0, timeT endTime = 0); /** * From LinedStaffManager */ virtual LinedStaff* getStaffForCanvasCoords(int x, int y) const; /** * Overridden from EditView */ virtual void updateView(); /** * Render segments on printing painter. This uses the current * font size and layout, rather than the optimal ones for the * printer configuration (notation editing is not quite WYSIWYG, * and we may be in a non-page mode). * * To print optimally use slotFilePrint, which will create * another NotationView with the optimal settings and call print * on that. */ virtual void print(bool previewOnly = false); public slots: /** * Print the current set of segments, by creating another * NotationView with the printing configuration but the same * segments, font etc as this view and asking it to print. */ void slotFilePrint(); /** * Preview the current set of segments, by creating another * NotationView with the printing configuration but the same * segments, font etc as this view and asking it to preview. */ void slotFilePrintPreview(); /** * export a Lilypond file */ bool exportLilypondFile(QString url, bool forPreview = false); /** * Export to a temporary file and process */ void slotPrintLilypond(); void slotPreviewLilypond(); void slotLilypondViewProcessExited(KProcess *); /** * put the marked text/object into the clipboard and remove it * from the document */ void slotEditCut(); /** * put the marked text/object into the clipboard */ void slotEditCopy(); /** * paste the clipboard into the document */ void slotEditPaste(); /** * cut the selection and close the gap, moving subsequent events * towards the start of the segment */ void slotEditCutAndClose(); /** * paste the clipboard into the document, offering a choice for how */ void slotEditGeneralPaste(); /** * delete the selection (cut without the copy) */ void slotEditDelete(); /** * toggles the tools toolbar */ void slotToggleToolsToolBar(); /** * toggles the notes toolbar */ void slotToggleNotesToolBar(); /** * toggles the rests toolbar */ void slotToggleRestsToolBar(); /** * toggles the accidentals toolbar */ void slotToggleAccidentalsToolBar(); /** * toggles the clefs toolbar */ void slotToggleClefsToolBar(); /** * toggles the marks toolbar */ void slotToggleMarksToolBar(); /** * toggles the group toolbar */ void slotToggleGroupToolBar(); /** * toggles the font toolbar */ void slotToggleLayoutToolBar(); /** * toggles the transport toolbar */ void slotToggleTransportToolBar(); /** * toggles the meta toolbar */ void slotToggleMetaToolBar(); /// note switch slot void slotNoteAction(); /// switch to last selected note void slotLastNoteAction(); /// accidental switch slots void slotNoAccidental(); void slotFollowAccidental(); void slotSharp(); void slotFlat(); void slotNatural(); void slotDoubleSharp(); void slotDoubleFlat(); /// clef switch slots void slotTrebleClef(); void slotAltoClef(); void slotTenorClef(); void slotBassClef(); /// text tool void slotText(); /// guitar chord tool void slotGuitarChord(); /// editing tools void slotEraseSelected(); void slotSelectSelected(); void slotToggleStepByStep(); /// status stuff void slotUpdateInsertModeStatus(); void slotUpdateAnnotationsStatus(); void slotUpdateLilyPondDirectivesStatus(); /// edit menu void slotPreviewSelection(); void slotClearLoop(); void slotClearSelection(); void slotEditSelectFromStart(); void slotEditSelectToEnd(); void slotEditSelectWholeStaff(); void slotFilterSelection(); /// view menu void slotLinearMode(); void slotContinuousPageMode(); void slotMultiPageMode(); void slotToggleChordsRuler(); void slotToggleRawNoteRuler(); void slotToggleTempoRuler(); void slotToggleAnnotations(); void slotToggleLilyPondDirectives(); void slotEditLyrics(); /// group slots void slotGroupBeam(); void slotGroupAutoBeam(); void slotGroupBreak(); void slotGroupSimpleTuplet(); void slotGroupGeneralTuplet(); void slotGroupTuplet(bool simple); void slotGroupUnTuplet(); void slotGroupGrace(); void slotGroupUnGrace(); void slotGroupSlur(); void slotGroupPhrasingSlur(); void slotGroupGlissando(); void slotGroupCrescendo(); void slotGroupDecrescendo(); void slotGroupMakeChord(); void slotGroupOctave2Up(); void slotGroupOctaveUp(); void slotGroupOctaveDown(); void slotGroupOctave2Down(); void slotAddIndication(std::string type, QString cat); /// transforms slots void slotTransformsNormalizeRests(); void slotTransformsCollapseRests(); void slotTransformsCollapseNotes(); void slotTransformsTieNotes(); void slotTransformsUntieNotes(); void slotTransformsMakeNotesViable(); void slotTransformsDeCounterpoint(); void slotTransformsStemsUp(); void slotTransformsStemsDown(); void slotTransformsRestoreStems(); void slotTransformsSlursAbove(); void slotTransformsSlursBelow(); void slotTransformsRestoreSlurs(); void slotTransformsQuantize(); void slotTransformsFixQuantization(); void slotTransformsRemoveQuantization(); void slotTransformsInterpret(); void slotRespellDoubleFlat(); void slotRespellFlat(); void slotRespellNatural(); void slotRespellSharp(); void slotRespellDoubleSharp(); void slotRespellUp(); void slotRespellDown(); void slotRespellRestore(); void slotShowCautionary(); void slotCancelCautionary(); void slotSetStyleFromAction(); void slotInsertNoteFromAction();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -