reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit c77d5e6acadea39f130972726fbdd7f31ca23d47
parent 27f57993b269296a8083d36d367e63ebd576044b
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sun, 17 Sep 2017 00:50:50 -0400

support registering scripts into the MIDI Event List Editor and Media Explorer sections

Diffstat:
Msrc/about.cpp | 8+++++---
Msrc/source.cpp | 8+++++---
Msrc/source.hpp | 10++++++----
Msrc/transaction.cpp | 8+++++---
Mtest/source.cpp | 45+++++++++++++++++----------------------------
5 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/src/about.cpp b/src/about.cpp @@ -545,9 +545,11 @@ void AboutPackageDelegate::init(About *dialog) void AboutPackageDelegate::updateList(const int index) { const pair<Source::Section, const char *> sectionMap[] = { - {Source::MainSection, "Main"}, - {Source::MIDIEditorSection, "MIDI Editor"}, - {Source::MIDIInlineEditorSection, "MIDI Inline Editor"}, + {Source::MainSection, "Main"}, + {Source::MIDIEditorSection, "MIDI Editor"}, + {Source::MIDIInlineEditorSection, "MIDI Inline Editor"}, + {Source::MIDIEventListEditorSection, "MIDI Event List Editor"}, + {Source::MediaExplorerSection, "Media Explorer"}, }; if(index < 0) diff --git a/src/source.cpp b/src/source.cpp @@ -30,8 +30,12 @@ auto Source::getSection(const char *name) -> Section return MainSection; else if(!strcmp(name, "midi_editor")) return MIDIEditorSection; - else if(!strcmp(name, "midi_inline_editor")) + else if(!strcmp(name, "midi_inlineeditor")) return MIDIInlineEditorSection; + else if(!strcmp(name, "midi_eventlisteditor")) + return MIDIEventListEditorSection; + else if(!strcmp(name, "mediaexplorer")) + return MediaExplorerSection; else if(!strcmp(name, "true")) return ImplicitSection; else @@ -47,8 +51,6 @@ auto Source::detectSection(const string &category) -> Section if(topcategory == "midi editor") return MIDIEditorSection; - else if(topcategory == "midi inline editor") - return MIDIInlineEditorSection; else return MainSection; } diff --git a/src/source.hpp b/src/source.hpp @@ -28,10 +28,12 @@ class Version; class Source { public: enum Section { - UnknownSection = 0, - MainSection = 1<<0, - MIDIEditorSection = 1<<1, - MIDIInlineEditorSection = 1<<2, + UnknownSection = 0, + MainSection = 1<<0, + MIDIEditorSection = 1<<1, + MIDIInlineEditorSection = 1<<2, + MIDIEventListEditorSection = 1<<3, + MediaExplorerSection = 1<<4, ImplicitSection = -1, // for compatibility with v1.0 }; diff --git a/src/transaction.cpp b/src/transaction.cpp @@ -250,9 +250,11 @@ void Transaction::registerQueued() void Transaction::registerScript(const HostTicket &reg, const bool isLastCall) { const pair<Source::Section, int> sectionMap[] = { - {Source::MainSection, 0}, - {Source::MIDIEditorSection, 32060}, - {Source::MIDIInlineEditorSection, 32062}, + {Source::MainSection, 0}, + {Source::MIDIEditorSection, 32060}, + {Source::MIDIEventListEditorSection, 32061}, + {Source::MIDIInlineEditorSection, 32062}, + {Source::MediaExplorerSection, 32063}, }; if(!AddRemoveReaScript || !reg.file.sections) diff --git a/test/source.cpp b/test/source.cpp @@ -54,11 +54,13 @@ TEST_CASE("source type from package", M) { } TEST_CASE("parse file section", M) { - REQUIRE(-1 == Source::getSection("true")); - REQUIRE(0 == Source::getSection("hello")); - REQUIRE(Source::MainSection == Source::getSection("main")); - REQUIRE(Source::MIDIEditorSection == Source::getSection("midi_editor")); - REQUIRE(Source::MIDIInlineEditorSection == Source::getSection("midi_inline_editor")); + REQUIRE(Source::getSection("true") == -1); + REQUIRE(Source::getSection("hello") == Source::UnknownSection); + REQUIRE(Source::getSection("main") == Source::MainSection); + REQUIRE(Source::getSection("midi_editor") == Source::MIDIEditorSection); + REQUIRE(Source::getSection("midi_inlineeditor") == Source::MIDIInlineEditorSection); + REQUIRE(Source::getSection("midi_eventlisteditor") == Source::MIDIEventListEditorSection); + REQUIRE(Source::getSection("mediaexplorer") == Source::MediaExplorerSection); } TEST_CASE("explicit source section", M) { @@ -83,7 +85,16 @@ TEST_CASE("explicit source section", M) { } } -TEST_CASE("implicit source section") { +TEST_CASE("implicit section detection (v1.0 compatibility)", M) { + REQUIRE(Source::MainSection == Source::detectSection("Hello World")); + REQUIRE(Source::MainSection == Source::detectSection("Hello/World")); + REQUIRE(Source::MainSection == Source::detectSection("Hello/midi editor")); + + REQUIRE(Source::MIDIEditorSection == Source::detectSection("midi editor")); + REQUIRE(Source::MIDIEditorSection == Source::detectSection("midi editor/Hello")); +} + +TEST_CASE("implicit section detection from source (v1.0 compatibility)") { Index ri("Index Name"); SECTION("main") { @@ -105,28 +116,6 @@ TEST_CASE("implicit source section") { source.setSections(Source::ImplicitSection); REQUIRE(source.sections() == Source::MIDIEditorSection); } - - SECTION("midi inline editor") { - Category cat("MIDI Inline Editor", &ri); - Package pack(Package::ScriptType, "package name", &cat); - Version ver("1.0", &pack); - - Source source("filename", "url", &ver); - source.setSections(Source::ImplicitSection); - REQUIRE(source.sections() == Source::MIDIInlineEditorSection); - } -} - -TEST_CASE("implicit section detection", M) { - REQUIRE(Source::MainSection == Source::detectSection("Hello World")); - REQUIRE(Source::MainSection == Source::detectSection("Hello/World")); - REQUIRE(Source::MainSection == Source::detectSection("Hello/midi editor")); - - REQUIRE(Source::MIDIEditorSection == Source::detectSection("midi editor")); - REQUIRE(Source::MIDIEditorSection == Source::detectSection("midi editor/Hello")); - - REQUIRE(Source::MIDIInlineEditorSection == - Source::detectSection("midi inline editor")); } TEST_CASE("empty source url", M) {