SPAOP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SourcePanel.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Martin Hansen
3  *
4  * This file is part of SPAOP (Spatial Audio Object Positioner).
5  *
6  * SPAOP is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * SPAOP is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with SPAOP. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef SOURCEPANEL_H_INCLUDED
21 #define SOURCEPANEL_H_INCLUDED
22 
23 #define OTHER_SOURCES_ALPHA 80
26 #include <memory>
27 
28 #include "Room.h"
29 #include "SourceCollection.h"
30 #include "SourceDisplay.h"
31 #include "JuceHeader.h"
32 
33 namespace wonderjuce {
34 
35 //==============================================================================
40 class SourcePanel : public SourceDisplay
41 {
42 public:
43  SourcePanel(const String& componentName = String::empty);
44 
46  virtual ~SourcePanel();
47 
49  void paint (Graphics& g);
50 
52  void mouseDown(const MouseEvent &event) override;
53 
55  void mouseDrag(const MouseEvent &event) override;
56 
58  void mouseUp(const MouseEvent &event) override;
59 
66  float getXPos();
67 
74  float getYPos();
75 
76 
83  class Listener
84  {
85  public:
87  virtual ~Listener() {}
88 
97  virtual void sourcePanelDragStarted (SourcePanel* panel) {}
98 
106  virtual void sourcePanelValuesChanged (SourcePanel* panel) = 0;
107 
113  virtual void sourcePanelDragEnded (SourcePanel* panel) {}
114  };
115 
117  void addListener (Listener* listener);
118 
120  void removeListener (Listener* listener);
121 
129  bool setSources(std::shared_ptr<const wonder::SourceCollection> sources);
130 
138  bool setSource(int sourceID);
139 
146  void setShowOtherSources(bool showOthers);
147 
154  bool showsOtherSources() const;
155 
156  float getFocusPointX();
157 
158  float getFocusPointY();
159 
160  Point<float> getFocusPoint();
161 
162 private:
163  float x, y;
164  std::shared_ptr<const wonder::SourceCollection> sources_;
165  bool showOthers_;
166  int sourceID_;
167  bool dotIsHit_;
168  ListenerList <Listener> listeners;
169 
170  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SourcePanel)
171 };
172 
173 }
174 
175 
176 
177 #endif // SOURCEPANEL_H_INCLUDED
float getYPos()
Returns the y coordinate of the source controlled by this SourcePanel, normalized within [0...
Definition: SourcePanel.cpp:134
virtual ~SourcePanel()
Destructor.
Definition: SourcePanel.cpp:37
Point< float > getFocusPoint()
Returns the "focus point", the point where this component shall be auto-centered (for example...
Definition: SourcePanel.cpp:191
void mouseDrag(const MouseEvent &event) override
Definition: SourcePanel.cpp:93
float getFocusPointX()
Returns the x-coordinate of the "focus point".
Definition: SourcePanel.cpp:181
virtual ~Listener()
Destructor.
Definition: SourcePanel.h:88
void mouseDown(const MouseEvent &event) override
Definition: SourcePanel.cpp:73
void paint(Graphics &g)
Definition: SourcePanel.cpp:41
void mouseUp(const MouseEvent &event) override
Definition: SourcePanel.cpp:118
virtual void sourcePanelValuesChanged(SourcePanel *panel)=0
Called when the SourcePanel's value is changed.
SourcePanel(const String &componentName=String::empty)
Definition: SourcePanel.cpp:26
A GUI component that displays a two-dimensional view of a source's position and allows the re-positio...
Definition: SourcePanel.h:41
void removeListener(Listener *listener)
Removes a previously-registered listener.
Definition: SourcePanel.cpp:144
void addListener(Listener *listener)
Adds a listener to be called when this panel's values change.
Definition: SourcePanel.cpp:139
virtual void sourcePanelDragStarted(SourcePanel *panel)
Called when the position-dot is about to be dragged.
Definition: SourcePanel.h:98
A class for receiving callbacks from a SourcePanel.
Definition: SourcePanel.h:84
virtual void sourcePanelDragEnded(SourcePanel *panel)
Called after a drag operation has finished.
Definition: SourcePanel.h:114
float getFocusPointY()
Returns the y-coordinate of the "focus point".
Definition: SourcePanel.cpp:186
bool setSources(std::shared_ptr< const wonder::SourceCollection > sources)
Sets the SourceCollection object that holds the information about the sources to be displayed...
Definition: SourcePanel.cpp:149
bool setSource(int sourceID)
Sets the ID of the source to be shown as the main source that can be controlled using this SourcePane...
Definition: SourcePanel.cpp:160
void setShowOtherSources(bool showOthers)
Sets whether the other sources (not controlled by this panel) shall be shown.
Definition: SourcePanel.cpp:171
float getXPos()
Returns the x coordinate of the source controlled by this SourcePanel, normalized within [0...
Definition: SourcePanel.cpp:129
bool showsOtherSources() const
Returns the current showOtherSources setting.
Definition: SourcePanel.cpp:176