File: DistrhoUIGLBars.cpp

package info (click to toggle)
dpf-plugins 1.6%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 145,284 kB
  • sloc: cpp: 299,382; ansic: 61,509; objc: 2,715; makefile: 2,076; xml: 618; sh: 462; java: 211; python: 184
file content (122 lines) | stat: -rw-r--r-- 3,097 bytes parent folder | download | duplicates (2)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
 * DISTRHO glBars Plugin based on XMMS/XBMC "GL Bars"
 * Copyright (C) 1998-2000  Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
 * Copyright (C) 2000 Christian Zander <phoenix@minion.de>
 * Copyright (C) 2015 Nedko Arnaudov
 * Copyright (C) 2016-2022 Filipe Coelho <falktx@falktx.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or any later version.
 *
 * 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 General Public License for more details.
 *
 * For a full copy of the license see the LICENSE file.
 */

#include "DistrhoPluginGLBars.hpp"
#include "DistrhoUIGLBars.hpp"

START_NAMESPACE_DISTRHO

// -----------------------------------------------------------------------

DistrhoUIGLBars::DistrhoUIGLBars()
    : UI(512, 512),
      fInitialized(false),
      fResizeHandle(this)
{
    const double scaleFactor = getScaleFactor();

    if (d_isNotZero(scaleFactor))
        setSize(512*scaleFactor, 512*scaleFactor);

    setGeometryConstraints(256*scaleFactor, 256*scaleFactor, true);

    // no need to show resize handle if window is user-resizable
    if (isResizable())
        fResizeHandle.hide();
}

DistrhoUIGLBars::~DistrhoUIGLBars()
{
    if (! fInitialized)
        return;

    if (DistrhoPluginGLBars* const dspPtr = (DistrhoPluginGLBars*)getPluginInstancePointer())
    {
        const MutexLocker csm(dspPtr->fMutex);
        dspPtr->fState = nullptr;
    }
}

// -----------------------------------------------------------------------
// DSP Callbacks

void DistrhoUIGLBars::parameterChanged(uint32_t index, float value)
{
    switch (index)
    {
    case kParameterScale:
        fState.scale = value;
        break;

    case kParameterSpeed:
        fState.hSpeed = value;
        break;

    case kParameterX:
        fState.x_speed = value;
        break;

    case kParameterY:
        fState.y_speed = value;
        break;

    case kParameterZ:
        fState.z_speed = value;
        break;
    }
}

// -----------------------------------------------------------------------
// UI Callbacks

void DistrhoUIGLBars::uiIdle()
{
    repaint();

    if (DistrhoPluginGLBars* const dspPtr = (DistrhoPluginGLBars*)getPluginInstancePointer())
    {
        if (dspPtr->fState != nullptr)
            return;

        fInitialized = true;

        const MutexLocker csm(dspPtr->fMutex);
        dspPtr->fState = &fState;
    }
}

// -----------------------------------------------------------------------
// Widget Callbacks

void DistrhoUIGLBars::onDisplay()
{
    fState.Render();
}

// -----------------------------------------------------------------------

UI* createUI()
{
    return new DistrhoUIGLBars();
}

// -----------------------------------------------------------------------

END_NAMESPACE_DISTRHO