aboutsummaryrefslogtreecommitdiff
path: root/simple-visualization/simplevisualization.cpp
blob: 0c3a5b9e917a078d465f0822427d3e893f0844b5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "simplevisualization.hpp"
#include "qmpkeyboardwindow.hpp"

qmpSimpleVisualization::qmpSimpleVisualization(qmpPluginAPI *_api)
{
    api = _api;
}
void qmpSimpleVisualization::show()
{
    p->show();
}
void qmpSimpleVisualization::close()
{
    p->close();
}
void qmpSimpleVisualization::init()
{
    api->registerFunctionality(this, "Keyboard", "Keyboard", api->isDarkTheme() ? ":/img/visualization_i.svg" : ":/img/visualization.svg", 0, true);
    for (int i = 0; i < 16; ++i)
    {
        api->registerOptionUint("", "", "Keyboard/acolor" + std::to_string(i), 0, 0xffffff, 0xffff66cc);
        api->registerOptionUint("", "", "Keyboard/bcolor" + std::to_string(i), 0, 0xffffff, 0xff66ccff);
    }
    p = new qmpKeyboardWindow(api, (QWidget *)api->getMainWindow());
    auto refreshfn = [this](const void *, void *)
    {
        this->p->resetAll();
    };
    uihs = api->registerUIHook("main.stop", refreshfn, nullptr);
    uihsk = api->registerUIHook("main.seek", refreshfn, nullptr);
    uihsk = api->registerUIHook("preset.set", refreshfn, nullptr);
    uihsk = api->registerUIHook("channel.ccchange", refreshfn, nullptr);
}
void qmpSimpleVisualization::deinit()
{
    if (!api)
        return;
    close();
    api->unregisterFunctionality("Keyboard");
    api->unregisterUIHook("main.stop", uihs);
    api->unregisterUIHook("main.seek", uihsk);
    delete p;
}
const char *qmpSimpleVisualization::pluginGetName()
{
    return "QMidiPlayer Simple Visualization Plugin";
}
const char *qmpSimpleVisualization::pluginGetVersion()
{
    return PLUGIN_VERSION;
}