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