xref: /haiku/src/apps/midiplayer/ScopeView.h (revision 42bcaa84c0eb475d3f6c49a7a7f4cc8d72083f5b)
10fe1abb5Smahlzeit /*
20fe1abb5Smahlzeit  * Copyright (c) 2004 Matthijs Hollemans
30fe1abb5Smahlzeit  *
40fe1abb5Smahlzeit  * Permission is hereby granted, free of charge, to any person obtaining a
50fe1abb5Smahlzeit  * copy of this software and associated documentation files (the "Software"),
60fe1abb5Smahlzeit  * to deal in the Software without restriction, including without limitation
70fe1abb5Smahlzeit  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
80fe1abb5Smahlzeit  * and/or sell copies of the Software, and to permit persons to whom the
90fe1abb5Smahlzeit  * Software is furnished to do so, subject to the following conditions:
100fe1abb5Smahlzeit  *
110fe1abb5Smahlzeit  * The above copyright notice and this permission notice shall be included in
120fe1abb5Smahlzeit  * all copies or substantial portions of the Software.
130fe1abb5Smahlzeit  *
140fe1abb5Smahlzeit  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
150fe1abb5Smahlzeit  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
160fe1abb5Smahlzeit  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
170fe1abb5Smahlzeit  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
180fe1abb5Smahlzeit  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
190fe1abb5Smahlzeit  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
200fe1abb5Smahlzeit  * DEALINGS IN THE SOFTWARE.
210fe1abb5Smahlzeit  */
22*42bcaa84SJohn Scipione #ifndef _SCOPE_VIEW_H
23*42bcaa84SJohn Scipione #define _SCOPE_VIEW_H
240fe1abb5Smahlzeit 
250fe1abb5Smahlzeit 
260fe1abb5Smahlzeit #include <View.h>
270fe1abb5Smahlzeit 
280fe1abb5Smahlzeit 
29*42bcaa84SJohn Scipione class ScopeView : public BView {
30*42bcaa84SJohn Scipione public:
310fe1abb5Smahlzeit 	ScopeView();
320fe1abb5Smahlzeit 	virtual ~ScopeView();
330fe1abb5Smahlzeit 
3479054474Smahlzeit 	virtual void AttachedToWindow();
3579054474Smahlzeit 	virtual void DetachedFromWindow();
3679054474Smahlzeit 	virtual void Draw(BRect updateRect);
3779054474Smahlzeit 
38*42bcaa84SJohn Scipione 	void SetPlaying(bool playing);
39*42bcaa84SJohn Scipione 	void SetEnabled(bool enabled);
40*42bcaa84SJohn Scipione 	void SetHaveFile(bool haveFile);
41*42bcaa84SJohn Scipione 	void SetLoading(bool loading);
42*42bcaa84SJohn Scipione 	void SetLiveInput(bool liveInput);
430fe1abb5Smahlzeit 
440fe1abb5Smahlzeit private:
450fe1abb5Smahlzeit 	typedef BView super;
460fe1abb5Smahlzeit 
4779054474Smahlzeit 	static int32 _Thread(void* data);
4879054474Smahlzeit 	int32 Thread();
4979054474Smahlzeit 
50c75d8265Smahlzeit 	void DrawLoading();
5179054474Smahlzeit 	void DrawNoFile();
5279054474Smahlzeit 	void DrawDisabled();
53b1902a09Smahlzeit 	void DrawStopped();
5479054474Smahlzeit 	void DrawPlaying();
5579054474Smahlzeit 
56c75d8265Smahlzeit 	void DrawText(const char* text);
57c75d8265Smahlzeit 
58*42bcaa84SJohn Scipione 	bool fIsFinished;
59*42bcaa84SJohn Scipione 	bool fIsPlaying;
60*42bcaa84SJohn Scipione 	bool fIsEnabled;
61*42bcaa84SJohn Scipione 	bool fHaveFile;
62*42bcaa84SJohn Scipione 	bool fIsLoading;
63*42bcaa84SJohn Scipione 	bool fIsLiveInput;
64*42bcaa84SJohn Scipione 
65*42bcaa84SJohn Scipione 	int32 fSampleCount;
66*42bcaa84SJohn Scipione 	int16* fLeftSamples;
67*42bcaa84SJohn Scipione 	int16* fRightSamples;
68*42bcaa84SJohn Scipione 
69*42bcaa84SJohn Scipione 	thread_id fScopeThreadID;
700fe1abb5Smahlzeit };
710fe1abb5Smahlzeit 
72*42bcaa84SJohn Scipione 
73*42bcaa84SJohn Scipione inline void
74*42bcaa84SJohn Scipione ScopeView::SetPlaying(bool playing)
75*42bcaa84SJohn Scipione {
76*42bcaa84SJohn Scipione 	fIsPlaying = playing;
77*42bcaa84SJohn Scipione }
78*42bcaa84SJohn Scipione 
79*42bcaa84SJohn Scipione 
80*42bcaa84SJohn Scipione inline void
81*42bcaa84SJohn Scipione ScopeView::SetEnabled(bool enabled)
82*42bcaa84SJohn Scipione {
83*42bcaa84SJohn Scipione 	fIsEnabled = enabled;
84*42bcaa84SJohn Scipione }
85*42bcaa84SJohn Scipione 
86*42bcaa84SJohn Scipione 
87*42bcaa84SJohn Scipione inline void
88*42bcaa84SJohn Scipione ScopeView::SetHaveFile(bool haveFile)
89*42bcaa84SJohn Scipione {
90*42bcaa84SJohn Scipione 	fHaveFile = haveFile;
91*42bcaa84SJohn Scipione }
92*42bcaa84SJohn Scipione 
93*42bcaa84SJohn Scipione 
94*42bcaa84SJohn Scipione inline void
95*42bcaa84SJohn Scipione ScopeView::SetLoading(bool loading)
96*42bcaa84SJohn Scipione {
97*42bcaa84SJohn Scipione 	fIsLoading = loading;
98*42bcaa84SJohn Scipione }
99*42bcaa84SJohn Scipione 
100*42bcaa84SJohn Scipione 
101*42bcaa84SJohn Scipione inline void
102*42bcaa84SJohn Scipione ScopeView::SetLiveInput(bool liveInput)
103*42bcaa84SJohn Scipione {
104*42bcaa84SJohn Scipione 	fIsLiveInput = liveInput;
105*42bcaa84SJohn Scipione }
106*42bcaa84SJohn Scipione 
107*42bcaa84SJohn Scipione 
108*42bcaa84SJohn Scipione #endif // _SCOPE_VIEW_H
109