blob: 0ee1dd592e28665441308abd9597580e2f67a9d5 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
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.comc5aeccd2011-07-17 14:42:08 +00008#ifndef SkColorPalette_DEFINED
9#define SkColorPalette_DEFINED
10
11#define PaletteSlots 5
12#define PalettePadding 5
13class SkColorPalette : public SkView {
14public:
15 SkColorPalette();
16 SkColor getColor() { return fCurrColor; }
17protected:
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();
23private:
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.combda03db2012-08-14 20:27:54 +000034#endif