xref: /haiku/src/apps/soundrecorder/TrackSlider.h (revision 24159a0c7d6d6dcba9f2a0c1a7c08d2c8167f21b)
1 /*
2  * Copyright 2005, Jérôme Duval. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Inspired by SoundCapture from Be newsletter (Media Kit Basics: Consumers and Producers)
6  */
7 #ifndef TRACKSLIDER_H
8 #define TRACKSLIDER_H
9 
10 #include <Control.h>
11 #include <Bitmap.h>
12 #include <Font.h>
13 
14 class TrackSlider : public BControl
15 {
16 public:
17 	TrackSlider(BRect rect, const char* title, BMessage *msg, uint32 resizeFlags);
18 	~TrackSlider();
19 	void AttachedToWindow();
20 	virtual void Draw(BRect);
21 	virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
22 	virtual void MouseUp(BPoint point);
23 	virtual void MouseDown(BPoint point);
24 	void SetMainTime(bigtime_t timestamp, bool reset);
25 	void SetTotalTime(bigtime_t timestamp, bool reset);
26 	bigtime_t * MainTime() { return &fMainTime; };
27 	bigtime_t RightTime() { return fRightTime; };
28 	bigtime_t LeftTime() { return fLeftTime; };
29 	void ResetMainTime();
30 	virtual void FrameResized(float width, float height);
31 private:
32 	void DrawCounter(bigtime_t timestamp, float position, bool isTracking);
33 	void TimeToString(bigtime_t timestamp, char *string);
34 	void UpdatePosition(BPoint point);
35 	BBitmap leftBitmap, rightBitmap, leftThumbBitmap, rightThumbBitmap;
36 	float fRight;
37 
38 	bigtime_t fLeftTime;
39 	bigtime_t fRightTime;
40 	bigtime_t fMainTime;
41 	bigtime_t fTotalTime;
42 
43 	float fPositionX;
44 	float fLeftX;
45 	float fRightX;
46 	float fLastX;
47 	bool fLeftTracking;
48 	bool fRightTracking;
49 	bool fMainTracking;
50 
51 	BFont fFont;
52 };
53 
54 #endif	/* TRACKSLIDER_H */
55