blob: 62a84e989cecc953baed6820fce7cdc72415d102 [file] [log] [blame]
[email protected]8d1b864d12010-10-10 00:04:341// Copyright (c) 2010 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef GFX_NATIVE_THEME_LINUX_H_
6#define GFX_NATIVE_THEME_LINUX_H_
7
8#include "base/basictypes.h"
9#include "skia/ext/platform_canvas.h"
10
11namespace skia {
12class PlatformCanvas;
13}
14
15namespace gfx {
16class Rect;
17class Size;
18
19// Linux theming API.
20class NativeThemeLinux {
21 public:
22 // Gets our singleton instance.
23 static NativeThemeLinux* instance();
24
25 // The part to be painted / sized.
26 enum Part {
27 kScrollbarDownArrow,
28 kScrollbarLeftArrow,
29 kScrollbarRightArrow,
30 kScrollbarUpArrow,
31 kScrollbarHorizontalThumb,
32 kScrollbarVerticalThumb,
33 kScrollbarHorizontalTrack,
34 kScrollbarVerticalTrack
35 };
36
37 // The state of the part.
38 enum State {
39 kDisabled,
40 kHover,
41 kNormal,
42 kPressed,
43 };
44
45 // Extra data needed to draw scrollbar track correctly.
46 struct ScrollbarTrackExtraParams {
47 int track_x;
48 int track_y;
49 int track_width;
50 int track_height;
51 };
52
53 union ExtraParams {
54 ScrollbarTrackExtraParams scrollbar_track;
55 };
56
57 // Return the size of the part.
58 virtual gfx::Size GetSize(Part part) const;
59 // Paint the part to the canvas.
60 virtual void Paint(skia::PlatformCanvas* canvas,
61 Part part,
62 State state,
63 const gfx::Rect& rect,
64 const ExtraParams& extra);
65 // Supports theme specific colors.
66 void SetScrollbarColors(unsigned inactive_color,
67 unsigned active_color,
68 unsigned track_color) const;
69
70 protected:
71 NativeThemeLinux();
72 virtual ~NativeThemeLinux();
73
74 // Draw the arrow.
75 virtual void PaintArrowButton(
76 skia::PlatformCanvas* gc,
77 const gfx::Rect& rect,
78 Part direction,
79 State state);
80 // Paint the track. Done before the thumb so that it can contain alpha.
81 virtual void PaintTrack(skia::PlatformCanvas* canvas,
82 Part part,
83 State state,
84 const ScrollbarTrackExtraParams& extra_params,
85 const gfx::Rect& rect);
86 // Draw the thumb over the track.
87 virtual void PaintThumb(skia::PlatformCanvas* canvas,
88 Part part,
89 State state,
90 const gfx::Rect& rect);
91
92 private:
93 void DrawVertLine(SkCanvas* canvas,
94 int x,
95 int y1,
96 int y2,
97 const SkPaint& paint) const;
98 void DrawHorizLine(SkCanvas* canvas,
99 int x1,
100 int x2,
101 int y,
102 const SkPaint& paint) const;
103 void DrawBox(SkCanvas* canvas,
104 const gfx::Rect& rect,
105 const SkPaint& paint) const;
106 SkScalar Clamp(SkScalar value,
107 SkScalar min,
108 SkScalar max) const;
109 SkColor SaturateAndBrighten(SkScalar* hsv,
110 SkScalar saturate_amount,
111 SkScalar brighten_amount) const;
112 SkColor OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const;
113
114 static unsigned int scrollbar_width_;
115 static unsigned int button_length_;
116 static unsigned int thumb_inactive_color_;
117 static unsigned int thumb_active_color_;
118 static unsigned int track_color_;
119
120 DISALLOW_COPY_AND_ASSIGN(NativeThemeLinux);
121};
122
123} // namespace gfx
124
125#endif // GFX_NATIVE_THEME_LINUX_H_