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 class NativeTheme; | |
23 | |
24 // Observers which are notified when the native theme changes. | |
25 class NATIVE_THEME_EXPORT NativeThemeObserver { | |
sky
2014/04/24 22:52:01
nit: move to own file.
msw
2014/04/25 00:14:51
Done.
| |
26 public: | |
27 virtual ~NativeThemeObserver(); | |
sky
2014/04/24 22:52:01
make protected (since not owned).
msw
2014/04/25 00:14:51
Done.
| |
28 | |
29 // Called when the native theme changes. The observed theme is passed so that | |
30 // observers may handle changes to their associated native theme instances. | |
31 virtual void OnNativeThemeUpdate(ui::NativeTheme* observed_theme) = 0; | |
sky
2014/04/24 22:52:01
OnNativeThemeUpdated?
msw
2014/04/25 00:14:51
Done.
| |
32 }; | |
33 | |
21 // This class supports drawing UI controls (like buttons, text fields, lists, | 34 // This class supports drawing UI controls (like buttons, text fields, lists, |
22 // comboboxes, etc) that look like the native UI controls of the underlying | 35 // 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 | 36 // 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 | 37 // dialog box backgrounds, etc., which are obtained from the system theme where |
25 // possible. | 38 // possible. |
26 // | 39 // |
27 // The supported control types are listed in the Part enum. These parts can be | 40 // 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 | 41 // 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. | 42 // state is part-specific. The supported colors are listed in the ColorId enum. |
30 // | 43 // |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 // Return a color from the system theme. | 316 // Return a color from the system theme. |
304 virtual SkColor GetSystemColor(ColorId color_id) const = 0; | 317 virtual SkColor GetSystemColor(ColorId color_id) const = 0; |
305 | 318 |
306 // Returns a shared instance of the native theme. | 319 // Returns a shared instance of the native theme. |
307 // The returned object should not be deleted by the caller. This function | 320 // 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. | 321 // 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 | 322 // Each port of NativeTheme should provide its own implementation of this |
310 // function, returning the port's subclass. | 323 // function, returning the port's subclass. |
311 static NativeTheme* instance(); | 324 static NativeTheme* instance(); |
312 | 325 |
326 // Add or remove observers to be notified when the native theme changes. | |
327 void AddObserver(NativeThemeObserver* observer); | |
328 void RemoveObserver(NativeThemeObserver* observer); | |
329 | |
313 protected: | 330 protected: |
331 // Notify observers of native theme changes. | |
332 void NotifyObservers(); | |
333 | |
314 NativeTheme(); | 334 NativeTheme(); |
315 virtual ~NativeTheme(); | 335 virtual ~NativeTheme(); |
316 | 336 |
317 unsigned int thumb_inactive_color_; | 337 unsigned int thumb_inactive_color_; |
318 unsigned int thumb_active_color_; | 338 unsigned int thumb_active_color_; |
319 unsigned int track_color_; | 339 unsigned int track_color_; |
320 | 340 |
341 private: | |
342 // Observers to notify when the native theme changes. | |
343 ObserverList<NativeThemeObserver> native_theme_observers_; | |
344 | |
321 DISALLOW_COPY_AND_ASSIGN(NativeTheme); | 345 DISALLOW_COPY_AND_ASSIGN(NativeTheme); |
322 }; | 346 }; |
323 | 347 |
324 } // namespace ui | 348 } // namespace ui |
325 | 349 |
326 #endif // UI_NATIVE_THEME_NATIVE_THEME_H_ | 350 #endif // UI_NATIVE_THEME_NATIVE_THEME_H_ |
OLD | NEW |