epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | */ |
yangsu@google.com | c5aeccd | 2011-07-17 14:42:08 +0000 | [diff] [blame] | 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(); |
| 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 | |
rmistry@google.com | bda03db | 2012-08-14 20:27:54 +0000 | [diff] [blame^] | 34 | #endif |
| 35 | |