1 
2 /*
3  * Copyright 2011 Google Inc.
4  *
5  * Use of this source code is governed by a BSD-style license that can be
6  * found in the LICENSE file.
7  */
8 #ifndef SkColorPalette_DEFINED
9 #define SkColorPalette_DEFINED
10 
11 #define PaletteSlots 5
12 #define PalettePadding 5
13 class SkColorPalette : public SkView {
14 public:
15     SkColorPalette();
getColor()16     SkColor getColor() { return fCurrColor; }
17 protected:
18     virtual bool onEvent(const SkEvent& evt);
19     virtual void onDraw(SkCanvas* canvas);
20     virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y);
21     virtual bool onClick(SkView::Click* click);
22     virtual void onSizeChange();
23 private:
24     int selectSlot(SkPoint& cursorPosition);
25     SkColor selectColorFromGradient(SkPoint& cursorPosition);
26     int     fSelected;
27     SkRect  fGradientRect;
28     SkRect  fSlotRect;
29     SkColor fCurrColor;
30     SkColor fColors[PaletteSlots];
31     typedef SkView INHERITED;
32 };
33 
34 #endif
35