1 /*
2  *  tracker/PeakLevelControl.h
3  *
4  *  Copyright 2009 Peter Barth
5  *
6  *  This file is part of Milkytracker.
7  *
8  *  Milkytracker is free software: you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation, either version 3 of the License, or
11  *  (at your option) any later version.
12  *
13  *  Milkytracker is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with Milkytracker.  If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 /*
24  *  PeakLevelControl.h
25  *  MilkyTracker
26  *
27  *  Created by Peter Barth on 28.10.05.
28  *
29  */
30 
31 #ifndef PEAKLEVELCONTROL__H
32 #define PEAKLEVELCONTROL__H
33 
34 #include "BasicTypes.h"
35 #include "Control.h"
36 #include "Event.h"
37 
38 class PeakLevelControl : public PPControl
39 {
40 private:
41 	PPColor color;
42 
43 	bool border;
44 	PPColor ourOwnBorderColor;
45 	const PPColor* borderColor;
46 
47 	// extent
48 	pp_int32 visibleWidth;
49 	pp_int32 visibleHeight;
50 
51 	pp_int32 peak[2];
52 
53 	pp_uint8 peakColorLUT[256][3];
54 
55 public:
56 	PeakLevelControl(pp_int32 id,
57 					 PPScreen* parentScreen,
58 					 EventListenerInterface* eventListener,
59 					 const PPPoint& location, const PPSize& size,
60 					 bool border = true);
61 
62 	~PeakLevelControl();
63 
setColor(pp_int32 r,pp_int32 g,pp_int32 b)64 	void setColor(pp_int32 r,pp_int32 g,pp_int32 b) { color.r = r; color.g = g; color.b = b; }
setColor(PPColor color)65 	void setColor(PPColor color) { this->color = color; }
66 
setBorderColor(const PPColor & color)67 	void setBorderColor(const PPColor& color) { this->borderColor = &color; }
68 
setPeak(pp_int32 whichPeak,pp_int32 p)69 	void setPeak(pp_int32 whichPeak, pp_int32 p) { if (p>65536) p = 65536; if (p < 0) p = 0; peak[whichPeak] = p; }
getPeak(pp_int32 whichPeak)70 	pp_int32 getPeak(pp_int32 whichPeak) const { return peak[whichPeak]; }
71 
72 	// from PPControl
73 	virtual void paint(PPGraphicsAbstract* graphics);
74 
75 private:
76 	void buildColorLUT();
77 };
78 
79 
80 #endif
81