1 /* 2 * Copyright 2006-2012 Stephan Aßmus <superstippi@gmx.de> 3 * Distributed under the terms of the MIT License. 4 */ 5 6 #ifndef ALPHA_SLIDER_H 7 #define ALPHA_SLIDER_H 8 9 #include <Control.h> 10 11 class AlphaSlider : public BControl { 12 public: 13 AlphaSlider(orientation dir = B_HORIZONTAL, 14 BMessage* message = NULL, 15 border_style border = B_FANCY_BORDER); 16 virtual ~AlphaSlider(); 17 18 // BControl interface 19 virtual void WindowActivated(bool active); 20 virtual void MakeFocus(bool focus); 21 22 virtual BSize MinSize(); 23 virtual BSize PreferredSize(); 24 virtual BSize MaxSize(); 25 26 virtual void MouseDown(BPoint where); 27 virtual void MouseUp(BPoint where); 28 virtual void MouseMoved(BPoint where, uint32 transit, 29 const BMessage* dragMessage); 30 31 virtual void KeyDown(const char* bytes, int32 numBytes); 32 33 virtual void Draw(BRect updateRect); 34 virtual void FrameResized(float width, float height); 35 36 virtual void SetValue(int32 value); 37 virtual void SetEnabled(bool enabled); 38 39 // AlphaSlider 40 void SetColor(const rgb_color& color); 41 IsTracking()42 bool IsTracking() const 43 { return fDragging; } 44 45 private: 46 void _UpdateColors(); 47 void _AllocBitmap(int32 width, int32 height); 48 BRect _BitmapRect() const; 49 int32 _ValueFor(BPoint where) const; 50 51 private: 52 BBitmap* fBitmap; 53 rgb_color fColor; 54 bool fDragging; 55 orientation fOrientation; 56 border_style fBorderStyle; 57 }; 58 59 #endif // ALPHA_SLIDER_H 60