From 6b200f3cfaa19ac1bffec825eed7dca57a32ab7a Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Thu, 14 Jul 2016 19:08:14 -0700 Subject: [PATCH 01/33] more source for observers revision --- Source/Utilities/TSQueue.h | 121 ++++++++++++++++++ Source/Utilities/Utilities.h | 55 ++++++++ .../Utilities/recursive_read_write_mutex.cpp | 87 +++++++++++++ Source/Utilities/recursive_read_write_mutex.h | 77 +++++++++++ 4 files changed, 340 insertions(+) create mode 100644 Source/Utilities/TSQueue.h create mode 100644 Source/Utilities/recursive_read_write_mutex.cpp create mode 100644 Source/Utilities/recursive_read_write_mutex.h diff --git a/Source/Utilities/TSQueue.h b/Source/Utilities/TSQueue.h new file mode 100644 index 000000000..4c4713470 --- /dev/null +++ b/Source/Utilities/TSQueue.h @@ -0,0 +1,121 @@ +#pragma once +#include +#include +#include +template +class threadsafe_queue { +public: + threadsafe_queue(): + head_(new node_), tail_(head_.get()) {} + threadsafe_queue(const threadsafe_queue& other) = delete; + threadsafe_queue& operator=(const threadsafe_queue& other) = delete; + + void Push(T new_value); + std::shared_ptr WaitAndPop(); + void WaitAndPop(T& value); + std::shared_ptr TryPop(); + bool TryPop(T& value); + void Empty(); + void NotifyOther(); + +private: + bool other_notification_; + mutable std::mutex head_mutex_; + mutable std::mutex tail_mutex_; + node_* tail_; + std::condition_variable data_cond_; + std::unique_ptr head_; + struct node_ { + std::shared_ptr data_; + std::unique_ptr next_; + }; + + node_* GetTail_() { + std::lock_guard tail_lock(tail_mutex_); + return tail_; + } + std::unique_ptr PopHead_() { + std::unique_ptr old_head = std::move(head_); + head_ = std::move(old_head->next_); + return old_head; + } + std::unique_lock WaitForData_() { + std::unique_lock head_lock(head_mutex_); + data_cond_.wait(head_lock, [&]() {return head_.get() != GetTail_(); }); + return std::move(head_lock); + } + std::unique_ptr WaitPopHead_() { + std::unique_lock head_lock(WaitForData_()); + return PopHead_(); + } + std::unique_ptr WaitPopHead_(T& value) { + std::unique_lock head_lock(WaitForData_()); + value = std::move(*head_->data_); + return PopHead_(); + } + std::unique_ptr TryPopHead_() { + std::lock_guard head_lock(head_mutex_); + if (head_.get() == GetTail_()) { + return std::unique_ptr(); + } + return PopHead_(); + } + std::unique_ptr TryPopHead_(T& value) { + std::lock_guard head_lock(head_mutex_); + if (head_.get() == GetTail_()) { + return std::unique_ptr(); + } + value = std::move(*head_->data_); + return PopHead_(); + } +}; + +template +void threadsafe_queue::Push(T new_value) { + std::shared_ptr new_data( + std::make_shared(std::move(new_value))); + std::unique_ptr p(new node_); + { + std::lock_guard tail_lock(tail_mutex_); + tail_->data_ = new_data; + node_* const new_tail = p.get(); + tail_->next_ = std::move(p); + tail_ = new_tail; + } + data_cond_.notify_one(); +} + +template +std::shared_ptr threadsafe_queue::WaitAndPop() { + std::unique_ptr const old_head = WaitPopHead_(); + return old_head->data_; +} + +template +void threadsafe_queue::WaitAndPop(T& value) { + std::unique_ptr const old_head = WaitPopHead_(value); +} + +template +std::shared_ptr threadsafe_queue::TryPop() { + std::unique_ptr old_head = TryPopHead_(); + return old_head ? old_head->data_ : std::shared_ptr(); +} + +template +bool threadsafe_queue::TryPop(T& value) { + std::unique_ptr const old_head = TryPopHead_(value); + return old_head; +} + +template +void threadsafe_queue::Empty() { + std::lock_guard head_lock(head_mutex_); + return (head_.get() == GetTail_()); +} + +template +void threadsafe_queue::NotifyOther() { + other_notification_ = true; + data_cond_.notify_all(); +} diff --git a/Source/Utilities/Utilities.h b/Source/Utilities/Utilities.h index 0f4c62d83..98e4ecb07 100644 --- a/Source/Utilities/Utilities.h +++ b/Source/Utilities/Utilities.h @@ -79,3 +79,58 @@ lock_guard guard(lock); // do job } */ + +template +class threadsafe_queue { +private: + bool other_notification_{false}; + mutable std::mutex mut_; + std::condition_variable data_cond_; + std::queue data_queue_; +public: + threadsafe_queue() {} + void NotifyOther() { + other_notification_ = true; + data_cond_.notify_all(); + } + void push(T new_value) { + std::lock_guard lk(mut_); + data_queue_.push(std::move(new_value)) + ; data_cond_.notify_one(); + } + void wait_and_pop(T& value) { + std::unique_lock lk(mut_); + data_cond_.wait(lk, [this] {return !data_queue_.empty(); }); + value = std::move(data_queue_.front()); + data_queue_.pop(); + } + std::shared_ptr wait_and_pop() { + std::unique_lock lk(mut_); + data_cond_.wait(lk, [this] {return !data_queue_.empty(); }); + std::shared_ptr res( + std::make_shared(std::move(data_queue_.front()))); + data_queue_.pop(); + return res; + } + bool try_pop(T& value) { + std::lock_guard lk(mut_); + if (data_queue_.empty()) + return false; + value = std::move(data_queue_.front()); + data_queue_.pop(); + return true; + } + std::shared_ptr try_pop() { + std::lock_guard lk(mut_); + if (data_queue_.empty()) + return std::shared_ptr(); + std::shared_ptr res( + std::make_shared(std::move(data_queue_.front()))); + data_queue_.pop(); + return res; + } + bool empty() const { + std::lock_guard lk(mut_); + return data_queue_.empty(); + } +}; diff --git a/Source/Utilities/recursive_read_write_mutex.cpp b/Source/Utilities/recursive_read_write_mutex.cpp new file mode 100644 index 000000000..0457bde53 --- /dev/null +++ b/Source/Utilities/recursive_read_write_mutex.cpp @@ -0,0 +1,87 @@ +/* + * Copyright © 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored By: Alan Griffiths + */ + +#include "recursive_read_write_mutex.h" + +#include + +void mir::RecursiveReadWriteMutex::read_lock() +{ + auto const my_id = std::this_thread::get_id(); + + std::unique_lock lock{mutex}; + cv.wait(lock, [&]{ + return !write_locking_thread.count || + write_locking_thread.id == my_id; }); + + auto const my_count = std::find_if( + read_locking_threads.begin(), + read_locking_threads.end(), + [my_id](ThreadLockCount const& candidate) { return my_id == candidate.id; }); + + if (my_count == read_locking_threads.end()) + { + read_locking_threads.push_back(ThreadLockCount(my_id, 1U)); + } + else + { + ++(my_count->count); + } +} + +void mir::RecursiveReadWriteMutex::read_unlock() +{ + auto const my_id = std::this_thread::get_id(); + + std::lock_guard lock{mutex}; + auto const my_count = std::find_if( + read_locking_threads.begin(), + read_locking_threads.end(), + [my_id](ThreadLockCount const& candidate) { return my_id == candidate.id; }); + + --(my_count->count); + + cv.notify_all(); +} + +void mir::RecursiveReadWriteMutex::write_lock() +{ + auto const my_id = std::this_thread::get_id(); + + std::unique_lock lock{mutex}; + cv.wait(lock, [&] + { + if (write_locking_thread.count && + write_locking_thread.id != my_id) return false; + for (auto const& candidate : read_locking_threads) + { + if (candidate.id != my_id && candidate.count != 0) return false; + } + return true; + }); + + ++write_locking_thread.count; + write_locking_thread.id = my_id; +} + +void mir::RecursiveReadWriteMutex::write_unlock() +{ + std::lock_guard lock{mutex}; + --write_locking_thread.count; + cv.notify_all(); +} diff --git a/Source/Utilities/recursive_read_write_mutex.h b/Source/Utilities/recursive_read_write_mutex.h new file mode 100644 index 000000000..6897e522f --- /dev/null +++ b/Source/Utilities/recursive_read_write_mutex.h @@ -0,0 +1,77 @@ +/* + * Copyright © 2014 Canonical Ltd. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authored By: Alan Griffiths + */ + +#ifndef MIR_RECURSIVE_READ_WRITE_MUTEX_H_ +#define MIR_RECURSIVE_READ_WRITE_MUTEX_H_ + +#include +#include +#include + +namespace mir +{ +/** a recursive read-write mutex. + * Note that a write lock can be acquired if no other threads have a read lock. + */ +class RecursiveReadWriteMutex +{ +public: + void read_lock(); + + void read_unlock(); + + void write_lock(); + + void write_unlock(); + +private: + std::mutex mutex; + std::condition_variable cv; + struct ThreadLockCount + { + ThreadLockCount() : id(), count(0) {} + ThreadLockCount(std::thread::id id, unsigned int count) : id(id), count(count) {} + std::thread::id id; + unsigned int count; + }; + std::vector read_locking_threads; + ThreadLockCount write_locking_thread; +}; + +class RecursiveReadLock +{ +public: + explicit RecursiveReadLock(RecursiveReadWriteMutex& mutex) : mutex(mutex) { mutex.read_lock(); } + ~RecursiveReadLock() { mutex.read_unlock(); } + +private: + RecursiveReadWriteMutex& mutex; +}; + +class RecursiveWriteLock +{ +public: + explicit RecursiveWriteLock(RecursiveReadWriteMutex& mutex) : mutex(mutex) { mutex.write_lock(); } + ~RecursiveWriteLock() { mutex.write_unlock(); } + +private: + RecursiveReadWriteMutex& mutex; +}; +} + +#endif /* MIR_RECURSIVE_READ_WRITE_MUTEX_H_ */ From 9f495ca639a16b35acc4c77cac270a0623a0523c Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Thu, 14 Jul 2016 21:27:22 -0700 Subject: [PATCH 02/33] Improve hash function --- Source/CommandMap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/CommandMap.h b/Source/CommandMap.h index a9ed99ad9..198c48291 100644 --- a/Source/CommandMap.h +++ b/Source/CommandMap.h @@ -64,8 +64,8 @@ namespace std { template <> struct hash { std::size_t operator()(const MIDI_Message& k) const noexcept { - return (std::hash()(k.isCC) ^ std::hash()(k.channel) ^ - (std::hash()(k.data) << 1)); + return std::hash()(k.isCC) ^ std::hash()(k.channel) ^ + std::hash()(k.data << 2); } }; From a15b820e033177856401e95afdbed59d4c1be903 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Thu, 14 Jul 2016 21:47:21 -0700 Subject: [PATCH 03/33] cleanup version checker code --- Source/VersionChecker.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Source/VersionChecker.cpp b/Source/VersionChecker.cpp index f30b425bf..8f62ffc04 100644 --- a/Source/VersionChecker.cpp +++ b/Source/VersionChecker.cpp @@ -33,16 +33,17 @@ void VersionChecker::Init(std::weak_ptr&& settings_manager) noe void VersionChecker::run() { const URL version_url{"http://rsjaffe.github.io/MIDI2LR/version.xml"}; const std::unique_ptr version_xml_element{version_url.readEntireXmlStream()}; - int last_checked{0}; - if (auto smp = settings_manager_.lock()) - last_checked = smp->getLastVersionFound(); - if (version_xml_element != nullptr && - (version_xml_element->getIntAttribute("latest") > ProjectInfo::versionNumber) && - (version_xml_element->getIntAttribute("latest") != last_checked)) { - new_version_ = version_xml_element->getIntAttribute("latest"); + + if (version_xml_element != nullptr) { + int last_checked = 0; if (auto smp = settings_manager_.lock()) - smp->setLastVersionFound(new_version_); - triggerAsyncUpdate(); + last_checked = smp->getLastVersionFound(); + new_version_ = version_xml_element->getIntAttribute("latest"); + if (new_version_ > ProjectInfo::versionNumber && new_version_ != last_checked) { + if (auto smp = settings_manager_.lock()) + smp->setLastVersionFound(new_version_); + triggerAsyncUpdate(); + } } } From 02a386a98d22eb8bd991d6c1cd322f963a1de700 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Fri, 15 Jul 2016 21:11:50 -0700 Subject: [PATCH 04/33] another observer pattern --- Source/Utilities/EventType.h | 14 ++++++++++++ Source/Utilities/Subject.h | 43 ++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 Source/Utilities/EventType.h create mode 100644 Source/Utilities/Subject.h diff --git a/Source/Utilities/EventType.h b/Source/Utilities/EventType.h new file mode 100644 index 000000000..41d4064e4 --- /dev/null +++ b/Source/Utilities/EventType.h @@ -0,0 +1,14 @@ +// +// Copyright (c) 2013 Juan Palacios juan.palacios.puyana@gmail.com +// Subject to the BSD 2-Clause License +// - see < http://opensource.org/licenses/BSD-2-Clause> +// + +#ifndef EVENTTYPE_H_ +#define EVENTTYPE_H_ + +enum class EventType { CONNECTED, DISCONNECTED, BLUE, YELLOW, ORANGE }; + +#endif + + diff --git a/Source/Utilities/Subject.h b/Source/Utilities/Subject.h new file mode 100644 index 000000000..7cf5ae0ad --- /dev/null +++ b/Source/Utilities/Subject.h @@ -0,0 +1,43 @@ +// +// Copyright (c) 2013 Juan Palacios juan.palacios.puyana@gmail.com +// Subject to the BSD 2-Clause License +// - see < http://opensource.org/licenses/BSD-2-Clause> +// + +#ifndef SUBJECT_H_ +#define SUBJECT_H_ + +#include +#include +#include +#include // for std::forward + +template +class Subject +{ + public: + Subject()=default; + template + void registerObserver(const Event& event, Observer&& observer) + { + observers_[event].push_back(std::forward(observer)); + } + template + void registerObserver(Event&& event, Observer&& observer) + { + observers_[std::move(event)].push_back(std::forward(observer)); + } + + void notify(const Event& event) const + { + for (const auto& obs : observers_.at(event)) obs(); + } + // disallow copying and assigning + Subject(const Subject&)=delete; + Subject& operator=(const Subject&)=delete; + + private: + std::map>> observers_; +}; + +#endif // SUBJECT_H_ From c9ef5cd754ad8d4364b13d1fc83fb40b3e34c54b Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Fri, 15 Jul 2016 22:25:53 -0700 Subject: [PATCH 05/33] needed to compile threadsafe queue --- Source/Utilities/Utilities.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/Utilities/Utilities.h b/Source/Utilities/Utilities.h index 98e4ecb07..9a62b947a 100644 --- a/Source/Utilities/Utilities.h +++ b/Source/Utilities/Utilities.h @@ -25,6 +25,8 @@ static constexpr bool ndebug = false; #endif #include +#include +#include namespace RSJ { template struct counter { From 6c76ca3c48a70cf28a65615507b71fbf8c79c4c1 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Fri, 15 Jul 2016 22:26:20 -0700 Subject: [PATCH 06/33] use multimap for command to midi messages --- Source/CommandMap.cpp | 18 +++++++++++++++--- Source/CommandMap.h | 4 +++- Source/LR_IPC_In.cpp | 36 +++++++++++++++--------------------- Source/LR_IPC_In.h | 3 --- Source/MainComponent.cpp | 8 ++++---- 5 files changed, 37 insertions(+), 32 deletions(-) diff --git a/Source/CommandMap.cpp b/Source/CommandMap.cpp index 97f4ae28d..e39935d51 100644 --- a/Source/CommandMap.cpp +++ b/Source/CommandMap.cpp @@ -29,7 +29,7 @@ void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message & // command:message map if (command < LRCommandList::LRStringList.size()) { message_map_[message] = LRCommandList::LRStringList[command]; - command_string_map_[LRCommandList::LRStringList[command]] = message; + command_string_map_.insert(std::pair(LRCommandList::LRStringList[command], message)); } else message_map_[message] = LRCommandList::NextPrevProfile[command - LRCommandList::LRStringList.size()]; @@ -37,7 +37,7 @@ void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message & void CommandMap::addCommandforMessage(const String& command, const MIDI_Message &message) { message_map_[message] = command; - command_string_map_[command] = message; + command_string_map_.insert(std::pair(command, message)); } const String& CommandMap::getCommandforMessage(const MIDI_Message &message) const { @@ -60,8 +60,20 @@ bool CommandMap::messageExistsInMap(const MIDI_Message &message) const { return message_map_.count(message) > 0 ? true : false; } +int CommandMap::getMessageCountForCommand(const String &command) const { + return command_string_map_.count(command); +} + +std::vector CommandMap::getMessagesForCommand(const String &command) const { + std::vector mm; + const auto range = command_string_map_.equal_range(command); + for (auto it = range.first; it != range.second; ++it) + mm.push_back(it->second); + return mm; +} + const MIDI_Message& CommandMap::getMessageForCommand(const String &command) const { - return command_string_map_.at(command); + return command_string_map_.find(command)->second; } bool CommandMap::commandHasAssociatedMessage(const String &command) const { return command_string_map_.count(command) > 0 ? true : false; diff --git a/Source/CommandMap.h b/Source/CommandMap.h index 198c48291..01175d325 100644 --- a/Source/CommandMap.h +++ b/Source/CommandMap.h @@ -104,6 +104,8 @@ class CommandMap { // returns true if there is a mapping for a particular MIDI message bool messageExistsInMap(const MIDI_Message &message) const; + int getMessageCountForCommand(const String &command) const; + std::vector getMessagesForCommand(const String &command) const; // gets the MIDI message associated to a LR command const MIDI_Message& getMessageForCommand(const String &command) const; @@ -116,7 +118,7 @@ class CommandMap { private: std::unordered_map message_map_; - std::unordered_map command_string_map_; + std::unordered_multimap command_string_map_; }; #endif // COMMANDMAP_H_INCLUDED diff --git a/Source/LR_IPC_In.cpp b/Source/LR_IPC_In.cpp index 218c2bce7..61464b2eb 100644 --- a/Source/LR_IPC_In.cpp +++ b/Source/LR_IPC_In.cpp @@ -53,18 +53,6 @@ void LR_IPC_IN::Init(std::shared_ptr& map_command, startTimer(1000); } -void LR_IPC_IN::refreshMIDIOutput() { - if (command_map_ && midi_sender_) { - // send associated CC messages to MIDI OUT devices - for (const auto& map_entry : parameter_map_) { - if (command_map_->commandHasAssociatedMessage(map_entry.first)) { - const auto& msg = command_map_->getMessageForCommand(map_entry.first); - midi_sender_->sendCC(msg.channel, msg.controller, map_entry.second); - } - } - } -} - void LR_IPC_IN::PleaseStopThread() { signalThreadShouldExit(); notify(); @@ -81,7 +69,6 @@ void LR_IPC_IN::run() { wait(kNotConnectedWait); } //end if (is not connected) else { - char line[kBufferSize + 1] = {'\0'};//plus one for \0 at end auto size_read = 0; auto can_read_line = true; @@ -162,16 +149,23 @@ void LR_IPC_IN::processLine(const juce::String& line) { JUCEApplication::getInstance()->systemRequestedQuit(); break; case 0: - // store updates in map - const auto original_value = value_string.getDoubleValue(); - parameter_map_[command] = static_cast(round(original_value * kMaxNRPN)); // send associated CC messages to MIDI OUT devices - if (command_map_ && command_map_->commandHasAssociatedMessage(command)) { - const auto& msg = command_map_->getMessageForCommand(command); - const auto value = static_cast(round( - ((msg.controller < 128) ? kMaxMIDI : kMaxNRPN) * original_value)); - if (midi_sender_) + if (command_map_ && midi_sender_ && command_map_->commandHasAssociatedMessage(command)) { + const auto original_value = value_string.getDoubleValue(); + if (command_map_->getMessageCountForCommand(command) > 1) { + const std::vector mm = command_map_->getMessagesForCommand(command); + for (const auto msg : mm) { + const auto value = static_cast(round( + ((msg.controller < 128) ? kMaxMIDI : kMaxNRPN) * original_value)); + midi_sender_->sendCC(msg.channel, msg.controller, value); + } + } + else { + const auto& msg = command_map_->getMessageForCommand(command); + const auto value = static_cast(round( + ((msg.controller < 128) ? kMaxMIDI : kMaxNRPN) * original_value)); midi_sender_->sendCC(msg.channel, msg.controller, value); + } } } } \ No newline at end of file diff --git a/Source/LR_IPC_In.h b/Source/LR_IPC_In.h index 1d91c5f93..23255a671 100644 --- a/Source/LR_IPC_In.h +++ b/Source/LR_IPC_In.h @@ -37,8 +37,6 @@ class LR_IPC_IN final: private StreamingSocket, void Init(std::shared_ptr& mapCommand, std::shared_ptr& profileManager, std::shared_ptr& midiSender) noexcept; - // re-enumerates MIDI OUT devices - void refreshMIDIOutput(); //signal exit to thread void PleaseStopThread(void); private: @@ -55,7 +53,6 @@ class LR_IPC_IN final: private StreamingSocket, std::shared_ptr command_map_{nullptr}; std::shared_ptr midi_sender_{nullptr}; std::shared_ptr profile_manager_{nullptr}; - std::unordered_map parameter_map_; }; #endif // LR_IPC_IN_H_INCLUDED diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 02d038086..c94780f1b 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -225,8 +225,8 @@ void MainContentComponent::buttonClicked(Button* button) { midi_sender_->RescanDevices(); } // Send new CC parameters to MIDI Out devices - if (const auto ptr = lr_ipc_in_.lock()) { - ptr->refreshMIDIOutput(); + if (const auto ptr = lr_ipc_out_.lock()) { + ptr->sendCommand("FullRefresh 1\n"); } } else if (button == &remove_row_button_) { @@ -322,8 +322,8 @@ void MainContentComponent::profileChanged(XmlElement* xml_element, const String& // _systemTrayComponent.showInfoBubble(filename, "Profile loaded"); // Send new CC parameters to MIDI Out devices - if (const auto ptr = lr_ipc_in_.lock()) { - ptr->refreshMIDIOutput(); + if (const auto ptr = lr_ipc_out_.lock()) { + ptr->sendCommand("FullRefresh 1\n"); } } From 58c255e13c078b837ac027459cfcd04a311b7643 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Fri, 15 Jul 2016 22:41:57 -0700 Subject: [PATCH 07/33] simplify code --- Source/CommandMap.cpp | 4 ++-- Source/LR_IPC_In.cpp | 25 +++++++++++++------------ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Source/CommandMap.cpp b/Source/CommandMap.cpp index e39935d51..f0ea000d7 100644 --- a/Source/CommandMap.cpp +++ b/Source/CommandMap.cpp @@ -29,7 +29,7 @@ void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message & // command:message map if (command < LRCommandList::LRStringList.size()) { message_map_[message] = LRCommandList::LRStringList[command]; - command_string_map_.insert(std::pair(LRCommandList::LRStringList[command], message)); + command_string_map_.insert({LRCommandList::LRStringList[command], message}); } else message_map_[message] = LRCommandList::NextPrevProfile[command - LRCommandList::LRStringList.size()]; @@ -37,7 +37,7 @@ void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message & void CommandMap::addCommandforMessage(const String& command, const MIDI_Message &message) { message_map_[message] = command; - command_string_map_.insert(std::pair(command, message)); + command_string_map_.insert({command, message}); } const String& CommandMap::getCommandforMessage(const MIDI_Message &message) const { diff --git a/Source/LR_IPC_In.cpp b/Source/LR_IPC_In.cpp index 61464b2eb..e62e92563 100644 --- a/Source/LR_IPC_In.cpp +++ b/Source/LR_IPC_In.cpp @@ -150,22 +150,23 @@ void LR_IPC_IN::processLine(const juce::String& line) { break; case 0: // send associated CC messages to MIDI OUT devices - if (command_map_ && midi_sender_ && command_map_->commandHasAssociatedMessage(command)) { - const auto original_value = value_string.getDoubleValue(); - if (command_map_->getMessageCountForCommand(command) > 1) { - const std::vector mm = command_map_->getMessagesForCommand(command); - for (const auto msg : mm) { + if (command_map_ && midi_sender_) + if (const auto cmd_count = command_map_->getMessageCountForCommand(command) > 0) { + const auto original_value = value_string.getDoubleValue(); + if (cmd_count > 1) { + const std::vector mm = command_map_->getMessagesForCommand(command); + for (const auto msg : mm) { + const auto value = static_cast(round( + ((msg.controller < 128) ? kMaxMIDI : kMaxNRPN) * original_value)); + midi_sender_->sendCC(msg.channel, msg.controller, value); + } + } + else { + const auto& msg = command_map_->getMessageForCommand(command); const auto value = static_cast(round( ((msg.controller < 128) ? kMaxMIDI : kMaxNRPN) * original_value)); midi_sender_->sendCC(msg.channel, msg.controller, value); } } - else { - const auto& msg = command_map_->getMessageForCommand(command); - const auto value = static_cast(round( - ((msg.controller < 128) ? kMaxMIDI : kMaxNRPN) * original_value)); - midi_sender_->sendCC(msg.channel, msg.controller, value); - } - } } } \ No newline at end of file From 24c1f49b5db8daf8f1c7a48774bf089ea35172b4 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Sat, 16 Jul 2016 08:15:04 -0700 Subject: [PATCH 08/33] stop foregrounding LR for keypresses Fixes keyboard focus issues in LR --- Source/SendKeys.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Source/SendKeys.cpp b/Source/SendKeys.cpp index 89fa487cf..95f83e378 100644 --- a/Source/SendKeys.cpp +++ b/Source/SendKeys.cpp @@ -32,11 +32,6 @@ MIDI2LR. If not, see . #endif namespace { #ifdef _WIN32 - bool IsForegroundProcess() { - return (GetCurrentProcessId() == - GetWindowThreadProcessId(GetForegroundWindow(), NULL)); - } - wchar_t MBtoWChar(const std::string& key) { wchar_t full_character; const auto return_value = MultiByteToWideChar(CP_UTF8, 0, key.data(), @@ -54,12 +49,9 @@ namespace { return full_character; } - HKL GetLanguageAndFGApp(std::string program_name) { + HKL GetLanguage(std::string program_name) { const auto hLRWnd = FindWindow(NULL, program_name.c_str()); if (hLRWnd) { - // Bring Lightroom to foreground if MIDI2LR is in foreground - if (IsForegroundProcess()) - SetForegroundWindow(hLRWnd); // get language that LR is using (if hLrWnd is found) const auto thread_id = GetWindowThreadProcessId(hLRWnd, NULL); return GetKeyboardLayout(thread_id); @@ -215,13 +207,13 @@ void SendKeys::SendKeyDownUp(const std::string& key, const bool alt_opt, for (const auto& c : key) lower_string.push_back(static_cast(std::tolower(c))); //c is char but tolower returns int #ifdef _WIN32 - //Lightroom handle - HKL language_id = GetLanguageAndFGApp("Lightroom"); + BYTE vk = 0; BYTE vk_modifiers = 0; if (SendKeys::key_map_.count(lower_string)) vk = SendKeys::key_map_.at(lower_string); else {// Translate key code to keyboard-dependent scan code, may be UTF-8 + const auto language_id = GetLanguage("Lightroom"); const auto vk_code_and_shift = VkKeyScanExW(MBtoWChar(key), language_id); vk = LOBYTE(vk_code_and_shift); vk_modifiers = HIBYTE(vk_code_and_shift); From f9dda8909932977b96ad355dee9f66c3d9052f60 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Sat, 16 Jul 2016 09:02:28 -0700 Subject: [PATCH 09/33] Added perspective x and y from transforms panel --- Source/LRCommands.cpp | 9 ++ Source/LRPlugin/MIDI2LR.lrplugin/Database.lua | 4 + Source/LRPlugin/MIDI2LR.lrplugin/MenuList.lua | 24 ++++ .../LRPlugin/MIDI2LR.lrplugin/ParamList.lua | 108 +++++++++++------- 4 files changed, 104 insertions(+), 41 deletions(-) diff --git a/Source/LRCommands.cpp b/Source/LRCommands.cpp index c41a942db..b7df67d54 100644 --- a/Source/LRCommands.cpp +++ b/Source/LRCommands.cpp @@ -323,6 +323,8 @@ const std::vector LRCommandList::LensCorrections = { "Perspective Rotate", "Perspective Scale", "Perspective Aspect", + "Perspective X", + "Perspective Y", "Vignette Amount", "Vignette Midpoint", "Reset Lens Manual Distortion Amount", @@ -331,6 +333,8 @@ const std::vector LRCommandList::LensCorrections = { "Reset Perspective Rotate", "Reset Perspective Scale", "Reset Perspective Aspect", + "Reset Perspective X", + "Reset Perspective Y", "Reset Vignette Amount", "Reset Vignette Midpoint", }; @@ -862,6 +866,8 @@ const std::vector LRCommandList::LRStringList = { "PerspectiveRotate", "PerspectiveScale", "PerspectiveAspect", + "PerspectiveX ", + "PerspectiveY ", "VignetteAmount", "VignetteMidpoint", "ResetLensManualDistortionAmount", @@ -870,6 +876,8 @@ const std::vector LRCommandList::LRStringList = { "ResetPerspectiveRotate", "ResetPerspectiveScale", "ResetPerspectiveAspect", + "ResetPerspectiveX", + "ResetPerspectiveY", "ResetVignetteAmount", "ResetVignetteMidpoint", /* Effects */ @@ -1102,6 +1110,7 @@ const std::vector LRCommandList::LRStringList = { "FullRefresh", }; + const std::vector LRCommandList::NextPrevProfile = { "Previous Profile", "Next Profile", diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua b/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua index c465a7dd3..f3cce4628 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua @@ -423,6 +423,8 @@ local DataBase = { {"PerspectiveRotate",'lensCorrectionsPanel',true,true,true,false,false,LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/PerspectiveRotate=Perspective Rotate"),lensCorrections,"Corrects for camera tilt. Uses the center of the original, uncropped photo as the axis of rotation.",'lensCorrectionsPanel'}, {"PerspectiveScale",'lensCorrectionsPanel',true,true,true,false,false,LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/PerspectiveScale=Perspective Scale"),lensCorrections,"Adjusts the image scale up or down. Helps to remove empty areas caused by perspective corrections and distortions. Displays areas of the image that extend beyond the crop boundary.",'lensCorrectionsPanel'}, {"PerspectiveAspect",'lensCorrectionsPanel',true,true,true,false,false,LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/PerspectiveAspect=Perspective Aspect"),lensCorrections,"Adjusts the amount the image is stretched horizontally or vertically.",'lensCorrectionsPanel'}, + {"PerspectiveX ",'lensCorrectionsPanel',true,true,true,false,true,LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/PerspectiveX=Perspective X"),lensCorrections,"Moves the center of the image laterally.",'lensCorrectionsPanel'}, + {"PerspectiveY ",'lensCorrectionsPanel',true,true,true,false,true,LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/PerspectiveY=Perspective Y"),lensCorrections,"Moves the center of the image vertically.",'lensCorrectionsPanel'}, {"VignetteAmount",'lensCorrectionsPanel',true,true,true,false,true,LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/VignetteAmount=Vignette Amount"),lensCorrections,"Sets the amount of lightening or darkening along the edges of an image. Corrects images that have darkened corners caused by lens faults or improper lens shading.",'lensCorrectionsPanel'}, {"VignetteMidpoint",'lensCorrectionsPanel',true,true,true,false,true,LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/VignetteMidpoint=Vignette Midpoint"),lensCorrections,"Specifies the width of area affected by the Amount slider. Specify a lower number to affect more of the image. Specify a higher number to restrict the effect to the edges of the image.",'lensCorrectionsPanel'}, {"ResetLensManualDistortionAmount",false,false,true,false,true,false,reset..' '..LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/LensManualDistortionAmount=Lens Manual Distortion Amount"),lensCorrections,"Reset to default. *button*",'lensCorrectionsPanel'}, @@ -431,6 +433,8 @@ local DataBase = { {"ResetPerspectiveRotate",false,false,true,false,true,false,reset..' '..LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/PerspectiveRotate=Perspective Rotate"),lensCorrections,"Reset to default. *button*",'lensCorrectionsPanel'}, {"ResetPerspectiveScale",false,false,true,false,true,false,reset..' '..LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/PerspectiveScale=Perspective Scale"),lensCorrections,"Reset to default. *button*",'lensCorrectionsPanel'}, {"ResetPerspectiveAspect",false,false,true,false,true,false,reset..' '..LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/PerspectiveAspect=Perspective Aspect"),lensCorrections,"Reset to default. *button*",'lensCorrectionsPanel'}, + {"ResetPerspectiveX",false,false,true,false,true,true,reset..' '..LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/PerspectiveX=Perspective X"),lensCorrections,"Reset to default. *button*",'lensCorrectionsPanel'}, + {"ResetPerspectiveY",false,false,true,false,true,true,reset..' '..LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/PerspectiveY=Perspective Y"),lensCorrections,"Reset to default. *button*",'lensCorrectionsPanel'}, {"ResetVignetteAmount",false,false,true,false,true,true,reset..' '..LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/VignetteAmount=Vignette Amount"),lensCorrections,"Reset to default. *button*",'lensCorrectionsPanel'}, {"ResetVignetteMidpoint",false,false,true,false,true,true,reset..' '..LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/VignetteMidpoint=Vignette Midpoint"),lensCorrections,"Reset to default. *button*",'lensCorrectionsPanel'}, {"RevealPanelEffects",false,false,true,false,true,false,show..' '..effects,effects,"Open Effects Panel in Develop Module. *button*"}, diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/MenuList.lua b/Source/LRPlugin/MIDI2LR.lrplugin/MenuList.lua index b5864f487..c5719ba64 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/MenuList.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/MenuList.lua @@ -1639,6 +1639,18 @@ "Lens Corrections", false }, + { + "PerspectiveX ", + "Perspective X", + "Lens Corrections", + false + }, + { + "PerspectiveY ", + "Perspective Y", + "Lens Corrections", + false + }, { "VignetteAmount", "Vignette Amount", @@ -1687,6 +1699,18 @@ "Lens Corrections", true }, + { + "ResetPerspectiveX", + "Reset Perspective X", + "Lens Corrections", + true + }, + { + "ResetPerspectiveY", + "Reset Perspective Y", + "Lens Corrections", + true + }, { "ResetVignetteAmount", "Reset Vignette Amount", diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/ParamList.lua b/Source/LRPlugin/MIDI2LR.lrplugin/ParamList.lua index 5a3b6149f..567653e3f 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/ParamList.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/ParamList.lua @@ -431,6 +431,14 @@ "PerspectiveAspect", "Perspective Aspect" }, + { + "PerspectiveX ", + "Perspective X" + }, + { + "PerspectiveY ", + "Perspective Y" + }, { "VignetteAmount", "Vignette Amount" @@ -710,6 +718,8 @@ "PerspectiveRotate", "PerspectiveScale", "PerspectiveAspect", + "PerspectiveX ", + "PerspectiveY ", "VignetteAmount", "VignetteMidpoint", "EnableEffects", @@ -869,6 +879,8 @@ "PerspectiveRotate", "PerspectiveScale", "PerspectiveAspect", + "PerspectiveX ", + "PerspectiveY ", "VignetteAmount", "VignetteMidpoint" }, @@ -917,11 +929,11 @@ }, BlueHue = { "Blue Hue Calibration", - 360 + 364 }, BlueSaturation = { "Blue Saturation Calibration", - 361 + 365 }, Brightness = { "Brightness", @@ -949,23 +961,23 @@ }, CropAngle = { "Crop Angle", - 501 + 505 }, CropBottom = { "Crop - Bottom", - 502 + 506 }, CropLeft = { "Crop - Left", - 503 + 507 }, CropRight = { "Crop - Right", - 504 + 508 }, CropTop = { "Crop - Top", - 505 + 509 }, DefringeGreenAmount = { "Defringe Green Amount", @@ -993,7 +1005,7 @@ }, Dehaze = { "Dehaze Amount", - 311 + 315 }, Exposure = { "Exposure", @@ -1001,15 +1013,15 @@ }, GrainAmount = { "Grain Amount", - 318 + 322 }, GrainFrequency = { "Grain Roughness", - 320 + 324 }, GrainSize = { "Grain Size", - 319 + 323 }, GrayMixerAqua = { "Gray Mixer Aqua", @@ -1045,11 +1057,11 @@ }, GreenHue = { "Green Hue Calibration", - 358 + 362 }, GreenSaturation = { "Green Saturation Calibration", - 359 + 363 }, Highlights = { "Highlights (Highlight Recovery in PV2003 and PV2010)", @@ -1195,37 +1207,45 @@ "Perspective Vertical", 294 }, + ["PerspectiveX "] = { + "Perspective X", + 299 + }, + ["PerspectiveY "] = { + "Perspective Y", + 300 + }, PostCropVignetteAmount = { "Post Crop Vignette Amount", - 312 + 316 }, PostCropVignetteFeather = { "Post Crop Vignette Feather", - 314 + 318 }, PostCropVignetteHighlightContrast = { "Post Crop Vignette Highlight Contrast", - 317 + 321 }, PostCropVignetteMidpoint = { "Post Crop Vignette Midpoint", - 313 + 317 }, PostCropVignetteRoundness = { "Post Crop Vignette Roundness", - 315 + 319 }, PostCropVignetteStyle = { "Post Crop Vignette Style", - 316 + 320 }, RedHue = { "Red Hue Calibration", - 356 + 360 }, RedSaturation = { "Red Saturation Calibration", - 357 + 361 }, Saturation = { "Saturation", @@ -1265,7 +1285,7 @@ }, ShadowTint = { "Shadow Tint Calibration", - 355 + 359 }, Shadows = { "Shadows (Fill Light in PV2003 and PV2010)", @@ -1321,11 +1341,11 @@ }, VignetteAmount = { "Vignette Amount", - 299 + 301 }, VignetteMidpoint = { "Vignette Midpoint", - 300 + 302 }, Whites = { "Whites (no effect in PV2003 and PV2010)", @@ -1333,71 +1353,71 @@ }, local_Blacks2012 = { "Local Adjustments Blacks (PV2012)", - 462 + 466 }, local_Clarity = { "Local Adjustments Clarity (PV2010 and PV2012)", - 463 + 467 }, local_Contrast = { "Local Adjustments Contrast (PV2010 and PV2012)", - 458 + 462 }, local_Defringe = { "Local Adjustments Defringe (PV2012)", - 469 + 473 }, local_Dehaze = { "Local Adjustments Dehaze (PV2012)", - 464 + 468 }, local_Exposure = { "Local Adjustments Exposure (PV2010 and PV2012)", - 457 + 461 }, local_Highlights = { "Local Adjustments Highlights (PV2012)", - 459 + 463 }, local_LuminanceNoise = { "Local Adjustments Luminence Noise Reduction (PV2012)", - 467 + 471 }, local_Moire = { "Local Adjustments Moire (PV2012)", - 468 + 472 }, local_Saturation = { "Local Adjustments Saturation (PV2010 and PV2012)", - 465 + 469 }, local_Shadows = { "Local Adjustments Shadows (PV2012)", - 460 + 464 }, local_Sharpness = { "Local Adjustments Sharpness (PV2010 and PV2012)", - 466 + 470 }, local_Temperature = { "Local Adjustments Temp. (PV2012)", - 455 + 459 }, local_Tint = { "Local Adjustments Tint (PV2012)", - 456 + 460 }, local_ToningLuminance = { "Local Toning Luminance (PV2010)", - 470 + 474 }, local_Whites2012 = { "Local Adjustments Whites (PV2012)", - 461 + 465 }, straightenAngle = { "Straighten Angle", - 500 + 504 } } local SendToMidi = { @@ -1482,6 +1502,8 @@ "PerspectiveRotate", "PerspectiveScale", "PerspectiveAspect", + "PerspectiveX ", + "PerspectiveY ", "VignetteAmount", "VignetteMidpoint", "Dehaze", @@ -1606,6 +1628,8 @@ PerspectiveRotate = "lensCorrectionsPanel", PerspectiveScale = "lensCorrectionsPanel", PerspectiveVertical = "lensCorrectionsPanel", + ["PerspectiveX "] = "lensCorrectionsPanel", + ["PerspectiveY "] = "lensCorrectionsPanel", PostCropVignetteAmount = "effectsPanel", PostCropVignetteFeather = "effectsPanel", PostCropVignetteHighlightContrast = "effectsPanel", @@ -1702,6 +1726,8 @@ ResetPerspectiveScale = "lensCorrectionsPanel", ResetPerspectiveUpright = "lensCorrectionsPanel", ResetPerspectiveVertical = "lensCorrectionsPanel", + ResetPerspectiveX = "lensCorrectionsPanel", + ResetPerspectiveY = "lensCorrectionsPanel", ResetPostCropVignetteAmount = "effectsPanel", ResetPostCropVignetteFeather = "effectsPanel", ResetPostCropVignetteHighlightContrast = "effectsPanel", From 5d9a4e3fb8152a473b0cb42cc14608ca907c0048 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Sat, 16 Jul 2016 09:55:03 -0700 Subject: [PATCH 10/33] Update controllers after rescan: ensure that NRPN values are in correct range. --- Source/LR_IPC_In.cpp | 9 ++++----- Source/LR_IPC_In.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/LR_IPC_In.cpp b/Source/LR_IPC_In.cpp index 218c2bce7..9961b4853 100644 --- a/Source/LR_IPC_In.cpp +++ b/Source/LR_IPC_In.cpp @@ -38,9 +38,6 @@ LR_IPC_IN::~LR_IPC_IN() { stopTimer(); stopThread(1000); close(); - command_map_.reset(); - profile_manager_.reset(); - midi_sender_.reset(); } void LR_IPC_IN::Init(std::shared_ptr& map_command, @@ -59,7 +56,9 @@ void LR_IPC_IN::refreshMIDIOutput() { for (const auto& map_entry : parameter_map_) { if (command_map_->commandHasAssociatedMessage(map_entry.first)) { const auto& msg = command_map_->getMessageForCommand(map_entry.first); - midi_sender_->sendCC(msg.channel, msg.controller, map_entry.second); + const auto value = static_cast(round( + ((msg.controller < 128) ? kMaxMIDI : kMaxNRPN) * map_entry.second)); + midi_sender_->sendCC(msg.channel, msg.controller, value); } } } @@ -164,7 +163,7 @@ void LR_IPC_IN::processLine(const juce::String& line) { case 0: // store updates in map const auto original_value = value_string.getDoubleValue(); - parameter_map_[command] = static_cast(round(original_value * kMaxNRPN)); + parameter_map_[command] = original_value; // send associated CC messages to MIDI OUT devices if (command_map_ && command_map_->commandHasAssociatedMessage(command)) { const auto& msg = command_map_->getMessageForCommand(command); diff --git a/Source/LR_IPC_In.h b/Source/LR_IPC_In.h index 1d91c5f93..c31226cef 100644 --- a/Source/LR_IPC_In.h +++ b/Source/LR_IPC_In.h @@ -55,7 +55,7 @@ class LR_IPC_IN final: private StreamingSocket, std::shared_ptr command_map_{nullptr}; std::shared_ptr midi_sender_{nullptr}; std::shared_ptr profile_manager_{nullptr}; - std::unordered_map parameter_map_; + std::unordered_map parameter_map_; }; #endif // LR_IPC_IN_H_INCLUDED From 7be0f0636000a3ee381f017febf09d7447f6f246 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Sat, 16 Jul 2016 10:13:55 -0700 Subject: [PATCH 11/33] Revert 062e7c8. Make copy/paste and apply preset for current photo only. Bug with apply all, will need more work before readding the functionality. --- Source/LRCommands.cpp | 85 ------ Source/LRPlugin/MIDI2LR.lrplugin/Client.lua | 126 +++------ .../MIDI2LR.lrplugin/ClientUtilities.lua | 62 ++--- Source/LRPlugin/MIDI2LR.lrplugin/Database.lua | 46 +--- Source/LRPlugin/MIDI2LR.lrplugin/MenuList.lua | 252 ------------------ .../LRPlugin/MIDI2LR.lrplugin/ParamList.lua | 248 ++++++++--------- 6 files changed, 187 insertions(+), 632 deletions(-) diff --git a/Source/LRCommands.cpp b/Source/LRCommands.cpp index b7df67d54..6a863ec5e 100644 --- a/Source/LRCommands.cpp +++ b/Source/LRCommands.cpp @@ -106,9 +106,7 @@ const std::vector LRCommandList::Develop = { "Show Develop", "Copy Settings", "Paste Settings", - "Paste Settings Include selected photos", "Paste Selected Settings", - "Paste Selected Settings Include selected photos", "Create Virtual Copy", "Reset Settings", "Reset Last Modified", @@ -445,46 +443,6 @@ const std::vector LRCommandList::DevelopPresets = { "Develop Preset 38", "Develop Preset 39", "Develop Preset 40", - "Develop Preset 1 Include selected photos", - "Develop Preset 2 Include selected photos", - "Develop Preset 3 Include selected photos", - "Develop Preset 4 Include selected photos", - "Develop Preset 5 Include selected photos", - "Develop Preset 6 Include selected photos", - "Develop Preset 7 Include selected photos", - "Develop Preset 8 Include selected photos", - "Develop Preset 9 Include selected photos", - "Develop Preset 10 Include selected photos", - "Develop Preset 11 Include selected photos", - "Develop Preset 12 Include selected photos", - "Develop Preset 13 Include selected photos", - "Develop Preset 14 Include selected photos", - "Develop Preset 15 Include selected photos", - "Develop Preset 16 Include selected photos", - "Develop Preset 17 Include selected photos", - "Develop Preset 18 Include selected photos", - "Develop Preset 19 Include selected photos", - "Develop Preset 20 Include selected photos", - "Develop Preset 21 Include selected photos", - "Develop Preset 22 Include selected photos", - "Develop Preset 23 Include selected photos", - "Develop Preset 24 Include selected photos", - "Develop Preset 25 Include selected photos", - "Develop Preset 26 Include selected photos", - "Develop Preset 27 Include selected photos", - "Develop Preset 28 Include selected photos", - "Develop Preset 29 Include selected photos", - "Develop Preset 30 Include selected photos", - "Develop Preset 31 Include selected photos", - "Develop Preset 32 Include selected photos", - "Develop Preset 33 Include selected photos", - "Develop Preset 34 Include selected photos", - "Develop Preset 35 Include selected photos", - "Develop Preset 36 Include selected photos", - "Develop Preset 37 Include selected photos", - "Develop Preset 38 Include selected photos", - "Develop Preset 39 Include selected photos", - "Develop Preset 40 Include selected photos", }; const std::vector LRCommandList::LocalAdjustments = { @@ -663,9 +621,7 @@ const std::vector LRCommandList::LRStringList = { "SwToMdevelop", "CopySettings", "PasteSettings", - "PasteSettingsAllSel", "PasteSelectedSettings", - "PasteSelectedSettingsAllSel", "VirtualCopy", "ResetAll", "ResetLast", @@ -982,46 +938,6 @@ const std::vector LRCommandList::LRStringList = { "Preset_38", "Preset_39", "Preset_40", - "Preset_1_AllSel", - "Preset_2_AllSel", - "Preset_3_AllSel", - "Preset_4_AllSel", - "Preset_5_AllSel", - "Preset_6_AllSel", - "Preset_7_AllSel", - "Preset_8_AllSel", - "Preset_9_AllSel", - "Preset_10_AllSel", - "Preset_11_AllSel", - "Preset_12_AllSel", - "Preset_13_AllSel", - "Preset_14_AllSel", - "Preset_15_AllSel", - "Preset_16_AllSel", - "Preset_17_AllSel", - "Preset_18_AllSel", - "Preset_19_AllSel", - "Preset_20_AllSel", - "Preset_21_AllSel", - "Preset_22_AllSel", - "Preset_23_AllSel", - "Preset_24_AllSel", - "Preset_25_AllSel", - "Preset_26_AllSel", - "Preset_27_AllSel", - "Preset_28_AllSel", - "Preset_29_AllSel", - "Preset_30_AllSel", - "Preset_31_AllSel", - "Preset_32_AllSel", - "Preset_33_AllSel", - "Preset_34_AllSel", - "Preset_35_AllSel", - "Preset_36_AllSel", - "Preset_37_AllSel", - "Preset_38_AllSel", - "Preset_39_AllSel", - "Preset_40_AllSel", /* Local Adjustments */ "GraduatedFilter", "RadialFilter", @@ -1110,7 +1026,6 @@ const std::vector LRCommandList::LRStringList = { "FullRefresh", }; - const std::vector LRCommandList::NextPrevProfile = { "Previous Profile", "Next Profile", diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua b/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua index 5cb48887b..cf74b7fff 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua @@ -167,91 +167,49 @@ LrTasks.startAsyncTask( LensProfileEnable = CU.fToggle01('LensProfileEnable'), Loupe = CU.fToggleTool('loupe'), Next = LrSelection.nextPhoto, - PasteSelectedSettings = CU.PasteSelectedSettings(false), - PasteSelectedSettingsAllSel = CU.PasteSelectedSettings(true), - PasteSettings = CU.PasteSettings(false), - PasteSettingsAllSel = CU.PasteSettings(true), + PasteSelectedSettings = CU.PasteSelectedSettings, + PasteSettings = CU.PasteSettings, Pick = LrSelection.flagAsPick, - Preset_1 = CU.fApplyPreset(1,false), - Preset_2 = CU.fApplyPreset(2,false), - Preset_3 = CU.fApplyPreset(3,false), - Preset_4 = CU.fApplyPreset(4,false), - Preset_5 = CU.fApplyPreset(5,false), - Preset_6 = CU.fApplyPreset(6,false), - Preset_7 = CU.fApplyPreset(7,false), - Preset_8 = CU.fApplyPreset(8,false), - Preset_9 = CU.fApplyPreset(9,false), - Preset_10 = CU.fApplyPreset(10,false), - Preset_11 = CU.fApplyPreset(11,false), - Preset_12 = CU.fApplyPreset(12,false), - Preset_13 = CU.fApplyPreset(13,false), - Preset_14 = CU.fApplyPreset(14,false), - Preset_15 = CU.fApplyPreset(15,false), - Preset_16 = CU.fApplyPreset(16,false), - Preset_17 = CU.fApplyPreset(17,false), - Preset_18 = CU.fApplyPreset(18,false), - Preset_19 = CU.fApplyPreset(19,false), - Preset_20 = CU.fApplyPreset(20,false), - Preset_21 = CU.fApplyPreset(21,false), - Preset_22 = CU.fApplyPreset(22,false), - Preset_23 = CU.fApplyPreset(23,false), - Preset_24 = CU.fApplyPreset(24,false), - Preset_25 = CU.fApplyPreset(25,false), - Preset_26 = CU.fApplyPreset(26,false), - Preset_27 = CU.fApplyPreset(27,false), - Preset_28 = CU.fApplyPreset(28,false), - Preset_29 = CU.fApplyPreset(29,false), - Preset_30 = CU.fApplyPreset(30,false), - Preset_31 = CU.fApplyPreset(31,false), - Preset_32 = CU.fApplyPreset(32,false), - Preset_33 = CU.fApplyPreset(33,false), - Preset_34 = CU.fApplyPreset(34,false), - Preset_35 = CU.fApplyPreset(35,false), - Preset_36 = CU.fApplyPreset(36,false), - Preset_37 = CU.fApplyPreset(37,false), - Preset_38 = CU.fApplyPreset(38,false), - Preset_39 = CU.fApplyPreset(39,false), - Preset_40 = CU.fApplyPreset(40,false), - Preset_1_AllSel = CU.fApplyPreset(1,true), - Preset_2_AllSel = CU.fApplyPreset(2,true), - Preset_3_AllSel = CU.fApplyPreset(3,true), - Preset_4_AllSel = CU.fApplyPreset(4,true), - Preset_5_AllSel = CU.fApplyPreset(5,true), - Preset_6_AllSel = CU.fApplyPreset(6,true), - Preset_7_AllSel = CU.fApplyPreset(7,true), - Preset_8_AllSel = CU.fApplyPreset(8,true), - Preset_9_AllSel = CU.fApplyPreset(9,true), - Preset_10_AllSel = CU.fApplyPreset(10,true), - Preset_11_AllSel = CU.fApplyPreset(11,true), - Preset_12_AllSel = CU.fApplyPreset(12,true), - Preset_13_AllSel = CU.fApplyPreset(13,true), - Preset_14_AllSel = CU.fApplyPreset(14,true), - Preset_15_AllSel = CU.fApplyPreset(15,true), - Preset_16_AllSel = CU.fApplyPreset(16,true), - Preset_17_AllSel = CU.fApplyPreset(17,true), - Preset_18_AllSel = CU.fApplyPreset(18,true), - Preset_19_AllSel = CU.fApplyPreset(19,true), - Preset_20_AllSel = CU.fApplyPreset(20,true), - Preset_21_AllSel = CU.fApplyPreset(21,true), - Preset_22_AllSel = CU.fApplyPreset(22,true), - Preset_23_AllSel = CU.fApplyPreset(23,true), - Preset_24_AllSel = CU.fApplyPreset(24,true), - Preset_25_AllSel = CU.fApplyPreset(25,true), - Preset_26_AllSel = CU.fApplyPreset(26,true), - Preset_27_AllSel = CU.fApplyPreset(27,true), - Preset_28_AllSel = CU.fApplyPreset(28,true), - Preset_29_AllSel = CU.fApplyPreset(29,true), - Preset_30_AllSel = CU.fApplyPreset(30,true), - Preset_31_AllSel = CU.fApplyPreset(31,true), - Preset_32_AllSel = CU.fApplyPreset(32,true), - Preset_33_AllSel = CU.fApplyPreset(33,true), - Preset_34_AllSel = CU.fApplyPreset(34,true), - Preset_35_AllSel = CU.fApplyPreset(35,true), - Preset_36_AllSel = CU.fApplyPreset(36,true), - Preset_37_AllSel = CU.fApplyPreset(37,true), - Preset_38_AllSel = CU.fApplyPreset(38,true), - Preset_39_AllSel = CU.fApplyPreset(39,true), - Preset_40_AllSel = CU.fApplyPreset(40,true), + Preset_1 = CU.fApplyPreset(1), + Preset_2 = CU.fApplyPreset(2), + Preset_3 = CU.fApplyPreset(3), + Preset_4 = CU.fApplyPreset(4), + Preset_5 = CU.fApplyPreset(5), + Preset_6 = CU.fApplyPreset(6), + Preset_7 = CU.fApplyPreset(7), + Preset_8 = CU.fApplyPreset(8), + Preset_9 = CU.fApplyPreset(9), + Preset_10 = CU.fApplyPreset(10), + Preset_11 = CU.fApplyPreset(11), + Preset_12 = CU.fApplyPreset(12), + Preset_13 = CU.fApplyPreset(13), + Preset_14 = CU.fApplyPreset(14), + Preset_15 = CU.fApplyPreset(15), + Preset_16 = CU.fApplyPreset(16), + Preset_17 = CU.fApplyPreset(17), + Preset_18 = CU.fApplyPreset(18), + Preset_19 = CU.fApplyPreset(19), + Preset_20 = CU.fApplyPreset(20), + Preset_21 = CU.fApplyPreset(21), + Preset_22 = CU.fApplyPreset(22), + Preset_23 = CU.fApplyPreset(23), + Preset_24 = CU.fApplyPreset(24), + Preset_25 = CU.fApplyPreset(25), + Preset_26 = CU.fApplyPreset(26), + Preset_27 = CU.fApplyPreset(27), + Preset_28 = CU.fApplyPreset(28), + Preset_29 = CU.fApplyPreset(29), + Preset_30 = CU.fApplyPreset(30), + Preset_31 = CU.fApplyPreset(31), + Preset_32 = CU.fApplyPreset(32), + Preset_33 = CU.fApplyPreset(33), + Preset_34 = CU.fApplyPreset(34), + Preset_35 = CU.fApplyPreset(35), + Preset_36 = CU.fApplyPreset(36), + Preset_37 = CU.fApplyPreset(37), + Preset_38 = CU.fApplyPreset(38), + Preset_39 = CU.fApplyPreset(39), + Preset_40 = CU.fApplyPreset(40), Prev = LrSelection.previousPhoto, Profile_Adobe_Standard = Ut.wrapFOM(LrDevelopController.setValue,'CameraProfile','Adobe Standard'), Profile_Camera_Clear = Ut.wrapFOM(LrDevelopController.setValue,'CameraProfile','Camera Clear'), diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/ClientUtilities.lua b/Source/LRPlugin/MIDI2LR.lrplugin/ClientUtilities.lua index 056f6ad2e..0bc84455f 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/ClientUtilities.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/ClientUtilities.lua @@ -32,7 +32,7 @@ local LrFunctionContext = import 'LrFunctionContext' local LrTasks = import 'LrTasks' local LrView = import 'LrView' -local function fApplyPreset(presetnumber,allselected) +local function fApplyPreset(presetnumber) return function() local presetUuid = ProgramPreferences.Presets[presetnumber] if presetUuid == nil or LrApplication.activeCatalog():getTargetPhoto() == nil then return end @@ -40,15 +40,7 @@ local function fApplyPreset(presetnumber,allselected) LrTasks.startAsyncTask ( function () LrApplication.activeCatalog():withWriteAccessDo( 'Apply preset '..preset:getName(), - function() - if allselected then - for _,p in ipairs(LrApplication.activeCatalog():getTargetPhotos()) do - p:applyDevelopPreset(preset) - end - else - LrApplication.activeCatalog():getTargetPhoto():applyDevelopPreset(preset) - end - end, + function() LrApplication.activeCatalog():getTargetPhoto():applyDevelopPreset(preset) end, { timeout = 4, callback = function() LrDialogs.showError(LOC("$$$/AgCustomMetadataRegistry/UpdateCatalog/Error=The catalog could not be updated with additional module metadata.").. 'PastePreset.') end, asynchronous = true } @@ -103,7 +95,7 @@ local function fToggleTool(param) end -local function PasteSelectedSettings (allselected) +local function PasteSelectedSettings () if MIDI2LR.Copied_Settings == nil or LrApplication.activeCatalog():getTargetPhoto() == nil then return end if ProgramPreferences.PastePopup then LrFunctionContext.callWithContext( "checkPaste", @@ -127,48 +119,32 @@ local function PasteSelectedSettings (allselected) end LrTasks.startAsyncTask ( function () - local photos = {} - if allselected then - photos = LrApplication.activeCatalog():getTargetPhotos() - else - photos[1] = LrApplication.activeCatalog():getTargetPhoto() - end - for _,p in ipairs(photos) do - local TargetSettings = p:getDevelopSettings() - for _,param in ipairs(ParamList.SelectivePasteIteration) do - if (ProgramPreferences.PasteList[param] and MIDI2LR.Copied_Settings[param]~=nil) then - TargetSettings[param] = MIDI2LR.Copied_Settings[param] - end + local TargetSettings = LrApplication.activeCatalog():getTargetPhoto():getDevelopSettings() + for _,param in ipairs(ParamList.SelectivePasteIteration) do + if (ProgramPreferences.PasteList[param] and MIDI2LR.Copied_Settings[param]~=nil) then + TargetSettings[param] = MIDI2LR.Copied_Settings[param] end - LrApplication.activeCatalog():withWriteAccessDo( - 'MIDI2LR: Paste selected settings', - function() p:applyDevelopSettings(TargetSettings) end, - { timeout = 4, - callback = function() - LrDialogs.showError(LOC("$$$/AgCustomMetadataRegistry/UpdateCatalog/Error=The catalog could not be updated with additional module metadata.")..' PasteSelectedSettings') - end, - asynchronous = true - } - ) end + LrApplication.activeCatalog():withWriteAccessDo( + 'MIDI2LR: Paste selected settings', + function() LrApplication.activeCatalog():getTargetPhoto():applyDevelopSettings(TargetSettings) end, + { timeout = 4, + callback = function() + LrDialogs.showError(LOC("$$$/AgCustomMetadataRegistry/UpdateCatalog/Error=The catalog could not be updated with additional module metadata.")..' PasteSelectedSettings') + end, + asynchronous = true + } + ) end ) end -local function PasteSettings (allselected) +local function PasteSettings () if MIDI2LR.Copied_Settings == nil or LrApplication.activeCatalog():getTargetPhoto() == nil then return end LrTasks.startAsyncTask ( function () LrApplication.activeCatalog():withWriteAccessDo( 'MIDI2LR: Paste settings', - function() - if allselected then - for _,p in ipairs(LrApplication.activeCatalog():getTargetPhotos()) do - p:applyDevelopSettings(MIDI2LR.Copied_Settings) - end - else - LrApplication.activeCatalog():getTargetPhoto():applyDevelopSettings(MIDI2LR.Copied_Settings) - end - end, + function() LrApplication.activeCatalog():getTargetPhoto():applyDevelopSettings(MIDI2LR.Copied_Settings) end, { timeout = 4, callback = function() LrDialogs.showError(LOC("$$$/AgCustomMetadataRegistry/UpdateCatalog/Error=The catalog could not be updated with additional module metadata.")..' PasteSettings') diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua b/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua index f3cce4628..8e2d95c3e 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua @@ -192,10 +192,8 @@ local DataBase = { {"SwToMdevelop",false,false,true,false,true,false,show..' '..LOC("$$$/SmartCollection/Criteria/Heading/Develop=Develop"),develop,"Switch to Develop module. *button*"}, --develop: copy paste sync {"CopySettings",false,false,true,false,true,false,LOC("$$$/AgLibrary/Menu/Develop/CopySettings=Copy Settings"):gsub("&",""),develop,"Copies all develop settings. Application will remember last copy operation and use that for all paste operations until a new *Copy Settings* is done or the application is restarted. *button*"}, - {"PasteSettings",false,false,true,false,true,false,LOC("$$$/AgCameraRawNamedSettings/Ops/PasteSettings=Paste Settings"),develop,"Pastes all develop settings to active photo only. *button*"}, - {"PasteSettingsAllSel",false,false,true,false,true,false,LOC("$$$/AgCameraRawNamedSettings/Ops/PasteSettings=Paste Settings"..' '..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos")),develop,"Pastes all develop settings to all selected photos. *button*"}, - {"PasteSelectedSettings",false,false,true,false,true,false,"Paste Selected Settings",develop,"Pastes only those settings checked in the **Options\226\128\148Paste Selections** dialog to active photo only. *button*"}, - {"PasteSelectedSettingsAllSel",false,false,true,false,true,false,"Paste Selected Settings"..' '..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),develop,"Pastes only those settings checked in the **Options\226\128\148Paste Selections** dialog to all selected photos. *button*"}, + {"PasteSettings",false,false,true,false,true,false,LOC("$$$/AgCameraRawNamedSettings/Ops/PasteSettings=Paste Settings"),develop,"Pastes all develop settings. *button*"}, + {"PasteSelectedSettings",false,false,true,false,true,false,"Paste Selected Settings",develop,"Pastes only those settings checked in the **Options\226\128\148Paste Selections** dialog. *button*"}, {"VirtualCopy",false,false,true,false,true,false,LOC("$$$/AgLibrary/Bezel/CreateVirtualCopy=Create Virtual Copy"):gsub('&',''),develop,"Creates a virtual copy for each of the currently selected photos and videos. The new virtual copies will be selected. *button*"}, {"ResetAll",false,false,true,false,true,false,LOC("$$$/AgCameraRawNamedSettings/Ops/ResetSettings=Reset Settings"),develop,"Reset to defaults. *button*"}, {"ResetLast",false,false,true,false,true,false,reset..' '..LOC("$$$/LibraryUpgradeCatalogUtils/CatalogInfo/LastModified/Label=Last Modified"):gsub(':',''),develop,"Resets the last parameter that was adjusted by an encoder or fader to default. *button*"}, @@ -542,46 +540,6 @@ local DataBase = { {"Preset_38",false,false,true,false,true,false,developPreset.." 38",developPresets,"Apply preset 38 to active photo only. *button*"}, {"Preset_39",false,false,true,false,true,false,developPreset.." 39",developPresets,"Apply preset 39 to active photo only. *button*"}, {"Preset_40",false,false,true,false,true,false,developPreset.." 40",developPresets,"Apply preset 40 to active photo only. *button*"}, - {"Preset_1_AllSel",false,false,true,false,true,false,developPreset.." 1 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 1 to all selected photos. *button*"}, - {"Preset_2_AllSel",false,false,true,false,true,false,developPreset.." 2 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 2 to all selected photos. *button*"}, - {"Preset_3_AllSel",false,false,true,false,true,false,developPreset.." 3 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 3 to all selected photos. *button*"}, - {"Preset_4_AllSel",false,false,true,false,true,false,developPreset.." 4 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 4 to all selected photos. *button*"}, - {"Preset_5_AllSel",false,false,true,false,true,false,developPreset.." 5 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 5 to all selected photos. *button*"}, - {"Preset_6_AllSel",false,false,true,false,true,false,developPreset.." 6 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 6 to all selected photos. *button*"}, - {"Preset_7_AllSel",false,false,true,false,true,false,developPreset.." 7 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 7 to all selected photos. *button*"}, - {"Preset_8_AllSel",false,false,true,false,true,false,developPreset.." 8 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 8 to all selected photos. *button*"}, - {"Preset_9_AllSel",false,false,true,false,true,false,developPreset.." 9 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 9 to all selected photos. *button*"}, - {"Preset_10_AllSel",false,false,true,false,true,false,developPreset.." 10 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 10 to all selected photos. *button*"}, - {"Preset_11_AllSel",false,false,true,false,true,false,developPreset.." 11 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 11 to all selected photos. *button*"}, - {"Preset_12_AllSel",false,false,true,false,true,false,developPreset.." 12 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 12 to all selected photos. *button*"}, - {"Preset_13_AllSel",false,false,true,false,true,false,developPreset.." 13 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 13 to all selected photos. *button*"}, - {"Preset_14_AllSel",false,false,true,false,true,false,developPreset.." 14 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 14 to all selected photos. *button*"}, - {"Preset_15_AllSel",false,false,true,false,true,false,developPreset.." 15 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 15 to all selected photos. *button*"}, - {"Preset_16_AllSel",false,false,true,false,true,false,developPreset.." 16 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 16 to all selected photos. *button*"}, - {"Preset_17_AllSel",false,false,true,false,true,false,developPreset.." 17 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 17 to all selected photos. *button*"}, - {"Preset_18_AllSel",false,false,true,false,true,false,developPreset.." 18 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 18 to all selected photos. *button*"}, - {"Preset_19_AllSel",false,false,true,false,true,false,developPreset.." 19 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 19 to all selected photos. *button*"}, - {"Preset_20_AllSel",false,false,true,false,true,false,developPreset.." 20 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 20 to all selected photos. *button*"}, - {"Preset_21_AllSel",false,false,true,false,true,false,developPreset.." 21 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 21 to all selected photos. *button*"}, - {"Preset_22_AllSel",false,false,true,false,true,false,developPreset.." 22 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 22 to all selected photos. *button*"}, - {"Preset_23_AllSel",false,false,true,false,true,false,developPreset.." 23 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 23 to all selected photos. *button*"}, - {"Preset_24_AllSel",false,false,true,false,true,false,developPreset.." 24 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 24 to all selected photos. *button*"}, - {"Preset_25_AllSel",false,false,true,false,true,false,developPreset.." 25 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 25 to all selected photos. *button*"}, - {"Preset_26_AllSel",false,false,true,false,true,false,developPreset.." 26 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 26 to all selected photos. *button*"}, - {"Preset_27_AllSel",false,false,true,false,true,false,developPreset.." 27 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 27 to all selected photos. *button*"}, - {"Preset_28_AllSel",false,false,true,false,true,false,developPreset.." 28 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 28 to all selected photos. *button*"}, - {"Preset_29_AllSel",false,false,true,false,true,false,developPreset.." 29 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 29 to all selected photos. *button*"}, - {"Preset_30_AllSel",false,false,true,false,true,false,developPreset.." 30 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 30 to all selected photos. *button*"}, - {"Preset_31_AllSel",false,false,true,false,true,false,developPreset.." 31 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 31 to all selected photos. *button*"}, - {"Preset_32_AllSel",false,false,true,false,true,false,developPreset.." 32 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 32 to all selected photos. *button*"}, - {"Preset_33_AllSel",false,false,true,false,true,false,developPreset.." 33 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 33 to all selected photos. *button*"}, - {"Preset_34_AllSel",false,false,true,false,true,false,developPreset.." 34 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 34 to all selected photos. *button*"}, - {"Preset_35_AllSel",false,false,true,false,true,false,developPreset.." 35 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 35 to all selected photos. *button*"}, - {"Preset_36_AllSel",false,false,true,false,true,false,developPreset.." 36 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 36 to all selected photos. *button*"}, - {"Preset_37_AllSel",false,false,true,false,true,false,developPreset.." 37 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 37 to all selected photos. *button*"}, - {"Preset_38_AllSel",false,false,true,false,true,false,developPreset.." 38 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 38 to all selected photos. *button*"}, - {"Preset_39_AllSel",false,false,true,false,true,false,developPreset.." 39 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 39 to all selected photos. *button*"}, - {"Preset_40_AllSel",false,false,true,false,true,false,developPreset.." 40 "..LOC("$$$/AgCreations/NewCreationDialog/CreateItemDialog/IncludeSelected=Include selected photos"),developPresets,"Apply preset 40 to all selected photos. *button*"}, --develop: spot and brush {"GraduatedFilter",false,false,true,false,true,false,show..' '..LOC("$$$/AgCameraRawNamedSettings/SaveNamedDialog/GraduatedFilters=Graduated Filters"),localizedAdjustments,"Select Graduated Filter mode in Develop Module. Repeated press toggles Loupe View. *button*"}, {"RadialFilter",false,false,true,false,true,false,show..' '..LOC("$$$/AgCameraRawNamedSettings/SaveNamedDialog/RadialFilters=Radial Filters"),localizedAdjustments,"Select Radial Filter View mode in Develop Module. Repeated press toggles Loupe View. *button*"}, diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/MenuList.lua b/Source/LRPlugin/MIDI2LR.lrplugin/MenuList.lua index c5719ba64..4c03d2bf0 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/MenuList.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/MenuList.lua @@ -463,24 +463,12 @@ "Develop", true }, - { - "PasteSettingsAllSel", - "Paste Settings Include selected photos", - "Develop", - true - }, { "PasteSelectedSettings", "Paste Selected Settings", "Develop", true }, - { - "PasteSelectedSettingsAllSel", - "Paste Selected Settings Include selected photos", - "Develop", - true - }, { "VirtualCopy", "Create Virtual Copy", @@ -2317,246 +2305,6 @@ "Develop Presets", true }, - { - "Preset_1_AllSel", - "Develop Preset 1 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_2_AllSel", - "Develop Preset 2 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_3_AllSel", - "Develop Preset 3 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_4_AllSel", - "Develop Preset 4 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_5_AllSel", - "Develop Preset 5 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_6_AllSel", - "Develop Preset 6 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_7_AllSel", - "Develop Preset 7 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_8_AllSel", - "Develop Preset 8 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_9_AllSel", - "Develop Preset 9 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_10_AllSel", - "Develop Preset 10 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_11_AllSel", - "Develop Preset 11 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_12_AllSel", - "Develop Preset 12 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_13_AllSel", - "Develop Preset 13 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_14_AllSel", - "Develop Preset 14 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_15_AllSel", - "Develop Preset 15 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_16_AllSel", - "Develop Preset 16 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_17_AllSel", - "Develop Preset 17 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_18_AllSel", - "Develop Preset 18 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_19_AllSel", - "Develop Preset 19 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_20_AllSel", - "Develop Preset 20 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_21_AllSel", - "Develop Preset 21 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_22_AllSel", - "Develop Preset 22 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_23_AllSel", - "Develop Preset 23 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_24_AllSel", - "Develop Preset 24 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_25_AllSel", - "Develop Preset 25 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_26_AllSel", - "Develop Preset 26 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_27_AllSel", - "Develop Preset 27 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_28_AllSel", - "Develop Preset 28 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_29_AllSel", - "Develop Preset 29 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_30_AllSel", - "Develop Preset 30 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_31_AllSel", - "Develop Preset 31 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_32_AllSel", - "Develop Preset 32 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_33_AllSel", - "Develop Preset 33 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_34_AllSel", - "Develop Preset 34 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_35_AllSel", - "Develop Preset 35 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_36_AllSel", - "Develop Preset 36 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_37_AllSel", - "Develop Preset 37 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_38_AllSel", - "Develop Preset 38 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_39_AllSel", - "Develop Preset 39 Include selected photos", - "Develop Presets", - true - }, - { - "Preset_40_AllSel", - "Develop Preset 40 Include selected photos", - "Develop Presets", - true - }, { "GraduatedFilter", "Show Graduated Filters", diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/ParamList.lua b/Source/LRPlugin/MIDI2LR.lrplugin/ParamList.lua index 567653e3f..025e028aa 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/ParamList.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/ParamList.lua @@ -925,499 +925,499 @@ local LimitEligible = { Blacks = { "Blacks", - 119 + 117 }, BlueHue = { "Blue Hue Calibration", - 364 + 362 }, BlueSaturation = { "Blue Saturation Calibration", - 365 + 363 }, Brightness = { "Brightness", - 112 + 110 }, Clarity = { "Clarity", - 121 + 119 }, ColorNoiseReduction = { "Color Noise Reduction", - 248 + 246 }, ColorNoiseReductionDetail = { "Color Noise Reduction Detail", - 249 + 247 }, ColorNoiseReductionSmoothness = { "Color Noise Reduction Smoothness", - 250 + 248 }, Contrast = { "Contrast", - 108 + 106 }, CropAngle = { "Crop Angle", - 505 + 463 }, CropBottom = { "Crop - Bottom", - 506 + 464 }, CropLeft = { "Crop - Left", - 507 + 465 }, CropRight = { "Crop - Right", - 508 + 466 }, CropTop = { "Crop - Top", - 509 + 467 }, DefringeGreenAmount = { "Defringe Green Amount", - 284 + 282 }, DefringeGreenHueHi = { "Defringe Green Hue - High", - 286 + 284 }, DefringeGreenHueLo = { "Defringe Green Hue - Low", - 285 + 283 }, DefringePurpleAmount = { "Defringe Purple Amount", - 281 + 279 }, DefringePurpleHueHi = { "Defringe Purple Hue - High", - 283 + 281 }, DefringePurpleHueLo = { "Defringe Purple Hue - Low", - 282 + 280 }, Dehaze = { "Dehaze Amount", - 315 + 313 }, Exposure = { "Exposure", - 106 + 104 }, GrainAmount = { "Grain Amount", - 322 + 320 }, GrainFrequency = { "Grain Roughness", - 324 + 322 }, GrainSize = { "Grain Size", - 323 + 321 }, GrayMixerAqua = { "Gray Mixer Aqua", - 191 + 189 }, GrayMixerBlue = { "Gray Mixer Blue", - 192 + 190 }, GrayMixerGreen = { "Gray Mixer Green", - 190 + 188 }, GrayMixerMagenta = { "Gray Mixer Magenta", - 194 + 192 }, GrayMixerOrange = { "Gray Mixer Orange", - 188 + 186 }, GrayMixerPurple = { "Gray Mixer Purple", - 193 + 191 }, GrayMixerRed = { "Gray Mixer Red", - 187 + 185 }, GrayMixerYellow = { "Gray Mixer Yellow", - 189 + 187 }, GreenHue = { "Green Hue Calibration", - 362 + 360 }, GreenSaturation = { "Green Saturation Calibration", - 363 + 361 }, Highlights = { "Highlights (Highlight Recovery in PV2003 and PV2010)", - 111 + 109 }, HueAdjustmentAqua = { "Hue Adjustment Aqua", - 173 + 171 }, HueAdjustmentBlue = { "Hue Adjustment Blue", - 174 + 172 }, HueAdjustmentGreen = { "Hue Adjustment Green", - 172 + 170 }, HueAdjustmentMagenta = { "Hue Adjustment Magenta", - 176 + 174 }, HueAdjustmentOrange = { "Hue Adjustment Orange", - 170 + 168 }, HueAdjustmentPurple = { "Hue Adjustment Purple", - 175 + 173 }, HueAdjustmentRed = { "Hue Adjustment Red", - 169 + 167 }, HueAdjustmentYellow = { "Hue Adjustment Yellow", - 171 + 169 }, LensManualDistortionAmount = { "Lens Manual Distortion Amount", - 293 + 291 }, LensProfileChromaticAberrationScale = { "Lens Profile Chromatic Aberration Scale", - 276 + 274 }, LensProfileDistortionScale = { "Lens Profile Distortion Scale", - 275 + 273 }, LensProfileVignettingScale = { "Lens Profile Vignetting Scale", - 277 + 275 }, LuminanceAdjustmentAqua = { "Luminance Adjustment Aqua", - 181 + 179 }, LuminanceAdjustmentBlue = { "Luminance Adjustment Blue", - 182 + 180 }, LuminanceAdjustmentGreen = { "Luminance Adjustment Green", - 180 + 178 }, LuminanceAdjustmentMagenta = { "Luminance Adjustment Magenta", - 184 + 182 }, LuminanceAdjustmentOrange = { "Luminance Adjustment Orange", - 178 + 176 }, LuminanceAdjustmentPurple = { "Luminance Adjustment Purple", - 183 + 181 }, LuminanceAdjustmentRed = { "Luminance Adjustment Red", - 177 + 175 }, LuminanceAdjustmentYellow = { "Luminance Adjustment Yellow", - 179 + 177 }, LuminanceNoiseReductionContrast = { "Luminance Contrast", - 247 + 245 }, LuminanceNoiseReductionDetail = { "Luminance Detail", - 246 + 244 }, LuminanceSmoothing = { "Luminance Smoothing", - 245 + 243 }, ParametricDarks = { "Dark Tones", - 145 + 143 }, ParametricHighlightSplit = { "Highlight Split", - 151 + 149 }, ParametricHighlights = { "Highlight Tones", - 148 + 146 }, ParametricLights = { "Light Tones", - 146 + 144 }, ParametricMidtoneSplit = { "Midtone Split", - 150 + 148 }, ParametricShadowSplit = { "Shadow Split", - 149 + 147 }, ParametricShadows = { "Shadow Tones", - 147 + 145 }, PerspectiveAspect = { "Perspective Aspect", - 298 + 296 }, PerspectiveHorizontal = { "Perspective Horizontal", - 295 + 293 }, PerspectiveRotate = { "Perspective Rotate", - 296 + 294 }, PerspectiveScale = { "Perspective Scale", - 297 + 295 }, PerspectiveVertical = { "Perspective Vertical", - 294 + 292 }, ["PerspectiveX "] = { "Perspective X", - 299 + 297 }, ["PerspectiveY "] = { "Perspective Y", - 300 + 298 }, PostCropVignetteAmount = { "Post Crop Vignette Amount", - 316 + 314 }, PostCropVignetteFeather = { "Post Crop Vignette Feather", - 318 + 316 }, PostCropVignetteHighlightContrast = { "Post Crop Vignette Highlight Contrast", - 321 + 319 }, PostCropVignetteMidpoint = { "Post Crop Vignette Midpoint", - 317 + 315 }, PostCropVignetteRoundness = { "Post Crop Vignette Roundness", - 319 + 317 }, PostCropVignetteStyle = { "Post Crop Vignette Style", - 320 + 318 }, RedHue = { "Red Hue Calibration", - 360 + 358 }, RedSaturation = { "Red Saturation Calibration", - 361 + 359 }, Saturation = { "Saturation", - 124 + 122 }, SaturationAdjustmentAqua = { "Saturation Adjustment Aqua", - 165 + 163 }, SaturationAdjustmentBlue = { "Saturation Adjustment Blue", - 166 + 164 }, SaturationAdjustmentGreen = { "Saturation Adjustment Green", - 164 + 162 }, SaturationAdjustmentMagenta = { "Saturation Adjustment Magenta", - 168 + 166 }, SaturationAdjustmentOrange = { "Saturation Adjustment Orange", - 162 + 160 }, SaturationAdjustmentPurple = { "Saturation Adjustment Purple", - 167 + 165 }, SaturationAdjustmentRed = { "Saturation Adjustment Red", - 161 + 159 }, SaturationAdjustmentYellow = { "Saturation Adjustment Yellow", - 163 + 161 }, ShadowTint = { "Shadow Tint Calibration", - 359 + 357 }, Shadows = { "Shadows (Fill Light in PV2003 and PV2010)", - 114 + 112 }, SharpenDetail = { "Sharpen Detail", - 243 + 241 }, SharpenEdgeMasking = { "Sharpen Edge Masking", - 244 + 242 }, SharpenRadius = { "Sharpen Radius", - 242 + 240 }, Sharpness = { "Sharpness", - 241 + 239 }, SplitToningBalance = { "Split Toning Balance", - 233 + 231 }, SplitToningHighlightHue = { "Highlight Hue", - 231 + 229 }, SplitToningHighlightSaturation = { "Highlight Saturation", - 232 + 230 }, SplitToningShadowHue = { "Shadow Hue", - 229 + 227 }, SplitToningShadowSaturation = { "Shadow Saturation", - 230 + 228 }, Temperature = { "Temperature", - 104 + 102 }, Tint = { "Tint", - 105 + 103 }, Vibrance = { "Vibrance", - 123 + 121 }, VignetteAmount = { "Vignette Amount", - 301 + 299 }, VignetteMidpoint = { "Vignette Midpoint", - 302 + 300 }, Whites = { "Whites (no effect in PV2003 and PV2010)", - 117 + 115 }, local_Blacks2012 = { "Local Adjustments Blacks (PV2012)", - 466 + 424 }, local_Clarity = { "Local Adjustments Clarity (PV2010 and PV2012)", - 467 + 425 }, local_Contrast = { "Local Adjustments Contrast (PV2010 and PV2012)", - 462 + 420 }, local_Defringe = { "Local Adjustments Defringe (PV2012)", - 473 + 431 }, local_Dehaze = { "Local Adjustments Dehaze (PV2012)", - 468 + 426 }, local_Exposure = { "Local Adjustments Exposure (PV2010 and PV2012)", - 461 + 419 }, local_Highlights = { "Local Adjustments Highlights (PV2012)", - 463 + 421 }, local_LuminanceNoise = { "Local Adjustments Luminence Noise Reduction (PV2012)", - 471 + 429 }, local_Moire = { "Local Adjustments Moire (PV2012)", - 472 + 430 }, local_Saturation = { "Local Adjustments Saturation (PV2010 and PV2012)", - 469 + 427 }, local_Shadows = { "Local Adjustments Shadows (PV2012)", - 464 + 422 }, local_Sharpness = { "Local Adjustments Sharpness (PV2010 and PV2012)", - 470 + 428 }, local_Temperature = { "Local Adjustments Temp. (PV2012)", - 459 + 417 }, local_Tint = { "Local Adjustments Tint (PV2012)", - 460 + 418 }, local_ToningLuminance = { "Local Toning Luminance (PV2010)", - 474 + 432 }, local_Whites2012 = { "Local Adjustments Whites (PV2012)", - 465 + 423 }, straightenAngle = { "Straighten Angle", - 504 + 462 } } local SendToMidi = { From 9eebcc5fbe32267a43c4220ca672f6d196582a12 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sat, 16 Jul 2016 14:25:07 -0700 Subject: [PATCH 12/33] change shutdown signalling to flag, kill OSX app at close --- Source/LRPlugin/MIDI2LR.lrplugin/Client.lua | 17 +++++------------ Source/LRPlugin/MIDI2LR.lrplugin/ShutDown.lua | 8 +++----- .../MIDI2LR.lrplugin/ShutDownPlugin.lua | 3 +-- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua b/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua index cf74b7fff..23668d906 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua @@ -22,10 +22,6 @@ MIDI2LR. If not, see . local LrMobdebug = import 'LrMobdebug' LrMobdebug.start() --]]-----------end debug section --- signal for halt plugin if reloaded--LR doesn't kill main loop otherwise -math.randomseed(os.time()) -currentLoadVersion = rawget (_G, 'currentLoadVersion') or math.random() -currentLoadVersion = currentLoadVersion + 1 + math.random() local LrTasks = import 'LrTasks' -- Main task @@ -87,7 +83,7 @@ LrTasks.startAsyncTask( local LrStringUtils = import 'LrStringUtils' local LrUndo = import 'LrUndo' --global variables - MIDI2LR = {PARAM_OBSERVER = {}, SERVER = {}} --non-local but in MIDI2LR namespace + MIDI2LR = {PARAM_OBSERVER = {}, SERVER = {}, RUNNING = true} --non-local but in MIDI2LR namespace --local variables local LastParam = '' local UpdateParamPickup, UpdateParamNoPickup, UpdateParam @@ -497,17 +493,13 @@ LrTasks.startAsyncTask( LrShell.openFilesInApp({LrPathUtils.child(_PLUGIN.path, 'Info.lua')}, LrPathUtils.child(_PLUGIN.path, 'MIDI2LR.app')) end - math.randomseed(os.time()) - currentLoadVersion = math.random() --in case currentLoadVersion gets initialized to 0 each load - local loadVersion = currentLoadVersion - -- add an observer for develop param changes--needs to occur in develop module -- will drop out of loop if loadversion changes or if in develop module with selected photo - while (loadVersion == currentLoadVersion) and ((LrApplicationView.getCurrentModuleName() ~= 'develop') or (LrApplication.activeCatalog():getTargetPhoto() == nil)) do + while MIDI2LR.RUNNING and ((LrApplicationView.getCurrentModuleName() ~= 'develop') or (LrApplication.activeCatalog():getTargetPhoto() == nil)) do LrTasks.sleep ( .29 ) guardsetting:performWithGuard(Profiles.checkProfile) end --sleep away until ended or until develop module activated - if loadVersion == currentLoadVersion then --didn't drop out of loop because of program termination + if MIDI2LR.RUNNING then --didn't drop out of loop because of program termination LrDevelopController.revealAdjustedControls( true ) -- reveal affected parameter in panel track if ProgramPreferences.TrackingDelay ~= nil then LrDevelopController.setTrackingDelay(ProgramPreferences.TrackingDelay) @@ -519,11 +511,12 @@ LrTasks.startAsyncTask( guardreading:performWithGuard(CurrentObserver,observer) end ) - while (loadVersion == currentLoadVersion) do --detect halt or reload + while MIDI2LR.RUNNING do --detect halt or reload LrTasks.sleep( .29 ) guardsetting:performWithGuard(Profiles.checkProfile) end end + MIDI2LR.SERVER:send('TerminateApplication 1\n') client:close() MIDI2LR.SERVER:close() end diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/ShutDown.lua b/Source/LRPlugin/MIDI2LR.lrplugin/ShutDown.lua index f572724eb..6ac039125 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/ShutDown.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/ShutDown.lua @@ -22,20 +22,18 @@ return { local LrPathUtils = import 'LrPathUtils' local LrShell = import 'LrShell' local LrTasks = import 'LrTasks' + + MIDI2LR.RUNNING = false progressFunction (0, LOC("$$$/AgPluginManager/Status/HttpServer/StopServer=Stopping Server")) LrTasks.startAsyncTask(function() if(WIN_ENV) then LrShell.openFilesInApp({'--LRSHUTDOWN'}, LrPathUtils.child(_PLUGIN.path, 'MIDI2LR.exe')) else - LrShell.openFilesInApp({'--LRSHUTDOWN'}, LrPathUtils.child(_PLUGIN.path, 'MIDI2LR.app')) + LrTasks.execute('kill `pgrep MIDI2LR`') -- extreme, but maybe it'll work until I can close it more gracefully end end ) - --- math.randomseed(os.time()) --- currentLoadVersion = rawget (_G, 'currentLoadVersion') or math.random() --- currentLoadVersion = currentLoadVersion + 1 + math.random() --signal halt to main background function progressFunction (1, LOC("$$$/AgPluginManager/Status/HttpServer/StopServer=Stopping Server")) doneFunction() end diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/ShutDownPlugin.lua b/Source/LRPlugin/MIDI2LR.lrplugin/ShutDownPlugin.lua index 867809cfd..2691454af 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/ShutDownPlugin.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/ShutDownPlugin.lua @@ -20,5 +20,4 @@ MIDI2LR. If not, see . MIDI2LR.SERVER:send('TerminateApplication 1\n') MIDI2LR.SERVER:close() - -currentLoadVersion = currentLoadVersion + 1 --signal halt to main background function \ No newline at end of file +MIDI2LR.RUNNING = false \ No newline at end of file From ccd1b5f2cadc24074495c866b436e361f5336102 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Sat, 16 Jul 2016 17:25:44 -0700 Subject: [PATCH 13/33] Fix errors: can't send through SERVER during shutdown, parallelize client and server termination. --- Source/LRPlugin/MIDI2LR.lrplugin/Client.lua | 1 - Source/LRPlugin/MIDI2LR.lrplugin/ShutDown.lua | 9 +++++++-- Source/LRPlugin/MIDI2LR.lrplugin/ShutDownPlugin.lua | 1 - 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua b/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua index 23668d906..f1867fdda 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/Client.lua @@ -516,7 +516,6 @@ LrTasks.startAsyncTask( guardsetting:performWithGuard(Profiles.checkProfile) end end - MIDI2LR.SERVER:send('TerminateApplication 1\n') client:close() MIDI2LR.SERVER:close() end diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/ShutDown.lua b/Source/LRPlugin/MIDI2LR.lrplugin/ShutDown.lua index 6ac039125..ad352c825 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/ShutDown.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/ShutDown.lua @@ -22,10 +22,14 @@ return { local LrPathUtils = import 'LrPathUtils' local LrShell = import 'LrShell' local LrTasks = import 'LrTasks' - - MIDI2LR.RUNNING = false + + progressFunction (0, LOC("$$$/AgPluginManager/Status/HttpServer/StopServer=Stopping Server")) + LrTasks.startAsyncTask(function() + MIDI2LR.RUNNING = false + end + ) LrTasks.startAsyncTask(function() if(WIN_ENV) then LrShell.openFilesInApp({'--LRSHUTDOWN'}, LrPathUtils.child(_PLUGIN.path, 'MIDI2LR.exe')) @@ -34,6 +38,7 @@ return { end end ) + progressFunction (1, LOC("$$$/AgPluginManager/Status/HttpServer/StopServer=Stopping Server")) doneFunction() end diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/ShutDownPlugin.lua b/Source/LRPlugin/MIDI2LR.lrplugin/ShutDownPlugin.lua index 2691454af..752fec773 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/ShutDownPlugin.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/ShutDownPlugin.lua @@ -18,6 +18,5 @@ MIDI2LR. If not, see . ------------------------------------------------------------------------------]] -MIDI2LR.SERVER:send('TerminateApplication 1\n') MIDI2LR.SERVER:close() MIDI2LR.RUNNING = false \ No newline at end of file From 46853df4eebb782e6dc56c18c8cea3968e4613d3 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Sat, 16 Jul 2016 17:48:16 -0700 Subject: [PATCH 14/33] Translate "Key" --- Source/LRPlugin/MIDI2LR.lrplugin/Database.lua | 81 ++++++++++--------- .../MIDI2LR.lrplugin/TranslatedStrings_de.txt | 1 + .../MIDI2LR.lrplugin/TranslatedStrings_en.txt | 1 + .../MIDI2LR.lrplugin/TranslatedStrings_es.txt | 1 + .../MIDI2LR.lrplugin/TranslatedStrings_fr.txt | 1 + .../MIDI2LR.lrplugin/TranslatedStrings_it.txt | 1 + .../MIDI2LR.lrplugin/TranslatedStrings_ja.txt | 1 + .../MIDI2LR.lrplugin/TranslatedStrings_ko.txt | 1 + .../MIDI2LR.lrplugin/TranslatedStrings_nl.txt | 1 + .../MIDI2LR.lrplugin/TranslatedStrings_pt.txt | 1 + .../MIDI2LR.lrplugin/TranslatedStrings_sv.txt | 1 + .../TranslatedStrings_zn_cn.txt | 1 + .../TranslatedStrings_zn_tw.txt | 1 + 13 files changed, 53 insertions(+), 40 deletions(-) diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua b/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua index 8e2d95c3e..9847ccc65 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua @@ -51,6 +51,7 @@ local whiteBalance = LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/W local coarse = LOC("$$$/AgPrint/CalibrationDialog/Coarse=Coarse") local fine = LOC("$$$/AgPrint/CalibrationDialog/Fine=Fine") +local key = LOC("$$$/MIDI2LR/Shortcuts/Key=Key") --[[---------------------------------------------------------------------------- @@ -95,46 +96,46 @@ To do: integrate "straightenAngle", translate RetouchInfo orientation local DataBase = { --Keyboard shortcuts - {'Key1',false,false,true,false,true,false,'Key 1',keyshortcuts,'Key 1. *button*'}, - {'Key2',false,false,true,false,true,false,'Key 2',keyshortcuts,'Key 2. *button*'}, - {'Key3',false,false,true,false,true,false,'Key 3',keyshortcuts,'Key 3. *button*'}, - {'Key4',false,false,true,false,true,false,'Key 4',keyshortcuts,'Key 4. *button*'}, - {'Key5',false,false,true,false,true,false,'Key 5',keyshortcuts,'Key 5. *button*'}, - {'Key6',false,false,true,false,true,false,'Key 6',keyshortcuts,'Key 6. *button*'}, - {'Key7',false,false,true,false,true,false,'Key 7',keyshortcuts,'Key 7. *button*'}, - {'Key8',false,false,true,false,true,false,'Key 8',keyshortcuts,'Key 8. *button*'}, - {'Key9',false,false,true,false,true,false,'Key 9',keyshortcuts,'Key 9. *button*'}, - {'Key10',false,false,true,false,true,false,'Key 10',keyshortcuts,'Key 10. *button*'}, - {'Key11',false,false,true,false,true,false,'Key 11',keyshortcuts,'Key 11. *button*'}, - {'Key12',false,false,true,false,true,false,'Key 12',keyshortcuts,'Key 12. *button*'}, - {'Key13',false,false,true,false,true,false,'Key 13',keyshortcuts,'Key 13. *button*'}, - {'Key14',false,false,true,false,true,false,'Key 14',keyshortcuts,'Key 14. *button*'}, - {'Key15',false,false,true,false,true,false,'Key 15',keyshortcuts,'Key 15. *button*'}, - {'Key16',false,false,true,false,true,false,'Key 16',keyshortcuts,'Key 16. *button*'}, - {'Key17',false,false,true,false,true,false,'Key 17',keyshortcuts,'Key 17. *button*'}, - {'Key18',false,false,true,false,true,false,'Key 18',keyshortcuts,'Key 18. *button*'}, - {'Key19',false,false,true,false,true,false,'Key 19',keyshortcuts,'Key 19. *button*'}, - {'Key20',false,false,true,false,true,false,'Key 20',keyshortcuts,'Key 20. *button*'}, - {'Key21',false,false,true,false,true,false,'Key 21',keyshortcuts,'Key 21. *button*'}, - {'Key22',false,false,true,false,true,false,'Key 22',keyshortcuts,'Key 22. *button*'}, - {'Key23',false,false,true,false,true,false,'Key 23',keyshortcuts,'Key 23. *button*'}, - {'Key24',false,false,true,false,true,false,'Key 24',keyshortcuts,'Key 24. *button*'}, - {'Key25',false,false,true,false,true,false,'Key 25',keyshortcuts,'Key 25. *button*'}, - {'Key26',false,false,true,false,true,false,'Key 26',keyshortcuts,'Key 26. *button*'}, - {'Key27',false,false,true,false,true,false,'Key 27',keyshortcuts,'Key 27. *button*'}, - {'Key28',false,false,true,false,true,false,'Key 28',keyshortcuts,'Key 28. *button*'}, - {'Key29',false,false,true,false,true,false,'Key 29',keyshortcuts,'Key 29. *button*'}, - {'Key30',false,false,true,false,true,false,'Key 30',keyshortcuts,'Key 30. *button*'}, - {'Key31',false,false,true,false,true,false,'Key 31',keyshortcuts,'Key 31. *button*'}, - {'Key32',false,false,true,false,true,false,'Key 32',keyshortcuts,'Key 32. *button*'}, - {'Key33',false,false,true,false,true,false,'Key 33',keyshortcuts,'Key 33. *button*'}, - {'Key34',false,false,true,false,true,false,'Key 34',keyshortcuts,'Key 34. *button*'}, - {'Key35',false,false,true,false,true,false,'Key 35',keyshortcuts,'Key 35. *button*'}, - {'Key36',false,false,true,false,true,false,'Key 36',keyshortcuts,'Key 36. *button*'}, - {'Key37',false,false,true,false,true,false,'Key 37',keyshortcuts,'Key 37. *button*'}, - {'Key38',false,false,true,false,true,false,'Key 38',keyshortcuts,'Key 38. *button*'}, - {'Key39',false,false,true,false,true,false,'Key 39',keyshortcuts,'Key 39. *button*'}, - {'Key40',false,false,true,false,true,false,'Key 40',keyshortcuts,'Key 40. *button*'}, + {'Key1',false,false,true,false,true,false,key..' 1',keyshortcuts,'Key 1. *button*'}, + {'Key2',false,false,true,false,true,false,key..' 2',keyshortcuts,'Key 2. *button*'}, + {'Key3',false,false,true,false,true,false,key..' 3',keyshortcuts,'Key 3. *button*'}, + {'Key4',false,false,true,false,true,false,key..' 4',keyshortcuts,'Key 4. *button*'}, + {'Key5',false,false,true,false,true,false,key..' 5',keyshortcuts,'Key 5. *button*'}, + {'Key6',false,false,true,false,true,false,key..' 6',keyshortcuts,'Key 6. *button*'}, + {'Key7',false,false,true,false,true,false,key..' 7',keyshortcuts,'Key 7. *button*'}, + {'Key8',false,false,true,false,true,false,key..' 8',keyshortcuts,'Key 8. *button*'}, + {'Key9',false,false,true,false,true,false,key..' 9',keyshortcuts,'Key 9. *button*'}, + {'Key10',false,false,true,false,true,false,key..' 10',keyshortcuts,'Key 10. *button*'}, + {'Key11',false,false,true,false,true,false,key..' 11',keyshortcuts,'Key 11. *button*'}, + {'Key12',false,false,true,false,true,false,key..' 12',keyshortcuts,'Key 12. *button*'}, + {'Key13',false,false,true,false,true,false,key..' 13',keyshortcuts,'Key 13. *button*'}, + {'Key14',false,false,true,false,true,false,key..' 14',keyshortcuts,'Key 14. *button*'}, + {'Key15',false,false,true,false,true,false,key..' 15',keyshortcuts,'Key 15. *button*'}, + {'Key16',false,false,true,false,true,false,key..' 16',keyshortcuts,'Key 16. *button*'}, + {'Key17',false,false,true,false,true,false,key..' 17',keyshortcuts,'Key 17. *button*'}, + {'Key18',false,false,true,false,true,false,key..' 18',keyshortcuts,'Key 18. *button*'}, + {'Key19',false,false,true,false,true,false,key..' 19',keyshortcuts,'Key 19. *button*'}, + {'Key20',false,false,true,false,true,false,key..' 20',keyshortcuts,'Key 20. *button*'}, + {'Key21',false,false,true,false,true,false,key..' 21',keyshortcuts,'Key 21. *button*'}, + {'Key22',false,false,true,false,true,false,key..' 22',keyshortcuts,'Key 22. *button*'}, + {'Key23',false,false,true,false,true,false,key..' 23',keyshortcuts,'Key 23. *button*'}, + {'Key24',false,false,true,false,true,false,key..' 24',keyshortcuts,'Key 24. *button*'}, + {'Key25',false,false,true,false,true,false,key..' 25',keyshortcuts,'Key 25. *button*'}, + {'Key26',false,false,true,false,true,false,key..' 26',keyshortcuts,'Key 26. *button*'}, + {'Key27',false,false,true,false,true,false,key..' 27',keyshortcuts,'Key 27. *button*'}, + {'Key28',false,false,true,false,true,false,key..' 28',keyshortcuts,'Key 28. *button*'}, + {'Key29',false,false,true,false,true,false,key..' 29',keyshortcuts,'Key 29. *button*'}, + {'Key30',false,false,true,false,true,false,key..' 30',keyshortcuts,'Key 30. *button*'}, + {'Key31',false,false,true,false,true,false,key..' 31',keyshortcuts,'Key 31. *button*'}, + {'Key32',false,false,true,false,true,false,key..' 32',keyshortcuts,'Key 32. *button*'}, + {'Key33',false,false,true,false,true,false,key..' 33',keyshortcuts,'Key 33. *button*'}, + {'Key34',false,false,true,false,true,false,key..' 34',keyshortcuts,'Key 34. *button*'}, + {'Key35',false,false,true,false,true,false,key..' 35',keyshortcuts,'Key 35. *button*'}, + {'Key36',false,false,true,false,true,false,key..' 36',keyshortcuts,'Key 36. *button*'}, + {'Key37',false,false,true,false,true,false,key..' 37',keyshortcuts,'Key 37. *button*'}, + {'Key38',false,false,true,false,true,false,key..' 38',keyshortcuts,'Key 38. *button*'}, + {'Key39',false,false,true,false,true,false,key..' 39',keyshortcuts,'Key 39. *button*'}, + {'Key40',false,false,true,false,true,false,key..' 40',keyshortcuts,'Key 40. *button*'}, --General Workspace --workspace: grid view options {"ShoVwgrid",false,false,true,false,true,false,primaryDisplay..' '..LOC("$$$/AgPhotoBin/ViewMode/Library/Grid=Grid"),general,"Displays photos as thumbnails in cells, which can be viewed in compact and expanded sizes. *button*"}, diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_de.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_de.txt index 87df7f8ca..9e9466645 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_de.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_de.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=Verwendung: einen MIDI-Controller verbinden, MIDI2LR starten, und mit der Bearbeitung beginnen! Für Details siehe https://github.com/rsjaffe/MIDI2LR/wiki" "$$$/MIDI2LR/Preferences/cantload=Einstellungen konnten nicht geladen werden. Verwende Standard-Einstellungen." "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=Taste" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_en.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_en.txt index 8240f30c7..f69dd3895 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_en.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_en.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=How to use: connect a MIDI controller, launch MIDI2LR, and begin editing! See https://github.com/rsjaffe/MIDI2LR/wiki for details." "$$$/MIDI2LR/Preferences/cantload=Unable to load preferences. Using default settings." "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=Key" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_es.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_es.txt index 108adab71..67ab8e0fb 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_es.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_es.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=Modo de empleo: conectar un controlador MIDI, lanzar MIDI2LR, y comenzar a editar! Ver https://github.com/rsjaffe/MIDI2LR/wiki para más detalles." "$$$/MIDI2LR/Preferences/cantload=No se puede cargar preferencias. Utilizando la configuración predeterminada." "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=Tecla" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_fr.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_fr.txt index e29dca919..e514a55ed 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_fr.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_fr.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=Comment utiliser: connecter au contrôleur MIDI, lancer MIDI2LR, et commencer l’édition! Voir https://github.com/rsjaffe/MIDI2LR/wiki pour plus de détails." "$$$/MIDI2LR/Preferences/cantload=Unable to load preferences. Using default settings." "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=Touche" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_it.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_it.txt index 43b3320ef..33651b8f0 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_it.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_it.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=Modo d'uso: collegare un controller MIDI, avviare MIDI2LR, e iniziare la modifica! Vedere https://github.com/rsjaffe/MIDI2LR/wiki per i dettagli." "$$$/MIDI2LR/Preferences/cantload=Impossibile caricare le preferenze. Utilizzo delle impostazioni predefinite." "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=Tasto" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_ja.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_ja.txt index 6fcd8f3ef..7721705d9 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_ja.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_ja.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=使用方法:MIDIコントローラを接続し、MIDI2LRを起動し、編集を開始!詳細については、https://github.com/rsjaffe/MIDI2LR/wikiを参照してください。" "$$$/MIDI2LR/Preferences/cantload=環境設定を読み込むことができません。デフォルト設定を使用して。" "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=キー" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_ko.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_ko.txt index 5e6827963..44f213485 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_ko.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_ko.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=사용 방법 : MIDI 컨트롤러를 연결 MIDI2LR를 시작하고, 편집을 시작! 자세한 내용은 https://github.com/rsjaffe/MIDI2LR/wiki를 참조하십시오." "$$$/MIDI2LR/Preferences/cantload=기본 설정을로드 할 수 없습니다. 기본 설정을 사용." "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=키" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_nl.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_nl.txt index 0612e753b..a1e6baffa 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_nl.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_nl.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=Hoe gebruik je; Sluit een MIDI controller aan, start MIDI2LR, en begin met bewerken! Zie https://github.com/rsjaffe/MIDI2LR/wiki voor meer gegevens." "$$$/MIDI2LR/Preferences/cantload=Het is niet mogelijk om de voorkeursinstellingen te laden. De standaard instellingen wordt gebruikt." "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=Toets" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_pt.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_pt.txt index abe9c04d5..577406a1d 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_pt.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_pt.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=Como usar: conectar um controlador MIDI, lançar MIDI2LR, e começar a editar! Veja https://github.com/rsjaffe/MIDI2LR/wiki para mais detalhes." "$$$/MIDI2LR/Preferences/cantload=Não é possível carregar preferências. Usando as configurações padrão." "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=Tecla" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_sv.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_sv.txt index 97c57cdca..c4d6136c8 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_sv.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_sv.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=Hur man använder: ansluta en MIDI-controller, starta MIDI2LR, och börja redigera! Se https://github.com/rsjaffe/MIDI2LR/wiki för mer information." "$$$/MIDI2LR/Preferences/cantload=Det går inte att läsa in inställningarna. Med standardinställningar ." "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=Nyckel" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_zn_cn.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_zn_cn.txt index 5af4e8e3f..777e4579b 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_zn_cn.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_zn_cn.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=使用方法:连接MIDI控制器,启动MIDI2LR,并开始编辑!见https://github.com/rsjaffe/MIDI2LR/wiki了解详情。" "$$$/MIDI2LR/Preferences/cantload=无法加载偏好。使用默认设置。" "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=鍵" diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_zn_tw.txt b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_zn_tw.txt index 119045b78..7c267870a 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_zn_tw.txt +++ b/Source/LRPlugin/MIDI2LR.lrplugin/TranslatedStrings_zn_tw.txt @@ -4,6 +4,7 @@ "$$$/MIDI2LR/About/about=使用方法:連接MIDI控制器,啟動MIDI2LR,並開始編輯!見https://github.com/rsjaffe/MIDI2LR/wiki了解詳情。" "$$$/MIDI2LR/Preferences/cantload=無法加載偏好。使用默認設置。" "$$$/MIDI2LR/Options/TrackingDelay=Tracking Delay" +"$$$/MIDI2LR/Shortcuts/Key=键" From 06a89522f0a55ca67c01ac34dbb513cd5c3f90ae Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sat, 16 Jul 2016 20:05:06 -0700 Subject: [PATCH 15/33] Utilities: checks for photo selected if needed by function --- Source/LRPlugin/MIDI2LR.lrplugin/Utilities.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/Utilities.lua b/Source/LRPlugin/MIDI2LR.lrplugin/Utilities.lua index 6176d2bb9..6e4761e72 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/Utilities.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/Utilities.lua @@ -27,6 +27,7 @@ MIDI2LR. If not, see . --viewing this file. --imports +local LrApplication = import 'LrApplication' local LrApplicationView = import 'LrApplicationView' local LrDevelopController = import 'LrDevelopController' @@ -86,6 +87,7 @@ local function wrapFOM(F,...) end end return function() + if needsModule[F]['photoSelected'] and LrApplication.activeCatalog():getTargetPhoto() == nil then return end if LrApplicationView.getCurrentModuleName() ~= openModule then LrApplicationView.switchToModule(openModule) end @@ -111,6 +113,7 @@ local function wrapFCM(F,...) end end return function() + if needsModule[F]['photoSelected'] and LrApplication.activeCatalog():getTargetPhoto() == nil then return end local currentMod = LrApplicationView.getCurrentModuleName() if currentMod ~= openModule then LrApplicationView.switchToModule(openModule) @@ -140,6 +143,7 @@ local function wrapFIM(F,Rnil,...) end end return function () + if needsModule[F]['photoSelected'] and LrApplication.activeCatalog():getTargetPhoto() == nil then return Rnil end if LrApplicationView.getCurrentModuleName() ~= openModule then return Rnil end @@ -162,6 +166,7 @@ local function execFOM(F,...) if openModule == nil then return F(...) --proper tail call end + if needsModule[F]['photoSelected'] and LrApplication.activeCatalog():getTargetPhoto() == nil then return end if LrApplicationView.getCurrentModuleName() ~= openModule then LrApplicationView.switchToModule(openModule) end @@ -183,6 +188,7 @@ local function execFCM(F,...) if openModule == nil then return F(...) --proper tail call end + if needsModule[F]['photoSelected'] and LrApplication.activeCatalog():getTargetPhoto() == nil then return end local retval local currentMod = LrApplicationView.getCurrentModuleName() if currentMod ~= openModule then @@ -206,6 +212,7 @@ end -- @treturn function Function closure. -------------------------------------------------------------------------------- local function execFIM(F,Rnil,...) + if needsModule[F]['photoSelected'] and LrApplication.activeCatalog():getTargetPhoto() == nil then return Rnil end local openModule = needsModule[F]['module'] if openModule == nil or openModule == LrApplicationView.getCurrentModuleName() then return F(...) --proper tail call From 469184951d2a0834c0534311c5a75266c3f3b47e Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sat, 16 Jul 2016 20:46:14 -0700 Subject: [PATCH 16/33] use explicit namespaces --- Source/LR_IPC_In.cpp | 43 +++++++++++++++++++++---------------------- Source/LR_IPC_In.h | 9 +++++---- Source/LR_IPC_Out.cpp | 33 +++++++++++++++++---------------- Source/LR_IPC_Out.h | 15 ++++++++------- Source/Main.cpp | 24 ++++++++++++++---------- 5 files changed, 65 insertions(+), 59 deletions(-) diff --git a/Source/LR_IPC_In.cpp b/Source/LR_IPC_In.cpp index 9961b4853..0f1309b29 100644 --- a/Source/LR_IPC_In.cpp +++ b/Source/LR_IPC_In.cpp @@ -32,12 +32,12 @@ namespace { constexpr auto kReadyWait = 0; } -LR_IPC_IN::LR_IPC_IN(): StreamingSocket{}, Thread{"LR_IPC_IN"} {} +LR_IPC_IN::LR_IPC_IN(): juce::StreamingSocket{}, juce::Thread{"LR_IPC_IN"} {} LR_IPC_IN::~LR_IPC_IN() { - stopTimer(); - stopThread(1000); - close(); + juce::Timer::stopTimer(); + juce::Thread::stopThread(1000); + juce::StreamingSocket::close(); } void LR_IPC_IN::Init(std::shared_ptr& map_command, @@ -47,7 +47,7 @@ void LR_IPC_IN::Init(std::shared_ptr& map_command, profile_manager_ = profile_manager; midi_sender_ = midi_sender; //start the timer - startTimer(1000); + juce::Timer::startTimer(1000); } void LR_IPC_IN::refreshMIDIOutput() { @@ -65,42 +65,41 @@ void LR_IPC_IN::refreshMIDIOutput() { } void LR_IPC_IN::PleaseStopThread() { - signalThreadShouldExit(); - notify(); + juce::Thread::signalThreadShouldExit(); + juce::Thread::notify(); } void LR_IPC_IN::run() { - while (!threadShouldExit()) { + while (!juce::Thread::threadShouldExit()) { //if not connected, executes a wait 333 then goes back to while //if connected, tries to read a line, checks thread status and connection //status before each read attempt //doesn't terminate thread if disconnected, as currently don't have graceful //way to restart thread - if (!isConnected()) { - wait(kNotConnectedWait); + if (!juce::StreamingSocket::isConnected()) { + juce::Thread::wait(kNotConnectedWait); } //end if (is not connected) else { - char line[kBufferSize + 1] = {'\0'};//plus one for \0 at end auto size_read = 0; auto can_read_line = true; // parse input until we have a line, then process that line, quit if // connection lost - while (!juce::String(line).endsWithChar('\n') && isConnected()) { - if (threadShouldExit()) + while (!juce::String(line).endsWithChar('\n') && juce::StreamingSocket::isConnected()) { + if (juce::Thread::threadShouldExit()) goto threadExit;//break out of nested whiles - const auto wait_status = waitUntilReady(true, kReadyWait); + const auto wait_status = juce::StreamingSocket::waitUntilReady(true, kReadyWait); switch (wait_status) { case -1: can_read_line = false; goto dumpLine; //read line failed, break out of switch and while case 0: - wait(kEmptyWait); + juce::Thread::wait(kEmptyWait); break; //try again to read until char shows up case 1: if (size_read == kBufferSize) throw std::out_of_range("Buffer overflow in LR_IPC_IN"); - size_read += read(line + size_read, 1, false); + size_read += juce::StreamingSocket::read(line + size_read, 1, false); break; default: throw std::invalid_argument("waitUntilReady returned unexpected value"); @@ -116,17 +115,17 @@ void LR_IPC_IN::run() { } //end else (is connected) } //while not threadshouldexit threadExit: /* empty statement */; - std::lock_guard< decltype(timer_mutex_) > lock(timer_mutex_); - stopTimer(); + std::lock_guard lock(timer_mutex_); + juce::Timer::stopTimer(); //thread_started_ = false; //don't change flag while depending upon it } void LR_IPC_IN::timerCallback() { - std::lock_guard< decltype(timer_mutex_) > lock(timer_mutex_); - if (!isConnected()) { - if (connect("127.0.0.1", kLrInPort, kConnectTryTime)) + std::lock_guard lock(timer_mutex_); + if (!juce::StreamingSocket::isConnected()) { + if (juce::StreamingSocket::connect("127.0.0.1", kLrInPort, kConnectTryTime)) if (!thread_started_) { - startThread(); //avoid starting thread during shutdown + juce::Thread::startThread(); //avoid starting thread during shutdown thread_started_ = true; } } diff --git a/Source/LR_IPC_In.h b/Source/LR_IPC_In.h index c31226cef..62ab6c671 100644 --- a/Source/LR_IPC_In.h +++ b/Source/LR_IPC_In.h @@ -28,9 +28,10 @@ MIDI2LR. If not, see . #include "ProfileManager.h" #include "SendKeys.h" -class LR_IPC_IN final: private StreamingSocket, - private Timer, - private Thread { +class LR_IPC_IN final: + private juce::StreamingSocket, + private juce::Timer, + private juce::Thread { public: LR_IPC_IN(); virtual ~LR_IPC_IN(); @@ -47,7 +48,7 @@ class LR_IPC_IN final: private StreamingSocket, // Timer callback virtual void timerCallback() override; // process a line received from the socket - void processLine(const String& line); + void processLine(const juce::String& line); bool thread_started_{false}; mutable std::mutex timer_mutex_; diff --git a/Source/LR_IPC_Out.cpp b/Source/LR_IPC_Out.cpp index a2e45a699..8d977d4c2 100644 --- a/Source/LR_IPC_Out.cpp +++ b/Source/LR_IPC_Out.cpp @@ -29,14 +29,14 @@ namespace { constexpr auto kMaxNRPN = 16383.0; } -LR_IPC_OUT::LR_IPC_OUT(): InterprocessConnection() {} +LR_IPC_OUT::LR_IPC_OUT(): juce::InterprocessConnection() {} LR_IPC_OUT::~LR_IPC_OUT() { { std::lock_guard lock(timer_mutex_); timer_off_ = true; - stopTimer(); - disconnect(); + juce::Timer::stopTimer(); + juce::InterprocessConnection::disconnect(); } command_map_.reset(); } @@ -51,7 +51,7 @@ void LR_IPC_OUT::Init(std::shared_ptr& command_map, } //start the timer - startTimer(1000); + juce::Timer::startTimer(1000); } void LR_IPC_OUT::addListener(LRConnectionListener *listener) { @@ -61,12 +61,12 @@ void LR_IPC_OUT::addListener(LRConnectionListener *listener) { listeners_.push_back(listener); } -void LR_IPC_OUT::sendCommand(const String &command) { +void LR_IPC_OUT::sendCommand(const juce::String &command) { { std::lock_guard lock(command_mutex_); command_ += command; } - triggerAsyncUpdate(); + juce::AsyncUpdater::triggerAsyncUpdate(); } void LR_IPC_OUT::handleMidiCC(int midi_channel, int controller, int value) { @@ -84,12 +84,12 @@ void LR_IPC_OUT::handleMidiCC(int midi_channel, int controller, int value) { double computed_value = value; computed_value /= (controller < 128) ? kMaxMIDI : kMaxNRPN; - command_to_send += String::formatted(" %g\n", computed_value); + command_to_send += juce::String::formatted(" %g\n", computed_value); { std::lock_guard lock(command_mutex_); command_ += command_to_send; } - triggerAsyncUpdate(); + juce::AsyncUpdater::triggerAsyncUpdate(); } } @@ -105,12 +105,12 @@ void LR_IPC_OUT::handleMidiNote(int midi_channel, int note) { return; auto command_to_send = command_map_->getCommandforMessage(message); - command_to_send += String(" 1\n"); + command_to_send += juce::String(" 1\n"); { std::lock_guard lock(command_mutex_); command_ += command_to_send; } - triggerAsyncUpdate(); + juce::AsyncUpdater::triggerAsyncUpdate(); } } @@ -124,22 +124,23 @@ void LR_IPC_OUT::connectionLost() { listener->disconnected(); } -void LR_IPC_OUT::messageReceived(const MemoryBlock& /*msg*/) {} +void LR_IPC_OUT::messageReceived(const juce::MemoryBlock& /*msg*/) {} void LR_IPC_OUT::handleAsyncUpdate() { - String command_copy; + juce::String command_copy; { std::lock_guard lock(command_mutex_); command_copy = std::move(command_); //JUCE::String swaps in this case } //check if there is a connection - if (isConnected()) { - getSocket()->write(command_copy.getCharPointer(), command_copy.length()); + if (juce::InterprocessConnection::isConnected()) { + juce::InterprocessConnection::getSocket()-> + write(command_copy.getCharPointer(), command_copy.length()); } } void LR_IPC_OUT::timerCallback() { std::lock_guard lock(timer_mutex_); - if (!isConnected() && !timer_off_) - connectToSocket("127.0.0.1", kLrOutPort, kConnectTryTime); + if (!juce::InterprocessConnection::isConnected() && !timer_off_) + juce::InterprocessConnection::connectToSocket("127.0.0.1", kLrOutPort, kConnectTryTime); } \ No newline at end of file diff --git a/Source/LR_IPC_Out.h b/Source/LR_IPC_Out.h index 805e8097b..b65a1458f 100644 --- a/Source/LR_IPC_Out.h +++ b/Source/LR_IPC_Out.h @@ -40,10 +40,11 @@ class LRConnectionListener { ///< . }; -class LR_IPC_OUT final: private InterprocessConnection, +class LR_IPC_OUT final: + private juce::InterprocessConnection, public MIDICommandListener, - private AsyncUpdater, - private Timer { + private juce::AsyncUpdater, + private juce::Timer { public: LR_IPC_OUT(); virtual ~LR_IPC_OUT(); @@ -53,7 +54,7 @@ class LR_IPC_OUT final: private InterprocessConnection, void addListener(LRConnectionListener *listener); // sends a command to the plugin - void sendCommand(const String& command); + void sendCommand(const juce::String& command); // MIDICommandListener interface virtual void handleMidiCC(int midiChannel, int controller, int value) override; @@ -63,7 +64,7 @@ class LR_IPC_OUT final: private InterprocessConnection, // IPC interface virtual void connectionMade() override; virtual void connectionLost() override; - virtual void messageReceived(const MemoryBlock& msg) override; + virtual void messageReceived(const juce::MemoryBlock& msg) override; // AsyncUpdater interface virtual void handleAsyncUpdate() override; // Timer callback @@ -71,11 +72,11 @@ class LR_IPC_OUT final: private InterprocessConnection, std::vector listeners_; bool timer_off_{false}; - const static std::unordered_map keypress_mappings_; + const static std::unordered_map keypress_mappings_; mutable RSJ::spinlock command_mutex_; //fast spinlock for brief use mutable std::mutex timer_mutex_; //fix race during shutdown std::shared_ptr command_map_; - String command_; + juce::String command_; }; #endif // LR_IPC_OUT_H_INCLUDED diff --git a/Source/Main.cpp b/Source/Main.cpp index 80f1a0b7f..8e871eb76 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -40,7 +40,7 @@ MIDI2LR. If not, see . const juce::String ShutDownString{"--LRSHUTDOWN"}; -class MIDI2LRApplication final: public JUCEApplication { +class MIDI2LRApplication final: public juce::JUCEApplication { public: MIDI2LRApplication() { command_map_ = std::make_shared(); @@ -52,10 +52,10 @@ class MIDI2LRApplication final: public JUCEApplication { lr_ipc_in_ = std::make_shared(); } - const String getApplicationName() override { + const juce::String getApplicationName() override { return ProjectInfo::projectName; } - const String getApplicationVersion() override { + const juce::String getApplicationVersion() override { return ProjectInfo::versionString; } bool moreThanOneInstanceAllowed() override { @@ -64,7 +64,7 @@ class MIDI2LRApplication final: public JUCEApplication { //============================================================================== - void initialise(const String& command_line) override { + void initialise(const juce::String& command_line) override { //Called when the application starts. // This will be called once to let the application do whatever initialization @@ -130,13 +130,13 @@ class MIDI2LRApplication final: public JUCEApplication { if (lr_ipc_in_) lr_ipc_in_->PleaseStopThread(); auto default_profile = - File::getSpecialLocation(File::currentExecutableFile).getSiblingFile("default.xml"); + juce::File::getSpecialLocation(juce::File::currentExecutableFile).getSiblingFile("default.xml"); if (command_map_) command_map_->toXMLDocument(default_profile); quit(); } - void anotherInstanceStarted(const String& command_line) override { + void anotherInstanceStarted(const juce::String& command_line) override { // When another instance of the application is launched while this one is // running, this method is invoked, and the commandLine parameter tells you // what the other instance's command-line arguments were. @@ -147,7 +147,7 @@ class MIDI2LRApplication final: public JUCEApplication { } void unhandledException(const std::exception * e, - const String & sourceFilename, int lineNumber + const juce::String& sourceFilename, int lineNumber ) override { // If any unhandled exceptions make it through to the message dispatch // loop, this callback will be triggered, in case you want to log them or @@ -156,9 +156,13 @@ class MIDI2LRApplication final: public JUCEApplication { // If the type of exception is derived from the std::exception class, the // pointer passed-in will be valid. If the exception is of unknown type, // this pointer will be null. - if (auto a = Logger::getCurrentLogger()) - Logger::writeToLog(juce::String(e->what()) + " " + sourceFilename + - " line " + juce::String(lineNumber)); + if (juce::Logger::getCurrentLogger()) + if (e) + juce::Logger::writeToLog(juce::String(e->what()) + " " + sourceFilename + + " line " + juce::String(lineNumber)); + else + juce::Logger::writeToLog(sourceFilename + " line " + juce::String(lineNumber)); + std::terminate(); // can't go on with the program } From 04ab56734b6d769ba5f2ba3b7a1aebac25a9889c Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sat, 16 Jul 2016 22:03:17 -0700 Subject: [PATCH 17/33] use explicit namespace. completed. --- Source/CommandMap.cpp | 16 +++--- Source/CommandMap.h | 16 +++--- Source/CommandMenu.cpp | 10 ++-- Source/CommandMenu.h | 10 ++-- Source/CommandTable.cpp | 12 ++--- Source/CommandTable.h | 4 +- Source/CommandTableModel.cpp | 18 +++---- Source/CommandTableModel.h | 10 ++-- Source/LRCommands.cpp | 46 ++++++++-------- Source/LRCommands.h | 44 +++++++-------- Source/MIDIProcessor.cpp | 8 +-- Source/MIDIProcessor.h | 6 +-- Source/MIDISender.cpp | 14 ++--- Source/MIDISender.h | 2 +- Source/MainComponent.cpp | 102 +++++++++++++++++------------------ Source/MainComponent.h | 43 +++++++-------- Source/MainWindow.cpp | 8 +-- Source/MainWindow.h | 12 ++--- Source/ProfileManager.cpp | 24 ++++----- Source/ProfileManager.h | 10 ++-- Source/SettingsComponent.cpp | 20 +++---- Source/SettingsComponent.h | 32 +++++------ Source/SettingsManager.cpp | 14 ++--- Source/SettingsManager.h | 6 +-- Source/VersionChecker.cpp | 18 +++---- Source/VersionChecker.h | 4 +- 26 files changed, 255 insertions(+), 254 deletions(-) diff --git a/Source/CommandMap.cpp b/Source/CommandMap.cpp index 97f4ae28d..5ce683c8c 100644 --- a/Source/CommandMap.cpp +++ b/Source/CommandMap.cpp @@ -35,12 +35,12 @@ void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message & message_map_[message] = LRCommandList::NextPrevProfile[command - LRCommandList::LRStringList.size()]; } -void CommandMap::addCommandforMessage(const String& command, const MIDI_Message &message) { +void CommandMap::addCommandforMessage(const juce::String& command, const MIDI_Message &message) { message_map_[message] = command; command_string_map_[command] = message; } -const String& CommandMap::getCommandforMessage(const MIDI_Message &message) const { +const juce::String& CommandMap::getCommandforMessage(const MIDI_Message &message) const { return message_map_.at(message); } @@ -60,18 +60,18 @@ bool CommandMap::messageExistsInMap(const MIDI_Message &message) const { return message_map_.count(message) > 0 ? true : false; } -const MIDI_Message& CommandMap::getMessageForCommand(const String &command) const { +const MIDI_Message& CommandMap::getMessageForCommand(const juce::String &command) const { return command_string_map_.at(command); } -bool CommandMap::commandHasAssociatedMessage(const String &command) const { +bool CommandMap::commandHasAssociatedMessage(const juce::String &command) const { return command_string_map_.count(command) > 0 ? true : false; } -void CommandMap::toXMLDocument(File& file) const { +void CommandMap::toXMLDocument(juce::File& file) const { if (message_map_.size()) {//don't bother if map is empty // save the contents of the command map to an xml file - XmlElement root{"settings"}; + juce::XmlElement root{"settings"}; for (const auto& map_entry : message_map_) { - auto* setting = new XmlElement{"setting"}; + auto* setting = new juce::XmlElement{"setting"}; setting->setAttribute("channel", map_entry.first.channel); if (map_entry.first.isCC) setting->setAttribute("controller", map_entry.first.controller); @@ -82,7 +82,7 @@ void CommandMap::toXMLDocument(File& file) const { } if (!root.writeToFile(file, "")) // Give feedback if file-save doesn't work - AlertWindow::showMessageBox(AlertWindow::WarningIcon, "File Save Error", + juce::AlertWindow::showMessageBox(juce::AlertWindow::WarningIcon, "File Save Error", "Unable to save file as specified. Please try again, and consider saving to a different location."); } } \ No newline at end of file diff --git a/Source/CommandMap.h b/Source/CommandMap.h index 198c48291..b83709262 100644 --- a/Source/CommandMap.h +++ b/Source/CommandMap.h @@ -70,7 +70,7 @@ namespace std { }; template <> - struct hash { + struct hash { std::size_t operator()(const String& k) const noexcept { return k.hash(); } @@ -89,10 +89,10 @@ class CommandMap { // adds an entry to the message:command map, and a corresponding entry to the // command:message map - void addCommandforMessage(const String &command, const MIDI_Message &cc); + void addCommandforMessage(const juce::String &command, const MIDI_Message &cc); // gets the LR command associated to a MIDI message - const String& getCommandforMessage(const MIDI_Message &message) const; + const juce::String& getCommandforMessage(const MIDI_Message &message) const; // in the command:message map // removes a MIDI message from the message:command map, and it's associated entry @@ -105,18 +105,18 @@ class CommandMap { bool messageExistsInMap(const MIDI_Message &message) const; // gets the MIDI message associated to a LR command - const MIDI_Message& getMessageForCommand(const String &command) const; + const MIDI_Message& getMessageForCommand(const juce::String &command) const; // returns true if there is a mapping for a particular LR command - bool commandHasAssociatedMessage(const String &command) const; + bool commandHasAssociatedMessage(const juce::String &command) const; // saves the message:command map as an XML file - void toXMLDocument(File& file) const; + void toXMLDocument(juce::File& file) const; private: - std::unordered_map message_map_; - std::unordered_map command_string_map_; + std::unordered_map message_map_; + std::unordered_map command_string_map_; }; #endif // COMMANDMAP_H_INCLUDED diff --git a/Source/CommandMenu.cpp b/Source/CommandMenu.cpp index 4d1c2a05e..9a8c66d9d 100644 --- a/Source/CommandMenu.cpp +++ b/Source/CommandMenu.cpp @@ -24,7 +24,7 @@ MIDI2LR. If not, see . #include "LRCommands.h" CommandMenu::CommandMenu(const MIDI_Message& message): - TextButton{"Unmapped"}, + juce::TextButton{"Unmapped"}, message_{message}, menus_({"Keyboard Shortcuts for User", "General", "Library", "Develop", @@ -62,16 +62,16 @@ void CommandMenu::setSelectedItem(unsigned int index) { setButtonText(LRCommandList::NextPrevProfile[index - 1 - LRCommandList::LRStringList.size()]); } -void CommandMenu::buttonClicked(Button* /*button*/) { +void CommandMenu::buttonClicked(juce::Button* /*button*/) { size_t index = 1; auto submenu_tick_set = false; - PopupMenu main_menu; + juce::PopupMenu main_menu; main_menu.addItem(index, "Unmapped", true, submenu_tick_set = (index == selected_item_)); index++; // add each submenu for (size_t menu_index = 0; menu_index < menus_.size(); menu_index++) { - PopupMenu subMenu; + juce::PopupMenu subMenu; for (const auto& command : menu_entries_[menu_index]) { auto already_mapped = false; if ((index - 1 < LRCommandList::LRStringList.size()) && (command_map_)) { @@ -83,7 +83,7 @@ void CommandMenu::buttonClicked(Button* /*button*/) { // disabling a previously mapped entry if (already_mapped) - subMenu.addColouredItem(index, command, Colours::red, true, + subMenu.addColouredItem(index, command, juce::Colours::red, true, index == selected_item_); else subMenu.addItem(index, command, true, index == selected_item_); diff --git a/Source/CommandMenu.h b/Source/CommandMenu.h index 8e0ae1290..02d4d7505 100644 --- a/Source/CommandMenu.h +++ b/Source/CommandMenu.h @@ -25,8 +25,8 @@ MIDI2LR. If not, see . #include "../JuceLibraryCode/JuceHeader.h" #include "CommandMap.h" -class CommandMenu final: public TextButton, - private ButtonListener { +class CommandMenu final: public juce::TextButton, + private juce::ButtonListener { public: CommandMenu(const MIDI_Message& msg); void Init(std::shared_ptr& map_command); @@ -38,10 +38,10 @@ class CommandMenu final: public TextButton, private: // ButtonListener interface - virtual void buttonClicked(Button* button) override; + virtual void buttonClicked(juce::Button* button) override; - const std::vector menus_; - const std::vector> menu_entries_; + const std::vector menus_; + const std::vector> menu_entries_; MIDI_Message message_; size_t selected_item_{std::numeric_limits::max()}; std::shared_ptr command_map_{nullptr}; diff --git a/Source/CommandTable.cpp b/Source/CommandTable.cpp index 054af48f1..46bc276f8 100644 --- a/Source/CommandTable.cpp +++ b/Source/CommandTable.cpp @@ -20,12 +20,12 @@ MIDI2LR. If not, see . */ #include "CommandTable.h" -CommandTable::CommandTable(const String& component_name, TableListBoxModel *model): - TableListBox{component_name, model} { - setHeader(new TableHeaderComponent{}); +CommandTable::CommandTable(const String& component_name, juce::TableListBoxModel *model): + juce::TableListBox::TableListBox{component_name, model} { + setHeader(new juce::TableHeaderComponent{}); getHeader().addColumn("MIDI Command", 1, 150, 30, -1, - TableHeaderComponent::notResizable | TableHeaderComponent::sortable); + juce::TableHeaderComponent::notResizable | juce::TableHeaderComponent::sortable); getHeader().addColumn("LR Command", 2, 150, 30, -1, - TableHeaderComponent::notResizable | TableHeaderComponent::sortable | - TableHeaderComponent::sortedForwards); + juce::TableHeaderComponent::notResizable | juce::TableHeaderComponent::sortable | + juce::TableHeaderComponent::sortedForwards); } \ No newline at end of file diff --git a/Source/CommandTable.h b/Source/CommandTable.h index 29929537b..a1237372f 100644 --- a/Source/CommandTable.h +++ b/Source/CommandTable.h @@ -24,9 +24,9 @@ MIDI2LR. If not, see . #include "../JuceLibraryCode/JuceHeader.h" -class CommandTable final: public TableListBox { +class CommandTable final: public juce::TableListBox { public: - CommandTable(const String& component_name, TableListBoxModel *model); + CommandTable(const juce::String& component_name, juce::TableListBoxModel *model); private: diff --git a/Source/CommandTableModel.cpp b/Source/CommandTableModel.cpp index 7f3e4aa9c..65511210a 100644 --- a/Source/CommandTableModel.cpp +++ b/Source/CommandTableModel.cpp @@ -50,7 +50,7 @@ int CommandTableModel::getNumRows() { return commands_.size(); } -void CommandTableModel::paintRowBackground(Graphics &g, int /*rowNumber*/, +void CommandTableModel::paintRowBackground(juce::Graphics &g, int /*rowNumber*/, int /*width*/, int /*height*/, bool row_is_selected) { //This must draw the background behind one of the rows in the table. @@ -60,10 +60,10 @@ void CommandTableModel::paintRowBackground(Graphics &g, int /*rowNumber*/, // Note that the rowNumber value may be greater than the number of rows in your // list, so be careful that you don't assume it's less than getNumRows(). if (row_is_selected) - g.fillAll(Colours::lightblue); + g.fillAll(juce::Colours::lightblue); } -void CommandTableModel::paintCell(Graphics &g, int row_number, int column_id, +void CommandTableModel::paintCell(juce::Graphics &g, int row_number, int column_id, int width, int height, bool /*rowIsSelected*/) { //This must draw one of the cells. @@ -72,22 +72,22 @@ void CommandTableModel::paintCell(Graphics &g, int row_number, int column_id, // Note that the rowNumber value may be greater than the number of rows in your // list, so be careful that you don't assume it's less than getNumRows(). - g.setColour(Colours::black); + g.setColour(juce::Colours::black); g.setFont(12.0f); if (column_id == 1) // write the MIDI message in the MIDI command column { if (commands_[row_number].isCC) - g.drawText(String::formatted("%d | CC: %d", commands_[row_number].channel, - commands_[row_number].controller), 0, 0, width, height, Justification::centred); + g.drawText(juce::String::formatted("%d | CC: %d", commands_[row_number].channel, + commands_[row_number].controller), 0, 0, width, height, juce::Justification::centred); else g.drawText(String::formatted("%d | Note: %d", commands_[row_number].channel, commands_[row_number].pitch), 0, 0, width, height, Justification::centred); } } -Component *CommandTableModel::refreshComponentForCell(int row_number, - int column_id, bool /*isRowSelected*/, Component *existing_component_to_update) { +juce::Component *CommandTableModel::refreshComponentForCell(int row_number, + int column_id, bool /*isRowSelected*/, juce::Component *existing_component_to_update) { //This is used to create or update a custom component to go in a cell. // Any cell may contain a custom component, or can just be drawn with the @@ -160,7 +160,7 @@ void CommandTableModel::removeAllRows() { } } -void CommandTableModel::buildFromXml(const XmlElement * const root) { +void CommandTableModel::buildFromXml(const juce::XmlElement * const root) { if (root->getTagName().compare("settings") != 0) return; diff --git a/Source/CommandTableModel.h b/Source/CommandTableModel.h index 6a1db6ec4..f4c8811a7 100644 --- a/Source/CommandTableModel.h +++ b/Source/CommandTableModel.h @@ -36,12 +36,12 @@ class CommandTableModel final: public juce::TableListBoxModel { // TableListBoxModel overrides virtual void sortOrderChanged(int newSortColumnId, bool isForwards) override; virtual int getNumRows() override; - virtual void paintRowBackground(Graphics &, int rowNumber, int width, + virtual void paintRowBackground(juce::Graphics &, int rowNumber, int width, int height, bool rowIsSelected) override; - virtual void paintCell(Graphics &, int rowNumber, int columnId, int width, + virtual void paintCell(juce::Graphics &, int rowNumber, int columnId, int width, int height, bool rowIsSelected) override; - virtual Component *refreshComponentForCell(int rowNumber, int columnId, - bool isRowSelected, Component *existingComponentToUpdate) override; + virtual juce::Component *refreshComponentForCell(int rowNumber, int columnId, + bool isRowSelected, juce::Component *existingComponentToUpdate) override; // adds a row with a corresponding MIDI message to the table void addRow(int midi_channel, int midi_data, bool isCC); @@ -53,7 +53,7 @@ class CommandTableModel final: public juce::TableListBoxModel { void removeAllRows(); // builds the table from an XML file - void buildFromXml(const XmlElement * const elem); + void buildFromXml(const juce::XmlElement * const elem); // returns the index of the row associated to a particular MIDI message int getRowForMessage(int midi_channel, int midi_data, bool isCC) const; diff --git a/Source/LRCommands.cpp b/Source/LRCommands.cpp index 6a863ec5e..d923c8dc9 100644 --- a/Source/LRCommands.cpp +++ b/Source/LRCommands.cpp @@ -22,7 +22,7 @@ MIDI2LR. If not, see . #include #include "CommandMap.h" -const std::vector LRCommandList::KeyShortcuts = { +const std::vector LRCommandList::KeyShortcuts = { "Key 1", "Key 2", "Key 3", @@ -65,7 +65,7 @@ const std::vector LRCommandList::KeyShortcuts = { "Key 40", }; -const std::vector LRCommandList::General = { +const std::vector LRCommandList::General = { "Primary Display Grid", "Primary Display Loupe", "Primary Display Compare", @@ -81,7 +81,7 @@ const std::vector LRCommandList::General = { "Previous Photo", }; -const std::vector LRCommandList::Library = { +const std::vector LRCommandList::Library = { "Show Library", "Set Pick Flag", "Set Rejected Flag", @@ -102,7 +102,7 @@ const std::vector LRCommandList::Library = { "Primary Display People", }; -const std::vector LRCommandList::Develop = { +const std::vector LRCommandList::Develop = { "Show Develop", "Copy Settings", "Paste Settings", @@ -120,7 +120,7 @@ const std::vector LRCommandList::Develop = { "Primary Display Loupe", }; -const std::vector LRCommandList::BasicAdjustments = { +const std::vector LRCommandList::BasicAdjustments = { "Show Basic Tone", "White Balance As Shot", "White Balance Auto", @@ -155,7 +155,7 @@ const std::vector LRCommandList::BasicAdjustments = { "Reset Saturation", }; -const std::vector LRCommandList::ToneCurve = { +const std::vector LRCommandList::ToneCurve = { "Show Tone Curve", "Enable Tone Curve", "Dark Tones", @@ -174,7 +174,7 @@ const std::vector LRCommandList::ToneCurve = { "Reset Highlight Split", }; -const std::vector LRCommandList::Mixer = { +const std::vector LRCommandList::Mixer = { "Show Color Adjustments", "Enable Color Adjustments", "Saturation Adjustment Red", @@ -213,7 +213,7 @@ const std::vector LRCommandList::Mixer = { "Gray Mixer Magenta", }; -const std::vector LRCommandList::ResetMixer = { +const std::vector LRCommandList::ResetMixer = { "Reset Saturation Adjustment Red", "Reset Saturation Adjustment Orange", "Reset Saturation Adjustment Yellow", @@ -248,7 +248,7 @@ const std::vector LRCommandList::ResetMixer = { "Reset Gray Mixer Magenta", }; -const std::vector LRCommandList::SplitToning = { +const std::vector LRCommandList::SplitToning = { "Show Split Toning", "Enable Split Toning", "Shadow Hue", @@ -263,7 +263,7 @@ const std::vector LRCommandList::SplitToning = { "Reset Split Toning Balance", }; -const std::vector LRCommandList::Detail = { +const std::vector LRCommandList::Detail = { "Show Detail", "Enable Detail", "Sharpness", @@ -288,7 +288,7 @@ const std::vector LRCommandList::Detail = { "Reset Color Noise Reduction Smoothness", }; -const std::vector LRCommandList::LensCorrections = { +const std::vector LRCommandList::LensCorrections = { "Show Lens Corrections", "Enable Lens Corrections", "Perspective Correction Off", @@ -337,7 +337,7 @@ const std::vector LRCommandList::LensCorrections = { "Reset Vignette Midpoint", }; -const std::vector LRCommandList::Effects = { +const std::vector LRCommandList::Effects = { "Show Effects", "Enable Effects", "Dehaze Amount", @@ -362,7 +362,7 @@ const std::vector LRCommandList::Effects = { "Reset Grain Roughness", }; -const std::vector LRCommandList::Calibration = { +const std::vector LRCommandList::Calibration = { "Show Calibration", "Enable Calibration", "Adobe Standard", @@ -402,7 +402,7 @@ const std::vector LRCommandList::Calibration = { "Reset Blue Saturation Calibration", }; -const std::vector LRCommandList::DevelopPresets = { +const std::vector LRCommandList::DevelopPresets = { "Develop Preset 1", "Develop Preset 2", "Develop Preset 3", @@ -445,7 +445,7 @@ const std::vector LRCommandList::DevelopPresets = { "Develop Preset 40", }; -const std::vector LRCommandList::LocalAdjustments = { +const std::vector LRCommandList::LocalAdjustments = { "Show Graduated Filters", "Show Radial Filters", "Show Red-Eye Correction", @@ -495,7 +495,7 @@ const std::vector LRCommandList::LocalAdjustments = { "Reset Spot Removal", }; -const std::vector LRCommandList::Crop = { +const std::vector LRCommandList::Crop = { "Straighten Angle", "Crop Angle", "Crop - Bottom", @@ -507,7 +507,7 @@ const std::vector LRCommandList::Crop = { "Show Crop", }; -const std::vector LRCommandList::ToolModulePanel = { +const std::vector LRCommandList::ToolModulePanel = { "Show Loupe", "Show Map", "Show Book", @@ -516,7 +516,7 @@ const std::vector LRCommandList::ToolModulePanel = { "Show Web", }; -const std::vector LRCommandList::SecondaryDisplay = { +const std::vector LRCommandList::SecondaryDisplay = { "Secondary Display Loupe", "Secondary Display Live Loupe", "Secondary Display Locked Loupe", @@ -527,7 +527,7 @@ const std::vector LRCommandList::SecondaryDisplay = { "Secondary Display Show", }; -const std::vector LRCommandList::ProgramProfiles = { +const std::vector LRCommandList::ProgramProfiles = { "Profile: 1", "Profile: 2", "Profile: 3", @@ -541,7 +541,7 @@ const std::vector LRCommandList::ProgramProfiles = { "Manual Update", }; -const std::vector LRCommandList::LRStringList = { +const std::vector LRCommandList::LRStringList = { "Unmapped", /* Keyboard Shortcuts for User */ "Key1", @@ -1026,13 +1026,13 @@ const std::vector LRCommandList::LRStringList = { "FullRefresh", }; -const std::vector LRCommandList::NextPrevProfile = { +const std::vector LRCommandList::NextPrevProfile = { "Previous Profile", "Next Profile", }; -int LRCommandList::getIndexOfCommand(const String& command) { - static std::unordered_map indexMap; +int LRCommandList::getIndexOfCommand(const juce::String& command) { + static std::unordered_map indexMap; // better to check for empty then length, as empty has a constant run time behavior. if (indexMap.empty()) { diff --git a/Source/LRCommands.h b/Source/LRCommands.h index cc61398fb..7b48f7917 100644 --- a/Source/LRCommands.h +++ b/Source/LRCommands.h @@ -28,34 +28,34 @@ MIDI2LR. If not, see . class LRCommandList { public: // Strings that LR uses - static const std::vector LRStringList; + static const std::vector LRStringList; // Sectioned and readable develop param strings - static const std::vector KeyShortcuts; - static const std::vector General; - static const std::vector Library; - static const std::vector Develop; - static const std::vector BasicAdjustments; - static const std::vector ToneCurve; - static const std::vector Mixer; - static const std::vector ResetMixer; - static const std::vector SplitToning; - static const std::vector Detail; - static const std::vector LensCorrections; - static const std::vector Effects; - static const std::vector Calibration; - static const std::vector DevelopPresets; - static const std::vector LocalAdjustments; - static const std::vector Crop; - static const std::vector ToolModulePanel; - static const std::vector SecondaryDisplay; - static const std::vector ProgramProfiles; + static const std::vector KeyShortcuts; + static const std::vector General; + static const std::vector Library; + static const std::vector Develop; + static const std::vector BasicAdjustments; + static const std::vector ToneCurve; + static const std::vector Mixer; + static const std::vector ResetMixer; + static const std::vector SplitToning; + static const std::vector Detail; + static const std::vector LensCorrections; + static const std::vector Effects; + static const std::vector Calibration; + static const std::vector DevelopPresets; + static const std::vector LocalAdjustments; + static const std::vector Crop; + static const std::vector ToolModulePanel; + static const std::vector SecondaryDisplay; + static const std::vector ProgramProfiles; // MIDI2LR commands - static const std::vector NextPrevProfile; + static const std::vector NextPrevProfile; // Map of command strings to indices - static int getIndexOfCommand(const String& command); + static int getIndexOfCommand(const juce::String& command); private: LRCommandList() noexcept; diff --git a/Source/MIDIProcessor.cpp b/Source/MIDIProcessor.cpp index 9de99a61a..154c36349 100644 --- a/Source/MIDIProcessor.cpp +++ b/Source/MIDIProcessor.cpp @@ -28,8 +28,8 @@ void MIDIProcessor::Init(void) { InitDevices_(); } -void MIDIProcessor::handleIncomingMidiMessage(MidiInput * /*device*/, - const MidiMessage &message) { +void MIDIProcessor::handleIncomingMidiMessage(juce::MidiInput * /*device*/, + const juce::MidiMessage &message) { if (message.isController()) { const auto channel = static_cast(message.getChannel()); // 1-based @@ -72,8 +72,8 @@ void MIDIProcessor::RescanDevices() { } void MIDIProcessor::InitDevices_() { - for (auto idx = 0; idx < MidiInput::getDevices().size(); idx++) { - auto dev = MidiInput::openDevice(idx, this); + for (auto idx = 0; idx < juce::MidiInput::getDevices().size(); idx++) { + auto dev = juce::MidiInput::openDevice(idx, this); if (dev != nullptr) { devices_.emplace_back(dev); devices_[idx]->start(); diff --git a/Source/MIDIProcessor.h b/Source/MIDIProcessor.h index 9f6a0c5e8..3f64ffc0e 100644 --- a/Source/MIDIProcessor.h +++ b/Source/MIDIProcessor.h @@ -34,7 +34,7 @@ class MIDICommandListener { virtual ~MIDICommandListener() {}; }; -class MIDIProcessor final: private MidiInputCallback { +class MIDIProcessor final: private juce::MidiInputCallback { public: MIDIProcessor() noexcept; virtual ~MIDIProcessor(); @@ -47,12 +47,12 @@ class MIDIProcessor final: private MidiInputCallback { private: // overridden from MidiInputCallback - void handleIncomingMidiMessage(MidiInput*, const MidiMessage&) override; + void handleIncomingMidiMessage(juce::MidiInput*, const juce::MidiMessage&) override; void InitDevices_(); NRPN_Filter nrpn_filter_; - std::vector> devices_; + std::vector> devices_; std::vector listeners_; }; diff --git a/Source/MIDISender.cpp b/Source/MIDISender.cpp index 4eb681df5..d4580865d 100644 --- a/Source/MIDISender.cpp +++ b/Source/MIDISender.cpp @@ -31,7 +31,7 @@ void MIDISender::Init(void) { void MIDISender::sendCC(int midi_channel, int controller, int value) const { if (controller < 128) { // regular message for (auto& dev : output_devices_) - dev->sendMessageNow(MidiMessage::controllerEvent(midi_channel, controller, + dev->sendMessageNow(juce::MidiMessage::controllerEvent(midi_channel, controller, value)); } else { // NRPN @@ -40,10 +40,10 @@ void MIDISender::sendCC(int midi_channel, int controller, int value) const { const auto valueLSB = value & 0x7f; const auto valueMSB = (value >> 7) & 0x7F; for (auto& dev : output_devices_) { - dev->sendMessageNow(MidiMessage::controllerEvent(midi_channel, 99, parameterMSB)); - dev->sendMessageNow(MidiMessage::controllerEvent(midi_channel, 98, parameterLSB)); - dev->sendMessageNow(MidiMessage::controllerEvent(midi_channel, 6, valueMSB)); - dev->sendMessageNow(MidiMessage::controllerEvent(midi_channel, 38, valueLSB)); + dev->sendMessageNow(juce::MidiMessage::controllerEvent(midi_channel, 99, parameterMSB)); + dev->sendMessageNow(juce::MidiMessage::controllerEvent(midi_channel, 98, parameterLSB)); + dev->sendMessageNow(juce::MidiMessage::controllerEvent(midi_channel, 6, valueMSB)); + dev->sendMessageNow(juce::MidiMessage::controllerEvent(midi_channel, 38, valueLSB)); } } } @@ -54,8 +54,8 @@ void MIDISender::RescanDevices() { } void MIDISender::InitDevices_() { - for (auto idx = 0; idx < MidiOutput::getDevices().size(); idx++) { - auto dev = MidiOutput::openDevice(idx); + for (auto idx = 0; idx < juce::MidiOutput::getDevices().size(); idx++) { + auto dev = juce::MidiOutput::openDevice(idx); if (dev != nullptr) output_devices_.emplace_back(dev); } diff --git a/Source/MIDISender.h b/Source/MIDISender.h index 8de9efe63..bbd7527f1 100644 --- a/Source/MIDISender.h +++ b/Source/MIDISender.h @@ -38,7 +38,7 @@ class MIDISender { private: void InitDevices_(); - std::vector> output_devices_; + std::vector> output_devices_; }; #endif // MIDISENDER_H_INCLUDED diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 02d038086..f2bd0374d 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -68,9 +68,9 @@ void MainContentComponent::Init(std::shared_ptr& command_map, setSize(kMainWidth, kMainHeight); // Main title - title_label_.setFont(Font{36.f, Font::bold}); + title_label_.setFont(juce::Font{36.f, juce::Font::bold}); title_label_.setEditable(false); - title_label_.setColour(Label::textColourId, Colours::darkgrey); + title_label_.setColour(juce::Label::textColourId, juce::Colours::darkgrey); title_label_.setComponentEffect(&title_shadow_); title_label_.setBounds(kMainLeft, 10, kMainWidth - 2 * kMainLeft, 30); addToLayout(&title_label_, anchorMidLeft, anchorMidRight); @@ -83,11 +83,11 @@ void MainContentComponent::Init(std::shared_ptr& command_map, addAndMakeVisible(version_label_); // Connection status - connection_label_.setFont(Font{12.f, Font::bold}); + connection_label_.setFont(juce::Font{12.f, juce::Font::bold}); connection_label_.setEditable(false); - connection_label_.setColour(Label::backgroundColourId, Colours::red); - connection_label_.setColour(Label::textColourId, Colours::black); - connection_label_.setJustificationType(Justification::centred); + connection_label_.setColour(juce::Label::backgroundColourId, juce::Colours::red); + connection_label_.setColour(juce::Label::textColourId, juce::Colours::black); + connection_label_.setJustificationType(juce::Justification::centred); connection_label_.setBounds(200, 15, kMainWidth - kMainLeft - 200, 20); addToLayout(&connection_label_, anchorMidLeft, anchorMidRight); addAndMakeVisible(connection_label_); @@ -129,13 +129,13 @@ void MainContentComponent::Init(std::shared_ptr& command_map, SetLabelSettings(profile_name_label_); profile_name_label_.setBounds(kMainLeft, kMainHeight - 100, label_width, 20); addToLayout(&profile_name_label_, anchorMidLeft, anchorMidRight); - profile_name_label_.setJustificationType(Justification::centred); + profile_name_label_.setJustificationType(juce::Justification::centred); addAndMakeVisible(profile_name_label_); // Last MIDI command - command_label_.setFont(Font{12.f, Font::bold}); + command_label_.setFont(juce::Font{12.f, juce::Font::bold}); command_label_.setEditable(false); - command_label_.setColour(Label::textColourId, Colours::darkgrey); + command_label_.setColour(juce::Label::textColourId, juce::Colours::darkgrey); command_label_.setBounds(kMainLeft + label_width, kMainHeight - 100, label_width, 20); addToLayout(&command_label_, anchorMidLeft, anchorMidRight); @@ -159,16 +159,16 @@ void MainContentComponent::Init(std::shared_ptr& command_map, current_status_.setBounds(kMainLeft, kMainHeight - 30, kMainWidth - kMainLeft * 2, 20); addToLayout(¤t_status_, anchorMidLeft, anchorMidRight); - current_status_.setJustificationType(Justification::centred); + current_status_.setJustificationType(juce::Justification::centred); SetLabelSettings(current_status_); addAndMakeVisible(current_status_); if (settings_manager_) { // Try to load a default.xml if the user has not set a profile directory if (settings_manager_->getProfileDirectory().isEmpty()) { - File default_profile = - File::getSpecialLocation(File::currentExecutableFile).getSiblingFile("default.xml"); - std::unique_ptr xml_element{XmlDocument::parse(default_profile)}; + juce::File default_profile = + juce::File::getSpecialLocation(juce::File::currentExecutableFile).getSiblingFile("default.xml"); + std::unique_ptr xml_element{juce::XmlDocument::parse(default_profile)}; if (xml_element) { command_table_model_.buildFromXml(xml_element.get()); command_table_.updateContent(); @@ -183,13 +183,13 @@ void MainContentComponent::Init(std::shared_ptr& command_map, activateLayout(); } -void MainContentComponent::paint(Graphics& g) { - g.fillAll(Colours::white); +void MainContentComponent::paint(juce::Graphics& g) { + g.fillAll(juce::Colours::white); } void MainContentComponent::handleMidiCC(int midi_channel, int controller, int value) { // Display the CC parameters and add/highlight row in table corresponding to the CC - last_command_ = String::formatted("%d: CC%d [%d]", midi_channel, controller, value); + last_command_ = juce::String::formatted("%d: CC%d [%d]", midi_channel, controller, value); command_table_model_.addRow(midi_channel, controller, true); row_to_select_ = command_table_model_.getRowForMessage(midi_channel, controller, true); triggerAsyncUpdate(); @@ -197,23 +197,23 @@ void MainContentComponent::handleMidiCC(int midi_channel, int controller, int va void MainContentComponent::handleMidiNote(int midi_channel, int note) { // Display the Note parameters and add/highlight row in table corresponding to the Note - last_command_ = String::formatted("%d: Note [%d]", midi_channel, note); + last_command_ = juce::String::formatted("%d: Note [%d]", midi_channel, note); command_table_model_.addRow(midi_channel, note, false); row_to_select_ = command_table_model_.getRowForMessage(midi_channel, note, false); triggerAsyncUpdate(); } void MainContentComponent::connected() { - connection_label_.setText("Connected to LR", NotificationType::dontSendNotification); - connection_label_.setColour(Label::backgroundColourId, Colours::greenyellow); + connection_label_.setText("Connected to LR", juce::NotificationType::dontSendNotification); + connection_label_.setColour(juce::Label::backgroundColourId, Colours::greenyellow); } void MainContentComponent::disconnected() { - connection_label_.setText("Not connected to LR", NotificationType::dontSendNotification); - connection_label_.setColour(Label::backgroundColourId, Colours::red); + connection_label_.setText("Not connected to LR", juce::NotificationType::dontSendNotification); + connection_label_.setColour(juce::Label::backgroundColourId, juce::Colours::red); } -void MainContentComponent::buttonClicked(Button* button) { +void MainContentComponent::buttonClicked(juce::Button* button) { if (button == &rescan_button_) { // Re-enumerate MIDI IN and OUT devices @@ -243,21 +243,21 @@ void MainContentComponent::buttonClicked(Button* button) { } if (!profile_directory.exists()) { - profile_directory = File::getCurrentWorkingDirectory(); + profile_directory = juce::File::getCurrentWorkingDirectory(); } - WildcardFileFilter wildcard_filter{"*.xml", String::empty, "MIDI2LR profiles"}; - FileBrowserComponent browser{FileBrowserComponent::canSelectFiles | - FileBrowserComponent::saveMode | - FileBrowserComponent::warnAboutOverwriting, profile_directory, + juce::WildcardFileFilter wildcard_filter{"*.xml", juce::String::empty, "MIDI2LR profiles"}; + juce::FileBrowserComponent browser{juce::FileBrowserComponent::canSelectFiles | + juce::FileBrowserComponent::saveMode | + juce::FileBrowserComponent::warnAboutOverwriting, profile_directory, &wildcard_filter, nullptr}; - FileChooserDialogBox dialog_box{"Save profile", + juce::FileChooserDialogBox dialog_box{"Save profile", "Enter filename to save profile", browser, true, - Colours::lightgrey}; + juce::Colours::lightgrey}; if (dialog_box.show()) { - File selected_file = browser.getSelectedFile(0).withFileExtension("xml"); + juce::File selected_file = browser.getSelectedFile(0).withFileExtension("xml"); if (command_map_) { command_map_->toXMLDocument(selected_file); @@ -265,34 +265,34 @@ void MainContentComponent::buttonClicked(Button* button) { } } else if (button == &load_button_) { - File profile_directory; + juce::File profile_directory; if (settings_manager_) { profile_directory = settings_manager_->getProfileDirectory(); } if (!profile_directory.exists()) { - profile_directory = File::getCurrentWorkingDirectory(); + profile_directory = juce::File::getCurrentWorkingDirectory(); } - WildcardFileFilter wildcard_filter{"*.xml", String::empty, "MIDI2LR profiles"}; - FileBrowserComponent browser{FileBrowserComponent::canSelectFiles | - FileBrowserComponent::openMode, profile_directory, + juce::WildcardFileFilter wildcard_filter{"*.xml", juce::String::empty, "MIDI2LR profiles"}; + juce::FileBrowserComponent browser{juce::FileBrowserComponent::canSelectFiles | + juce::FileBrowserComponent::openMode, profile_directory, &wildcard_filter, nullptr}; - FileChooserDialogBox dialog_box{"Open profile", "Select a profile to open", - browser, true, Colours::lightgrey}; + juce::FileChooserDialogBox dialog_box{"Open profile", "Select a profile to open", + browser, true, juce::Colours::lightgrey}; if (dialog_box.show()) { - std::unique_ptr xml_element{XmlDocument::parse(browser.getSelectedFile(0))}; + std::unique_ptr xml_element{juce::XmlDocument::parse(browser.getSelectedFile(0))}; if (xml_element) { const auto new_profile = browser.getSelectedFile(0); - const auto command = String{"ChangedToFullPath "} +new_profile.getFullPathName() + "\n"; + const auto command = juce::String{"ChangedToFullPath "} +new_profile.getFullPathName() + "\n"; if (const auto ptr = lr_ipc_out_.lock()) { ptr->sendCommand(command); } profile_name_label_.setText(new_profile.getFileName(), - NotificationType::dontSendNotification); + juce::NotificationType::dontSendNotification); command_table_model_.buildFromXml(xml_element.get()); command_table_.updateContent(); command_table_.repaint(); @@ -300,7 +300,7 @@ void MainContentComponent::buttonClicked(Button* button) { } } else if (button == &settings_button_) { - DialogWindow::LaunchOptions dialog_options; + juce::DialogWindow::LaunchOptions dialog_options; dialog_options.dialogTitle = "Settings"; //create new object auto *component = new SettingsComponent{}; @@ -314,7 +314,7 @@ void MainContentComponent::buttonClicked(Button* button) { } } -void MainContentComponent::profileChanged(XmlElement* xml_element, const String& file_name) { +void MainContentComponent::profileChanged(juce::XmlElement* xml_element, const juce::String& file_name) { command_table_model_.buildFromXml(xml_element); command_table_.updateContent(); command_table_.repaint(); @@ -329,24 +329,24 @@ void MainContentComponent::profileChanged(XmlElement* xml_element, const String& void MainContentComponent::SetTimerText(int time_value) { if (time_value > 0) { - current_status_.setText(String::formatted("Hiding in %i Sec.", time_value), - NotificationType::dontSendNotification); + current_status_.setText(juce::String::formatted("Hiding in %i Sec.", time_value), + juce::NotificationType::dontSendNotification); } else { - current_status_.setText("", NotificationType::dontSendNotification); + current_status_.setText("", juce::NotificationType::dontSendNotification); } } -void MainContentComponent::SetLabelSettings(Label &label_to_set) { - label_to_set.setFont(Font{12.f, Font::bold}); +void MainContentComponent::SetLabelSettings(juce::Label &label_to_set) { + label_to_set.setFont(juce::Font{12.f, juce::Font::bold}); label_to_set.setEditable(false); - label_to_set.setColour(Label::textColourId, Colours::darkgrey); + label_to_set.setColour(juce::Label::textColourId, juce::Colours::darkgrey); } void MainContentComponent::handleAsyncUpdate() { // Update the last command label and set its colour to green - command_label_.setText(last_command_, NotificationType::dontSendNotification); - command_label_.setColour(Label::backgroundColourId, Colours::greenyellow); + command_label_.setText(last_command_, juce::NotificationType::dontSendNotification); + command_label_.setColour(juce::Label::backgroundColourId, juce::Colours::greenyellow); startTimer(1000); // Update the command table to add and/or select row corresponding to midi command @@ -356,6 +356,6 @@ void MainContentComponent::handleAsyncUpdate() { void MainContentComponent::timerCallback() { // reset the command label's background to white - command_label_.setColour(Label::backgroundColourId, Colours::white); + command_label_.setColour(juce::Label::backgroundColourId, juce::Colours::white); stopTimer(); } \ No newline at end of file diff --git a/Source/MainComponent.h b/Source/MainComponent.h index 9a7bd159c..6d13ef811 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -37,12 +37,13 @@ MIDI2LR. If not, see . #include "ResizableLayout.h" #include "SettingsManager.h" -class MainContentComponent final: public Component, +class MainContentComponent final: + public juce::Component, public MIDICommandListener, public LRConnectionListener, - private AsyncUpdater, - private Timer, - private ButtonListener, + private juce::AsyncUpdater, + private juce::Timer, + private juce::ButtonListener, public ProfileChangeListener, public ResizableLayout { public: @@ -65,16 +66,16 @@ class MainContentComponent final: public Component, virtual void disconnected() override; // ProfileChangeListener interface - virtual void profileChanged(XmlElement* elem, const String& file_name) override; + virtual void profileChanged(juce::XmlElement* elem, const juce::String& file_name) override; void SetTimerText(int time_value); protected: - void SetLabelSettings(Label &lblToSet); + void SetLabelSettings(juce::Label &lblToSet); private: - void paint(Graphics&) override; + void paint(juce::Graphics&) override; // Button interface - virtual void buttonClicked(Button* button) override; + virtual void buttonClicked(juce::Button* button) override; // AsyncUpdater interface virtual void handleAsyncUpdate() override; @@ -83,14 +84,14 @@ class MainContentComponent final: public Component, CommandTable command_table_{"Table", nullptr}; CommandTableModel command_table_model_{}; - DropShadowEffect title_shadow_; + juce::DropShadowEffect title_shadow_; int row_to_select_; - Label command_label_{"Command", ""}; - Label connection_label_{"Connection", "Not connected to LR"}; - Label current_status_{"CurrentStatus", "no extra info"}; - Label profile_name_label_{"ProfileNameLabel", ""}; - Label title_label_{"Title", "MIDI2LR"}; - Label version_label_{"Version", "Version " + String{ ProjectInfo::versionString }}; + juce::Label command_label_{"Command", ""}; + juce::Label connection_label_{"Connection", "Not connected to LR"}; + juce::Label current_status_{"CurrentStatus", "no extra info"}; + juce::Label profile_name_label_{"ProfileNameLabel", ""}; + juce::Label title_label_{"Title", "MIDI2LR"}; + juce::Label version_label_{"Version", "Version " + juce::String{ ProjectInfo::versionString }}; std::shared_ptr command_map_{nullptr}; std::weak_ptr lr_ipc_in_; std::weak_ptr lr_ipc_out_; @@ -98,12 +99,12 @@ class MainContentComponent final: public Component, std::shared_ptr midi_sender_{nullptr}; std::shared_ptr settings_manager_{nullptr}; std::unique_ptr settings_dialog_; - String last_command_; - TextButton load_button_{"Load"}; - TextButton remove_row_button_{"Remove selected row"}; - TextButton rescan_button_{"Rescan MIDI devices"}; - TextButton save_button_{"Save"}; - TextButton settings_button_{"Settings"}; + juce::String last_command_; + juce::TextButton load_button_{"Load"}; + juce::TextButton remove_row_button_{"Remove selected row"}; + juce::TextButton rescan_button_{"Rescan MIDI devices"}; + juce::TextButton save_button_{"Save"}; + juce::TextButton settings_button_{"Settings"}; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainContentComponent) diff --git a/Source/MainWindow.cpp b/Source/MainWindow.cpp index f2d1011d1..0614c113f 100644 --- a/Source/MainWindow.cpp +++ b/Source/MainWindow.cpp @@ -37,7 +37,7 @@ void MainWindow::Init(std::shared_ptr& command_map, } //start timing - this->startTimer(1000); + juce::Timer::startTimer(1000); if (window_content_) { window_content_->Init(command_map, std::move(lr_ipc_in), std::move(lr_ipc_out), @@ -59,12 +59,12 @@ void MainWindow::timerCallback(void) { if (auto_hide_counter_ == 0) { //first stop the timer so it will not be called again - this->stopTimer(); + juce::Timer::stopTimer(); //check if the window is not already minimized - if (!this->isMinimised()) { + if (!juce::ResizableWindow::isMinimised()) { if (decreased_value) { - this->minimiseButtonPressed(); + juce::DocumentWindow::minimiseButtonPressed(); } } } diff --git a/Source/MainWindow.h b/Source/MainWindow.h index dcf012985..6a85995c0 100644 --- a/Source/MainWindow.h +++ b/Source/MainWindow.h @@ -27,12 +27,12 @@ MIDI2LR. If not, see . #include "MainComponent.h" #include "SettingsManager.h" -class MainWindow final: private DocumentWindow, private Timer { +class MainWindow final: private juce::DocumentWindow, private juce::Timer { public: - MainWindow(String name): DocumentWindow{name, - Colours::lightgrey, - DocumentWindow::minimiseButton | - DocumentWindow::closeButton}, Timer() + MainWindow(String name): juce::DocumentWindow{name, + juce::Colours::lightgrey, + juce::DocumentWindow::minimiseButton | + juce::DocumentWindow::closeButton}, juce::Timer() { setUsingNativeTitleBar(true); window_content_ = new MainContentComponent{}; @@ -62,7 +62,7 @@ class MainWindow final: private DocumentWindow, private Timer { // This is called when the user tries to close this window. Here, we'll just // ask the app to quit when this happens, but you can change this to do // whatever you need. - JUCEApplication::getInstance()->systemRequestedQuit(); + juce::JUCEApplication::getInstance()->systemRequestedQuit(); } // the timer callback function virtual void timerCallback() override; diff --git a/Source/ProfileManager.cpp b/Source/ProfileManager.cpp index 4ef746a8d..75d8efdb2 100644 --- a/Source/ProfileManager.cpp +++ b/Source/ProfileManager.cpp @@ -48,11 +48,11 @@ void ProfileManager::addListener(ProfileChangeListener *listener) { listeners_.push_back(listener); } -void ProfileManager::setProfileDirectory(const File& directory) { +void ProfileManager::setProfileDirectory(const juce::File& directory) { profile_location_ = directory; - Array file_array; - directory.findChildFiles(file_array, File::findFiles, false, "*.xml"); + juce::Array file_array; + directory.findChildFiles(file_array, juce::File::findFiles, false, "*.xml"); current_profile_index_ = 0; profiles_.clear(); @@ -74,20 +74,20 @@ void ProfileManager::switchToProfile(int profile_index) { } } -void ProfileManager::switchToProfile(const String& profile) { +void ProfileManager::switchToProfile(const juce::String& profile) { const auto profile_file = profile_location_.getChildFile(profile); if (profile_file.exists()) { - std::unique_ptr xml_element{XmlDocument::parse(profile_file)}; + std::unique_ptr xml_element{juce::XmlDocument::parse(profile_file)}; for (auto listener : listeners_) listener->profileChanged(xml_element.get(), profile); if (const auto ptr = lr_ipc_out_.lock()) { - auto command = String{"ChangedToDirectory "} + - File::addTrailingSeparator(profile_location_.getFullPathName()) + - String{"\n"}; + auto command = juce::String{"ChangedToDirectory "} + + juce::File::addTrailingSeparator(profile_location_.getFullPathName()) + + juce::String{"\n"}; ptr->sendCommand(command); - command = String("ChangedToFile ") + profile + String("\n"); + command = juce::String("ChangedToFile ") + profile + juce::String("\n"); ptr->sendCommand(command); } } @@ -148,9 +148,9 @@ void ProfileManager::handleMidiNote(int midi_channel, int note) { } void ProfileManager::connected() { - const auto command = String{"ChangedToDirectory "} + - File::addTrailingSeparator(profile_location_.getFullPathName()) + - String{"\n"}; + const auto command = juce::String{"ChangedToDirectory "} + + juce::File::addTrailingSeparator(profile_location_.getFullPathName()) + + juce::String{"\n"}; if (const auto ptr = lr_ipc_out_.lock()) { ptr->sendCommand(command); } diff --git a/Source/ProfileManager.h b/Source/ProfileManager.h index 203d96d56..ec707383f 100644 --- a/Source/ProfileManager.h +++ b/Source/ProfileManager.h @@ -30,13 +30,13 @@ MIDI2LR. If not, see . class ProfileChangeListener { public: // called when the current profile is changed - virtual void profileChanged(XmlElement* elem, const String& file_name) = 0; + virtual void profileChanged(juce::XmlElement* elem, const juce::String& file_name) = 0; virtual ~ProfileChangeListener() {}; }; class ProfileManager final: public MIDICommandListener, - private AsyncUpdater, public LRConnectionListener { + private juce::AsyncUpdater, public LRConnectionListener { public: ProfileManager() noexcept; virtual ~ProfileManager() {}; @@ -47,7 +47,7 @@ class ProfileManager final: public MIDICommandListener, void addListener(ProfileChangeListener *listener); // sets the default profile directory and scans its contents for profiles - void setProfileDirectory(const File& dir); + void setProfileDirectory(const juce::File& dir); // returns an array of profile names const std::vector& getMenuItems() const noexcept; @@ -56,7 +56,7 @@ class ProfileManager final: public MIDICommandListener, void switchToProfile(int profileIdx); // switches to a profile defined by a name - void switchToProfile(const String& profile); + void switchToProfile(const juce::String& profile); // switches to the next profile void switchToNextProfile(); @@ -84,7 +84,7 @@ class ProfileManager final: public MIDICommandListener, ProfileManager(ProfileManager const&) = delete; void operator=(ProfileManager const&) = delete; - File profile_location_; + juce::File profile_location_; int current_profile_index_{0}; std::shared_ptr command_map_{nullptr}; std::vector listeners_; diff --git a/Source/SettingsComponent.cpp b/Source/SettingsComponent.cpp index 0bab5e6de..8d1e7e674 100644 --- a/Source/SettingsComponent.cpp +++ b/Source/SettingsComponent.cpp @@ -46,16 +46,16 @@ void SettingsComponent::Init(std::weak_ptr&& settings_manager) addToLayout(&pickup_group_, anchorMidLeft, anchorMidRight); addAndMakeVisible(pickup_group_); - pickup_label_.setFont(Font{12.f, Font::bold}); + pickup_label_.setFont(juce::Font{12.f, juce::Font::bold}); pickup_label_.setText("Disabling the pickup mode may be better for touchscreen interfaces and may solve issues with LR not picking up fast fader/knob movements", NotificationType::dontSendNotification); pickup_label_.setBounds(SettingsLeft, 15, SettingsWidth - 2 * SettingsLeft, 50); addToLayout(&pickup_label_, anchorMidLeft, anchorMidRight); pickup_label_.setEditable(false); - pickup_label_.setColour(Label::textColourId, Colours::darkgrey); + pickup_label_.setColour(juce::Label::textColourId, juce::Colours::darkgrey); addAndMakeVisible(pickup_label_); pickup_enabled_.addListener(this); - pickup_enabled_.setToggleState(ptr->getPickupEnabled(), NotificationType::dontSendNotification); + pickup_enabled_.setToggleState(ptr->getPickupEnabled(), juce::NotificationType::dontSendNotification); pickup_enabled_.setBounds(SettingsLeft, 60, SettingsWidth - 2 * SettingsLeft, 32); addToLayout(&pickup_enabled_, anchorMidLeft, anchorMidRight); addAndMakeVisible(pickup_enabled_); @@ -74,9 +74,9 @@ void SettingsComponent::Init(std::weak_ptr&& settings_manager) profile_location_label_.setEditable(false); profile_location_label_.setBounds(SettingsLeft, 145, SettingsWidth - 2 * SettingsLeft, 30); addToLayout(&profile_location_label_, anchorMidLeft, anchorMidRight); - profile_location_label_.setColour(Label::textColourId, Colours::darkgrey); + profile_location_label_.setColour(juce::Label::textColourId, juce::Colours::darkgrey); addAndMakeVisible(profile_location_label_); - profile_location_label_.setText(ptr->getProfileDirectory(), NotificationType::dontSendNotification); + profile_location_label_.setText(ptr->getProfileDirectory(), juce::NotificationType::dontSendNotification); ////// ----------------------- auto hide section ------------------------------------ autohide_group_.setText("Auto hide"); @@ -84,18 +84,18 @@ void SettingsComponent::Init(std::weak_ptr&& settings_manager) addToLayout(&autohide_group_, anchorMidLeft, anchorMidRight); addAndMakeVisible(autohide_group_); - autohide_explain_label_.setFont(Font{12.f, Font::bold}); - autohide_explain_label_.setText("Autohide the plugin window in x seconds, select 0 for disabling autohide", NotificationType::dontSendNotification); + autohide_explain_label_.setFont(juce::Font{12.f, juce::Font::bold}); + autohide_explain_label_.setText("Autohide the plugin window in x seconds, select 0 for disabling autohide", juce::NotificationType::dontSendNotification); autohide_explain_label_.setBounds(SettingsLeft, 215, SettingsWidth - 2 * SettingsLeft, 50); addToLayout(&autohide_explain_label_, anchorMidLeft, anchorMidRight); autohide_explain_label_.setEditable(false); - autohide_explain_label_.setFont(Font{12.f, Font::bold}); - autohide_explain_label_.setColour(Label::textColourId, Colours::darkgrey); + autohide_explain_label_.setFont(juce::Font{12.f, juce::Font::bold}); + autohide_explain_label_.setColour(juce::Label::textColourId, juce::Colours::darkgrey); addAndMakeVisible(autohide_explain_label_); autohide_setting_.setBounds(SettingsLeft, 245, SettingsWidth - 2 * SettingsLeft, 50); autohide_setting_.setRange(0, 10, 1); - autohide_setting_.setValue(ptr->getAutoHideTime(), NotificationType::dontSendNotification); + autohide_setting_.setValue(ptr->getAutoHideTime(), juce::NotificationType::dontSendNotification); addToLayout(&autohide_setting_, anchorMidLeft, anchorMidRight); //add this as the lister for the data diff --git a/Source/SettingsComponent.h b/Source/SettingsComponent.h index 5c8142743..dad4af98a 100644 --- a/Source/SettingsComponent.h +++ b/Source/SettingsComponent.h @@ -27,29 +27,29 @@ MIDI2LR. If not, see . #include "SettingsManager.h" class SettingsComponent final: - public Component, - private ButtonListener, + public juce::Component, + private juce::ButtonListener, private ResizableLayout, - private Slider::Listener { + private juce::Slider::Listener { public: SettingsComponent(); ~SettingsComponent(); void Init(std::weak_ptr&& settings_manager); private: - void paint(Graphics&) override; - virtual void buttonClicked(Button* button) override; - virtual void sliderValueChanged(Slider* slider) override; - - GroupComponent autohide_group_{}; - GroupComponent pickup_group_{}; - GroupComponent profile_group_{}; - Label autohide_explain_label_{}; - Label pickup_label_{"PickupLabel", ""}; - Label profile_location_label_{"Profile Label"}; - Slider autohide_setting_; + void paint(juce::Graphics&) override; + virtual void buttonClicked(juce::Button* button) override; + virtual void sliderValueChanged(juce::Slider* slider) override; + + juce::GroupComponent autohide_group_{}; + juce::GroupComponent pickup_group_{}; + juce::GroupComponent profile_group_{}; + juce::Label autohide_explain_label_{}; + juce::Label pickup_label_{"PickupLabel", ""}; + juce::Label profile_location_label_{"Profile Label"}; + juce::Slider autohide_setting_; std::weak_ptr settings_manager_; - TextButton profile_location_button_{"Choose Profile Folder"}; - ToggleButton pickup_enabled_{"Enable Pickup Mode"}; + juce::TextButton profile_location_button_{"Choose Profile Folder"}; + juce::ToggleButton pickup_enabled_{"Enable Pickup Mode"}; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SettingsComponent) }; diff --git a/Source/SettingsManager.cpp b/Source/SettingsManager.cpp index 3ffe40c39..2db1f53d1 100644 --- a/Source/SettingsManager.cpp +++ b/Source/SettingsManager.cpp @@ -24,14 +24,14 @@ MIDI2LR. If not, see . const juce::String AutoHideSection{"autohide"}; SettingsManager::SettingsManager() { - PropertiesFile::Options file_options; + juce::PropertiesFile::Options file_options; file_options.applicationName = "MIDI2LR"; file_options.commonToAllUsers = false; file_options.filenameSuffix = "xml"; file_options.osxLibrarySubFolder = "Application Support/MIDI2LR"; - file_options.storageFormat = PropertiesFile::storeAsXML; + file_options.storageFormat = juce::PropertiesFile::storeAsXML; - properties_file_ = std::make_unique(file_options); + properties_file_ = std::make_unique(file_options); } void SettingsManager::Init(std::weak_ptr&& lr_ipc_out, @@ -61,14 +61,14 @@ void SettingsManager::setPickupEnabled(bool enabled) { properties_file_->saveIfNeeded(); if (const auto ptr = lr_ipc_out_.lock()) { - ptr->sendCommand(String::formatted("Pickup %d\n", enabled)); + ptr->sendCommand(juce::String::formatted("Pickup %d\n", enabled)); } } -String SettingsManager::getProfileDirectory() const noexcept { +juce::String SettingsManager::getProfileDirectory() const noexcept { return properties_file_->getValue("profile_directory"); } -void SettingsManager::setProfileDirectory(const String& profile_directory_name) { +void SettingsManager::setProfileDirectory(const juce::String& profile_directory_name) { properties_file_->setValue("profile_directory", profile_directory_name); properties_file_->saveIfNeeded(); if (const auto ptr = profile_manager_.lock()) { @@ -78,7 +78,7 @@ void SettingsManager::setProfileDirectory(const String& profile_directory_name) void SettingsManager::connected() { if (const auto ptr = lr_ipc_out_.lock()) { - ptr->sendCommand(String::formatted("Pickup %d\n", getPickupEnabled())); + ptr->sendCommand(juce::String::formatted("Pickup %d\n", getPickupEnabled())); } } diff --git a/Source/SettingsManager.h b/Source/SettingsManager.h index 165066143..a73885e9c 100644 --- a/Source/SettingsManager.h +++ b/Source/SettingsManager.h @@ -36,8 +36,8 @@ class SettingsManager final: public LRConnectionListener { bool getPickupEnabled() const noexcept; void setPickupEnabled(bool enabled); - String getProfileDirectory() const noexcept; - void setProfileDirectory(const String& profile_directory); + juce::String getProfileDirectory() const noexcept; + void setProfileDirectory(const juce::String& profile_directory); // LRConnectionListener interface virtual void connected() override; @@ -51,7 +51,7 @@ class SettingsManager final: public LRConnectionListener { private: - std::unique_ptr properties_file_; + std::unique_ptr properties_file_; std::weak_ptr lr_ipc_out_; std::weak_ptr profile_manager_; }; diff --git a/Source/VersionChecker.cpp b/Source/VersionChecker.cpp index 8f62ffc04..b4faf2f3d 100644 --- a/Source/VersionChecker.cpp +++ b/Source/VersionChecker.cpp @@ -20,7 +20,7 @@ MIDI2LR. If not, see . */ #include "VersionChecker.h" -VersionChecker::VersionChecker() noexcept : Thread{"VersionChecker"} {} +VersionChecker::VersionChecker() noexcept : juce::Thread{"VersionChecker"} {} VersionChecker::~VersionChecker() { stopThread(100); @@ -31,8 +31,8 @@ void VersionChecker::Init(std::weak_ptr&& settings_manager) noe } void VersionChecker::run() { - const URL version_url{"http://rsjaffe.github.io/MIDI2LR/version.xml"}; - const std::unique_ptr version_xml_element{version_url.readEntireXmlStream()}; + const juce::URL version_url{"http://rsjaffe.github.io/MIDI2LR/version.xml"}; + const std::unique_ptr version_xml_element{version_url.readEntireXmlStream()}; if (version_xml_element != nullptr) { int last_checked = 0; @@ -49,19 +49,19 @@ void VersionChecker::run() { void VersionChecker::handleAsyncUpdate() { // show a dialog box indicating there is a newer version available - DialogWindow::LaunchOptions dialog_options; + juce::DialogWindow::LaunchOptions dialog_options; dialog_options.dialogTitle = "New Version Available!"; const auto major{(new_version_ & 0xFF000000) >> 24}; const auto minor{(new_version_ & 0xFF0000) >> 16}; const auto rev{(new_version_ & 0xFF00) >> 8}; const auto build{(new_version_ & 0xFF)}; - const auto version_string{String::formatted("New version %d.%d.%d.%d available", + const auto version_string{juce::String::formatted("New version %d.%d.%d.%d available", major, minor, rev, build)}; - const URL download_url{"https://github.com/rsjaffe/MIDI2LR/releases/latest"}; - dialog_options.content.setOwned(new HyperlinkButton{version_string, download_url}); + const juce::URL download_url{"https://github.com/rsjaffe/MIDI2LR/releases/latest"}; + dialog_options.content.setOwned(new juce::HyperlinkButton{version_string, download_url}); dialog_options.content->setSize(300, 100); - (static_cast(dialog_options.content.get()))-> - setFont(Font{18.f}, false); + (static_cast(dialog_options.content.get()))-> + setFont(juce::Font{18.f}, false); dialog_options.escapeKeyTriggersCloseButton = true; dialog_.reset(dialog_options.create()); dialog_->setVisible(true); diff --git a/Source/VersionChecker.h b/Source/VersionChecker.h index a9a12c705..9ed1fe1c3 100644 --- a/Source/VersionChecker.h +++ b/Source/VersionChecker.h @@ -25,7 +25,7 @@ MIDI2LR. If not, see . #include "../JuceLibraryCode/JuceHeader.h" #include "SettingsManager.h" -class VersionChecker final: public Thread, private AsyncUpdater { +class VersionChecker final: public juce::Thread, private juce::AsyncUpdater { public: VersionChecker() noexcept; ~VersionChecker(); @@ -41,7 +41,7 @@ class VersionChecker final: public Thread, private AsyncUpdater { int new_version_; std::weak_ptr settings_manager_; - std::unique_ptr dialog_; + std::unique_ptr dialog_; }; #endif // VERSIONCHECKER_H_INCLUDED From 62c536fbe637c13c5f194f2b16dd134f0075d055 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sat, 16 Jul 2016 22:12:07 -0700 Subject: [PATCH 18/33] make swap explicit --- Source/LR_IPC_Out.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/LR_IPC_Out.cpp b/Source/LR_IPC_Out.cpp index 8d977d4c2..e00b530d2 100644 --- a/Source/LR_IPC_Out.cpp +++ b/Source/LR_IPC_Out.cpp @@ -130,7 +130,7 @@ void LR_IPC_OUT::handleAsyncUpdate() { juce::String command_copy; { std::lock_guard lock(command_mutex_); - command_copy = std::move(command_); //JUCE::String swaps in this case + command_copy.swapWith(command_); //JUCE::String swaps in this case } //check if there is a connection if (juce::InterprocessConnection::isConnected()) { From d70c1fa603dd25015c204294a80dd937a66dc763 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sun, 17 Jul 2016 17:21:30 -0700 Subject: [PATCH 19/33] Reduced juce::String as much as is practical retained its use for juce functions requiring it --- Builds/VisualStudio2015/MIDI2LR.vcxproj | 1197 ++++++++--------- .../VisualStudio2015/MIDI2LR.vcxproj.filters | 108 +- Source/CommandMap.cpp | 8 +- Source/CommandMap.h | 23 +- Source/CommandMenu.h | 2 +- Source/CommandTable.cpp | 4 +- Source/CommandTableModel.cpp | 4 +- Source/LRCommands.cpp | 46 +- Source/LRCommands.h | 44 +- Source/LRPlugin/MIDI2LR.lrplugin/Database.lua | 1 + Source/LR_IPC_In.cpp | 38 +- Source/LR_IPC_In.h | 4 +- Source/LR_IPC_Out.cpp | 12 +- Source/LR_IPC_Out.h | 7 +- Source/MainComponent.cpp | 2 +- Source/MainComponent.h | 2 +- Source/MainWindow.h | 5 +- Source/NrpnMessage.h | 2 +- Source/ProfileManager.cpp | 16 +- Source/SendKeys.cpp | 2 +- Source/SettingsComponent.h | 4 +- Source/SettingsManager.cpp | 4 +- Source/Utilities/Utilities.cpp | 23 + Source/Utilities/Utilities.h | 11 + 24 files changed, 755 insertions(+), 814 deletions(-) create mode 100644 Source/Utilities/Utilities.cpp diff --git a/Builds/VisualStudio2015/MIDI2LR.vcxproj b/Builds/VisualStudio2015/MIDI2LR.vcxproj index 92ab1f9bd..1c8c44c59 100644 --- a/Builds/VisualStudio2015/MIDI2LR.vcxproj +++ b/Builds/VisualStudio2015/MIDI2LR.vcxproj @@ -1,5 +1,4 @@ - - + @@ -15,7 +14,7 @@ {62CE7F88-4C2A-C448-873F-40363B88C6A3} v140 - + Application false @@ -27,11 +26,10 @@ true v140 - - + + - + v140 @@ -50,7 +48,7 @@ true true Win32 - + Disabled @@ -59,7 +57,7 @@ _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.3.0.1;JUCE_APP_VERSION_HEX=0x1030001;%(PreprocessorDefinitions) MultiThreadedDebug true - + $(IntDir)\ $(IntDir)\ $(IntDir)\ @@ -92,7 +90,7 @@ true true Win32 - + Full @@ -100,7 +98,7 @@ _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.3.0.1;JUCE_APP_VERSION_HEX=0x1030001;%(PreprocessorDefinitions) MultiThreaded true - + $(IntDir)\ $(IntDir)\ $(IntDir)\ @@ -129,25 +127,26 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + true @@ -1549,579 +1548,579 @@ true - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - + - - - + + + \ No newline at end of file diff --git a/Builds/VisualStudio2015/MIDI2LR.vcxproj.filters b/Builds/VisualStudio2015/MIDI2LR.vcxproj.filters index ee05db92b..b0ef2e03d 100644 --- a/Builds/VisualStudio2015/MIDI2LR.vcxproj.filters +++ b/Builds/VisualStudio2015/MIDI2LR.vcxproj.filters @@ -1,5 +1,4 @@ - - + @@ -451,9 +450,6 @@ Juce Modules\juce_audio_basics - - Juce Modules\juce_audio_basics - Juce Modules\juce_audio_devices\audio_cd @@ -496,12 +492,6 @@ Juce Modules\juce_audio_devices\native - - Juce Modules\juce_audio_devices\native - - - Juce Modules\juce_audio_devices\native - Juce Modules\juce_audio_devices\native @@ -535,9 +525,6 @@ Juce Modules\juce_audio_devices - - Juce Modules\juce_audio_devices - Juce Modules\juce_audio_formats\codecs\flac\libFLAC @@ -709,9 +696,6 @@ Juce Modules\juce_audio_formats - - Juce Modules\juce_audio_formats - Juce Modules\juce_core\containers @@ -820,21 +804,6 @@ Juce Modules\juce_core\native - - Juce Modules\juce_core\native - - - Juce Modules\juce_core\native - - - Juce Modules\juce_core\native - - - Juce Modules\juce_core\native - - - Juce Modules\juce_core\native - Juce Modules\juce_core\native @@ -1000,9 +969,6 @@ Juce Modules\juce_core - - Juce Modules\juce_core - Juce Modules\juce_data_structures\app_properties @@ -1027,9 +993,6 @@ Juce Modules\juce_data_structures - - Juce Modules\juce_data_structures - Juce Modules\juce_events\broadcasters @@ -1063,15 +1026,9 @@ Juce Modules\juce_events\native - - Juce Modules\juce_events\native - Juce Modules\juce_events\native - - Juce Modules\juce_events\native - Juce Modules\juce_events\native @@ -1084,9 +1041,6 @@ Juce Modules\juce_events - - Juce Modules\juce_events - Juce Modules\juce_graphics\colour @@ -1363,12 +1317,6 @@ Juce Modules\juce_graphics\native - - Juce Modules\juce_graphics\native - - - Juce Modules\juce_graphics\native - Juce Modules\juce_graphics\native @@ -1387,9 +1335,6 @@ Juce Modules\juce_graphics - - Juce Modules\juce_graphics - Juce Modules\juce_gui_basics\application @@ -1618,12 +1563,6 @@ Juce Modules\juce_gui_basics\native - - Juce Modules\juce_gui_basics\native - - - Juce Modules\juce_gui_basics\native - Juce Modules\juce_gui_basics\native @@ -1633,21 +1572,6 @@ Juce Modules\juce_gui_basics\native - - Juce Modules\juce_gui_basics\native - - - Juce Modules\juce_gui_basics\native - - - Juce Modules\juce_gui_basics\native - - - Juce Modules\juce_gui_basics\native - - - Juce Modules\juce_gui_basics\native - Juce Modules\juce_gui_basics\native @@ -1768,9 +1692,6 @@ Juce Modules\juce_gui_basics - - Juce Modules\juce_gui_basics - Juce Modules\juce_gui_extra\code_editor @@ -1819,27 +1740,15 @@ Juce Modules\juce_gui_extra\native - - Juce Modules\juce_gui_extra\native - Juce Modules\juce_gui_extra\native Juce Modules\juce_gui_extra\native - - Juce Modules\juce_gui_extra\native - - - Juce Modules\juce_gui_extra\native - Juce Modules\juce_gui_extra\native - - Juce Modules\juce_gui_extra\native - Juce Modules\juce_gui_extra\native @@ -1852,9 +1761,6 @@ Juce Modules\juce_gui_extra - - Juce Modules\juce_gui_extra - Juce Library Code @@ -1885,6 +1791,7 @@ Juce Library Code + @@ -3534,6 +3441,15 @@ Juce Library Code + + + + + + + + + @@ -3560,4 +3476,4 @@ Juce Library Code - + \ No newline at end of file diff --git a/Source/CommandMap.cpp b/Source/CommandMap.cpp index 5ce683c8c..9d69d0999 100644 --- a/Source/CommandMap.cpp +++ b/Source/CommandMap.cpp @@ -35,12 +35,12 @@ void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message & message_map_[message] = LRCommandList::NextPrevProfile[command - LRCommandList::LRStringList.size()]; } -void CommandMap::addCommandforMessage(const juce::String& command, const MIDI_Message &message) { +void CommandMap::addCommandforMessage(const std::string& command, const MIDI_Message &message) { message_map_[message] = command; command_string_map_[command] = message; } -const juce::String& CommandMap::getCommandforMessage(const MIDI_Message &message) const { +const std::string& CommandMap::getCommandforMessage(const MIDI_Message &message) const { return message_map_.at(message); } @@ -60,10 +60,10 @@ bool CommandMap::messageExistsInMap(const MIDI_Message &message) const { return message_map_.count(message) > 0 ? true : false; } -const MIDI_Message& CommandMap::getMessageForCommand(const juce::String &command) const { +const MIDI_Message& CommandMap::getMessageForCommand(const std::string &command) const { return command_string_map_.at(command); } -bool CommandMap::commandHasAssociatedMessage(const juce::String &command) const { +bool CommandMap::commandHasAssociatedMessage(const std::string &command) const { return command_string_map_.count(command) > 0 ? true : false; } void CommandMap::toXMLDocument(juce::File& file) const { diff --git a/Source/CommandMap.h b/Source/CommandMap.h index b83709262..a33a1c389 100644 --- a/Source/CommandMap.h +++ b/Source/CommandMap.h @@ -59,7 +59,7 @@ struct MIDI_Message { } }; -// hash functions for MIDI_Message and String +// hash functions namespace std { template <> struct hash { @@ -68,13 +68,6 @@ namespace std { std::hash()(k.data << 2); } }; - - template <> - struct hash { - std::size_t operator()(const String& k) const noexcept { - return k.hash(); - } - }; } class CommandMap { @@ -84,15 +77,15 @@ class CommandMap { // adds an entry to the message:command map, and a corresponding entry to the // command:message map will look up the string by the index (but it is preferred to -// directly use the String) +// directly use the string) void addCommandforMessage(unsigned int command, const MIDI_Message &cc); // adds an entry to the message:command map, and a corresponding entry to the // command:message map - void addCommandforMessage(const juce::String &command, const MIDI_Message &cc); + void addCommandforMessage(const std::string &command, const MIDI_Message &cc); // gets the LR command associated to a MIDI message - const juce::String& getCommandforMessage(const MIDI_Message &message) const; + const std::string& getCommandforMessage(const MIDI_Message &message) const; // in the command:message map // removes a MIDI message from the message:command map, and it's associated entry @@ -105,18 +98,18 @@ class CommandMap { bool messageExistsInMap(const MIDI_Message &message) const; // gets the MIDI message associated to a LR command - const MIDI_Message& getMessageForCommand(const juce::String &command) const; + const MIDI_Message& getMessageForCommand(const std::string &command) const; // returns true if there is a mapping for a particular LR command - bool commandHasAssociatedMessage(const juce::String &command) const; + bool commandHasAssociatedMessage(const std::string &command) const; // saves the message:command map as an XML file void toXMLDocument(juce::File& file) const; private: - std::unordered_map message_map_; - std::unordered_map command_string_map_; + std::unordered_map message_map_; + std::unordered_map command_string_map_; }; #endif // COMMANDMAP_H_INCLUDED diff --git a/Source/CommandMenu.h b/Source/CommandMenu.h index 02d4d7505..2d6c534a3 100644 --- a/Source/CommandMenu.h +++ b/Source/CommandMenu.h @@ -41,7 +41,7 @@ class CommandMenu final: public juce::TextButton, virtual void buttonClicked(juce::Button* button) override; const std::vector menus_; - const std::vector> menu_entries_; + const std::vector> menu_entries_; MIDI_Message message_; size_t selected_item_{std::numeric_limits::max()}; std::shared_ptr command_map_{nullptr}; diff --git a/Source/CommandTable.cpp b/Source/CommandTable.cpp index 46bc276f8..47b4dc0c1 100644 --- a/Source/CommandTable.cpp +++ b/Source/CommandTable.cpp @@ -20,8 +20,8 @@ MIDI2LR. If not, see . */ #include "CommandTable.h" -CommandTable::CommandTable(const String& component_name, juce::TableListBoxModel *model): - juce::TableListBox::TableListBox{component_name, model} { +CommandTable::CommandTable(const juce::String& component_name, juce::TableListBoxModel *model): + juce::TableListBox{component_name, model} { setHeader(new juce::TableHeaderComponent{}); getHeader().addColumn("MIDI Command", 1, 150, 30, -1, juce::TableHeaderComponent::notResizable | juce::TableHeaderComponent::sortable); diff --git a/Source/CommandTableModel.cpp b/Source/CommandTableModel.cpp index 65511210a..10f2c0f7d 100644 --- a/Source/CommandTableModel.cpp +++ b/Source/CommandTableModel.cpp @@ -180,7 +180,7 @@ void CommandTableModel::buildFromXml(const juce::XmlElement * const root) { } else { command_map_->addCommandforMessage(setting-> - getStringAttribute("command_string"), message); + getStringAttribute("command_string").toStdString(), message); } } else if (setting->hasAttribute("note")) { @@ -195,7 +195,7 @@ void CommandTableModel::buildFromXml(const juce::XmlElement * const root) { } else { command_map_->addCommandforMessage(setting-> - getStringAttribute("command_string"), note); + getStringAttribute("command_string").toStdString(), note); } } setting = setting->getNextElement(); diff --git a/Source/LRCommands.cpp b/Source/LRCommands.cpp index d923c8dc9..aad3d4231 100644 --- a/Source/LRCommands.cpp +++ b/Source/LRCommands.cpp @@ -22,7 +22,7 @@ MIDI2LR. If not, see . #include #include "CommandMap.h" -const std::vector LRCommandList::KeyShortcuts = { +const std::vector LRCommandList::KeyShortcuts = { "Key 1", "Key 2", "Key 3", @@ -65,7 +65,7 @@ const std::vector LRCommandList::KeyShortcuts = { "Key 40", }; -const std::vector LRCommandList::General = { +const std::vector LRCommandList::General = { "Primary Display Grid", "Primary Display Loupe", "Primary Display Compare", @@ -81,7 +81,7 @@ const std::vector LRCommandList::General = { "Previous Photo", }; -const std::vector LRCommandList::Library = { +const std::vector LRCommandList::Library = { "Show Library", "Set Pick Flag", "Set Rejected Flag", @@ -102,7 +102,7 @@ const std::vector LRCommandList::Library = { "Primary Display People", }; -const std::vector LRCommandList::Develop = { +const std::vector LRCommandList::Develop = { "Show Develop", "Copy Settings", "Paste Settings", @@ -120,7 +120,7 @@ const std::vector LRCommandList::Develop = { "Primary Display Loupe", }; -const std::vector LRCommandList::BasicAdjustments = { +const std::vector LRCommandList::BasicAdjustments = { "Show Basic Tone", "White Balance As Shot", "White Balance Auto", @@ -155,7 +155,7 @@ const std::vector LRCommandList::BasicAdjustments = { "Reset Saturation", }; -const std::vector LRCommandList::ToneCurve = { +const std::vector LRCommandList::ToneCurve = { "Show Tone Curve", "Enable Tone Curve", "Dark Tones", @@ -174,7 +174,7 @@ const std::vector LRCommandList::ToneCurve = { "Reset Highlight Split", }; -const std::vector LRCommandList::Mixer = { +const std::vector LRCommandList::Mixer = { "Show Color Adjustments", "Enable Color Adjustments", "Saturation Adjustment Red", @@ -213,7 +213,7 @@ const std::vector LRCommandList::Mixer = { "Gray Mixer Magenta", }; -const std::vector LRCommandList::ResetMixer = { +const std::vector LRCommandList::ResetMixer = { "Reset Saturation Adjustment Red", "Reset Saturation Adjustment Orange", "Reset Saturation Adjustment Yellow", @@ -248,7 +248,7 @@ const std::vector LRCommandList::ResetMixer = { "Reset Gray Mixer Magenta", }; -const std::vector LRCommandList::SplitToning = { +const std::vector LRCommandList::SplitToning = { "Show Split Toning", "Enable Split Toning", "Shadow Hue", @@ -263,7 +263,7 @@ const std::vector LRCommandList::SplitToning = { "Reset Split Toning Balance", }; -const std::vector LRCommandList::Detail = { +const std::vector LRCommandList::Detail = { "Show Detail", "Enable Detail", "Sharpness", @@ -288,7 +288,7 @@ const std::vector LRCommandList::Detail = { "Reset Color Noise Reduction Smoothness", }; -const std::vector LRCommandList::LensCorrections = { +const std::vector LRCommandList::LensCorrections = { "Show Lens Corrections", "Enable Lens Corrections", "Perspective Correction Off", @@ -337,7 +337,7 @@ const std::vector LRCommandList::LensCorrections = { "Reset Vignette Midpoint", }; -const std::vector LRCommandList::Effects = { +const std::vector LRCommandList::Effects = { "Show Effects", "Enable Effects", "Dehaze Amount", @@ -362,7 +362,7 @@ const std::vector LRCommandList::Effects = { "Reset Grain Roughness", }; -const std::vector LRCommandList::Calibration = { +const std::vector LRCommandList::Calibration = { "Show Calibration", "Enable Calibration", "Adobe Standard", @@ -402,7 +402,7 @@ const std::vector LRCommandList::Calibration = { "Reset Blue Saturation Calibration", }; -const std::vector LRCommandList::DevelopPresets = { +const std::vector LRCommandList::DevelopPresets = { "Develop Preset 1", "Develop Preset 2", "Develop Preset 3", @@ -445,7 +445,7 @@ const std::vector LRCommandList::DevelopPresets = { "Develop Preset 40", }; -const std::vector LRCommandList::LocalAdjustments = { +const std::vector LRCommandList::LocalAdjustments = { "Show Graduated Filters", "Show Radial Filters", "Show Red-Eye Correction", @@ -495,7 +495,7 @@ const std::vector LRCommandList::LocalAdjustments = { "Reset Spot Removal", }; -const std::vector LRCommandList::Crop = { +const std::vector LRCommandList::Crop = { "Straighten Angle", "Crop Angle", "Crop - Bottom", @@ -507,7 +507,7 @@ const std::vector LRCommandList::Crop = { "Show Crop", }; -const std::vector LRCommandList::ToolModulePanel = { +const std::vector LRCommandList::ToolModulePanel = { "Show Loupe", "Show Map", "Show Book", @@ -516,7 +516,7 @@ const std::vector LRCommandList::ToolModulePanel = { "Show Web", }; -const std::vector LRCommandList::SecondaryDisplay = { +const std::vector LRCommandList::SecondaryDisplay = { "Secondary Display Loupe", "Secondary Display Live Loupe", "Secondary Display Locked Loupe", @@ -527,7 +527,7 @@ const std::vector LRCommandList::SecondaryDisplay = { "Secondary Display Show", }; -const std::vector LRCommandList::ProgramProfiles = { +const std::vector LRCommandList::ProgramProfiles = { "Profile: 1", "Profile: 2", "Profile: 3", @@ -541,7 +541,7 @@ const std::vector LRCommandList::ProgramProfiles = { "Manual Update", }; -const std::vector LRCommandList::LRStringList = { +const std::vector LRCommandList::LRStringList = { "Unmapped", /* Keyboard Shortcuts for User */ "Key1", @@ -1026,13 +1026,13 @@ const std::vector LRCommandList::LRStringList = { "FullRefresh", }; -const std::vector LRCommandList::NextPrevProfile = { +const std::vector LRCommandList::NextPrevProfile = { "Previous Profile", "Next Profile", }; -int LRCommandList::getIndexOfCommand(const juce::String& command) { - static std::unordered_map indexMap; +int LRCommandList::getIndexOfCommand(const std::string& command) { + static std::unordered_map indexMap; // better to check for empty then length, as empty has a constant run time behavior. if (indexMap.empty()) { diff --git a/Source/LRCommands.h b/Source/LRCommands.h index 7b48f7917..76a87dc0b 100644 --- a/Source/LRCommands.h +++ b/Source/LRCommands.h @@ -28,34 +28,34 @@ MIDI2LR. If not, see . class LRCommandList { public: // Strings that LR uses - static const std::vector LRStringList; + static const std::vector LRStringList; // Sectioned and readable develop param strings - static const std::vector KeyShortcuts; - static const std::vector General; - static const std::vector Library; - static const std::vector Develop; - static const std::vector BasicAdjustments; - static const std::vector ToneCurve; - static const std::vector Mixer; - static const std::vector ResetMixer; - static const std::vector SplitToning; - static const std::vector Detail; - static const std::vector LensCorrections; - static const std::vector Effects; - static const std::vector Calibration; - static const std::vector DevelopPresets; - static const std::vector LocalAdjustments; - static const std::vector Crop; - static const std::vector ToolModulePanel; - static const std::vector SecondaryDisplay; - static const std::vector ProgramProfiles; + static const std::vector KeyShortcuts; + static const std::vector General; + static const std::vector Library; + static const std::vector Develop; + static const std::vector BasicAdjustments; + static const std::vector ToneCurve; + static const std::vector Mixer; + static const std::vector ResetMixer; + static const std::vector SplitToning; + static const std::vector Detail; + static const std::vector LensCorrections; + static const std::vector Effects; + static const std::vector Calibration; + static const std::vector DevelopPresets; + static const std::vector LocalAdjustments; + static const std::vector Crop; + static const std::vector ToolModulePanel; + static const std::vector SecondaryDisplay; + static const std::vector ProgramProfiles; // MIDI2LR commands - static const std::vector NextPrevProfile; + static const std::vector NextPrevProfile; // Map of command strings to indices - static int getIndexOfCommand(const juce::String& command); + static int getIndexOfCommand(const std::string& command); private: LRCommandList() noexcept; diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua b/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua index 9847ccc65..54b653355 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/Database.lua @@ -46,6 +46,7 @@ local secondaryDisplay = LOC("$$$/AgApplication/Menu/Window/SecondaryDisplay=Sec local show = LOC("$$$/AgLibrary/LibraryInfo/Show=Show") local splitToning = LOC("$$$/AgCameraRawNamedSettings/SaveNamedDialog/SplitToning=Split Toning") local toneCurve = LOC("$$$/AgDevelop/CameraRawPanel/TargetName/ToneCurve=Tone Curve") +local transform = LOC("$$$/AgDevelop/CameraRawPanel/Transform=Transform") local viewModes = LOC("$$$/AgDevelop/Toolbar/ViewModesTool=View Modes") local whiteBalance = LOC("$$$/AgCameraRawNamedSettings/CameraRawSettingMapping/WhiteBalance=White Balance") diff --git a/Source/LR_IPC_In.cpp b/Source/LR_IPC_In.cpp index 0f1309b29..bd0425143 100644 --- a/Source/LR_IPC_In.cpp +++ b/Source/LR_IPC_In.cpp @@ -19,6 +19,7 @@ MIDI2LR. If not, see . ============================================================================== */ #include "LR_IPC_In.h" +#include "Utilities/Utilities.h" #include namespace { @@ -85,7 +86,7 @@ void LR_IPC_IN::run() { auto can_read_line = true; // parse input until we have a line, then process that line, quit if // connection lost - while (!juce::String(line).endsWithChar('\n') && juce::StreamingSocket::isConnected()) { + while (std::string(line).back() != '\n' && juce::StreamingSocket::isConnected()) { if (juce::Thread::threadShouldExit()) goto threadExit;//break out of nested whiles const auto wait_status = juce::StreamingSocket::waitUntilReady(true, kReadyWait); @@ -101,16 +102,16 @@ void LR_IPC_IN::run() { throw std::out_of_range("Buffer overflow in LR_IPC_IN"); size_read += juce::StreamingSocket::read(line + size_read, 1, false); break; - default: - throw std::invalid_argument("waitUntilReady returned unexpected value"); } } // end while !\n and is connected // if lose connection, line may not be terminated - if (can_read_line && juce::String(line).endsWithChar('\n')) { - juce::String param{line}; - processLine(param); - } + { + std::string param{line}; + if (can_read_line && param.back() == '\n') { + processLine(param); + } + } //scope param dumpLine: /* empty statement */; } //end else (is connected) } //while not threadshouldexit @@ -130,16 +131,16 @@ void LR_IPC_IN::timerCallback() { } } } -void LR_IPC_IN::processLine(const juce::String& line) { - const static std::unordered_map cmds = { - {juce::String{"SwitchProfile"},1}, - {juce::String{"SendKey"},2}, - {juce::String{"TerminateApplication"},3}, +void LR_IPC_IN::processLine(const std::string& line) { + const static std::unordered_map cmds = { + {"SwitchProfile",1}, + {"SendKey",2}, + {"TerminateApplication",3}, }; // process input into [parameter] [Value] - const auto trimmed_line = line.trim(); - const auto command = trimmed_line.upToFirstOccurrenceOf(" ", false, false); - const auto value_string = trimmed_line.fromFirstOccurrenceOf(" ", false, false); + const auto trimmed_line = RSJ::trim(line); + const auto command = trimmed_line.substr(0, trimmed_line.find(' ')); + const auto value_string = trimmed_line.substr(trimmed_line.find(' ') + 1); switch (cmds.count(command) ? cmds.at(command) : 0) { case 1: //SwitchProfile @@ -149,9 +150,8 @@ void LR_IPC_IN::processLine(const juce::String& line) { case 2: //SendKey { std::bitset<3> modifiers{static_cast - (value_string.getIntValue())}; - send_keys_.SendKeyDownUp(value_string. - trimCharactersAtStart("0123456789").trimStart().toStdString(), + (std::stoi(value_string))}; + send_keys_.SendKeyDownUp(RSJ::ltrim(RSJ::ltrim(value_string, RSJ::digit)), modifiers[0], modifiers[1], modifiers[2]); break; } @@ -161,7 +161,7 @@ void LR_IPC_IN::processLine(const juce::String& line) { break; case 0: // store updates in map - const auto original_value = value_string.getDoubleValue(); + const auto original_value = std::stod(value_string); parameter_map_[command] = original_value; // send associated CC messages to MIDI OUT devices if (command_map_ && command_map_->commandHasAssociatedMessage(command)) { diff --git a/Source/LR_IPC_In.h b/Source/LR_IPC_In.h index 62ab6c671..7608d5a76 100644 --- a/Source/LR_IPC_In.h +++ b/Source/LR_IPC_In.h @@ -48,7 +48,7 @@ class LR_IPC_IN final: // Timer callback virtual void timerCallback() override; // process a line received from the socket - void processLine(const juce::String& line); + void processLine(const std::string& line); bool thread_started_{false}; mutable std::mutex timer_mutex_; @@ -56,7 +56,7 @@ class LR_IPC_IN final: std::shared_ptr command_map_{nullptr}; std::shared_ptr midi_sender_{nullptr}; std::shared_ptr profile_manager_{nullptr}; - std::unordered_map parameter_map_; + std::unordered_map parameter_map_; }; #endif // LR_IPC_IN_H_INCLUDED diff --git a/Source/LR_IPC_Out.cpp b/Source/LR_IPC_Out.cpp index e00b530d2..a61f94802 100644 --- a/Source/LR_IPC_Out.cpp +++ b/Source/LR_IPC_Out.cpp @@ -61,7 +61,7 @@ void LR_IPC_OUT::addListener(LRConnectionListener *listener) { listeners_.push_back(listener); } -void LR_IPC_OUT::sendCommand(const juce::String &command) { +void LR_IPC_OUT::sendCommand(const std::string& command) { { std::lock_guard lock(command_mutex_); command_ += command; @@ -84,7 +84,7 @@ void LR_IPC_OUT::handleMidiCC(int midi_channel, int controller, int value) { double computed_value = value; computed_value /= (controller < 128) ? kMaxMIDI : kMaxNRPN; - command_to_send += juce::String::formatted(" %g\n", computed_value); + command_to_send += ' ' + std::to_string(computed_value) + '\n'; { std::lock_guard lock(command_mutex_); command_ += command_to_send; @@ -105,7 +105,7 @@ void LR_IPC_OUT::handleMidiNote(int midi_channel, int note) { return; auto command_to_send = command_map_->getCommandforMessage(message); - command_to_send += juce::String(" 1\n"); + command_to_send += " 1\n"; { std::lock_guard lock(command_mutex_); command_ += command_to_send; @@ -127,15 +127,15 @@ void LR_IPC_OUT::connectionLost() { void LR_IPC_OUT::messageReceived(const juce::MemoryBlock& /*msg*/) {} void LR_IPC_OUT::handleAsyncUpdate() { - juce::String command_copy; + std::string command_copy; { std::lock_guard lock(command_mutex_); - command_copy.swapWith(command_); //JUCE::String swaps in this case + command_copy.swap(command_); } //check if there is a connection if (juce::InterprocessConnection::isConnected()) { juce::InterprocessConnection::getSocket()-> - write(command_copy.getCharPointer(), command_copy.length()); + write(command_copy.c_str(), command_copy.length()); } } diff --git a/Source/LR_IPC_Out.h b/Source/LR_IPC_Out.h index b65a1458f..1b4983674 100644 --- a/Source/LR_IPC_Out.h +++ b/Source/LR_IPC_Out.h @@ -40,7 +40,7 @@ class LRConnectionListener { ///< . }; -class LR_IPC_OUT final: +class LR_IPC_OUT final: private juce::InterprocessConnection, public MIDICommandListener, private juce::AsyncUpdater, @@ -54,7 +54,7 @@ class LR_IPC_OUT final: void addListener(LRConnectionListener *listener); // sends a command to the plugin - void sendCommand(const juce::String& command); + void sendCommand(const std::string& command); // MIDICommandListener interface virtual void handleMidiCC(int midiChannel, int controller, int value) override; @@ -72,11 +72,10 @@ class LR_IPC_OUT final: std::vector listeners_; bool timer_off_{false}; - const static std::unordered_map keypress_mappings_; mutable RSJ::spinlock command_mutex_; //fast spinlock for brief use mutable std::mutex timer_mutex_; //fix race during shutdown std::shared_ptr command_map_; - juce::String command_; + std::string command_; }; #endif // LR_IPC_OUT_H_INCLUDED diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index f2bd0374d..f1d362c72 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -286,7 +286,7 @@ void MainContentComponent::buttonClicked(juce::Button* button) { std::unique_ptr xml_element{juce::XmlDocument::parse(browser.getSelectedFile(0))}; if (xml_element) { const auto new_profile = browser.getSelectedFile(0); - const auto command = juce::String{"ChangedToFullPath "} +new_profile.getFullPathName() + "\n"; + const std::string command = "ChangedToFullPath " + new_profile.getFullPathName().toStdString() + '\n'; if (const auto ptr = lr_ipc_out_.lock()) { ptr->sendCommand(command); diff --git a/Source/MainComponent.h b/Source/MainComponent.h index 6d13ef811..99d8a4501 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -37,7 +37,7 @@ MIDI2LR. If not, see . #include "ResizableLayout.h" #include "SettingsManager.h" -class MainContentComponent final: +class MainContentComponent final: public juce::Component, public MIDICommandListener, public LRConnectionListener, diff --git a/Source/MainWindow.h b/Source/MainWindow.h index 6a85995c0..dfa10e204 100644 --- a/Source/MainWindow.h +++ b/Source/MainWindow.h @@ -29,11 +29,10 @@ MIDI2LR. If not, see . class MainWindow final: private juce::DocumentWindow, private juce::Timer { public: - MainWindow(String name): juce::DocumentWindow{name, + MainWindow(juce::String name): juce::DocumentWindow{name, juce::Colours::lightgrey, juce::DocumentWindow::minimiseButton | - juce::DocumentWindow::closeButton}, juce::Timer() - { + juce::DocumentWindow::closeButton}, juce::Timer() { setUsingNativeTitleBar(true); window_content_ = new MainContentComponent{}; diff --git a/Source/NrpnMessage.h b/Source/NrpnMessage.h index ee51b4038..cbfaa24f0 100644 --- a/Source/NrpnMessage.h +++ b/Source/NrpnMessage.h @@ -25,7 +25,7 @@ MIDI2LR. If not, see . class NRPN_Message { // This is a simplified NRPN message class, and assumes that all NRPN messages - // have 4 messages, though the NRPN standard allows ommission of the 4th + // have 4 messages, though the NRPN standard allows ommission of the 4th // message. If the 4th message is dropped, this class silently consumes the // message without emitting anything. public: diff --git a/Source/ProfileManager.cpp b/Source/ProfileManager.cpp index 75d8efdb2..d23b92986 100644 --- a/Source/ProfileManager.cpp +++ b/Source/ProfileManager.cpp @@ -83,11 +83,11 @@ void ProfileManager::switchToProfile(const juce::String& profile) { listener->profileChanged(xml_element.get(), profile); if (const auto ptr = lr_ipc_out_.lock()) { - auto command = juce::String{"ChangedToDirectory "} + - juce::File::addTrailingSeparator(profile_location_.getFullPathName()) + - juce::String{"\n"}; + std::string command = "ChangedToDirectory " + + juce::File::addTrailingSeparator(profile_location_.getFullPathName()).toStdString() + + '\n'; ptr->sendCommand(command); - command = juce::String("ChangedToFile ") + profile + juce::String("\n"); + command = "ChangedToFile " + profile.toStdString() + '\n'; ptr->sendCommand(command); } } @@ -95,7 +95,7 @@ void ProfileManager::switchToProfile(const juce::String& profile) { void ProfileManager::switchToNextProfile() { current_profile_index_++; - if (current_profile_index_ == static_cast(profiles_.size())) + if (current_profile_index_ == static_cast(profiles_.size())) current_profile_index_ = 0; switchToProfile(current_profile_index_); @@ -148,9 +148,9 @@ void ProfileManager::handleMidiNote(int midi_channel, int note) { } void ProfileManager::connected() { - const auto command = juce::String{"ChangedToDirectory "} + - juce::File::addTrailingSeparator(profile_location_.getFullPathName()) + - juce::String{"\n"}; + const std::string command = "ChangedToDirectory " + + juce::File::addTrailingSeparator(profile_location_.getFullPathName()).toStdString() + + '\n'; if (const auto ptr = lr_ipc_out_.lock()) { ptr->sendCommand(command); } diff --git a/Source/SendKeys.cpp b/Source/SendKeys.cpp index 95f83e378..bec6dcfc9 100644 --- a/Source/SendKeys.cpp +++ b/Source/SendKeys.cpp @@ -207,7 +207,7 @@ void SendKeys::SendKeyDownUp(const std::string& key, const bool alt_opt, for (const auto& c : key) lower_string.push_back(static_cast(std::tolower(c))); //c is char but tolower returns int #ifdef _WIN32 - + BYTE vk = 0; BYTE vk_modifiers = 0; if (SendKeys::key_map_.count(lower_string)) diff --git a/Source/SettingsComponent.h b/Source/SettingsComponent.h index dad4af98a..de055c059 100644 --- a/Source/SettingsComponent.h +++ b/Source/SettingsComponent.h @@ -26,10 +26,10 @@ MIDI2LR. If not, see . #include "ResizableLayout.h" #include "SettingsManager.h" -class SettingsComponent final: +class SettingsComponent final: public juce::Component, private juce::ButtonListener, - private ResizableLayout, + private ResizableLayout, private juce::Slider::Listener { public: SettingsComponent(); diff --git a/Source/SettingsManager.cpp b/Source/SettingsManager.cpp index 2db1f53d1..7b9069db1 100644 --- a/Source/SettingsManager.cpp +++ b/Source/SettingsManager.cpp @@ -61,7 +61,7 @@ void SettingsManager::setPickupEnabled(bool enabled) { properties_file_->saveIfNeeded(); if (const auto ptr = lr_ipc_out_.lock()) { - ptr->sendCommand(juce::String::formatted("Pickup %d\n", enabled)); + ptr->sendCommand("Pickup " + std::to_string(static_cast(enabled)) + '\n'); } } juce::String SettingsManager::getProfileDirectory() const noexcept { @@ -78,7 +78,7 @@ void SettingsManager::setProfileDirectory(const juce::String& profile_directory_ void SettingsManager::connected() { if (const auto ptr = lr_ipc_out_.lock()) { - ptr->sendCommand(juce::String::formatted("Pickup %d\n", getPickupEnabled())); + ptr->sendCommand("Pickup " + std::to_string(static_cast(getPickupEnabled())) + '\n'); } } diff --git a/Source/Utilities/Utilities.cpp b/Source/Utilities/Utilities.cpp new file mode 100644 index 000000000..61abd5408 --- /dev/null +++ b/Source/Utilities/Utilities.cpp @@ -0,0 +1,23 @@ +#include "Utilities.h" + +std::string RSJ::trim(const std::string& str, const std::string& what) { + auto front = str.find_first_not_of(what); + if (front == std::string::npos) + return std::string(); + auto back = str.find_last_not_of(what); + return str.substr(front, back - front + 1); +} + +std::string RSJ::ltrim(const std::string& str, const std::string& what) { + auto front = str.find_first_not_of(what); + if (front == std::string::npos) + return std::string(); + return str.substr(front); +} + +std::string RSJ::rtrim(const std::string& str, const std::string& what) { + auto back = str.find_last_not_of(what); + if (back == std::string::npos) + return std::string(); + return str.substr(0, back + 1); +} \ No newline at end of file diff --git a/Source/Utilities/Utilities.h b/Source/Utilities/Utilities.h index 9a62b947a..76cdfe394 100644 --- a/Source/Utilities/Utilities.h +++ b/Source/Utilities/Utilities.h @@ -25,6 +25,7 @@ static constexpr bool ndebug = false; #endif #include +#include #include #include namespace RSJ { @@ -136,3 +137,13 @@ class threadsafe_queue { return data_queue_.empty(); } }; + +namespace RSJ { + static const std::string space = " \t\n\v\f\r"; + static const std::string blank = " \t"; + static const std::string digit = "0123456789"; + + std::string trim(const std::string& str, const std::string& what = RSJ::digit); + std::string ltrim(const std::string& str, const std::string& what = RSJ::digit); + std::string rtrim(const std::string& str, const std::string& what = RSJ::digit); +}; From 4859544ce1fb9ecbbb51fd8e764219656f9f9c38 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sun, 17 Jul 2016 18:17:21 -0700 Subject: [PATCH 20/33] make juce::Timer handling consistent --- Source/LR_IPC_In.cpp | 9 +++++++-- Source/LR_IPC_In.h | 1 + Source/LR_IPC_Out.cpp | 2 +- Source/MainComponent.cpp | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/LR_IPC_In.cpp b/Source/LR_IPC_In.cpp index 0f1309b29..e7e5caf60 100644 --- a/Source/LR_IPC_In.cpp +++ b/Source/LR_IPC_In.cpp @@ -35,7 +35,11 @@ namespace { LR_IPC_IN::LR_IPC_IN(): juce::StreamingSocket{}, juce::Thread{"LR_IPC_IN"} {} LR_IPC_IN::~LR_IPC_IN() { - juce::Timer::stopTimer(); + { + std::lock_guard lock(timer_mutex_); + timer_off_ = true; + juce::Timer::stopTimer(); + } juce::Thread::stopThread(1000); juce::StreamingSocket::close(); } @@ -116,13 +120,14 @@ void LR_IPC_IN::run() { } //while not threadshouldexit threadExit: /* empty statement */; std::lock_guard lock(timer_mutex_); + timer_off_ = true; juce::Timer::stopTimer(); //thread_started_ = false; //don't change flag while depending upon it } void LR_IPC_IN::timerCallback() { std::lock_guard lock(timer_mutex_); - if (!juce::StreamingSocket::isConnected()) { + if (!juce::StreamingSocket::isConnected() && !timer_off_) { if (juce::StreamingSocket::connect("127.0.0.1", kLrInPort, kConnectTryTime)) if (!thread_started_) { juce::Thread::startThread(); //avoid starting thread during shutdown diff --git a/Source/LR_IPC_In.h b/Source/LR_IPC_In.h index 62ab6c671..d1f4c5d26 100644 --- a/Source/LR_IPC_In.h +++ b/Source/LR_IPC_In.h @@ -51,6 +51,7 @@ class LR_IPC_IN final: void processLine(const juce::String& line); bool thread_started_{false}; + bool timer_off_{false}; mutable std::mutex timer_mutex_; SendKeys send_keys_; std::shared_ptr command_map_{nullptr}; diff --git a/Source/LR_IPC_Out.cpp b/Source/LR_IPC_Out.cpp index e00b530d2..ef7c1e21b 100644 --- a/Source/LR_IPC_Out.cpp +++ b/Source/LR_IPC_Out.cpp @@ -36,8 +36,8 @@ LR_IPC_OUT::~LR_IPC_OUT() { std::lock_guard lock(timer_mutex_); timer_off_ = true; juce::Timer::stopTimer(); - juce::InterprocessConnection::disconnect(); } + juce::InterprocessConnection::disconnect(); command_map_.reset(); } diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index f2bd0374d..c602afe9b 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -357,5 +357,5 @@ void MainContentComponent::handleAsyncUpdate() { void MainContentComponent::timerCallback() { // reset the command label's background to white command_label_.setColour(juce::Label::backgroundColourId, juce::Colours::white); - stopTimer(); + juce::Timer::stopTimer(); } \ No newline at end of file From f60d2b169495431564f5052fbb328089755441e7 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sun, 17 Jul 2016 18:52:44 -0700 Subject: [PATCH 21/33] added contains for std::string --- Source/Utilities/Utilities.cpp | 2 +- Source/Utilities/Utilities.h | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Source/Utilities/Utilities.cpp b/Source/Utilities/Utilities.cpp index 61abd5408..1cfdfdbaa 100644 --- a/Source/Utilities/Utilities.cpp +++ b/Source/Utilities/Utilities.cpp @@ -20,4 +20,4 @@ std::string RSJ::rtrim(const std::string& str, const std::string& what) { if (back == std::string::npos) return std::string(); return str.substr(0, back + 1); -} \ No newline at end of file +} diff --git a/Source/Utilities/Utilities.h b/Source/Utilities/Utilities.h index 76cdfe394..c495a6e8a 100644 --- a/Source/Utilities/Utilities.h +++ b/Source/Utilities/Utilities.h @@ -137,13 +137,14 @@ class threadsafe_queue { return data_queue_.empty(); } }; - namespace RSJ { static const std::string space = " \t\n\v\f\r"; static const std::string blank = " \t"; static const std::string digit = "0123456789"; - - std::string trim(const std::string& str, const std::string& what = RSJ::digit); - std::string ltrim(const std::string& str, const std::string& what = RSJ::digit); - std::string rtrim(const std::string& str, const std::string& what = RSJ::digit); + std::string trim(const std::string& str, const std::string& what = RSJ::space); + std::string ltrim(const std::string& str, const std::string& what = RSJ::space); + std::string rtrim(const std::string& str, const std::string& what = RSJ::space); + inline bool contains(const std::string& str, const std::string& what = RSJ::space) { + return str.find_first_of(what) != std::string::npos; + } }; From c4c7fe08dec76eafa98c9e11e9b6d22b37063840 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sun, 17 Jul 2016 20:59:46 -0700 Subject: [PATCH 22/33] Make sure #includes are comprehensive--less likely to break compile with code changes --- Source/CommandMap.h | 2 ++ Source/CommandMenu.cpp | 2 +- Source/CommandMenu.h | 3 +++ Source/CommandTableModel.h | 3 ++- Source/LR_IPC_In.cpp | 1 + Source/LR_IPC_In.h | 3 +++ Source/LR_IPC_Out.h | 3 +++ Source/MIDIProcessor.h | 3 ++- Source/MIDISender.h | 3 ++- Source/Main.cpp | 1 + Source/MainComponent.h | 1 + Source/MainWindow.h | 1 + Source/ProfileManager.h | 2 ++ Source/SendKeys.cpp | 1 + Source/SendKeys.h | 1 + Source/SettingsComponent.h | 1 + Source/SettingsManager.h | 1 + Source/VersionChecker.h | 1 + 18 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Source/CommandMap.h b/Source/CommandMap.h index b83709262..680e11f57 100644 --- a/Source/CommandMap.h +++ b/Source/CommandMap.h @@ -22,6 +22,8 @@ MIDI2LR. If not, see . #ifndef COMMANDMAP_H_INCLUDED #define COMMANDMAP_H_INCLUDED + +#include #include #include "../JuceLibraryCode/JuceHeader.h" diff --git a/Source/CommandMenu.cpp b/Source/CommandMenu.cpp index 9a8c66d9d..4a45dc52b 100644 --- a/Source/CommandMenu.cpp +++ b/Source/CommandMenu.cpp @@ -47,7 +47,7 @@ CommandMenu::CommandMenu(const MIDI_Message& message): void CommandMenu::Init(std::shared_ptr& mapCommand) { //copy the pointer command_map_ = mapCommand; - addListener(this); + juce::Button::addListener(this); } void CommandMenu::setMsg(const MIDI_Message& message) noexcept { diff --git a/Source/CommandMenu.h b/Source/CommandMenu.h index 02d4d7505..8b8fbd7ba 100644 --- a/Source/CommandMenu.h +++ b/Source/CommandMenu.h @@ -21,7 +21,10 @@ MIDI2LR. If not, see . */ #ifndef COMMANDMENU_H_INCLUDED #define COMMANDMENU_H_INCLUDED + +#include #include +#include #include "../JuceLibraryCode/JuceHeader.h" #include "CommandMap.h" diff --git a/Source/CommandTableModel.h b/Source/CommandTableModel.h index f4c8811a7..5a78f71a1 100644 --- a/Source/CommandTableModel.h +++ b/Source/CommandTableModel.h @@ -22,8 +22,9 @@ MIDI2LR. If not, see . #ifndef COMMANDTABLEMODEL_H #define COMMANDTABLEMODEL_H -#include #include +#include +#include #include "../JuceLibraryCode/JuceHeader.h" #include "CommandMap.h" #include "CommandMenu.h" diff --git a/Source/LR_IPC_In.cpp b/Source/LR_IPC_In.cpp index e7e5caf60..668ab31aa 100644 --- a/Source/LR_IPC_In.cpp +++ b/Source/LR_IPC_In.cpp @@ -20,6 +20,7 @@ MIDI2LR. If not, see . */ #include "LR_IPC_In.h" #include +#include namespace { constexpr auto kBufferSize = 256; diff --git a/Source/LR_IPC_In.h b/Source/LR_IPC_In.h index d1f4c5d26..88d15aa12 100644 --- a/Source/LR_IPC_In.h +++ b/Source/LR_IPC_In.h @@ -21,6 +21,9 @@ MIDI2LR. If not, see . */ #ifndef LR_IPC_IN_H_INCLUDED #define LR_IPC_IN_H_INCLUDED + +#include +#include #include #include "../JuceLibraryCode/JuceHeader.h" #include "CommandMap.h" diff --git a/Source/LR_IPC_Out.h b/Source/LR_IPC_Out.h index b65a1458f..a42ca4906 100644 --- a/Source/LR_IPC_Out.h +++ b/Source/LR_IPC_Out.h @@ -22,7 +22,10 @@ MIDI2LR. If not, see . #ifndef LR_IPC_OUT_H_INCLUDED #define LR_IPC_OUT_H_INCLUDED +#include #include +#include +#include #include "../JuceLibraryCode/JuceHeader.h" #include "Utilities/Utilities.h" #include "CommandMap.h" diff --git a/Source/MIDIProcessor.h b/Source/MIDIProcessor.h index 3f64ffc0e..dc8a40732 100644 --- a/Source/MIDIProcessor.h +++ b/Source/MIDIProcessor.h @@ -22,7 +22,8 @@ MIDI2LR. If not, see . #ifndef MIDIPROCESSOR_H_INCLUDED #define MIDIPROCESSOR_H_INCLUDED #include -#include +#include +#include #include "../JuceLibraryCode/JuceHeader.h" #include "NrpnMessage.h" diff --git a/Source/MIDISender.h b/Source/MIDISender.h index bbd7527f1..2067ca662 100644 --- a/Source/MIDISender.h +++ b/Source/MIDISender.h @@ -21,7 +21,8 @@ MIDI2LR. If not, see . */ #ifndef MIDISENDER_H_INCLUDED #define MIDISENDER_H_INCLUDED - +#include +#include #include "../JuceLibraryCode/JuceHeader.h" class MIDISender { diff --git a/Source/Main.cpp b/Source/Main.cpp index 8e871eb76..a7a68ba08 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -28,6 +28,7 @@ MIDI2LR. If not, see . ============================================================================== */ +#include #include "../JuceLibraryCode/JuceHeader.h" #include "CommandMap.h" #include "LR_IPC_IN.h" diff --git a/Source/MainComponent.h b/Source/MainComponent.h index 6d13ef811..c4d1dd173 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -26,6 +26,7 @@ MIDI2LR. If not, see . #ifndef MAINCOMPONENT_H_INCLUDED #define MAINCOMPONENT_H_INCLUDED +#include #include "../JuceLibraryCode/JuceHeader.h" #include "CommandMap.h" #include "CommandTable.h" diff --git a/Source/MainWindow.h b/Source/MainWindow.h index 6a85995c0..d4dc348d3 100644 --- a/Source/MainWindow.h +++ b/Source/MainWindow.h @@ -23,6 +23,7 @@ MIDI2LR. If not, see . #ifndef MAINWINDOW_H_INCLUDED #define MAINWINDOW_H_INCLUDED +#include #include "../JuceLibraryCode/JuceHeader.h" #include "MainComponent.h" #include "SettingsManager.h" diff --git a/Source/ProfileManager.h b/Source/ProfileManager.h index ec707383f..946ccb071 100644 --- a/Source/ProfileManager.h +++ b/Source/ProfileManager.h @@ -22,6 +22,8 @@ MIDI2LR. If not, see . #ifndef PROFILEMANAGER_H_INCLUDED #define PROFILEMANAGER_H_INCLUDED +#include +#include #include "../JuceLibraryCode/JuceHeader.h" #include "CommandMap.h" #include "LR_IPC_OUT.h" diff --git a/Source/SendKeys.cpp b/Source/SendKeys.cpp index 95f83e378..db57864ca 100644 --- a/Source/SendKeys.cpp +++ b/Source/SendKeys.cpp @@ -20,6 +20,7 @@ MIDI2LR. If not, see . */ #include "SendKeys.h" #include +#include #include #ifdef _WIN32 #include "Windows.h" diff --git a/Source/SendKeys.h b/Source/SendKeys.h index 78a72f1bd..1ba2c4b48 100644 --- a/Source/SendKeys.h +++ b/Source/SendKeys.h @@ -21,6 +21,7 @@ MIDI2LR. If not, see . */ #include +#include #include class SendKeys { diff --git a/Source/SettingsComponent.h b/Source/SettingsComponent.h index dad4af98a..a11301d55 100644 --- a/Source/SettingsComponent.h +++ b/Source/SettingsComponent.h @@ -22,6 +22,7 @@ MIDI2LR. If not, see . #ifndef SETTINGSCOMPONENT_H_INCLUDED #define SETTINGSCOMPONENT_H_INCLUDED +#include #include "../JuceLibraryCode/JuceHeader.h" #include "ResizableLayout.h" #include "SettingsManager.h" diff --git a/Source/SettingsManager.h b/Source/SettingsManager.h index a73885e9c..b1d16f345 100644 --- a/Source/SettingsManager.h +++ b/Source/SettingsManager.h @@ -22,6 +22,7 @@ MIDI2LR. If not, see . #ifndef SETTINGSMANAGER_H_INCLUDED #define SETTINGSMANAGER_H_INCLUDED +#include #include "../JuceLibraryCode/JuceHeader.h" #include "LR_IPC_OUT.h" #include "ProfileManager.h" diff --git a/Source/VersionChecker.h b/Source/VersionChecker.h index 9ed1fe1c3..7fb937618 100644 --- a/Source/VersionChecker.h +++ b/Source/VersionChecker.h @@ -22,6 +22,7 @@ MIDI2LR. If not, see . #ifndef VERSIONCHECKER_H_INCLUDED #define VERSIONCHECKER_H_INCLUDED +#include #include "../JuceLibraryCode/JuceHeader.h" #include "SettingsManager.h" From 3ee6fb407b0c29c7efe1fbb398589230c6b28382 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sun, 17 Jul 2016 21:00:07 -0700 Subject: [PATCH 23/33] anonymous namespace for constexpr --- Source/MainComponent.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index c602afe9b..37f394367 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -22,10 +22,12 @@ MIDI2LR. If not, see . #include "MIDISender.h" #include "SettingsComponent.h" -constexpr auto kMainWidth = 400; -constexpr auto kMainHeight = 650; -constexpr auto kMainLeft = 20; -constexpr auto kSpaceBetweenButton = 10; +namespace { + constexpr auto kMainWidth = 400; + constexpr auto kMainHeight = 650; + constexpr auto kMainLeft = 20; + constexpr auto kSpaceBetweenButton = 10; +} MainContentComponent::MainContentComponent(): ResizableLayout{this} {} From 441de120d44cae0323b1b100752b986891cc5e92 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Sun, 17 Jul 2016 21:39:52 -0700 Subject: [PATCH 24/33] Pull out UI calculations making it easier to alter layout. --- Source/MainComponent.cpp | 53 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 37f394367..21a495edd 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -27,6 +27,22 @@ namespace { constexpr auto kMainHeight = 650; constexpr auto kMainLeft = 20; constexpr auto kSpaceBetweenButton = 10; + constexpr auto kStandardHeight = 20; + constexpr auto kFullWidth = kMainWidth - kMainLeft * 2; + constexpr auto kButtonWidth = (kFullWidth - kSpaceBetweenButton * 2) / 3; + constexpr auto kButtonXIncrement = kButtonWidth + kSpaceBetweenButton; + constexpr auto kConnectionLabelWidth = kMainWidth - kMainLeft - 200; + constexpr auto kFirstButtonX = kMainLeft; + constexpr auto kSecondButtonX = kMainLeft + kButtonXIncrement; + constexpr auto kThirdButtonX = kMainLeft + kButtonXIncrement * 2; + constexpr auto kCommandTableHeight = kMainHeight - 210; + constexpr auto kLabelWidth = kFullWidth / 2; + constexpr auto kProfileNameY = kMainHeight - 100; + constexpr auto kCommandLabelX = kMainLeft + kLabelWidth; + constexpr auto kCommandLabelY = kMainHeight - 100; + constexpr auto kRemoveRowY = kMainHeight - 75; + constexpr auto kRescanY = kMainHeight - 50; + constexpr auto kCurrentStatusY = kMainHeight - 30; } MainContentComponent::MainContentComponent(): ResizableLayout{this} {} @@ -74,13 +90,13 @@ void MainContentComponent::Init(std::shared_ptr& command_map, title_label_.setEditable(false); title_label_.setColour(juce::Label::textColourId, juce::Colours::darkgrey); title_label_.setComponentEffect(&title_shadow_); - title_label_.setBounds(kMainLeft, 10, kMainWidth - 2 * kMainLeft, 30); + title_label_.setBounds(kMainLeft, 10, kFullWidth, 30); addToLayout(&title_label_, anchorMidLeft, anchorMidRight); addAndMakeVisible(title_label_); // Version label SetLabelSettings(version_label_); - version_label_.setBounds(kMainLeft, 40, kMainWidth - 2 * kMainLeft, 10); + version_label_.setBounds(kMainLeft, 40, kFullWidth, 10); addToLayout(&version_label_, anchorMidLeft, anchorMidRight); addAndMakeVisible(version_label_); @@ -90,46 +106,37 @@ void MainContentComponent::Init(std::shared_ptr& command_map, connection_label_.setColour(juce::Label::backgroundColourId, juce::Colours::red); connection_label_.setColour(juce::Label::textColourId, juce::Colours::black); connection_label_.setJustificationType(juce::Justification::centred); - connection_label_.setBounds(200, 15, kMainWidth - kMainLeft - 200, 20); + connection_label_.setBounds(200, 15, kConnectionLabelWidth, kStandardHeight); addToLayout(&connection_label_, anchorMidLeft, anchorMidRight); addAndMakeVisible(connection_label_); - //get the button width - constexpr long button_width = - (kMainWidth - 2 * kMainLeft - kSpaceBetweenButton * 2) / 3; - // Load button load_button_.addListener(this); - load_button_.setBounds(kMainLeft, 60, button_width, 20); + load_button_.setBounds(kFirstButtonX, 60, kButtonWidth, kStandardHeight); addToLayout(&load_button_, anchorMidLeft, anchorMidRight); addAndMakeVisible(load_button_); // Save button save_button_.addListener(this); - save_button_.setBounds(kMainLeft + button_width + kSpaceBetweenButton, 60, - button_width, 20); + save_button_.setBounds(kSecondButtonX, 60, kButtonWidth, kStandardHeight); addToLayout(&save_button_, anchorMidLeft, anchorMidRight); addAndMakeVisible(save_button_); // Settings button settings_button_.addListener(this); - settings_button_.setBounds(kMainLeft + button_width * 2 + kSpaceBetweenButton * 2, - 60, button_width, 20); + settings_button_.setBounds(kThirdButtonX, 60, kButtonWidth, kStandardHeight); addToLayout(&settings_button_, anchorMidLeft, anchorMidRight); addAndMakeVisible(settings_button_); // Command Table command_table_.setModel(&command_table_model_); - command_table_.setBounds(kMainLeft, 100, kMainWidth - kMainLeft * 2, - kMainHeight - 210); + command_table_.setBounds(kMainLeft, 100, kFullWidth, kCommandTableHeight); addToLayout(&command_table_, anchorMidLeft, anchorMidRight); addAndMakeVisible(command_table_); - constexpr long label_width = (kMainWidth - kMainLeft * 2) / 2; - // Profile name label SetLabelSettings(profile_name_label_); - profile_name_label_.setBounds(kMainLeft, kMainHeight - 100, label_width, 20); + profile_name_label_.setBounds(kMainLeft, kProfileNameY, kLabelWidth, kStandardHeight); addToLayout(&profile_name_label_, anchorMidLeft, anchorMidRight); profile_name_label_.setJustificationType(juce::Justification::centred); addAndMakeVisible(profile_name_label_); @@ -138,28 +145,24 @@ void MainContentComponent::Init(std::shared_ptr& command_map, command_label_.setFont(juce::Font{12.f, juce::Font::bold}); command_label_.setEditable(false); command_label_.setColour(juce::Label::textColourId, juce::Colours::darkgrey); - command_label_.setBounds(kMainLeft + label_width, kMainHeight - 100, - label_width, 20); + command_label_.setBounds(kCommandLabelX, kCommandLabelY, kLabelWidth, kStandardHeight); addToLayout(&command_label_, anchorMidLeft, anchorMidRight); addAndMakeVisible(command_label_); // Remove row button remove_row_button_.addListener(this); - remove_row_button_.setBounds(kMainLeft, kMainHeight - 75, - kMainWidth - kMainLeft * 2, 20); + remove_row_button_.setBounds(kMainLeft, kRemoveRowY, kFullWidth, kStandardHeight); addToLayout(&remove_row_button_, anchorMidLeft, anchorMidRight); addAndMakeVisible(remove_row_button_); // Rescan MIDI button rescan_button_.addListener(this); - rescan_button_.setBounds(kMainLeft, kMainHeight - 50, - kMainWidth - kMainLeft * 2, 20); + rescan_button_.setBounds(kMainLeft, kRescanY, kFullWidth, kStandardHeight); addToLayout(&rescan_button_, anchorMidLeft, anchorMidRight); addAndMakeVisible(rescan_button_); // adding the current status label, used for counting down. - current_status_.setBounds(kMainLeft, kMainHeight - 30, - kMainWidth - kMainLeft * 2, 20); + current_status_.setBounds(kMainLeft, kCurrentStatusY, kFullWidth, kStandardHeight); addToLayout(¤t_status_, anchorMidLeft, anchorMidRight); current_status_.setJustificationType(juce::Justification::centred); SetLabelSettings(current_status_); From 7eaffa1a4895fdec234f73d0d20c9391cf372287 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Mon, 18 Jul 2016 00:55:56 -0700 Subject: [PATCH 25/33] Add utilities.cpp to project --- .../MacOSX/MIDI2LR.xcodeproj/project.pbxproj | 4 + Builds/VisualStudio2015/MIDI2LR.vcxproj | 1198 +++++++++-------- .../VisualStudio2015/MIDI2LR.vcxproj.filters | 111 +- MIDI2LR.jucer | 1 + 4 files changed, 704 insertions(+), 610 deletions(-) diff --git a/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj b/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj index 60916f9b2..a3aa7583c 100644 --- a/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj @@ -19,6 +19,7 @@ 58EB708FC7BA51BF0A98F592 = {isa = PBXBuildFile; fileRef = FD6C1589BB9EF20BD7D7154B; }; BDF535168645F120058193A9 = {isa = PBXBuildFile; fileRef = F3184CED9270796B369FA288; }; F9F594A69212D79B99AC9C66 = {isa = PBXBuildFile; fileRef = 78C490E72B571C45E9BF65BE; }; + AC84367CD5D5CED546873EA6 = {isa = PBXBuildFile; fileRef = 26B20138C8D26938DBF3AAA6; }; 50AF5769741041F9CA022231 = {isa = PBXBuildFile; fileRef = 80AD4E80805D14FC930C2AE8; }; FD5777A03748CDE3465E71D3 = {isa = PBXBuildFile; fileRef = C58E726D80235E018C2E6235; }; 65EAA878A18A9E490DC550DF = {isa = PBXBuildFile; fileRef = 0F1673C5F027441E02A71C9F; }; @@ -215,6 +216,7 @@ 25F9708EB0BD2290A58D55C9 = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = misc.h; path = "../../JuceLibraryCode/modules/juce_audio_formats/codecs/oggvorbis/libvorbis-1.3.2/lib/misc.h"; sourceTree = "SOURCE_ROOT"; }; 2616BAA9398A55F2403A1F9D = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_InterProcessLock.h"; path = "../../JuceLibraryCode/modules/juce_core/threads/juce_InterProcessLock.h"; sourceTree = "SOURCE_ROOT"; }; 2670C5A85BC1A871CA42E4BA = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_linux_ALSA.cpp"; path = "../../JuceLibraryCode/modules/juce_audio_devices/native/juce_linux_ALSA.cpp"; sourceTree = "SOURCE_ROOT"; }; + 26B20138C8D26938DBF3AAA6 = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Utilities.cpp; path = ../../Source/Utilities/Utilities.cpp; sourceTree = "SOURCE_ROOT"; }; 26D45E9B6952F802964B6CA4 = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = jfdctfst.c; path = "../../JuceLibraryCode/modules/juce_graphics/image_formats/jpglib/jfdctfst.c"; sourceTree = "SOURCE_ROOT"; }; 27256A0458D9274F9D4EF629 = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "juce_RuntimePermissions.h"; path = "../../JuceLibraryCode/modules/juce_core/misc/juce_RuntimePermissions.h"; sourceTree = "SOURCE_ROOT"; }; 274CABCF9258A98B15EAA69E = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_LAMEEncoderAudioFormat.cpp"; path = "../../JuceLibraryCode/modules/juce_audio_formats/codecs/juce_LAMEEncoderAudioFormat.cpp"; sourceTree = "SOURCE_ROOT"; }; @@ -1136,6 +1138,7 @@ FFA41BC763316E256DFB4D95 = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "juce_win32_DirectWriteTypeface.cpp"; path = "../../JuceLibraryCode/modules/juce_graphics/native/juce_win32_DirectWriteTypeface.cpp"; sourceTree = "SOURCE_ROOT"; }; 3A2ACD2C7AF27315DB53ADC3 = {isa = PBXGroup; children = ( 58066C9BCAFFE6B9CC18F8DD, + 26B20138C8D26938DBF3AAA6, D3EB9CABC0016989295F149B, ); name = Utilities; sourceTree = ""; }; 55BA6062DF892191C9E9B3BE = {isa = PBXGroup; children = ( 3A2ACD2C7AF27315DB53ADC3, @@ -2529,6 +2532,7 @@ BDF535168645F120058193A9, F9F594A69212D79B99AC9C66, ); runOnlyForDeploymentPostprocessing = 0; }; 5F5721809F326210B38EECA0 = {isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + AC84367CD5D5CED546873EA6, 50AF5769741041F9CA022231, FD5777A03748CDE3465E71D3, 65EAA878A18A9E490DC550DF, diff --git a/Builds/VisualStudio2015/MIDI2LR.vcxproj b/Builds/VisualStudio2015/MIDI2LR.vcxproj index 1c8c44c59..6b9ee1cc0 100644 --- a/Builds/VisualStudio2015/MIDI2LR.vcxproj +++ b/Builds/VisualStudio2015/MIDI2LR.vcxproj @@ -1,4 +1,5 @@ - + + @@ -14,7 +15,7 @@ {62CE7F88-4C2A-C448-873F-40363B88C6A3} v140 - + Application false @@ -26,10 +27,11 @@ true v140 - - + + - + v140 @@ -48,7 +50,7 @@ true true Win32 - + Disabled @@ -57,7 +59,7 @@ _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.3.0.1;JUCE_APP_VERSION_HEX=0x1030001;%(PreprocessorDefinitions) MultiThreadedDebug true - + $(IntDir)\ $(IntDir)\ $(IntDir)\ @@ -90,7 +92,7 @@ true true Win32 - + Full @@ -98,7 +100,7 @@ _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.3.0.1;JUCE_APP_VERSION_HEX=0x1030001;%(PreprocessorDefinitions) MultiThreaded true - + $(IntDir)\ $(IntDir)\ $(IntDir)\ @@ -127,26 +129,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + true @@ -1548,579 +1550,579 @@ true - - - - - - - - - - + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - + - - - \ No newline at end of file + + + diff --git a/Builds/VisualStudio2015/MIDI2LR.vcxproj.filters b/Builds/VisualStudio2015/MIDI2LR.vcxproj.filters index b0ef2e03d..8320193a7 100644 --- a/Builds/VisualStudio2015/MIDI2LR.vcxproj.filters +++ b/Builds/VisualStudio2015/MIDI2LR.vcxproj.filters @@ -1,4 +1,5 @@ - + + @@ -303,6 +304,9 @@ + + MIDI2LR\Source\Utilities + MIDI2LR\Source @@ -450,6 +454,9 @@ Juce Modules\juce_audio_basics + + Juce Modules\juce_audio_basics + Juce Modules\juce_audio_devices\audio_cd @@ -492,6 +499,12 @@ Juce Modules\juce_audio_devices\native + + Juce Modules\juce_audio_devices\native + + + Juce Modules\juce_audio_devices\native + Juce Modules\juce_audio_devices\native @@ -525,6 +538,9 @@ Juce Modules\juce_audio_devices + + Juce Modules\juce_audio_devices + Juce Modules\juce_audio_formats\codecs\flac\libFLAC @@ -696,6 +712,9 @@ Juce Modules\juce_audio_formats + + Juce Modules\juce_audio_formats + Juce Modules\juce_core\containers @@ -804,6 +823,21 @@ Juce Modules\juce_core\native + + Juce Modules\juce_core\native + + + Juce Modules\juce_core\native + + + Juce Modules\juce_core\native + + + Juce Modules\juce_core\native + + + Juce Modules\juce_core\native + Juce Modules\juce_core\native @@ -969,6 +1003,9 @@ Juce Modules\juce_core + + Juce Modules\juce_core + Juce Modules\juce_data_structures\app_properties @@ -993,6 +1030,9 @@ Juce Modules\juce_data_structures + + Juce Modules\juce_data_structures + Juce Modules\juce_events\broadcasters @@ -1026,9 +1066,15 @@ Juce Modules\juce_events\native + + Juce Modules\juce_events\native + Juce Modules\juce_events\native + + Juce Modules\juce_events\native + Juce Modules\juce_events\native @@ -1041,6 +1087,9 @@ Juce Modules\juce_events + + Juce Modules\juce_events + Juce Modules\juce_graphics\colour @@ -1317,6 +1366,12 @@ Juce Modules\juce_graphics\native + + Juce Modules\juce_graphics\native + + + Juce Modules\juce_graphics\native + Juce Modules\juce_graphics\native @@ -1335,6 +1390,9 @@ Juce Modules\juce_graphics + + Juce Modules\juce_graphics + Juce Modules\juce_gui_basics\application @@ -1563,6 +1621,12 @@ Juce Modules\juce_gui_basics\native + + Juce Modules\juce_gui_basics\native + + + Juce Modules\juce_gui_basics\native + Juce Modules\juce_gui_basics\native @@ -1572,6 +1636,21 @@ Juce Modules\juce_gui_basics\native + + Juce Modules\juce_gui_basics\native + + + Juce Modules\juce_gui_basics\native + + + Juce Modules\juce_gui_basics\native + + + Juce Modules\juce_gui_basics\native + + + Juce Modules\juce_gui_basics\native + Juce Modules\juce_gui_basics\native @@ -1692,6 +1771,9 @@ Juce Modules\juce_gui_basics + + Juce Modules\juce_gui_basics + Juce Modules\juce_gui_extra\code_editor @@ -1740,15 +1822,27 @@ Juce Modules\juce_gui_extra\native + + Juce Modules\juce_gui_extra\native + Juce Modules\juce_gui_extra\native Juce Modules\juce_gui_extra\native + + Juce Modules\juce_gui_extra\native + + + Juce Modules\juce_gui_extra\native + Juce Modules\juce_gui_extra\native + + Juce Modules\juce_gui_extra\native + Juce Modules\juce_gui_extra\native @@ -1761,6 +1855,9 @@ Juce Modules\juce_gui_extra + + Juce Modules\juce_gui_extra + Juce Library Code @@ -1791,7 +1888,6 @@ Juce Library Code - @@ -3441,15 +3537,6 @@ Juce Library Code - - - - - - - - - @@ -3476,4 +3563,4 @@ Juce Library Code - \ No newline at end of file + diff --git a/MIDI2LR.jucer b/MIDI2LR.jucer index 5ca0b514a..9e135420b 100644 --- a/MIDI2LR.jucer +++ b/MIDI2LR.jucer @@ -8,6 +8,7 @@ + From d1d00d4dff688fa4f23dd37e3b2ceefd36d59e96 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Mon, 18 Jul 2016 18:07:12 -0700 Subject: [PATCH 26/33] Add headers for standard library fix some compile and linking issuess --- Source/CommandMap.cpp | 14 ++-- Source/CommandMap.h | 17 ++--- Source/CommandTableModel.cpp | 5 +- Source/CommandTableModel.h | 4 +- Source/LRCommands.cpp | 4 +- Source/LRCommands.h | 1 + Source/LR_IPC_In.h | 1 + Source/LR_IPC_Out.cpp | 6 +- Source/LR_IPC_Out.h | 1 + Source/MIDIProcessor.cpp | 12 ++-- Source/MIDISender.cpp | 4 +- Source/Main.cpp | 1 + Source/MainComponent.cpp | 44 +++++++------ Source/MainComponent.h | 2 +- Source/MainWindow.cpp | 1 + Source/ProfileManager.cpp | 6 +- Source/ResizableLayout.cpp | 4 +- Source/ResizableLayout.h | 6 +- Source/SendKeys.cpp | 1 - Source/SettingsComponent.cpp | 1 + Source/SettingsManager.cpp | 2 + Source/Utilities/Utilities.h | 121 ++++++++++++++++++----------------- Source/VersionChecker.cpp | 1 + 23 files changed, 138 insertions(+), 121 deletions(-) diff --git a/Source/CommandMap.cpp b/Source/CommandMap.cpp index 9d69d0999..105a69d54 100644 --- a/Source/CommandMap.cpp +++ b/Source/CommandMap.cpp @@ -24,7 +24,7 @@ MIDI2LR. If not, see . CommandMap::CommandMap() noexcept {} -void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message &message) { +void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message& message) { // adds a message to the message:command map, and its associated command to the // command:message map if (command < LRCommandList::LRStringList.size()) { @@ -35,16 +35,16 @@ void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message & message_map_[message] = LRCommandList::NextPrevProfile[command - LRCommandList::LRStringList.size()]; } -void CommandMap::addCommandforMessage(const std::string& command, const MIDI_Message &message) { +void CommandMap::addCommandforMessage(const std::string& command, const MIDI_Message& message) { message_map_[message] = command; command_string_map_[command] = message; } -const std::string& CommandMap::getCommandforMessage(const MIDI_Message &message) const { +const std::string& CommandMap::getCommandforMessage(const MIDI_Message& message) const { return message_map_.at(message); } -void CommandMap::removeMessage(const MIDI_Message &message) { +void CommandMap::removeMessage(const MIDI_Message& message) { // removes message from the message:command map, and its associated command from // the command:message map command_string_map_.erase(message_map_[message]); @@ -56,14 +56,14 @@ void CommandMap::clearMap() noexcept { message_map_.clear(); } -bool CommandMap::messageExistsInMap(const MIDI_Message &message) const { +bool CommandMap::messageExistsInMap(const MIDI_Message& message) const { return message_map_.count(message) > 0 ? true : false; } -const MIDI_Message& CommandMap::getMessageForCommand(const std::string &command) const { +const MIDI_Message& CommandMap::getMessageForCommand(const std::string& command) const { return command_string_map_.at(command); } -bool CommandMap::commandHasAssociatedMessage(const std::string &command) const { +bool CommandMap::commandHasAssociatedMessage(const std::string& command) const { return command_string_map_.count(command) > 0 ? true : false; } void CommandMap::toXMLDocument(juce::File& file) const { diff --git a/Source/CommandMap.h b/Source/CommandMap.h index 16f01005e..67c29795a 100644 --- a/Source/CommandMap.h +++ b/Source/CommandMap.h @@ -24,6 +24,7 @@ MIDI2LR. If not, see . #define COMMANDMAP_H_INCLUDED #include +#include #include #include "../JuceLibraryCode/JuceHeader.h" @@ -47,7 +48,7 @@ struct MIDI_Message { isCC(iscc), data(dat) {} - bool operator==(const MIDI_Message &other) const noexcept { + bool operator==(const MIDI_Message& other) const noexcept { return (isCC == other.isCC && channel == other.channel && data == other.data); } @@ -80,30 +81,30 @@ class CommandMap { // adds an entry to the message:command map, and a corresponding entry to the // command:message map will look up the string by the index (but it is preferred to // directly use the string) - void addCommandforMessage(unsigned int command, const MIDI_Message &cc); + void addCommandforMessage(unsigned int command, const MIDI_Message& cc); // adds an entry to the message:command map, and a corresponding entry to the // command:message map - void addCommandforMessage(const std::string &command, const MIDI_Message &cc); + void addCommandforMessage(const std::string& command, const MIDI_Message& cc); // gets the LR command associated to a MIDI message - const std::string& getCommandforMessage(const MIDI_Message &message) const; + const std::string& getCommandforMessage(const MIDI_Message& message) const; // in the command:message map // removes a MIDI message from the message:command map, and it's associated entry - void removeMessage(const MIDI_Message &message); + void removeMessage(const MIDI_Message& message); // clears both message:command and command:message maps void clearMap() noexcept; // returns true if there is a mapping for a particular MIDI message - bool messageExistsInMap(const MIDI_Message &message) const; + bool messageExistsInMap(const MIDI_Message& message) const; // gets the MIDI message associated to a LR command - const MIDI_Message& getMessageForCommand(const std::string &command) const; + const MIDI_Message& getMessageForCommand(const std::string& command) const; // returns true if there is a mapping for a particular LR command - bool commandHasAssociatedMessage(const std::string &command) const; + bool commandHasAssociatedMessage(const std::string& command) const; // saves the message:command map as an XML file void toXMLDocument(juce::File& file) const; diff --git a/Source/CommandTableModel.cpp b/Source/CommandTableModel.cpp index 10f2c0f7d..b00e11fb7 100644 --- a/Source/CommandTableModel.cpp +++ b/Source/CommandTableModel.cpp @@ -19,6 +19,7 @@ MIDI2LR. If not, see . ============================================================================== */ #include "CommandTableModel.h" +#include #include "LRCommands.h" CommandTableModel::CommandTableModel() noexcept {} @@ -50,7 +51,7 @@ int CommandTableModel::getNumRows() { return commands_.size(); } -void CommandTableModel::paintRowBackground(juce::Graphics &g, int /*rowNumber*/, +void CommandTableModel::paintRowBackground(juce::Graphics& g, int /*rowNumber*/, int /*width*/, int /*height*/, bool row_is_selected) { //This must draw the background behind one of the rows in the table. @@ -63,7 +64,7 @@ void CommandTableModel::paintRowBackground(juce::Graphics &g, int /*rowNumber*/, g.fillAll(juce::Colours::lightblue); } -void CommandTableModel::paintCell(juce::Graphics &g, int row_number, int column_id, +void CommandTableModel::paintCell(juce::Graphics& g, int row_number, int column_id, int width, int height, bool /*rowIsSelected*/) { //This must draw one of the cells. diff --git a/Source/CommandTableModel.h b/Source/CommandTableModel.h index 5a78f71a1..3dc1d046f 100644 --- a/Source/CommandTableModel.h +++ b/Source/CommandTableModel.h @@ -37,9 +37,9 @@ class CommandTableModel final: public juce::TableListBoxModel { // TableListBoxModel overrides virtual void sortOrderChanged(int newSortColumnId, bool isForwards) override; virtual int getNumRows() override; - virtual void paintRowBackground(juce::Graphics &, int rowNumber, int width, + virtual void paintRowBackground(juce::Graphics&, int rowNumber, int width, int height, bool rowIsSelected) override; - virtual void paintCell(juce::Graphics &, int rowNumber, int columnId, int width, + virtual void paintCell(juce::Graphics&, int rowNumber, int columnId, int width, int height, bool rowIsSelected) override; virtual juce::Component *refreshComponentForCell(int rowNumber, int columnId, bool isRowSelected, juce::Component *existingComponentToUpdate) override; diff --git a/Source/LRCommands.cpp b/Source/LRCommands.cpp index aad3d4231..0c08edf10 100644 --- a/Source/LRCommands.cpp +++ b/Source/LRCommands.cpp @@ -1037,10 +1037,10 @@ int LRCommandList::getIndexOfCommand(const std::string& command) { // better to check for empty then length, as empty has a constant run time behavior. if (indexMap.empty()) { int idx = 0; - for (auto &str : LRStringList) + for (const auto& str : LRStringList) indexMap[str] = idx++; - for (auto &str : NextPrevProfile) + for (const auto& str : NextPrevProfile) indexMap[str] = idx++; } diff --git a/Source/LRCommands.h b/Source/LRCommands.h index 76a87dc0b..191b18fde 100644 --- a/Source/LRCommands.h +++ b/Source/LRCommands.h @@ -22,6 +22,7 @@ MIDI2LR. If not, see . #ifndef LRCOMMANDS_H_INCLUDED #define LRCOMMANDS_H_INCLUDED +#include #include #include "../JuceLibraryCode/JuceHeader.h" diff --git a/Source/LR_IPC_In.h b/Source/LR_IPC_In.h index ca08abfd5..4465269bf 100644 --- a/Source/LR_IPC_In.h +++ b/Source/LR_IPC_In.h @@ -24,6 +24,7 @@ MIDI2LR. If not, see . #include #include +#include #include #include "../JuceLibraryCode/JuceHeader.h" #include "CommandMap.h" diff --git a/Source/LR_IPC_Out.cpp b/Source/LR_IPC_Out.cpp index eae7ddc6f..742c3cab7 100644 --- a/Source/LR_IPC_Out.cpp +++ b/Source/LR_IPC_Out.cpp @@ -55,7 +55,7 @@ void LR_IPC_OUT::Init(std::shared_ptr& command_map, } void LR_IPC_OUT::addListener(LRConnectionListener *listener) { - for (auto current_listener : listeners_) + for (const auto current_listener : listeners_) if (current_listener == listener) return; //don't add duplicates listeners_.push_back(listener); @@ -115,12 +115,12 @@ void LR_IPC_OUT::handleMidiNote(int midi_channel, int note) { } void LR_IPC_OUT::connectionMade() { - for (auto listener : listeners_) + for (const auto& listener : listeners_) listener->connected(); } void LR_IPC_OUT::connectionLost() { - for (auto listener : listeners_) + for (const auto& listener : listeners_) listener->disconnected(); } diff --git a/Source/LR_IPC_Out.h b/Source/LR_IPC_Out.h index 862eb1bd9..aa1e13747 100644 --- a/Source/LR_IPC_Out.h +++ b/Source/LR_IPC_Out.h @@ -24,6 +24,7 @@ MIDI2LR. If not, see . #include #include +#include #include #include #include "../JuceLibraryCode/JuceHeader.h" diff --git a/Source/MIDIProcessor.cpp b/Source/MIDIProcessor.cpp index 154c36349..c62456b53 100644 --- a/Source/MIDIProcessor.cpp +++ b/Source/MIDIProcessor.cpp @@ -29,7 +29,7 @@ void MIDIProcessor::Init(void) { } void MIDIProcessor::handleIncomingMidiMessage(juce::MidiInput * /*device*/, - const juce::MidiMessage &message) { + const juce::MidiMessage& message) { if (message.isController()) { const auto channel = static_cast(message.getChannel()); // 1-based @@ -39,32 +39,32 @@ void MIDIProcessor::handleIncomingMidiMessage(juce::MidiInput * /*device*/, static_cast(message.getControllerValue()); if (nrpn_filter_.ProcessMidi(channel, control, value)) { //true if nrpn piece if (nrpn_filter_.IsReady(channel)) { //send when finished - for (auto const& listener : listeners_) + for (const auto& listener : listeners_) listener->handleMidiCC(channel, nrpn_filter_.GetControl(channel), nrpn_filter_.GetValue(channel)); nrpn_filter_.Clear(channel); } } else //regular message - for (auto const& listener : listeners_) + for (const auto& listener : listeners_) listener->handleMidiCC(channel, control, value); } else if (message.isNoteOn()) { - for (auto const& listener : listeners_) { + for (const auto& listener : listeners_) { listener->handleMidiNote(message.getChannel(), message.getNoteNumber()); } } } void MIDIProcessor::addMIDICommandListener(MIDICommandListener* listener) { - for (auto const& current_listener : listeners_) + for (const auto& current_listener : listeners_) if (current_listener == listener) return; //don't add duplicates listeners_.push_back(listener); } void MIDIProcessor::RescanDevices() { - for (auto const& dev : devices_) + for (const auto& dev : devices_) dev->stop(); devices_.clear(); diff --git a/Source/MIDISender.cpp b/Source/MIDISender.cpp index d4580865d..5958dbe0f 100644 --- a/Source/MIDISender.cpp +++ b/Source/MIDISender.cpp @@ -30,7 +30,7 @@ void MIDISender::Init(void) { void MIDISender::sendCC(int midi_channel, int controller, int value) const { if (controller < 128) { // regular message - for (auto& dev : output_devices_) + for (const auto& dev : output_devices_) dev->sendMessageNow(juce::MidiMessage::controllerEvent(midi_channel, controller, value)); } @@ -39,7 +39,7 @@ void MIDISender::sendCC(int midi_channel, int controller, int value) const { const auto parameterMSB = (controller >> 7) & 0x7F; const auto valueLSB = value & 0x7f; const auto valueMSB = (value >> 7) & 0x7F; - for (auto& dev : output_devices_) { + for (const auto& dev : output_devices_) { dev->sendMessageNow(juce::MidiMessage::controllerEvent(midi_channel, 99, parameterMSB)); dev->sendMessageNow(juce::MidiMessage::controllerEvent(midi_channel, 98, parameterLSB)); dev->sendMessageNow(juce::MidiMessage::controllerEvent(midi_channel, 6, valueMSB)); diff --git a/Source/Main.cpp b/Source/Main.cpp index a7a68ba08..59c6b8081 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp @@ -28,6 +28,7 @@ MIDI2LR. If not, see . ============================================================================== */ +#include #include #include "../JuceLibraryCode/JuceHeader.h" #include "CommandMap.h" diff --git a/Source/MainComponent.cpp b/Source/MainComponent.cpp index 6b0d1744a..2a576989e 100644 --- a/Source/MainComponent.cpp +++ b/Source/MainComponent.cpp @@ -19,30 +19,32 @@ MIDI2LR. If not, see . ============================================================================== */ #include "MainComponent.h" +#include +#include #include "MIDISender.h" #include "SettingsComponent.h" namespace { - constexpr auto kMainWidth = 400; - constexpr auto kMainHeight = 650; - constexpr auto kMainLeft = 20; - constexpr auto kSpaceBetweenButton = 10; - constexpr auto kStandardHeight = 20; - constexpr auto kFullWidth = kMainWidth - kMainLeft * 2; - constexpr auto kButtonWidth = (kFullWidth - kSpaceBetweenButton * 2) / 3; - constexpr auto kButtonXIncrement = kButtonWidth + kSpaceBetweenButton; - constexpr auto kConnectionLabelWidth = kMainWidth - kMainLeft - 200; - constexpr auto kFirstButtonX = kMainLeft; - constexpr auto kSecondButtonX = kMainLeft + kButtonXIncrement; - constexpr auto kThirdButtonX = kMainLeft + kButtonXIncrement * 2; - constexpr auto kCommandTableHeight = kMainHeight - 210; - constexpr auto kLabelWidth = kFullWidth / 2; - constexpr auto kProfileNameY = kMainHeight - 100; - constexpr auto kCommandLabelX = kMainLeft + kLabelWidth; - constexpr auto kCommandLabelY = kMainHeight - 100; - constexpr auto kRemoveRowY = kMainHeight - 75; - constexpr auto kRescanY = kMainHeight - 50; - constexpr auto kCurrentStatusY = kMainHeight - 30; + constexpr int kMainWidth = 400; + constexpr int kMainHeight = 650; + constexpr int kMainLeft = 20; + constexpr int kSpaceBetweenButton = 10; + constexpr int kStandardHeight = 20; + constexpr int kFullWidth = kMainWidth - kMainLeft * 2; + constexpr int kButtonWidth = (kFullWidth - kSpaceBetweenButton * 2) / 3; + constexpr int kButtonXIncrement = kButtonWidth + kSpaceBetweenButton; + constexpr int kConnectionLabelWidth = kMainWidth - kMainLeft - 200; + constexpr int kFirstButtonX = kMainLeft; + constexpr int kSecondButtonX = kMainLeft + kButtonXIncrement; + constexpr int kThirdButtonX = kMainLeft + kButtonXIncrement * 2; + constexpr int kCommandTableHeight = kMainHeight - 210; + constexpr int kLabelWidth = kFullWidth / 2; + constexpr int kProfileNameY = kMainHeight - 100; + constexpr int kCommandLabelX = kMainLeft + kLabelWidth; + constexpr int kCommandLabelY = kMainHeight - 100; + constexpr int kRemoveRowY = kMainHeight - 75; + constexpr int kRescanY = kMainHeight - 50; + constexpr int kCurrentStatusY = kMainHeight - 30; } MainContentComponent::MainContentComponent(): ResizableLayout{this} {} @@ -342,7 +344,7 @@ void MainContentComponent::SetTimerText(int time_value) { } } -void MainContentComponent::SetLabelSettings(juce::Label &label_to_set) { +void MainContentComponent::SetLabelSettings(juce::Label& label_to_set) { label_to_set.setFont(juce::Font{12.f, juce::Font::bold}); label_to_set.setEditable(false); label_to_set.setColour(juce::Label::textColourId, juce::Colours::darkgrey); diff --git a/Source/MainComponent.h b/Source/MainComponent.h index b1fab92c6..02dbae2fe 100644 --- a/Source/MainComponent.h +++ b/Source/MainComponent.h @@ -71,7 +71,7 @@ class MainContentComponent final: void SetTimerText(int time_value); protected: - void SetLabelSettings(juce::Label &lblToSet); + void SetLabelSettings(juce::Label& lblToSet); private: void paint(juce::Graphics&) override; diff --git a/Source/MainWindow.cpp b/Source/MainWindow.cpp index 0614c113f..6c90d8918 100644 --- a/Source/MainWindow.cpp +++ b/Source/MainWindow.cpp @@ -20,6 +20,7 @@ MIDI2LR. If not, see . */ #include "MainWindow.h" +#include void MainWindow::Init(std::shared_ptr& command_map, std::weak_ptr&& lr_ipc_in, diff --git a/Source/ProfileManager.cpp b/Source/ProfileManager.cpp index d23b92986..b73cfb817 100644 --- a/Source/ProfileManager.cpp +++ b/Source/ProfileManager.cpp @@ -19,6 +19,8 @@ MIDI2LR. If not, see . ============================================================================== */ #include "ProfileManager.h" +#include +#include #include "LRCommands.h" ProfileManager::ProfileManager() noexcept {} @@ -42,7 +44,7 @@ void ProfileManager::Init(std::weak_ptr&& out, } void ProfileManager::addListener(ProfileChangeListener *listener) { - for (auto current_listener : listeners_) + for (const auto& current_listener : listeners_) if (current_listener == listener) return; //don't add duplicates listeners_.push_back(listener); @@ -79,7 +81,7 @@ void ProfileManager::switchToProfile(const juce::String& profile) { if (profile_file.exists()) { std::unique_ptr xml_element{juce::XmlDocument::parse(profile_file)}; - for (auto listener : listeners_) + for (const auto& listener : listeners_) listener->profileChanged(xml_element.get(), profile); if (const auto ptr = lr_ipc_out_.lock()) { diff --git a/Source/ResizableLayout.cpp b/Source/ResizableLayout.cpp index 2f5b631c6..4a7ba4662 100644 --- a/Source/ResizableLayout.cpp +++ b/Source/ResizableLayout.cpp @@ -91,8 +91,8 @@ ResizableLayout::ResizableLayout(Component* owner) ResizableLayout::~ResizableLayout() {} void ResizableLayout::addToLayout(Component* component, - const Point &topLeft, - const Point &bottomRight, + const Point& topLeft, + const Point& bottomRight, Style style) { jassert(topLeft != anchorNone); diff --git a/Source/ResizableLayout.h b/Source/ResizableLayout.h index 4d0f7e0f6..81b1f2c48 100644 --- a/Source/ResizableLayout.h +++ b/Source/ResizableLayout.h @@ -172,8 +172,8 @@ class ResizableLayout // use the constant anchorMidRight void addToLayout( Component *component, - const Point &topLeft, - const Point &bottomRight = anchorNone, + const Point& topLeft, + const Point& bottomRight = anchorNone, Style style = styleStretch); // Remove a Component from the Layout. @@ -209,7 +209,7 @@ class ResizableLayout Rect(int top0, int left0, int bottom0, int right0) { top = top0; left = left0; bottom = bottom0; right = right0; } - Rect(const Rectangle &r) { + Rect(const Rectangle& r) { top = int(r.getY()); left = int(r.getX()); bottom = int(r.getBottom()); right = int(r.getRight()); } operator Rectangle() const { diff --git a/Source/SendKeys.cpp b/Source/SendKeys.cpp index 1d6d190d4..603914169 100644 --- a/Source/SendKeys.cpp +++ b/Source/SendKeys.cpp @@ -28,7 +28,6 @@ MIDI2LR. If not, see . #import #import #import -#include #include #endif namespace { diff --git a/Source/SettingsComponent.cpp b/Source/SettingsComponent.cpp index 8d1e7e674..d32ea7364 100644 --- a/Source/SettingsComponent.cpp +++ b/Source/SettingsComponent.cpp @@ -20,6 +20,7 @@ MIDI2LR. If not, see . */ #include "SettingsComponent.h" +#include #include "../JuceLibraryCode/JuceHeader.h" namespace { diff --git a/Source/SettingsManager.cpp b/Source/SettingsManager.cpp index 7b9069db1..3885437f7 100644 --- a/Source/SettingsManager.cpp +++ b/Source/SettingsManager.cpp @@ -19,6 +19,8 @@ MIDI2LR. If not, see . ============================================================================== */ #include "SettingsManager.h" +#include +#include #include "ProfileManager.h" const juce::String AutoHideSection{"autohide"}; diff --git a/Source/Utilities/Utilities.h b/Source/Utilities/Utilities.h index c495a6e8a..ef5368ebb 100644 --- a/Source/Utilities/Utilities.h +++ b/Source/Utilities/Utilities.h @@ -26,8 +26,11 @@ static constexpr bool ndebug = false; #include #include +#include #include #include +#include +#include namespace RSJ { template struct counter { @@ -51,7 +54,7 @@ namespace RSJ { }; template std::atomic_int counter::objects_created(0); template std::atomic_int counter::objects_alive(0); -} + /* Usage: @@ -61,7 +64,7 @@ class X : RSJ::counter }; */ -namespace RSJ { + class spinlock { std::atomic_flag flag{ATOMIC_FLAG_INIT}; public: @@ -73,7 +76,7 @@ namespace RSJ { flag.clear(std::memory_order_release); } }; -} + /* Usage void foo() { @@ -83,61 +86,61 @@ lock_guard guard(lock); } */ -template -class threadsafe_queue { -private: - bool other_notification_{false}; - mutable std::mutex mut_; - std::condition_variable data_cond_; - std::queue data_queue_; -public: - threadsafe_queue() {} - void NotifyOther() { - other_notification_ = true; - data_cond_.notify_all(); - } - void push(T new_value) { - std::lock_guard lk(mut_); - data_queue_.push(std::move(new_value)) - ; data_cond_.notify_one(); - } - void wait_and_pop(T& value) { - std::unique_lock lk(mut_); - data_cond_.wait(lk, [this] {return !data_queue_.empty(); }); - value = std::move(data_queue_.front()); - data_queue_.pop(); - } - std::shared_ptr wait_and_pop() { - std::unique_lock lk(mut_); - data_cond_.wait(lk, [this] {return !data_queue_.empty(); }); - std::shared_ptr res( - std::make_shared(std::move(data_queue_.front()))); - data_queue_.pop(); - return res; - } - bool try_pop(T& value) { - std::lock_guard lk(mut_); - if (data_queue_.empty()) - return false; - value = std::move(data_queue_.front()); - data_queue_.pop(); - return true; - } - std::shared_ptr try_pop() { - std::lock_guard lk(mut_); - if (data_queue_.empty()) - return std::shared_ptr(); - std::shared_ptr res( - std::make_shared(std::move(data_queue_.front()))); - data_queue_.pop(); - return res; - } - bool empty() const { - std::lock_guard lk(mut_); - return data_queue_.empty(); - } -}; -namespace RSJ { + template + class threadsafe_queue { + private: + bool other_notification_{false}; + mutable std::mutex mut_; + std::condition_variable data_cond_; + std::queue data_queue_; + public: + threadsafe_queue() {} + void NotifyOther() { + other_notification_ = true; + data_cond_.notify_all(); + } + void push(T new_value) { + std::lock_guard lk(mut_); + data_queue_.push(std::move(new_value)) + ; data_cond_.notify_one(); + } + void wait_and_pop(T& value) { + std::unique_lock lk(mut_); + data_cond_.wait(lk, [this] {return !data_queue_.empty(); }); + value = std::move(data_queue_.front()); + data_queue_.pop(); + } + std::shared_ptr wait_and_pop() { + std::unique_lock lk(mut_); + data_cond_.wait(lk, [this] {return !data_queue_.empty(); }); + std::shared_ptr res( + std::make_shared(std::move(data_queue_.front()))); + data_queue_.pop(); + return res; + } + bool try_pop(T& value) { + std::lock_guard lk(mut_); + if (data_queue_.empty()) + return false; + value = std::move(data_queue_.front()); + data_queue_.pop(); + return true; + } + std::shared_ptr try_pop() { + std::lock_guard lk(mut_); + if (data_queue_.empty()) + return std::shared_ptr(); + std::shared_ptr res( + std::make_shared(std::move(data_queue_.front()))); + data_queue_.pop(); + return res; + } + bool empty() const { + std::lock_guard lk(mut_); + return data_queue_.empty(); + } + }; + static const std::string space = " \t\n\v\f\r"; static const std::string blank = " \t"; static const std::string digit = "0123456789"; @@ -147,4 +150,4 @@ namespace RSJ { inline bool contains(const std::string& str, const std::string& what = RSJ::space) { return str.find_first_of(what) != std::string::npos; } -}; +} diff --git a/Source/VersionChecker.cpp b/Source/VersionChecker.cpp index b4faf2f3d..ef1653cef 100644 --- a/Source/VersionChecker.cpp +++ b/Source/VersionChecker.cpp @@ -19,6 +19,7 @@ MIDI2LR. If not, see . ============================================================================== */ #include "VersionChecker.h" +#include VersionChecker::VersionChecker() noexcept : juce::Thread{"VersionChecker"} {} From c1177110d7eb79cda3e9523447b7e32e33f1b3f3 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Thu, 21 Jul 2016 20:07:07 -0400 Subject: [PATCH 27/33] simplify keycode for osx debugging --- Source/SendKeys.cpp | 46 ++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/Source/SendKeys.cpp b/Source/SendKeys.cpp index 603914169..300de9572 100644 --- a/Source/SendKeys.cpp +++ b/Source/SendKeys.cpp @@ -19,6 +19,7 @@ MIDI2LR. If not, see . ============================================================================== */ #include "SendKeys.h" +#include #include #include #include @@ -31,6 +32,12 @@ MIDI2LR. If not, see . #include #endif namespace { + std::string to_lower(const std::string& in) { + auto s = in; + std::transform(s.begin(), s.end(), s.begin(), std::tolower); + return s; + } + #ifdef _WIN32 wchar_t MBtoWChar(const std::string& key) { wchar_t full_character; @@ -203,15 +210,16 @@ std::mutex SendKeys::mutex_sending_{}; void SendKeys::SendKeyDownUp(const std::string& key, const bool alt_opt, const bool control_cmd, const bool shift) const { - std::string lower_string; //used for matching with key names - for (const auto& c : key) - lower_string.push_back(static_cast(std::tolower(c))); //c is char but tolower returns int + + const auto mapped_key = SendKeys::key_map_.find(to_lower(key)); + const auto in_keymap = mapped_key != SendKeys::key_map_.end(); + #ifdef _WIN32 BYTE vk = 0; BYTE vk_modifiers = 0; - if (SendKeys::key_map_.count(lower_string)) - vk = SendKeys::key_map_.at(lower_string); + if (in_keymap) + vk = mapped_key->second; else {// Translate key code to keyboard-dependent scan code, may be UTF-8 const auto language_id = GetLanguage("Lightroom"); const auto vk_code_and_shift = VkKeyScanExW(MBtoWChar(key), language_id); @@ -262,12 +270,17 @@ void SendKeys::SendKeyDownUp(const std::string& key, const bool alt_opt, #else const CGEventSourceRef source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); + CGEventRef d; CGEventRef u; + + CGEventRef cmdd = CGEventCreateKeyboardEvent(source, kVK_Command, true); + CGEventRef cmdu = CGEventCreateKeyboardEvent(source, kVK_Command, false); + uint64_t flags = 0; - if (SendKeys::key_map_.count(lower_string)) { - auto vk = SendKeys::key_map_.at(lower_string); + if (in_keymap) { + auto vk = mapped_key->second; d = CGEventCreateKeyboardEvent(source, vk, true); u = CGEventCreateKeyboardEvent(source, vk, false); } @@ -287,20 +300,19 @@ void SendKeys::SendKeyDownUp(const std::string& key, const bool alt_opt, CGEventSetFlags(d, static_cast(flags)); CGEventSetFlags(u, static_cast(flags)); } - CGEventRef cmdd = CGEventCreateKeyboardEvent(source, kVK_Command, true); - CGEventRef cmdu = CGEventCreateKeyboardEvent(source, kVK_Command, false); - { //restrict scope for mutex lock - constexpr CGEventTapLocation loc = kCGHIDEventTap; // kCGSessionEventTap also works + constexpr CGEventTapLocation loc = kCGSessionEventTap; + if (flags & kCGEventFlagMaskCommand) { + std::lock_guard lock(mutex_sending_); + CGEventPost(loc, cmdd); + CGEventPost(loc, d); + CGEventPost(loc, u); + CGEventPost(loc, cmdu); + } + else { std::lock_guard lock(mutex_sending_); - if (flags & kCGEventFlagMaskCommand) { - CGEventPost(loc, cmdd); - } CGEventPost(loc, d); CGEventPost(loc, u); - if (flags & kCGEventFlagMaskCommand) { - CGEventPost(loc, cmdu); - } } CFRelease(d); From 5a974a106f49922194c4b56f0e521da832d89df3 Mon Sep 17 00:00:00 2001 From: Rory Jaffe Date: Thu, 21 Jul 2016 20:07:28 -0400 Subject: [PATCH 28/33] more constants --- Source/LR_IPC_In.cpp | 28 ++++++++++++++++------------ Source/LR_IPC_Out.cpp | 16 +++++++++------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Source/LR_IPC_In.cpp b/Source/LR_IPC_In.cpp index 6c883c03f..b34f138e4 100644 --- a/Source/LR_IPC_In.cpp +++ b/Source/LR_IPC_In.cpp @@ -24,14 +24,17 @@ MIDI2LR. If not, see . #include namespace { - constexpr auto kBufferSize = 256; - constexpr auto kConnectTryTime = 100; - constexpr auto kEmptyWait = 100; - constexpr auto kLrInPort = 58764; - constexpr auto kMaxMIDI = 127.0; - constexpr auto kMaxNRPN = 16383.0; - constexpr auto kNotConnectedWait = 333; - constexpr auto kReadyWait = 0; + constexpr int kBufferSize = 256; + constexpr int kConnectTryTime = 100; + constexpr int kEmptyWait = 100; + constexpr char * kHost = "127.0.0.1"; + constexpr int kLrInPort = 58764; + constexpr double kMaxMIDI = 127.0; + constexpr double kMaxNRPN = 16383.0; + constexpr int kNotConnectedWait = 333; + constexpr int kReadyWait = 0; + constexpr int kStopWait = 1000; + constexpr int kTimerInterval = 1000; } LR_IPC_IN::LR_IPC_IN(): juce::StreamingSocket{}, juce::Thread{"LR_IPC_IN"} {} @@ -42,7 +45,7 @@ LR_IPC_IN::~LR_IPC_IN() { timer_off_ = true; juce::Timer::stopTimer(); } - juce::Thread::stopThread(1000); + juce::Thread::stopThread(kStopWait); juce::StreamingSocket::close(); } @@ -53,7 +56,7 @@ void LR_IPC_IN::Init(std::shared_ptr& map_command, profile_manager_ = profile_manager; midi_sender_ = midi_sender; //start the timer - juce::Timer::startTimer(1000); + juce::Timer::startTimer(kTimerInterval); } void LR_IPC_IN::refreshMIDIOutput() { @@ -129,14 +132,15 @@ void LR_IPC_IN::run() { void LR_IPC_IN::timerCallback() { std::lock_guard lock(timer_mutex_); - if (!juce::StreamingSocket::isConnected() && !timer_off_) { - if (juce::StreamingSocket::connect("127.0.0.1", kLrInPort, kConnectTryTime)) + if (!timer_off_ && !juce::StreamingSocket::isConnected()) { + if (juce::StreamingSocket::connect(kHost, kLrInPort, kConnectTryTime)) if (!thread_started_) { juce::Thread::startThread(); //avoid starting thread during shutdown thread_started_ = true; } } } + void LR_IPC_IN::processLine(const std::string& line) { const static std::unordered_map cmds = { {"SwitchProfile",1}, diff --git a/Source/LR_IPC_Out.cpp b/Source/LR_IPC_Out.cpp index 742c3cab7..ca038f0e2 100644 --- a/Source/LR_IPC_Out.cpp +++ b/Source/LR_IPC_Out.cpp @@ -23,10 +23,12 @@ MIDI2LR. If not, see . #include "LRCommands.h" namespace { - constexpr auto kConnectTryTime = 100; - constexpr auto kLrOutPort = 58763; - constexpr auto kMaxMIDI = 127.0; - constexpr auto kMaxNRPN = 16383.0; + constexpr int kConnectTryTime = 100; + constexpr char * kHost = "127.0.0.1"; + constexpr int kLrOutPort = 58763; + constexpr double kMaxMIDI = 127.0; + constexpr double kMaxNRPN = 16383.0; + constexpr int kTimerInterval = 1000; } LR_IPC_OUT::LR_IPC_OUT(): juce::InterprocessConnection() {} @@ -51,7 +53,7 @@ void LR_IPC_OUT::Init(std::shared_ptr& command_map, } //start the timer - juce::Timer::startTimer(1000); + juce::Timer::startTimer(kTimerInterval); } void LR_IPC_OUT::addListener(LRConnectionListener *listener) { @@ -141,6 +143,6 @@ void LR_IPC_OUT::handleAsyncUpdate() { void LR_IPC_OUT::timerCallback() { std::lock_guard lock(timer_mutex_); - if (!juce::InterprocessConnection::isConnected() && !timer_off_) - juce::InterprocessConnection::connectToSocket("127.0.0.1", kLrOutPort, kConnectTryTime); + if (!timer_off_ && !juce::InterprocessConnection::isConnected()) + juce::InterprocessConnection::connectToSocket(kHost, kLrOutPort, kConnectTryTime); } \ No newline at end of file From e71bfbac3ffe862c1569ef5aed605655968a5842 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Fri, 22 Jul 2016 22:34:17 -0700 Subject: [PATCH 29/33] Fix merge error (multimap "erased"). go to ordered map for speed. --- Source/CommandMap.cpp | 18 ++++++------------ Source/CommandMap.h | 7 +++---- Source/LR_IPC_In.cpp | 25 +++++++------------------ 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/Source/CommandMap.cpp b/Source/CommandMap.cpp index 349381f4a..749c53448 100644 --- a/Source/CommandMap.cpp +++ b/Source/CommandMap.cpp @@ -60,24 +60,18 @@ bool CommandMap::messageExistsInMap(const MIDI_Message& message) const { return message_map_.count(message) > 0 ? true : false; } -int CommandMap::getMessageCountForCommand(const std::string& command) const { - return command_string_map_.count(command); -} - -std::vector CommandMap::getMessagesForCommand(const std::string& command) const { - std::vector mm; +std::vector CommandMap::getMessagesForCommand(const std::string& command) const { + std::vector mm; const auto range = command_string_map_.equal_range(command); for (auto it = range.first; it != range.second; ++it) - mm.push_back(it->second); + mm.push_back(&it->second); return mm; } - -const MIDI_Message& CommandMap::getMessageForCommand(const std::string& command) const { - return command_string_map_.at(command); -} + bool CommandMap::commandHasAssociatedMessage(const std::string& command) const { - return command_string_map_.count(command) > 0 ? true : false; + return command_string_map_.find(command) != command_string_map_.end(); } + void CommandMap::toXMLDocument(juce::File& file) const { if (message_map_.size()) {//don't bother if map is empty // save the contents of the command map to an xml file diff --git a/Source/CommandMap.h b/Source/CommandMap.h index 100a91130..fe1cca1dd 100644 --- a/Source/CommandMap.h +++ b/Source/CommandMap.h @@ -24,6 +24,7 @@ MIDI2LR. If not, see . #define COMMANDMAP_H_INCLUDED #include +#include #include #include #include "../JuceLibraryCode/JuceHeader.h" @@ -100,10 +101,8 @@ class CommandMap { // returns true if there is a mapping for a particular MIDI message bool messageExistsInMap(const MIDI_Message& message) const; - int getMessageCountForCommand(const std::string& command) const; - std::vector getMessagesForCommand(const std::string& command) const; + std::vector getMessagesForCommand(const std::string& command) const; // gets the MIDI message associated to a LR command - const MIDI_Message& getMessageForCommand(const std::string& command) const; // returns true if there is a mapping for a particular LR command bool commandHasAssociatedMessage(const std::string& command) const; @@ -114,6 +113,6 @@ class CommandMap { private: std::unordered_map message_map_; - std::unordered_map command_string_map_; + std::multimap command_string_map_; }; #endif // COMMANDMAP_H_INCLUDED diff --git a/Source/LR_IPC_In.cpp b/Source/LR_IPC_In.cpp index 150cb3a66..97d746c55 100644 --- a/Source/LR_IPC_In.cpp +++ b/Source/LR_IPC_In.cpp @@ -152,25 +152,14 @@ void LR_IPC_IN::processLine(const std::string& line) { JUCEApplication::getInstance()->systemRequestedQuit(); break; case 0: - // send associated CC messages to MIDI OUT devices - if (command_map_ && midi_sender_) - if (const auto cmd_count = command_map_->getMessageCountForCommand(command)) { - const auto original_value = std::stod(value_string); - if (cmd_count > 1) { - const std::vector mm = command_map_->getMessagesForCommand(command); - for (const auto msg : mm) { - const auto value = static_cast(round( - ((msg.controller < 128) ? kMaxMIDI : kMaxNRPN) * original_value)); - midi_sender_->sendCC(msg.channel, msg.controller, value); - } - } - else { - const auto& msg = command_map_->getMessageForCommand(command); - const auto value = static_cast(round( - ((msg.controller < 128) ? kMaxMIDI : kMaxNRPN) * original_value)); - midi_sender_->sendCC(msg.channel, msg.controller, value); - } + if (command_map_ && midi_sender_ ) { + const auto original_value = std::stod(value_string); + for (const auto msg : command_map_->getMessagesForCommand(command)) { + const auto value = static_cast(round( + ((msg->controller < 128) ? kMaxMIDI : kMaxNRPN) * original_value)); + midi_sender_->sendCC(msg->channel, msg->controller, value); } + } } } \ No newline at end of file From c2ce76a23414c48e6db05273ec38c89f57c0aafe Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Sat, 23 Jul 2016 12:23:12 -0700 Subject: [PATCH 30/33] Change MIDI_Message to MIDI_Message_ID, inline some command map fns --- Source/CommandMap.cpp | 35 ++------------------- Source/CommandMap.h | 59 +++++++++++++++++++++++++++--------- Source/CommandMenu.cpp | 4 +-- Source/CommandMenu.h | 6 ++-- Source/CommandTableModel.cpp | 12 ++++---- Source/CommandTableModel.h | 2 +- Source/LR_IPC_Out.cpp | 4 +-- Source/ProfileManager.cpp | 4 +-- 8 files changed, 63 insertions(+), 63 deletions(-) diff --git a/Source/CommandMap.cpp b/Source/CommandMap.cpp index 749c53448..cf91ab457 100644 --- a/Source/CommandMap.cpp +++ b/Source/CommandMap.cpp @@ -24,7 +24,7 @@ MIDI2LR. If not, see . CommandMap::CommandMap() noexcept {} -void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message& message) { +void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message_ID& message) { // adds a message to the message:command map, and its associated command to the // command:message map if (command < LRCommandList::LRStringList.size()) { @@ -35,43 +35,14 @@ void CommandMap::addCommandforMessage(unsigned int command, const MIDI_Message& message_map_[message] = LRCommandList::NextPrevProfile[command - LRCommandList::LRStringList.size()]; } -void CommandMap::addCommandforMessage(const std::string& command, const MIDI_Message& message) { - message_map_[message] = command; - command_string_map_.insert({command, message}); -} - -const std::string& CommandMap::getCommandforMessage(const MIDI_Message& message) const { - return message_map_.at(message); -} - -void CommandMap::removeMessage(const MIDI_Message& message) { - // removes message from the message:command map, and its associated command from - // the command:message map - command_string_map_.erase(message_map_[message]); - message_map_.erase(message); -} - -void CommandMap::clearMap() noexcept { - command_string_map_.clear(); - message_map_.clear(); -} - -bool CommandMap::messageExistsInMap(const MIDI_Message& message) const { - return message_map_.count(message) > 0 ? true : false; -} - -std::vector CommandMap::getMessagesForCommand(const std::string& command) const { - std::vector mm; +std::vector CommandMap::getMessagesForCommand(const std::string& command) const { + std::vector mm; const auto range = command_string_map_.equal_range(command); for (auto it = range.first; it != range.second; ++it) mm.push_back(&it->second); return mm; } -bool CommandMap::commandHasAssociatedMessage(const std::string& command) const { - return command_string_map_.find(command) != command_string_map_.end(); -} - void CommandMap::toXMLDocument(juce::File& file) const { if (message_map_.size()) {//don't bother if map is empty // save the contents of the command map to an xml file diff --git a/Source/CommandMap.h b/Source/CommandMap.h index fe1cca1dd..36fa40936 100644 --- a/Source/CommandMap.h +++ b/Source/CommandMap.h @@ -29,7 +29,7 @@ MIDI2LR. If not, see . #include #include "../JuceLibraryCode/JuceHeader.h" -struct MIDI_Message { +struct MIDI_Message_ID { bool isCC; int channel; union { @@ -38,22 +38,22 @@ struct MIDI_Message { int data; }; - MIDI_Message(): + MIDI_Message_ID(): channel(0), isCC(0), data(0) {} - MIDI_Message(int ch, int dat, bool iscc): channel(ch), + MIDI_Message_ID(int ch, int dat, bool iscc): channel(ch), isCC(iscc), data(dat) {} - bool operator==(const MIDI_Message& other) const noexcept { + bool operator==(const MIDI_Message_ID& other) const noexcept { return (isCC == other.isCC && channel == other.channel && data == other.data); } - bool operator<(const MIDI_Message& other) const noexcept { + bool operator<(const MIDI_Message_ID& other) const noexcept { if (channel < other.channel) return true; if (channel == other.channel) { if (data < other.data) return true; @@ -66,8 +66,8 @@ struct MIDI_Message { // hash functions namespace std { template <> - struct hash { - std::size_t operator()(const MIDI_Message& k) const noexcept { + struct hash { + std::size_t operator()(const MIDI_Message_ID& k) const noexcept { return std::hash()(k.isCC) ^ std::hash()(k.channel) ^ std::hash()(k.data << 2); } @@ -82,26 +82,26 @@ class CommandMap { // adds an entry to the message:command map, and a corresponding entry to the // command:message map will look up the string by the index (but it is preferred to // directly use the string) - void addCommandforMessage(unsigned int command, const MIDI_Message& cc); + void addCommandforMessage(unsigned int command, const MIDI_Message_ID& cc); // adds an entry to the message:command map, and a corresponding entry to the // command:message map - void addCommandforMessage(const std::string& command, const MIDI_Message& cc); + void addCommandforMessage(const std::string& command, const MIDI_Message_ID& cc); // gets the LR command associated to a MIDI message - const std::string& getCommandforMessage(const MIDI_Message& message) const; + const std::string& getCommandforMessage(const MIDI_Message_ID& message) const; // in the command:message map // removes a MIDI message from the message:command map, and it's associated entry - void removeMessage(const MIDI_Message& message); + void removeMessage(const MIDI_Message_ID& message); // clears both message:command and command:message maps void clearMap() noexcept; // returns true if there is a mapping for a particular MIDI message - bool messageExistsInMap(const MIDI_Message& message) const; + bool messageExistsInMap(const MIDI_Message_ID& message) const; - std::vector getMessagesForCommand(const std::string& command) const; + std::vector getMessagesForCommand(const std::string& command) const; // gets the MIDI message associated to a LR command // returns true if there is a mapping for a particular LR command @@ -112,7 +112,36 @@ class CommandMap { private: - std::unordered_map message_map_; - std::multimap command_string_map_; + std::unordered_map message_map_; + std::multimap command_string_map_; }; + +inline void CommandMap::addCommandforMessage(const std::string& command, const MIDI_Message_ID& message) { + message_map_[message] = command; + command_string_map_.insert({command, message}); +} + +inline const std::string& CommandMap::getCommandforMessage(const MIDI_Message_ID& message) const { + return message_map_.at(message); +} + +inline void CommandMap::removeMessage(const MIDI_Message_ID& message) { + // removes message from the message:command map, and its associated command from + // the command:message map + command_string_map_.erase(message_map_[message]); + message_map_.erase(message); +} + +inline void CommandMap::clearMap() noexcept { + command_string_map_.clear(); + message_map_.clear(); +} + +inline bool CommandMap::messageExistsInMap(const MIDI_Message_ID& message) const { + return message_map_.find(message) != message_map_.end(); +} + +inline bool CommandMap::commandHasAssociatedMessage(const std::string& command) const { + return command_string_map_.find(command) != command_string_map_.end(); +} #endif // COMMANDMAP_H_INCLUDED diff --git a/Source/CommandMenu.cpp b/Source/CommandMenu.cpp index 4a45dc52b..f7e1b42cb 100644 --- a/Source/CommandMenu.cpp +++ b/Source/CommandMenu.cpp @@ -23,7 +23,7 @@ MIDI2LR. If not, see . #include #include "LRCommands.h" -CommandMenu::CommandMenu(const MIDI_Message& message): +CommandMenu::CommandMenu(const MIDI_Message_ID& message): juce::TextButton{"Unmapped"}, message_{message}, @@ -50,7 +50,7 @@ void CommandMenu::Init(std::shared_ptr& mapCommand) { juce::Button::addListener(this); } -void CommandMenu::setMsg(const MIDI_Message& message) noexcept { +void CommandMenu::setMsg(const MIDI_Message_ID& message) noexcept { message_ = message; } diff --git a/Source/CommandMenu.h b/Source/CommandMenu.h index 83f61a1af..8f929926d 100644 --- a/Source/CommandMenu.h +++ b/Source/CommandMenu.h @@ -31,10 +31,10 @@ MIDI2LR. If not, see . class CommandMenu final: public juce::TextButton, private juce::ButtonListener { public: - CommandMenu(const MIDI_Message& msg); + CommandMenu(const MIDI_Message_ID& msg); void Init(std::shared_ptr& map_command); // sets the MIDI message associated to this menu component - void setMsg(const MIDI_Message& msg) noexcept; + void setMsg(const MIDI_Message_ID& msg) noexcept; // sets which item in the menu is selected void setSelectedItem(unsigned int idx); @@ -45,7 +45,7 @@ class CommandMenu final: public juce::TextButton, const std::vector menus_; const std::vector> menu_entries_; - MIDI_Message message_; + MIDI_Message_ID message_; size_t selected_item_{std::numeric_limits::max()}; std::shared_ptr command_map_{nullptr}; }; diff --git a/Source/CommandTableModel.cpp b/Source/CommandTableModel.cpp index b00e11fb7..1daa77258 100644 --- a/Source/CommandTableModel.cpp +++ b/Source/CommandTableModel.cpp @@ -138,7 +138,7 @@ juce::Component *CommandTableModel::refreshComponentForCell(int row_number, } void CommandTableModel::addRow(int midi_channel, int midi_data, bool is_cc) { - const MIDI_Message msg{midi_channel, midi_data, is_cc}; + const MIDI_Message_ID msg{midi_channel, midi_data, is_cc}; if (command_map_ && !command_map_->messageExistsInMap(msg)) { commands_.push_back(msg); command_map_->addCommandforMessage(0, msg); // add an entry for 'no command' @@ -170,7 +170,7 @@ void CommandTableModel::buildFromXml(const juce::XmlElement * const root) { auto* setting = root->getFirstChildElement(); while ((setting) && (command_map_)) { if (setting->hasAttribute("controller")) { - const MIDI_Message message{setting->getIntAttribute("channel"), + const MIDI_Message_ID message{setting->getIntAttribute("channel"), setting->getIntAttribute("controller"), true}; addRow(message.channel, message.controller, true); @@ -185,7 +185,7 @@ void CommandTableModel::buildFromXml(const juce::XmlElement * const root) { } } else if (setting->hasAttribute("note")) { - const MIDI_Message note{setting->getIntAttribute("channel"), + const MIDI_Message_ID note{setting->getIntAttribute("channel"), setting->getIntAttribute("note"), false}; addRow(note.channel, note.pitch, false); @@ -217,7 +217,7 @@ int CommandTableModel::getRowForMessage(int midi_channel, int midi_data, bool is void CommandTableModel::Sort() { // use LRCommandList::getIndexOfCommand(string); to sort by command // sort the command map - auto msg_idx = [this](MIDI_Message a) {return LRCommandList::getIndexOfCommand + auto msg_idx = [this](MIDI_Message_ID a) {return LRCommandList::getIndexOfCommand (command_map_->getCommandforMessage(a)); }; if (current_sort.first == 1) @@ -228,8 +228,8 @@ void CommandTableModel::Sort() { else if (current_sort.second) std::sort(commands_.begin(), commands_.end(), - [&msg_idx](MIDI_Message a, MIDI_Message b) { return msg_idx(a) < msg_idx(b); }); + [&msg_idx](MIDI_Message_ID a, MIDI_Message_ID b) { return msg_idx(a) < msg_idx(b); }); else std::sort(commands_.rbegin(), commands_.rend(), - [&msg_idx](MIDI_Message a, MIDI_Message b) { return msg_idx(a) < msg_idx(b); }); + [&msg_idx](MIDI_Message_ID a, MIDI_Message_ID b) { return msg_idx(a) < msg_idx(b); }); } \ No newline at end of file diff --git a/Source/CommandTableModel.h b/Source/CommandTableModel.h index 3dc1d046f..688085ac2 100644 --- a/Source/CommandTableModel.h +++ b/Source/CommandTableModel.h @@ -64,7 +64,7 @@ class CommandTableModel final: public juce::TableListBoxModel { std::pair current_sort{2,true}; std::pair prior_sort{2,true}; std::shared_ptr command_map_{nullptr}; - std::vector commands_; + std::vector commands_; //============================================================================== JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CommandTableModel) diff --git a/Source/LR_IPC_Out.cpp b/Source/LR_IPC_Out.cpp index ca038f0e2..6a1a1583f 100644 --- a/Source/LR_IPC_Out.cpp +++ b/Source/LR_IPC_Out.cpp @@ -72,7 +72,7 @@ void LR_IPC_OUT::sendCommand(const std::string& command) { } void LR_IPC_OUT::handleMidiCC(int midi_channel, int controller, int value) { - MIDI_Message message{midi_channel, controller, true}; + MIDI_Message_ID message{midi_channel, controller, true}; if (command_map_) { if (!command_map_->messageExistsInMap(message) || @@ -96,7 +96,7 @@ void LR_IPC_OUT::handleMidiCC(int midi_channel, int controller, int value) { } void LR_IPC_OUT::handleMidiNote(int midi_channel, int note) { - MIDI_Message message{midi_channel, note, false}; + MIDI_Message_ID message{midi_channel, note, false}; if (command_map_) { if (!command_map_->messageExistsInMap(message) || diff --git a/Source/ProfileManager.cpp b/Source/ProfileManager.cpp index b73cfb817..0b1428315 100644 --- a/Source/ProfileManager.cpp +++ b/Source/ProfileManager.cpp @@ -111,7 +111,7 @@ void ProfileManager::switchToPreviousProfile() { } void ProfileManager::handleMidiCC(int midi_channel, int controller, int value) { - const MIDI_Message cc{midi_channel, controller, true}; + const MIDI_Message_ID cc{midi_channel, controller, true}; if (command_map_) { // return if the value isn't 127, or the command isn't a valid @@ -131,7 +131,7 @@ void ProfileManager::handleMidiCC(int midi_channel, int controller, int value) { } void ProfileManager::handleMidiNote(int midi_channel, int note) { - const MIDI_Message note_msg{midi_channel, note, false}; + const MIDI_Message_ID note_msg{midi_channel, note, false}; if (command_map_) { // return if the command isn't a valid profile-related command From 9037459b33c041f79fc9fdbdd74af251523e5d76 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Sat, 23 Jul 2016 12:27:29 -0700 Subject: [PATCH 31/33] Version 1.4.0.0 --- Builds/MacOSX/Info-App.plist | 4 ++-- Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj | 8 ++++---- Builds/VisualStudio2015/MIDI2LR.vcxproj | 4 ++-- Builds/VisualStudio2015/resources.rc | 6 +++--- JuceLibraryCode/JuceHeader.h | 4 ++-- MIDI2LR.jucer | 2 +- Source/LRPlugin/MIDI2LR.lrplugin/Info.lua | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Builds/MacOSX/Info-App.plist b/Builds/MacOSX/Info-App.plist index 94a2d281f..a6b2c3184 100644 --- a/Builds/MacOSX/Info-App.plist +++ b/Builds/MacOSX/Info-App.plist @@ -18,9 +18,9 @@ CFBundleSignature ???? CFBundleShortVersionString - 1.3.0.1 + 1.4.0.0 CFBundleVersion - 1.3.0.1 + 1.4.0.0 NSHumanReadableCopyright NSHighResolutionCapable diff --git a/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj b/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj index a3aa7583c..ac91a787a 100644 --- a/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj @@ -2453,8 +2453,8 @@ "_NDEBUG=1", "NDEBUG=1", "JUCER_XCODE_MAC_F6D2F4CF=1", - "JUCE_APP_VERSION=1.3.0.1", - "JUCE_APP_VERSION_HEX=0x1030001", ); + "JUCE_APP_VERSION=1.4.0.0", + "JUCE_APP_VERSION_HEX=0x1040000", ); GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)"); @@ -2479,8 +2479,8 @@ "_NDEBUG=1", "NDEBUG=1", "JUCER_XCODE_MAC_F6D2F4CF=1", - "JUCE_APP_VERSION=1.3.0.1", - "JUCE_APP_VERSION_HEX=0x1030001", ); + "JUCE_APP_VERSION=1.4.0.0", + "JUCE_APP_VERSION_HEX=0x1040000", ); GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)"); diff --git a/Builds/VisualStudio2015/MIDI2LR.vcxproj b/Builds/VisualStudio2015/MIDI2LR.vcxproj index 6b9ee1cc0..94b2bcd8c 100644 --- a/Builds/VisualStudio2015/MIDI2LR.vcxproj +++ b/Builds/VisualStudio2015/MIDI2LR.vcxproj @@ -56,7 +56,7 @@ Disabled EditAndContinue ..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.3.0.1;JUCE_APP_VERSION_HEX=0x1030001;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.4.0.0;JUCE_APP_VERSION_HEX=0x1040000;%(PreprocessorDefinitions) MultiThreadedDebug true @@ -97,7 +97,7 @@ Full ..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;%(AdditionalIncludeDirectories) - _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.3.0.1;JUCE_APP_VERSION_HEX=0x1030001;%(PreprocessorDefinitions) + _CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.4.0.0;JUCE_APP_VERSION_HEX=0x1040000;%(PreprocessorDefinitions) MultiThreaded true diff --git a/Builds/VisualStudio2015/resources.rc b/Builds/VisualStudio2015/resources.rc index 7430ca568..0a5567924 100644 --- a/Builds/VisualStudio2015/resources.rc +++ b/Builds/VisualStudio2015/resources.rc @@ -7,16 +7,16 @@ #include VS_VERSION_INFO VERSIONINFO -FILEVERSION 1,3,0,1 +FILEVERSION 1,4,0,0 BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904E4" BEGIN VALUE "FileDescription", "MIDI2LR\0" - VALUE "FileVersion", "1.3.0.1\0" + VALUE "FileVersion", "1.4.0.0\0" VALUE "ProductName", "MIDI2LR\0" - VALUE "ProductVersion", "1.3.0.1\0" + VALUE "ProductVersion", "1.4.0.0\0" END END diff --git a/JuceLibraryCode/JuceHeader.h b/JuceLibraryCode/JuceHeader.h index 013c1bdf0..75ed57770 100644 --- a/JuceLibraryCode/JuceHeader.h +++ b/JuceLibraryCode/JuceHeader.h @@ -37,8 +37,8 @@ namespace ProjectInfo { const char* const projectName = "MIDI2LR"; - const char* const versionString = "1.3.0.1"; - const int versionNumber = 0x1030001; + const char* const versionString = "1.4.0.0"; + const int versionNumber = 0x1040000; } #endif diff --git a/MIDI2LR.jucer b/MIDI2LR.jucer index 9e135420b..cbae8852c 100644 --- a/MIDI2LR.jucer +++ b/MIDI2LR.jucer @@ -1,6 +1,6 @@ - diff --git a/Source/LRPlugin/MIDI2LR.lrplugin/Info.lua b/Source/LRPlugin/MIDI2LR.lrplugin/Info.lua index d22becaab..1b9b3b05a 100644 --- a/Source/LRPlugin/MIDI2LR.lrplugin/Info.lua +++ b/Source/LRPlugin/MIDI2LR.lrplugin/Info.lua @@ -46,5 +46,5 @@ return { }, --]] }, - VERSION = { major=1, minor=3, revision=0, build=1} + VERSION = { major=1, minor=4, revision=0, build=0} } From ca0c73ab64125b5013d18d0a881f926713e45c21 Mon Sep 17 00:00:00 2001 From: rsjaffe Date: Sat, 23 Jul 2016 12:37:29 -0700 Subject: [PATCH 32/33] Add debug mode for OSX build --- Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj | 12 ++++++------ MIDI2LR.jucer | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj b/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj index ac91a787a..bd0df22bb 100644 --- a/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj +++ b/Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj @@ -2446,16 +2446,15 @@ CLANG_LINK_OBJC_RUNTIME = NO; COMBINE_HIDPI_IMAGES = YES; CONFIGURATION_BUILD_DIR = "$(PROJECT_DIR)/build/$(CONFIGURATION)"; - DEAD_CODE_STRIPPING = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_OPTIMIZATION_LEVEL = 3; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "_NDEBUG=1", - "NDEBUG=1", + "_DEBUG=1", + "DEBUG=1", "JUCER_XCODE_MAC_F6D2F4CF=1", "JUCE_APP_VERSION=1.4.0.0", "JUCE_APP_VERSION_HEX=0x1040000", ); - GCC_SYMBOLS_PRIVATE_EXTERN = YES; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)"); INFOPLIST_FILE = Info-App.plist; @@ -2494,6 +2493,7 @@ A2D85D5403DF5412CD4FEA31 = {isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; DEBUG_INFORMATION_FORMAT = "dwarf"; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = c99; GCC_INLINES_ARE_PRIVATE_EXTERN = YES; GCC_MODEL_TUNING = G5; diff --git a/MIDI2LR.jucer b/MIDI2LR.jucer index cbae8852c..35a47321a 100644 --- a/MIDI2LR.jucer +++ b/MIDI2LR.jucer @@ -90,7 +90,7 @@ Date: Sat, 23 Jul 2016 12:43:44 -0700 Subject: [PATCH 33/33] Changes to address XCode warnings. --- Source/CommandMap.h | 5 +++-- Source/LR_IPC_In.cpp | 2 +- Source/LR_IPC_Out.cpp | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/CommandMap.h b/Source/CommandMap.h index 36fa40936..4bf6a3024 100644 --- a/Source/CommandMap.h +++ b/Source/CommandMap.h @@ -39,14 +39,15 @@ struct MIDI_Message_ID { }; MIDI_Message_ID(): - channel(0), isCC(0), + channel(0), data(0) {} - MIDI_Message_ID(int ch, int dat, bool iscc): channel(ch), + MIDI_Message_ID(int ch, int dat, bool iscc): isCC(iscc), + channel(ch), data(dat) {} bool operator==(const MIDI_Message_ID& other) const noexcept { diff --git a/Source/LR_IPC_In.cpp b/Source/LR_IPC_In.cpp index a186823e1..2445a0002 100644 --- a/Source/LR_IPC_In.cpp +++ b/Source/LR_IPC_In.cpp @@ -27,7 +27,7 @@ namespace { constexpr int kBufferSize = 256; constexpr int kConnectTryTime = 100; constexpr int kEmptyWait = 100; - constexpr char * kHost = "127.0.0.1"; + constexpr auto kHost = "127.0.0.1"; constexpr int kLrInPort = 58764; constexpr double kMaxMIDI = 127.0; constexpr double kMaxNRPN = 16383.0; diff --git a/Source/LR_IPC_Out.cpp b/Source/LR_IPC_Out.cpp index 6a1a1583f..8051c75e2 100644 --- a/Source/LR_IPC_Out.cpp +++ b/Source/LR_IPC_Out.cpp @@ -24,7 +24,7 @@ MIDI2LR. If not, see . namespace { constexpr int kConnectTryTime = 100; - constexpr char * kHost = "127.0.0.1"; + constexpr auto kHost = "127.0.0.1"; constexpr int kLrOutPort = 58763; constexpr double kMaxMIDI = 127.0; constexpr double kMaxNRPN = 16383.0;