-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSpatializeComponent.cpp
171 lines (127 loc) · 3.77 KB
/
SpatializeComponent.cpp
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//
// SpatializeComponent.cpp
// ipReverb
//
// Created by Sam on 14/04/2018.
// Copyright © 2018 Sam. All rights reserved.
//
#include "SpatializeComponent.hpp"
SpatializeComponent::SpatializeComponent(){
;
}
void SpatializeComponent::resized(){
;
}
void SpatializeComponent::setXorigin(int inX){
xOrigin = inX;
}
void SpatializeComponent::setYorigin(int inY){
yOrigin = inY;
}
void SpatializeComponent::setWidth(int inWidth){
width = inWidth;
}
void SpatializeComponent::setHeight(int inHeight){
height = inHeight;
}
int SpatializeComponent::getMarkerXpos(){
return markerXpos;
}
int SpatializeComponent::getMarkerYpos(){
return markerYpos;
}
int SpatializeComponent::getMarkerSize(){
return markerSize;
}
void SpatializeComponent::setMarkerXpos(int inValue){
markerXpos = inValue;
}
void SpatializeComponent::setMarkerYpos(int inValue){
markerYpos = inValue;
}
void SpatializeComponent::setMarkerSize(int inValue){
markerSize = inValue;
}
void SpatializeComponent::paint(Graphics& g){
g.setColour(Colour (14, 34, 47));
g.fillRoundedRectangle(xOrigin, yOrigin, width, height, 5); //Draw Outline
g.setColour(Colour (255, 255, 255));
g.drawFittedText("X", xOrigin + width/2 - labelWidth/2, yOrigin + height - labelHeight, labelWidth, labelHeight, Justification::centred, 1);
g.drawFittedText("Y", xOrigin + width - labelWidth, yOrigin + height/2 - labelHeight/2, labelWidth, labelHeight, Justification::centred, 1);
g.drawFittedText("Z", xOrigin + 5, yOrigin + height/2 - labelHeight/2, labelWidth, labelHeight, Justification::centred, 1);
g.drawFittedText("ER Spatializer (m)", xOrigin + width/2 - 50, yOrigin - labelHeight * 2, 100, labelHeight*2, Justification::centred, 1);
g.setColour(Colour(255, 160, 0));
g.drawEllipse(markerXpos, markerYpos, markerSize, markerSize, 2);
}
void SpatializeComponent::drag(const MouseEvent &event){
float xPos = event.x;
float yPos = event.y;
if(clicked){
if(setSize){
markerSize = (((yPos - yOrigin) / height) * 30) + 10;
if(yPos < yOrigin)
markerSize = 10;
if(yPos > yOrigin + height)
markerSize = 39;
}
else{
markerXpos = xPos - markerSize/2;
markerYpos = yPos - markerSize/2;
if(markerXpos < xOrigin)
markerXpos = xOrigin;
if(markerXpos > xOrigin + width - markerSize)
markerXpos = xOrigin + width - markerSize;
if(markerYpos < yOrigin)
markerYpos = yOrigin;
if(markerYpos > yOrigin + height - markerSize)
markerYpos = yOrigin + height - markerSize;
}
}
}
void SpatializeComponent::down (const MouseEvent &event){
int numOfClicks = event.getNumberOfClicks();
int xPos = event.getMouseDownX();
int yPos = event.getMouseDownY();
if(xPos > markerXpos &&
xPos < markerXpos + markerSize &&
yPos > markerYpos &&
yPos < markerYpos + markerSize){
if(numOfClicks > 1){
markerXpos = xOrigin + width/2 - markerSize/2;
markerYpos = yOrigin + height/2 - markerSize/2;
}
else
clicked = true;
}
}
void SpatializeComponent::up (const MouseEvent &event){
clicked = false;
}
void SpatializeComponent::shiftDown(const ModifierKeys &modifiers){
setSize = modifiers.isShiftDown();
}
void SpatializeComponent::initMarker(){
markerXpos = xOrigin + width/2 - markerSize/2;
markerYpos = yOrigin + height/2 - markerSize/2;
}
float SpatializeComponent::getXvalue(){
return ((markerXpos) - xOrigin) / float(width - markerSize);
}
float SpatializeComponent::getYvalue(){
return ((markerYpos) - yOrigin) / float(height - markerSize);
}
float SpatializeComponent::getZvalue(){
return (markerSize - 10) / float(29);
}
int SpatializeComponent::getXOrigin(){
return xOrigin;
}
int SpatializeComponent::getYOrigin(){
return yOrigin;
}
int SpatializeComponent::getWidth(){
return width;
}
int SpatializeComponent::getHeight(){
return height;
}