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
14class SliderOffscreenView : public BView {
15
16public:
17	SliderOffscreenView(BRect frame, const char *name);
18	virtual		~SliderOffscreenView();
19	virtual	void	DrawX();
20
21	BBitmap leftBitmap, rightBitmap;
22	BBitmap leftThumbBitmap, rightThumbBitmap;
23	float fRight;
24
25	float fLeftX;
26	float fRightX;
27	float fPositionX;
28	float fLastX;
29};
30
31class TrackSlider : public BControl
32{
33public:
34	TrackSlider(BRect rect, const char* title, BMessage *msg, uint32 resizeFlags);
35	~TrackSlider();
36	void AttachedToWindow();
37	virtual void Draw(BRect);
38	virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
39	virtual void MouseUp(BPoint point);
40	virtual void MouseDown(BPoint point);
41	void SetMainTime(bigtime_t timestamp, bool reset);
42	void SetTotalTime(bigtime_t timestamp, bool reset);
43	bigtime_t * MainTime() { return &fMainTime; };
44	bigtime_t RightTime() { return fRightTime; };
45	bigtime_t LeftTime() { return fLeftTime; };
46	void ResetMainTime();
47	virtual void FrameResized(float width, float height);
48private:
49	void _DrawCounter(bigtime_t timestamp, float position, bool isTracking);
50	void _DrawMarker(float position);
51	void _TimeToString(bigtime_t timestamp, char *string);
52	void _UpdatePosition(BPoint point);
53	void _InitBitmap();
54	void _RenderBitmap();
55
56
57	bigtime_t fLeftTime;
58	bigtime_t fRightTime;
59	bigtime_t fMainTime;
60	bigtime_t fTotalTime;
61
62	bool fLeftTracking;
63	bool fRightTracking;
64	bool fMainTracking;
65
66	BFont fFont;
67	BBitmap *fBitmap;
68	SliderOffscreenView *fBitmapView;
69
70};
71
72
73#endif	/* TRACKSLIDER_H */
74