On Saturday 25 July 2009, Jani Frilander wrote:
> (and commented out what didn't compile :).
OK, Rosegarden 101...
I've just been adding the slots and other random code back in at the bottom of
the file as I go, and this seems like a reasonable best practice.
Now moving on to why this patch doesn't actually do anything... If I
uncomment all the bits that didn't compile, the first error I get is:
src/gui/editors/notation/NotationView.cpp:1953: error: ‘m_toolBox’ was not
declared in this scope
OK, the line of code is:
NoteInserter *currentInserter = dynamic_cast<NoteInserter *>
(m_toolBox->getTool(NoteInserter::ToolName));
There's no longer an m_toolBox. I don't know anything in particular about
this code either, so let's figure out how to translate it. We're working with
a NoteInserter here, so try searching for NoteInserter elsehwere in the code.
It yields:
} else if (dynamic_cast<NoteInserter *>(m_notationWidget-
>getCurrentTool())) {
This is a hint that "m_toolBox->getTool(NoteInserter::ToolName)" has more than
likely become "m_notationWidget->getCurrentTool()" due to refactoring, and
rewriting.
Let's try rewriting the code:
NoteInserter *currentInserter = dynamic_cast<NoteInserter *>
(m_notationWidget->getCurrentTool());
It compiles. Next error.
src/gui/editors/notation/NotationView.cpp:1982: error:
‘slotSetInsertCursorPosition’ was not declared in this scope
That's a tricky one, because we're in the middle of disposing of the old
insertion cursor, and just having one (blue) cursor to do everything. This
one you do pretty much have to comment out, like all the other examples of
slotSetInsertCursorPosition() being called.
OK, so at this point we try again, and the "make a tuplet out of a selection
of existing notes" feature seems to be working again. It was only one change
away from becoming useful, which is not bad for a first shot!
Committed revision 10559.
Why don't you fix the useful tuplet feature next. The "click this to enter
triplet insertion mode" feature that hangs off the bottom of the left-most
toolbar. (I have no idea what the slot is called, etc. That's part of the
challenge!) The other one has always been buggy, and I rarely use it. I get
better results going into "triplet insert mode" before entering anything.
See if you can get this one working without having to resort to commenting out
the useful parts, Grasshopper. :)
(OK, to be fair, I didn't actually try it with the m_toolbox line commented
out. Maybe it did something, but it probably didn't work correctly even if it
did. This business of hunting around for "prior art" gets easier as this slot
conversion process unfolds. I had to discover a lot of undocumented changes
(Chris sucks at documenting anything) the hard way in the last bit of this
myself, and those posts Chris made about this are a long way from being a
Rosetta stone.
Thanks for stepping up and jumping into the fire, and yes, of course I work on
Sunday. I work seven days a week most of the time.
--
D. Michael McIntyre
Modified: trunk/rosegarden/src/gui/editors/notation/NotationView.cpp
===================================================================
--- trunk/rosegarden/src/gui/editors/notation/NotationView.cpp 2009-07-27 03:03:41 UTC (rev 10558)
+++ trunk/rosegarden/src/gui/editors/notation/NotationView.cpp 2009-07-27 03:25:40 UTC (rev 10559)
@@ -56,6 +56,7 @@
#include "commands/notation/KeyInsertionCommand.h"
#include "commands/notation/MultiKeyInsertionCommand.h"
#include "commands/notation/SustainInsertionCommand.h"
+#include "commands/notation/TupletCommand.h"
#include "commands/segment/PasteToTriggerSegmentCommand.h"
#include "commands/segment/SegmentTransposeCommand.h"
@@ -71,6 +72,7 @@
#include "gui/dialogs/EventParameterDialog.h"
#include "gui/dialogs/KeySignatureDialog.h"
#include "gui/dialogs/IntervalDialog.h"
+#include "gui/dialogs/TupletDialog.h"
#include "gui/general/IconLoader.h"
#include "gui/general/LilyPondProcessor.h"
@@ -1900,6 +1902,88 @@
}
}
+void
+NewNotationView::slotGroupSimpleTuplet()
+{
+ slotGroupTuplet(true);
}
+void
+NewNotationView::slotGroupGeneralTuplet()
+{
+ slotGroupTuplet(false);
+}
+
+void
+NewNotationView::slotGroupTuplet(bool simple)
+{
+ timeT t = 0;
+ timeT unit = 0;
+ int tupled = 2;
+ int untupled = 3;
+ Segment *segment = 0;
+ bool hasTimingAlready = false;
+ EventSelection *selection = getSelection();
+
+ if (selection) {
+ t = selection->getStartTime();
+
+ timeT duration = selection->getTotalDuration();
+ Note::Type unitType = Note::getNearestNote(duration / 3, 0)
+ .getNoteType();
+ unit = Note(unitType).getDuration();
+
+ if (!simple) {
+ TupletDialog dialog(this, unitType, duration);
+ if (dialog.exec() != QDialog::Accepted)
+ return ;
+ unit = Note(dialog.getUnitType()).getDuration();
+ tupled = dialog.getTupledCount();
+ untupled = dialog.getUntupledCount();
+ hasTimingAlready = dialog.hasTimingAlready();
+ }
+
+ segment = &selection->getSegment();
+
+ } else {
+
+ t = getInsertionTime();
+
+ NoteInserter *currentInserter = dynamic_cast<NoteInserter *> (m_notationWidget->getCurrentTool());
+
+ Note::Type unitType;
+
+ if (currentInserter) {
+ unitType = currentInserter->getCurrentNote().getNoteType();
+ } else {
+ unitType = Note::Quaver;
+ }
+
+ unit = Note(unitType).getDuration();
+
+ if (!simple) {
+ TupletDialog dialog(this, unitType);
+ if (dialog.exec() != QDialog::Accepted)
+ return ;
+ unit = Note(dialog.getUnitType()).getDuration();
+ tupled = dialog.getTupledCount();
+ untupled = dialog.getUntupledCount();
+ hasTimingAlready = dialog.hasTimingAlready();
+ }
+
+ segment = getCurrentSegment();
+ }
+
+ CommandHistory::getInstance()->addCommand(new TupletCommand
+ (*segment, t, unit, untupled,
+ tupled, hasTimingAlready));
+
+ if (!hasTimingAlready) {
+// slotSetInsertCursorPosition(t + (unit * tupled), true, false);
+ }
+}
+
+
+}
+
#include "NotationView.moc"
Modified: trunk/rosegarden/src/gui/editors/notation/NotationView.h
===================================================================
--- trunk/rosegarden/src/gui/editors/notation/NotationView.h 2009-07-27 03:03:41 UTC (rev 10558)
+++ trunk/rosegarden/src/gui/editors/notation/NotationView.h 2009-07-27 03:25:40 UTC (rev 10559)
@@ -128,6 +128,10 @@
void slotUseOrnament();
void slotRemoveOrnament();
+ void slotGroupSimpleTuplet();
+ void slotGroupGeneralTuplet();
+ void slotGroupTuplet(bool simple);
+
/// Show or hide rulers
void slotToggleChordsRuler();
void slotToggleRawNoteRuler();
------------------------------------------------------------------------------
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel