1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 */ 8 9 #ifndef SEEK_SLIDER_H 10 #define SEEK_SLIDER_H 11 12 #include <Box.h> 13 #include <Control.h> 14 15 class SeekSlider : public BControl { 16 public: 17 SeekSlider(BRect frame, 18 const char* name, 19 BMessage* message, 20 int32 minValue, 21 int32 maxValue); 22 23 virtual ~SeekSlider(); 24 25 // BControl interface 26 virtual void AttachedToWindow(); 27 virtual void SetValue(int32 value); 28 virtual void Draw(BRect updateRect); 29 virtual void MouseDown(BPoint where); 30 virtual void MouseMoved(BPoint where, uint32 transit, 31 const BMessage* dragMessage); 32 virtual void MouseUp(BPoint where); 33 virtual void ResizeToPreferred(); 34 35 // SeekSlider 36 void SetPosition(float position); 37 bool IsTracking() const; 38 39 private: 40 int32 _ValueFor(float x) const; 41 int32 _KnobPosFor(BRect bounds, 42 int32 value) const; 43 void _StrokeFrame(BRect frame, 44 rgb_color left, 45 rgb_color top, 46 rgb_color right, 47 rgb_color bottom); 48 void _SetKnobPosition(int32 knobPos); 49 50 51 bool fTracking; 52 bigtime_t fLastTrackTime; 53 int32 fKnobPos; 54 int32 fMinValue; 55 int32 fMaxValue; 56 }; 57 58 59 #endif //SEEK_SLIDER_H 60