Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: ui/native_theme/native_theme.h

Issue 239093007: Update Windows UI on system color changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "ui/gfx/sys_color_change_listener.h"
10 #include "ui/native_theme/native_theme_export.h" 12 #include "ui/native_theme/native_theme_export.h"
11 13
12 class SkCanvas; 14 class SkCanvas;
13 15
14 namespace gfx { 16 namespace gfx {
15 class Rect; 17 class Rect;
16 class Size; 18 class Size;
17 } 19 }
18 20
19 namespace ui { 21 namespace ui {
20 22
23 // Observers which are notified when the native theme changes.
24 class NATIVE_THEME_EXPORT NativeThemeObserver {
Evan Stade 2014/04/22 00:32:32 yea, this does conflict with my patch in the sense
msw - DO NOT USE 2014/04/22 01:16:45 I'm not so sure about that naming... Shouldn't obs
Evan Stade 2014/04/22 17:43:44 Now that I see this isn't just replacing the Linux
msw 2014/04/22 19:48:58 I renamed this to OnNativeThemeUpdate, but I'd lik
Evan Stade 2014/04/22 21:09:18 Currently yes, but making this change provides a m
msw 2014/04/23 00:34:04 Agreed, but I don't want to unnecessarily expand t
25 public:
26 virtual ~NativeThemeObserver();
27
28 // Called whenever the underlying platform's native theme changes.
29 virtual void OnNativeThemeChange() = 0;
30 };
31
21 // This class supports drawing UI controls (like buttons, text fields, lists, 32 // This class supports drawing UI controls (like buttons, text fields, lists,
22 // comboboxes, etc) that look like the native UI controls of the underlying 33 // 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 34 // 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 35 // dialog box backgrounds, etc., which are obtained from the system theme where
25 // possible. 36 // possible.
26 // 37 //
27 // The supported control types are listed in the Part enum. These parts can be 38 // 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 39 // 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. 40 // state is part-specific. The supported colors are listed in the ColorId enum.
30 // 41 //
31 // Some parts require more information than simply the state in order to be 42 // Some parts require more information than simply the state in order to be
32 // drawn correctly, and this information is given to the Paint() method via the 43 // drawn correctly, and this information is given to the Paint() method via the
33 // ExtraParams union. Each part that requires more information has its own 44 // ExtraParams union. Each part that requires more information has its own
34 // field in the union. 45 // field in the union.
35 // 46 //
36 // NativeTheme also supports getting the default size of a given part with 47 // NativeTheme also supports getting the default size of a given part with
37 // the GetPartSize() method. 48 // the GetPartSize() method.
38 class NATIVE_THEME_EXPORT NativeTheme { 49 class NATIVE_THEME_EXPORT NativeTheme : public gfx::SysColorChangeListener {
39 public: 50 public:
40 // The part to be painted / sized. 51 // The part to be painted / sized.
41 enum Part { 52 enum Part {
42 kCheckbox, 53 kCheckbox,
43 kInnerSpinButton, 54 kInnerSpinButton,
44 kMenuList, 55 kMenuList,
45 kMenuCheck, 56 kMenuCheck,
46 kMenuCheckBackground, 57 kMenuCheckBackground,
47 kMenuPopupArrow, 58 kMenuPopupArrow,
48 kMenuPopupBackground, 59 kMenuPopupBackground,
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 // Return a color from the system theme. 314 // Return a color from the system theme.
304 virtual SkColor GetSystemColor(ColorId color_id) const = 0; 315 virtual SkColor GetSystemColor(ColorId color_id) const = 0;
305 316
306 // Returns a shared instance of the native theme. 317 // Returns a shared instance of the native theme.
307 // The returned object should not be deleted by the caller. This function 318 // 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. 319 // 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 320 // Each port of NativeTheme should provide its own implementation of this
310 // function, returning the port's subclass. 321 // function, returning the port's subclass.
311 static NativeTheme* instance(); 322 static NativeTheme* instance();
312 323
324 // Add or remove observers to be notified when the native theme changes.
325 void AddObserver(NativeThemeObserver* observer);
326 void RemoveObserver(NativeThemeObserver* observer);
327
328 // Notify observers of native theme changes.
329 void OnNativeThemeChange();
Evan Stade 2014/04/22 17:43:44 I think this should be protected
msw 2014/04/22 19:48:58 I agree, but Gtk2UI::OnStyleSet calls this. Perhap
Evan Stade 2014/04/22 21:09:18 You can expose it on NativeThemeGtk2 but not here.
msw 2014/04/23 00:34:04 Done (added NativeThemeGtk2::NotifyNativeThemeObse
330
313 protected: 331 protected:
314 NativeTheme(); 332 NativeTheme();
315 virtual ~NativeTheme(); 333 virtual ~NativeTheme();
316 334
335 // gfx::SysColorChangeListener implementation:
336 virtual void OnSysColorChange() OVERRIDE;
337
317 unsigned int thumb_inactive_color_; 338 unsigned int thumb_inactive_color_;
318 unsigned int thumb_active_color_; 339 unsigned int thumb_active_color_;
319 unsigned int track_color_; 340 unsigned int track_color_;
320 341
342 private:
343 // Observers to notify when the theme state changes.
344 ObserverList<NativeThemeObserver> native_theme_observers_;
345
346 // The system color change listener.
347 gfx::ScopedSysColorChangeListener color_change_listener_;
348
349
321 DISALLOW_COPY_AND_ASSIGN(NativeTheme); 350 DISALLOW_COPY_AND_ASSIGN(NativeTheme);
322 }; 351 };
323 352
324 } // namespace ui 353 } // namespace ui
325 354
326 #endif // UI_NATIVE_THEME_NATIVE_THEME_H_ 355 #endif // UI_NATIVE_THEME_NATIVE_THEME_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698