Chromium Code Reviews| Index: ui/gfx/native_theme_android.h |
| diff --git a/ui/gfx/native_theme_android.h b/ui/gfx/native_theme_android.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f35990bb7feea4b9d3f89fa5ca50d1c8eb719a9b |
| --- /dev/null |
| +++ b/ui/gfx/native_theme_android.h |
| @@ -0,0 +1,208 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_GFX_NATIVE_THEME_ANDROID_H_ |
| +#define UI_GFX_NATIVE_THEME_ANDROID_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "skia/ext/platform_canvas.h" |
| + |
| +namespace gfx { |
| +class Rect; |
| +class Size; |
| + |
| +// Android theming API. |
| +class NativeThemeAndroid { |
| + public: |
| + // The part to be painted / sized. |
| + enum Part { |
| + kScrollbarDownArrow, |
|
sky
2011/11/10 00:41:01
Use CAP_STYLE. The chromium style guide calls this
michaelbai
2011/11/10 22:51:36
These styles were used in all native_theme_{platfo
sky
2011/11/10 23:21:28
See native_theme_win.h
michaelbai
2011/11/11 00:11:47
Done.
|
| + kScrollbarLeftArrow, |
| + kScrollbarRightArrow, |
| + kScrollbarUpArrow, |
| + kCheckbox, |
| + kRadio, |
| + kPushButton, |
| + kTextField, |
| + kMenuList, |
| + kSliderTrack, |
| + kSliderThumb, |
| + kInnerSpinButton, |
| + kProgressBar, |
| + }; |
| + |
| + // The state of the part. |
| + enum State { |
| + kDisabled, |
| + kHovered, |
| + kNormal, |
| + kPressed, |
| + }; |
| + |
| + struct ButtonExtraParams { |
| + bool checked; |
| + bool indeterminate; // Whether the button state is indeterminate. |
| + bool is_default; // Whether the button is default button. |
| + bool has_border; |
| + SkColor background_color; |
| + }; |
| + |
| + struct TextFieldExtraParams { |
| + bool is_text_area; |
| + bool is_listbox; |
| + SkColor background_color; |
| + }; |
| + |
| + struct MenuListExtraParams { |
| + bool has_border; |
| + bool has_border_radius; |
| + int arrow_x; |
| + int arrow_y; |
| + SkColor background_color; |
| + }; |
| + |
| + struct SliderExtraParams { |
| + bool vertical; |
| + bool in_drag; |
| + }; |
| + |
| + struct InnerSpinButtonExtraParams { |
| + bool spin_up; |
| + bool read_only; |
| + }; |
| + |
| + struct ProgressBarExtraParams { |
| + bool determinate; |
| + int value_rect_x; |
| + int value_rect_y; |
| + int value_rect_width; |
| + int value_rect_height; |
| + }; |
| + |
| + union ExtraParams { |
| + ButtonExtraParams button; |
| + MenuListExtraParams menu_list; |
| + SliderExtraParams slider; |
| + TextFieldExtraParams text_field; |
| + InnerSpinButtonExtraParams inner_spin; |
| + ProgressBarExtraParams progress_bar; |
| + }; |
| + |
| + // Gets our singleton instance. |
| + static NativeThemeAndroid* instance(); |
| + |
| + // Return the size of the part. |
| + virtual gfx::Size GetPartSize(Part part) const; |
|
sky
2011/11/10 00:41:01
Are there subclasses that warrant this being virtu
michaelbai
2011/11/10 22:51:36
Removed 'virtual', thanks
|
| + // Paint the part to the canvas. |
|
sky
2011/11/10 00:41:01
newline between 96 and 97.
michaelbai
2011/11/10 22:51:36
Done.
|
| + virtual void Paint(SkCanvas* canvas, |
| + Part part, |
| + State state, |
| + const gfx::Rect& rect, |
| + const ExtraParams& extra); |
| + |
| + protected: |
| + NativeThemeAndroid(); |
| + virtual ~NativeThemeAndroid(); |
| + |
| + // Draw the arrow. Used by scrollbar and inner spin button. |
| + virtual void PaintArrowButton( |
| + SkCanvas* gc, |
| + const gfx::Rect& rect, |
| + Part direction, |
| + State state); |
| + // Draw the checkbox. |
|
sky
2011/11/10 00:41:01
newline between methods.
michaelbai
2011/11/10 22:51:36
Done.
|
| + virtual void PaintCheckbox(SkCanvas* canvas, |
|
sky
2011/11/10 00:41:01
If you can't nicely align all params with the '(',
michaelbai
2011/11/10 22:51:36
Done.
|
| + State state, |
| + const gfx::Rect& rect, |
| + const ButtonExtraParams& button); |
| + // Draw the radio. |
| + virtual void PaintRadio(SkCanvas* canvas, |
| + State state, |
| + const gfx::Rect& rect, |
| + const ButtonExtraParams& button); |
| + // Draw the push button. |
| + virtual void PaintButton(SkCanvas* canvas, |
| + State state, |
| + const gfx::Rect& rect, |
| + const ButtonExtraParams& button); |
| + // Draw the text field. |
| + virtual void PaintTextField(SkCanvas* canvas, |
| + State state, |
| + const gfx::Rect& rect, |
| + const TextFieldExtraParams& text); |
| + // Draw the menu list. |
| + virtual void PaintMenuList(SkCanvas* canvas, |
| + State state, |
| + const gfx::Rect& rect, |
| + const MenuListExtraParams& menu_list); |
| + // Draw the slider track. |
| + virtual void PaintSliderTrack(SkCanvas* canvas, |
| + State state, |
| + const gfx::Rect& rect, |
| + const SliderExtraParams& slider); |
| + // Draw the slider thumb. |
| + virtual void PaintSliderThumb(SkCanvas* canvas, |
| + State state, |
| + const gfx::Rect& rect, |
| + const SliderExtraParams& slider); |
| + // Draw the inner spin button. |
| + virtual void PaintInnerSpinButton(SkCanvas* canvas, |
| + State state, |
| + const gfx::Rect& rect, |
| + const InnerSpinButtonExtraParams& spin_button); |
| + // Draw the progress bar. |
| + virtual void PaintProgressBar(SkCanvas* canvas, |
| + State state, |
| + const gfx::Rect& rect, |
| + const ProgressBarExtraParams& progress_bar); |
| + |
| + protected: |
|
sky
2011/11/10 00:41:01
remove this since you're already in the protected
michaelbai
2011/11/10 22:51:36
Done.
|
| + bool IntersectsClipRectInt(SkCanvas* canvas, |
|
sky
2011/11/10 00:41:01
Add descriptions of all your methods.
michaelbai
2011/11/10 22:51:36
Done.
|
| + int x, int y, int w, int h); |
| + |
| + void DrawBitmapInt(SkCanvas* canvas, const SkBitmap& bitmap, |
|
sky
2011/11/10 00:41:01
wrap bitmap to the next line.
michaelbai
2011/11/10 22:51:36
Done.
|
| + int src_x, int src_y, int src_w, int src_h, |
| + int dest_x, int dest_y, int dest_w, int dest_h); |
| + |
| + void DrawTiledImage(SkCanvas* canvas, |
| + const SkBitmap& bitmap, |
| + int src_x, int src_y, |
| + double tile_scale_x, double tile_scale_y, |
| + int dest_x, int dest_y, int w, int h) const; |
| + |
| + SkColor SaturateAndBrighten(SkScalar* hsv, |
| + SkScalar saturate_amount, |
| + SkScalar brighten_amount) const; |
| + |
| + private: |
| + void DrawVertLine(SkCanvas* canvas, |
| + int x, |
| + int y1, |
| + int y2, |
| + const SkPaint& paint) const; |
| + void DrawHorizLine(SkCanvas* canvas, |
| + int x1, |
| + int x2, |
| + int y, |
| + const SkPaint& paint) const; |
| + void DrawBox(SkCanvas* canvas, |
| + const gfx::Rect& rect, |
| + const SkPaint& paint) const; |
| + SkScalar Clamp(SkScalar value, |
| + SkScalar min, |
| + SkScalar max) const; |
| + SkColor OutlineColor(SkScalar* hsv1, SkScalar* hsv2) const; |
| + |
| + static unsigned int scrollbar_width_; |
| + static unsigned int button_length_; |
| + static unsigned int thumb_inactive_color_; |
| + static unsigned int thumb_active_color_; |
| + static unsigned int track_color_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(NativeThemeAndroid); |
| +}; |
| + |
| +} // namespace gfx |
| + |
| +#endif // UI_GFX_NATIVE_THEME_ANDROID_H_ |