Triggered Segment Feature w/ Patch

View: New views
11 Messages — Rating Filter:   Alert me  

Triggered Segment Feature w/ Patch

by Julie S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Micheal, Chris, and other:

As a first coding contribution to RG. I'd like you to consider my feature request and patch which I've attached.

Feature Request:
In the Manage Triggered Segments window when pasting contents of clipboard as a new triggered segment, when only a single segment is in the clipboard, instead of "<No-Label>" appearing, use the name of the segment in the clipboard as the label of the triggered segment.

Patch:
I've attached a proposed patch to fulfill the feature request.

...

original file /src/commands/segment/PasteToTriggerSegmentCommand.cpp

line 101:
        m_segment->setLabel(qstrtostr(m_label));

new code starting at line 101:
        if (m_label == "" && m_clipboard->isSingleSegment()) {
            m_segment->setLabel(m_clipboard->getSingleSegment()->getLabel());
        }
        else {
            m_segment->setLabel(qstrtostr(m_label));
        }

...

Known issues:
* Label for triggered segment contains "(copied)" or "(excert)" in label from clipboard based on selection process.
...

Please let me know what is needed help include this feature to RG.  I happy to add to this to make it better, but wanted to get a nod of approval first.

Sincerely,
Julie Swango



     
[PasteToTriggerSegmentCommand.cpp]

/* -*- 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.
    Copyright 2000-2008 the Rosegarden development team.
 
    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.
*/


#include "PasteToTriggerSegmentCommand.h"

#include "base/Event.h"
#include <klocale.h>
#include "misc/Strings.h"
#include "base/Clipboard.h"
#include "base/Composition.h"
#include "base/NotationTypes.h"
#include "base/Segment.h"
#include "base/TriggerSegment.h"
#include <qstring.h>

namespace Rosegarden
{

PasteToTriggerSegmentCommand::PasteToTriggerSegmentCommand(Composition *composition,
        Clipboard *clipboard,
        QString label,
        int basePitch,
        int baseVelocity) :
        KNamedCommand(i18n("Paste as New Triggered Segment")),
        m_composition(composition),
        m_clipboard(new Clipboard(*clipboard)),
        m_label(label),
        m_basePitch(basePitch),
        m_baseVelocity(baseVelocity),
        m_segment(0),
        m_detached(false)
{
    // nothing else
}

PasteToTriggerSegmentCommand::~PasteToTriggerSegmentCommand()
{
    if (m_detached)
        delete m_segment;
    delete m_clipboard;
}

void
PasteToTriggerSegmentCommand::execute()
{
    if (m_segment) {

        m_composition->addTriggerSegment(m_segment, m_id, m_basePitch, m_baseVelocity);

    } else {

        if (m_clipboard->isEmpty())
            return ;

        m_segment = new Segment();

        timeT earliestStartTime = 0;
        timeT latestEndTime = 0;

        for (Clipboard::iterator i = m_clipboard->begin();
                i != m_clipboard->end(); ++i) {

            if (i == m_clipboard->begin() ||
                    (*i)->getStartTime() < earliestStartTime) {
                earliestStartTime = (*i)->getStartTime();
            }

            if ((*i)->getEndMarkerTime() > latestEndTime)
                latestEndTime = (*i)->getEndMarkerTime();
        }

        for (Clipboard::iterator i = m_clipboard->begin();
                i != m_clipboard->end(); ++i) {

            for (Segment::iterator si = (*i)->begin();
                    (*i)->isBeforeEndMarker(si); ++si) {
                if (!(*si)->isa(Note::EventRestType)) {
                    m_segment->insert
                    (new Event(**si,
                               (*si)->getAbsoluteTime() - earliestStartTime));
                }
            }
        }

        if (m_label == "" && m_clipboard->isSingleSegment()) {
            m_segment->setLabel(m_clipboard->getSingleSegment()->getLabel());
        }
        else {
            m_segment->setLabel(qstrtostr(m_label));
        }

        TriggerSegmentRec *rec =
            m_composition->addTriggerSegment(m_segment, m_basePitch, m_baseVelocity);
        if (rec)
            m_id = rec->getId();
    }

    m_composition->getTriggerSegmentRec(m_id)->updateReferences();

    m_detached = false;
}

void
PasteToTriggerSegmentCommand::unexecute()
{
    if (m_segment)
        m_composition->detachTriggerSegment(m_id);
    m_detached = true;
}

}


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Re: Triggered Segment Feature w/ Patch

by Julie S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry, there was a typo at the end:

original:
> Known issues:
> * Label for triggered segment contains "(copied)"
> or "(excert)" in label from clipboard based on
> selection process.

should read:
* Label for triggered segment contains "(copied)"
or "(excerpt)" in label from clipboard based on
selection process.

Sincerely,
Julie



     

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Re: Triggered Segment Feature w/ Patch

by Julie S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry, an new update.  I messed up the spacing just after #include list in the first patch I sent.  Here is the the update with the corrected formatting.

This should really be it.

Sincerely,
Julie S.



     
[PasteToTriggerSegmentCommand.cpp]

/* -*- 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.
    Copyright 2000-2008 the Rosegarden development team.
 
    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.
*/


#include "PasteToTriggerSegmentCommand.h"

#include "base/Event.h"
#include <klocale.h>
#include "misc/Strings.h"
#include "base/Clipboard.h"
#include "base/Composition.h"
#include "base/NotationTypes.h"
#include "base/Segment.h"
#include "base/TriggerSegment.h"
#include <qstring.h>


namespace Rosegarden
{

PasteToTriggerSegmentCommand::PasteToTriggerSegmentCommand(Composition *composition,
        Clipboard *clipboard,
        QString label,
        int basePitch,
        int baseVelocity) :
        KNamedCommand(i18n("Paste as New Triggered Segment")),
        m_composition(composition),
        m_clipboard(new Clipboard(*clipboard)),
        m_label(label),
        m_basePitch(basePitch),
        m_baseVelocity(baseVelocity),
        m_segment(0),
        m_detached(false)
{
    // nothing else
}

PasteToTriggerSegmentCommand::~PasteToTriggerSegmentCommand()
{
    if (m_detached)
        delete m_segment;
    delete m_clipboard;
}

void
PasteToTriggerSegmentCommand::execute()
{
    if (m_segment) {

        m_composition->addTriggerSegment(m_segment, m_id, m_basePitch, m_baseVelocity);

    } else {

        if (m_clipboard->isEmpty())
            return ;

        m_segment = new Segment();

        timeT earliestStartTime = 0;
        timeT latestEndTime = 0;

        for (Clipboard::iterator i = m_clipboard->begin();
                i != m_clipboard->end(); ++i) {

            if (i == m_clipboard->begin() ||
                    (*i)->getStartTime() < earliestStartTime) {
                earliestStartTime = (*i)->getStartTime();
            }

            if ((*i)->getEndMarkerTime() > latestEndTime)
                latestEndTime = (*i)->getEndMarkerTime();
        }

        for (Clipboard::iterator i = m_clipboard->begin();
                i != m_clipboard->end(); ++i) {

            for (Segment::iterator si = (*i)->begin();
                    (*i)->isBeforeEndMarker(si); ++si) {
                if (!(*si)->isa(Note::EventRestType)) {
                    m_segment->insert
                    (new Event(**si,
                               (*si)->getAbsoluteTime() - earliestStartTime));
                }
            }
        }

        if (m_label == "" && m_clipboard->isSingleSegment()) {
            m_segment->setLabel(m_clipboard->getSingleSegment()->getLabel());
        }
        else {
            m_segment->setLabel(qstrtostr(m_label));
        }

        TriggerSegmentRec *rec =
            m_composition->addTriggerSegment(m_segment, m_basePitch, m_baseVelocity);
        if (rec)
            m_id = rec->getId();
    }

    m_composition->getTriggerSegmentRec(m_id)->updateReferences();

    m_detached = false;
}

void
PasteToTriggerSegmentCommand::unexecute()
{
    if (m_segment)
        m_composition->detachTriggerSegment(m_id);
    m_detached = true;
}

}


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Re: Triggered Segment Feature w/ Patch

by D. Michael McIntyre :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 13 July 2008, Julie S wrote:

> This should really be it.

We LOVE feature requests expressed in patch form!

I hate to be nitpicky, but it would be really helpful if you could submit
future patches in the standard way.  To illustrate...

1. I'll copy your modified file over the original to simulate having worked on
a file in my local copy of SVN trunk/

  $ cd rosegarden
  $ cp /tmp/PasteToTriggerSegmentCommand.cpp src/commands/segment/

2. Now, from there, I'll make a proper patch

  $ svn diff > /tmp/my_patch

3. I've attached the result for comparison

--
D. Michael McIntyre

[my_patch]

Index: src/commands/segment/PasteToTriggerSegmentCommand.cpp
===================================================================
--- src/commands/segment/PasteToTriggerSegmentCommand.cpp (revision 8924)
+++ src/commands/segment/PasteToTriggerSegmentCommand.cpp (working copy)
@@ -98,7 +98,12 @@
             }
         }
 
-        m_segment->setLabel(qstrtostr(m_label));
+        if (m_label == "" && m_clipboard->isSingleSegment()) {
+            m_segment->setLabel(m_clipboard->getSingleSegment()->getLabel());
+        }
+        else {
+            m_segment->setLabel(qstrtostr(m_label));
+        }
 
         TriggerSegmentRec *rec =
             m_composition->addTriggerSegment(m_segment, m_basePitch, m_baseVelocity);


-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Re: Triggered Segment Feature w/ Patch

by Julie S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Dear Micheal,


You said:
> I hate to be nitpicky, but it would be really helpful if
> you could submit
> future patches in the standard way.

No that is not nitpicky at all.  I'm just new to this whole process.

So at after step 2:
>   $ svn diff > /tmp/my_patch

What do I do with the my_patch file I've created?

I read the writeup for developers, but didn't want to try updating your system--if I was even able too.  The last thing I want to do is mess things up.

 
Sincerely,
Julie


     

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Re: Triggered Segment Feature w/ Patch

by D. Michael McIntyre :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 13 July 2008, Julie S wrote:
> This should really be it.

Tested, committed in rev. 8925, and credited on the wiki page.

With extreme gratitude!  Thanks!
--
D. Michael McIntyre

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Re: Triggered Segment Feature w/ Patch

by D. Michael McIntyre :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sunday 13 July 2008, Julie S wrote:

> What do I do with the my_patch file I've created?

Attach it to a message, and send away.  If it's a huge patch, you might have
to send it directly to one of the developers, as we have a fairly low limit
on the maximum message size allowed on the lists.  (Of course when it comes
time to choose "one of the developers" I suppose I must be inviting you to
send everything my way, since if I were out there and wanted to get someone
to look at something in a reasonable period of time, I'd definitely pick me.  
Even I'm not here every day, but I come closer than anyone else by far.)

> I read the writeup for developers, but didn't want to try updating your
> system--if I was even able too.  The last thing I want to do is mess things
> up.

There's no real danger of messing anything up using the method I described.

Think of it this way.  You're walking through a cow pasture, not a minefield.  
You might step in something you wish you hadn't, but even if it costs a good
pair of shoes, it won't cost a leg.
--
D. Michael McIntyre

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Re: Triggered Segment Feature w/ Patch

by Julie S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Micheal,

Thank you.  I'll keep the minefield vs. cow pasture analogy in mind as I proceed.

Sincerely,
Julie S.



     

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Re: Triggered Segment Feature w/ Patch

by cannam :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Jul 13, 2008 at 4:24 PM, Julie S <msjulie_s@...> wrote:
> Feature Request:
> In the Manage Triggered Segments window when pasting contents of clipboard as a new triggered segment, when only a single segment is in the clipboard, instead of "<No-Label>" appearing, use the name of the segment in the clipboard as the label of the triggered segment.
>
> Patch:
> I've attached a proposed patch to fulfill the feature request.

Great!  As Michael said, we love this stuff.  Thanks.


Chris

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Parent Message unknown Re: Triggered Segment Feature w/ Patch

by Julie S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message




--- On Sun, 7/13/08, D. Michael McIntyre <michael.mcintyre@...> wrote:

> From: D. Michael McIntyre <michael.mcintyre@...>
> Subject: Re: [Rosegarden-devel] Triggered Segment Feature w/ Patch
> To: msjulie_s@...
> Date: Sunday, July 13, 2008, 9:08 PM
> On Sunday 13 July 2008, Julie S wrote:
>
> > Dear Micheal,
> >
> > Thank you.  I'll keep the minefield vs. cow
> pasture analogy in mind as I
> > proceed.
>
> M-i-c-h-a-e-l.  Sorry, I couldn't help myself.
>
> Think about Julius Caesar.  AE in Classical Latin is unique
> enough that it was
> traditionally represented with the digraph Æ, as in JVLIVS
> CÆSAR.  Michæl has
> the same phoneme in Classical pronunciation, and thus the
> spelling in English
> is always AE, and never EA, unless you have the misfortune
> to have been named
> by illiterate parents.  (The same sort of parents who name
> their daughters
> things like Reneé or Rènèè or Réneé, and other
> horrible permutations I've
> seen in real life.)  (Should be Renée, or if in doubt,
> leave the accent out.)
>
> My parents are/were only half illiterate.  My father STILL
> can't spell my name
> correctly after ALL THESE YEARS.  (And Mom is dead now, so
> my only living
> parent is kind of a moron when it comes to spelling his
> only child's name)
>
> It's a pet peeve.  Oops.  You stepped on something in
> that cow pasture
> already.  :D
>
> No worries, Julie, no worries, but I'm afraid I
> couldn't resist stepping up
> onto my soap box for a moment.  :)
> --
> D. Michael McIntyre


     

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Parent Message unknown Re: Triggered Segment Feature w/ Patch

by Julie S :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Michael,

No, names are important.  I didn't even notice I was consistently writing it wrong.  I guess I should have looked closer at your email address--and everything you've ever written.  I do apologize.

Sincerely,
Julie S.




     

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Rosegarden-devel mailing list
Rosegarden-devel@... - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel
LightInTheBox - Buy quality products at wholesale price