xref: /haiku/src/apps/midiplayer/ScopeView.h (revision ef2769426fe2a0bec2985377f99752d8a2cc2c3b)
10fe1abb5Smahlzeit /*
20fe1abb5Smahlzeit  * Copyright (c) 2004 Matthijs Hollemans
3*ef276942SJohn Scipione  * Copyright (c) 2008-2014 Haiku, Inc. All rights reserved.
40fe1abb5Smahlzeit  *
50fe1abb5Smahlzeit  * Permission is hereby granted, free of charge, to any person obtaining a
60fe1abb5Smahlzeit  * copy of this software and associated documentation files (the "Software"),
70fe1abb5Smahlzeit  * to deal in the Software without restriction, including without limitation
80fe1abb5Smahlzeit  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
90fe1abb5Smahlzeit  * and/or sell copies of the Software, and to permit persons to whom the
100fe1abb5Smahlzeit  * Software is furnished to do so, subject to the following conditions:
110fe1abb5Smahlzeit  *
120fe1abb5Smahlzeit  * The above copyright notice and this permission notice shall be included in
130fe1abb5Smahlzeit  * all copies or substantial portions of the Software.
140fe1abb5Smahlzeit  *
150fe1abb5Smahlzeit  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
160fe1abb5Smahlzeit  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
170fe1abb5Smahlzeit  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
180fe1abb5Smahlzeit  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
190fe1abb5Smahlzeit  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
200fe1abb5Smahlzeit  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
210fe1abb5Smahlzeit  * DEALINGS IN THE SOFTWARE.
220fe1abb5Smahlzeit  */
2342bcaa84SJohn Scipione #ifndef _SCOPE_VIEW_H
2442bcaa84SJohn Scipione #define _SCOPE_VIEW_H
250fe1abb5Smahlzeit 
260fe1abb5Smahlzeit 
270fe1abb5Smahlzeit #include <View.h>
280fe1abb5Smahlzeit 
290fe1abb5Smahlzeit 
3042bcaa84SJohn Scipione class ScopeView : public BView {
3142bcaa84SJohn Scipione public:
320fe1abb5Smahlzeit 	ScopeView();
330fe1abb5Smahlzeit 	virtual ~ScopeView();
340fe1abb5Smahlzeit 
3579054474Smahlzeit 	virtual void AttachedToWindow();
3679054474Smahlzeit 	virtual void DetachedFromWindow();
3779054474Smahlzeit 	virtual void Draw(BRect updateRect);
3879054474Smahlzeit 
3942bcaa84SJohn Scipione 	void SetPlaying(bool playing);
4042bcaa84SJohn Scipione 	void SetEnabled(bool enabled);
4142bcaa84SJohn Scipione 	void SetHaveFile(bool haveFile);
4242bcaa84SJohn Scipione 	void SetLoading(bool loading);
4342bcaa84SJohn Scipione 	void SetLiveInput(bool liveInput);
440fe1abb5Smahlzeit 
450fe1abb5Smahlzeit private:
460fe1abb5Smahlzeit 	typedef BView super;
470fe1abb5Smahlzeit 
4879054474Smahlzeit 	static int32 _Thread(void* data);
4979054474Smahlzeit 	int32 Thread();
5079054474Smahlzeit 
51c75d8265Smahlzeit 	void DrawLoading();
5279054474Smahlzeit 	void DrawNoFile();
5379054474Smahlzeit 	void DrawDisabled();
54b1902a09Smahlzeit 	void DrawStopped();
5579054474Smahlzeit 	void DrawPlaying();
5679054474Smahlzeit 
57c75d8265Smahlzeit 	void DrawText(const char* text);
58c75d8265Smahlzeit 
5942bcaa84SJohn Scipione 	bool fIsFinished;
6042bcaa84SJohn Scipione 	bool fIsPlaying;
6142bcaa84SJohn Scipione 	bool fIsEnabled;
6242bcaa84SJohn Scipione 	bool fHaveFile;
6342bcaa84SJohn Scipione 	bool fIsLoading;
6442bcaa84SJohn Scipione 	bool fIsLiveInput;
6542bcaa84SJohn Scipione 
6642bcaa84SJohn Scipione 	int32 fSampleCount;
6742bcaa84SJohn Scipione 	int16* fLeftSamples;
6842bcaa84SJohn Scipione 	int16* fRightSamples;
6942bcaa84SJohn Scipione 
7042bcaa84SJohn Scipione 	thread_id fScopeThreadID;
710fe1abb5Smahlzeit };
720fe1abb5Smahlzeit 
7342bcaa84SJohn Scipione 
7442bcaa84SJohn Scipione inline void
SetPlaying(bool playing)7542bcaa84SJohn Scipione ScopeView::SetPlaying(bool playing)
7642bcaa84SJohn Scipione {
7742bcaa84SJohn Scipione 	fIsPlaying = playing;
7842bcaa84SJohn Scipione }
7942bcaa84SJohn Scipione 
8042bcaa84SJohn Scipione 
8142bcaa84SJohn Scipione inline void
SetEnabled(bool enabled)8242bcaa84SJohn Scipione ScopeView::SetEnabled(bool enabled)
8342bcaa84SJohn Scipione {
8442bcaa84SJohn Scipione 	fIsEnabled = enabled;
8542bcaa84SJohn Scipione }
8642bcaa84SJohn Scipione 
8742bcaa84SJohn Scipione 
8842bcaa84SJohn Scipione inline void
SetHaveFile(bool haveFile)8942bcaa84SJohn Scipione ScopeView::SetHaveFile(bool haveFile)
9042bcaa84SJohn Scipione {
9142bcaa84SJohn Scipione 	fHaveFile = haveFile;
9242bcaa84SJohn Scipione }
9342bcaa84SJohn Scipione 
9442bcaa84SJohn Scipione 
9542bcaa84SJohn Scipione inline void
SetLoading(bool loading)9642bcaa84SJohn Scipione ScopeView::SetLoading(bool loading)
9742bcaa84SJohn Scipione {
9842bcaa84SJohn Scipione 	fIsLoading = loading;
9942bcaa84SJohn Scipione }
10042bcaa84SJohn Scipione 
10142bcaa84SJohn Scipione 
10242bcaa84SJohn Scipione inline void
SetLiveInput(bool liveInput)10342bcaa84SJohn Scipione ScopeView::SetLiveInput(bool liveInput)
10442bcaa84SJohn Scipione {
10542bcaa84SJohn Scipione 	fIsLiveInput = liveInput;
10642bcaa84SJohn Scipione }
10742bcaa84SJohn Scipione 
10842bcaa84SJohn Scipione 
10942bcaa84SJohn Scipione #endif // _SCOPE_VIEW_H
110