OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_NATIVE_THEME_NATIVE_THEME_H_ | 5 #ifndef UI_NATIVE_THEME_NATIVE_THEME_H_ |
6 #define UI_NATIVE_THEME_NATIVE_THEME_H_ | 6 #define UI_NATIVE_THEME_NATIVE_THEME_H_ |
7 | 7 |
| 8 #include "base/observer_list.h" |
8 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
9 #include "ui/gfx/native_widget_types.h" | 10 #include "ui/gfx/native_widget_types.h" |
10 #include "ui/native_theme/native_theme_export.h" | 11 #include "ui/native_theme/native_theme_export.h" |
11 | 12 |
12 class SkCanvas; | 13 class SkCanvas; |
13 | 14 |
14 namespace gfx { | 15 namespace gfx { |
15 class Rect; | 16 class Rect; |
16 class Size; | 17 class Size; |
17 } | 18 } |
18 | 19 |
19 namespace ui { | 20 namespace ui { |
20 | 21 |
| 22 // Observers which are notified when the native theme changes. |
| 23 class NATIVE_THEME_EXPORT NativeThemeObserver { |
| 24 public: |
| 25 virtual ~NativeThemeObserver(); |
| 26 |
| 27 // Called whenever the underlying platform's native theme changes. |
| 28 virtual void OnNativeThemeUpdate() = 0; |
| 29 }; |
| 30 |
21 // This class supports drawing UI controls (like buttons, text fields, lists, | 31 // This class supports drawing UI controls (like buttons, text fields, lists, |
22 // comboboxes, etc) that look like the native UI controls of the underlying | 32 // comboboxes, etc) that look like the native UI controls of the underlying |
23 // platform, such as Windows or Linux. It also supplies default colors for | 33 // platform, such as Windows or Linux. It also supplies default colors for |
24 // dialog box backgrounds, etc., which are obtained from the system theme where | 34 // dialog box backgrounds, etc., which are obtained from the system theme where |
25 // possible. | 35 // possible. |
26 // | 36 // |
27 // The supported control types are listed in the Part enum. These parts can be | 37 // The supported control types are listed in the Part enum. These parts can be |
28 // in any state given by the State enum, where the actual definition of the | 38 // in any state given by the State enum, where the actual definition of the |
29 // state is part-specific. The supported colors are listed in the ColorId enum. | 39 // state is part-specific. The supported colors are listed in the ColorId enum. |
30 // | 40 // |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 // Return a color from the system theme. | 313 // Return a color from the system theme. |
304 virtual SkColor GetSystemColor(ColorId color_id) const = 0; | 314 virtual SkColor GetSystemColor(ColorId color_id) const = 0; |
305 | 315 |
306 // Returns a shared instance of the native theme. | 316 // Returns a shared instance of the native theme. |
307 // The returned object should not be deleted by the caller. This function | 317 // The returned object should not be deleted by the caller. This function |
308 // is not thread safe and should only be called from the UI thread. | 318 // is not thread safe and should only be called from the UI thread. |
309 // Each port of NativeTheme should provide its own implementation of this | 319 // Each port of NativeTheme should provide its own implementation of this |
310 // function, returning the port's subclass. | 320 // function, returning the port's subclass. |
311 static NativeTheme* instance(); | 321 static NativeTheme* instance(); |
312 | 322 |
| 323 // Add or remove observers to be notified when the native theme changes. |
| 324 void AddObserver(NativeThemeObserver* observer); |
| 325 void RemoveObserver(NativeThemeObserver* observer); |
| 326 |
313 protected: | 327 protected: |
| 328 // Notify observers of native theme state changes. |
| 329 void NotifyObservers(); |
| 330 |
314 NativeTheme(); | 331 NativeTheme(); |
315 virtual ~NativeTheme(); | 332 virtual ~NativeTheme(); |
316 | 333 |
317 unsigned int thumb_inactive_color_; | 334 unsigned int thumb_inactive_color_; |
318 unsigned int thumb_active_color_; | 335 unsigned int thumb_active_color_; |
319 unsigned int track_color_; | 336 unsigned int track_color_; |
320 | 337 |
| 338 private: |
| 339 // Observers to notify when the theme state changes. |
| 340 ObserverList<NativeThemeObserver> native_theme_observers_; |
| 341 |
321 DISALLOW_COPY_AND_ASSIGN(NativeTheme); | 342 DISALLOW_COPY_AND_ASSIGN(NativeTheme); |
322 }; | 343 }; |
323 | 344 |
324 } // namespace ui | 345 } // namespace ui |
325 | 346 |
326 #endif // UI_NATIVE_THEME_NATIVE_THEME_H_ | 347 #endif // UI_NATIVE_THEME_NATIVE_THEME_H_ |
OLD | NEW |