hydrogen 1.2.3
MidiLearnable.cpp
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#include "MidiLearnable.h"
24#include "../HydrogenApp.h"
25
26#include <core/MidiMap.h>
27
28MidiLearnable::MidiLearnable() : m_pAction( nullptr ) {
30}
31
33 auto pHydrogenApp = HydrogenApp::get_instance();
34 if ( pHydrogenApp != nullptr ) {
35 pHydrogenApp->removeEventListener( this );
36 }
37}
38
39void MidiLearnable::setAction( std::shared_ptr<Action> pAction ){
40 m_pAction = pAction;
41
43}
44
void addEventListener(EventListener *pListener)
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
std::vector< std::pair< H2Core::MidiMessage::Event, int > > m_registeredMidiEvents
Stores all MIDI events mapped to m_pAction.
virtual void updateTooltip()
Indicates child class to recalculate its tool tip in case m_registeredMidiEvents changed.
std::shared_ptr< Action > m_pAction
void setAction(std::shared_ptr< Action > pAction)
void midiMapChangedEvent() override
Update m_registeredMidiEvents since the underlying #H2Core::MidiMap changed.
static MidiMap * get_instance()
Returns a pointer to the current MidiMap singleton stored in __instance.
Definition MidiMap.h:65
std::vector< std::pair< H2Core::MidiMessage::Event, int > > getRegisteredMidiEvents(std::shared_ptr< Action > pAction) const
Definition MidiMap.cpp:289