diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-07 00:01:05 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-07 00:01:05 +0000 |
commit | 004be35de05f34739b69edd0cdb035be8cb314c5 (patch) | |
tree | 138fae935a54500b390ab0b5e400a2decd600e97 | |
parent | d5169a9544854ff5cb35470c328a8e7f44ff5ef1 (diff) | |
download | chromium_src-004be35de05f34739b69edd0cdb035be8cb314c5.zip chromium_src-004be35de05f34739b69edd0cdb035be8cb314c5.tar.gz chromium_src-004be35de05f34739b69edd0cdb035be8cb314c5.tar.bz2 |
Makes windows using the native theme when in high contrast mode
BUG=332937
TEST=see bug
R=sadrul@chromium.org
Review URL: https://codereview.chromium.org/148323005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249538 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ui/native_theme/native_theme_aurawin.cc | 47 | ||||
-rw-r--r-- | ui/native_theme/native_theme_aurawin.h | 5 | ||||
-rw-r--r-- | ui/native_theme/native_theme_win.cc | 29 | ||||
-rw-r--r-- | ui/native_theme/native_theme_win.h | 9 |
4 files changed, 66 insertions, 24 deletions
diff --git a/ui/native_theme/native_theme_aurawin.cc b/ui/native_theme/native_theme_aurawin.cc index 0cb822f..aa00dad 100644 --- a/ui/native_theme/native_theme_aurawin.cc +++ b/ui/native_theme/native_theme_aurawin.cc @@ -39,6 +39,24 @@ const int kScrollbarArrowButtonImages[NativeTheme::kMaxState][9] = { const int kScrollbarTrackImages[9] = IMAGE_GRID(IDR_SCROLLBAR_BASE); +bool IsScrollbarPart(NativeTheme::Part part) { + switch (part) { + case NativeTheme::kScrollbarDownArrow: + case NativeTheme::kScrollbarLeftArrow: + case NativeTheme::kScrollbarRightArrow: + case NativeTheme::kScrollbarUpArrow: + case NativeTheme::kScrollbarHorizontalThumb: + case NativeTheme::kScrollbarVerticalThumb: + case NativeTheme::kScrollbarHorizontalTrack: + case NativeTheme::kScrollbarVerticalTrack: + case NativeTheme::kScrollbarHorizontalGripper: + case NativeTheme::kScrollbarVerticalGripper: + case NativeTheme::kScrollbarCorner: + return true; + } + return false; +} + } // namespace // static @@ -69,6 +87,20 @@ NativeThemeAuraWin::NativeThemeAuraWin() { NativeThemeAuraWin::~NativeThemeAuraWin() { } +void NativeThemeAuraWin::Paint(SkCanvas* canvas, + Part part, + State state, + const gfx::Rect& rect, + const ExtraParams& extra) const { + if (IsScrollbarPart(part) && + NativeThemeWin::instance()->IsUsingHighContrastTheme()) { + NativeThemeWin::instance()->Paint(canvas, part, state, rect, extra); + return; + } + + NativeThemeAura::Paint(canvas, part, state, rect, extra); +} + gfx::Size NativeThemeAuraWin::GetPartSize(Part part, State state, const ExtraParams& extra) const { @@ -78,19 +110,8 @@ gfx::Size NativeThemeAuraWin::GetPartSize(Part part, // We want aura on windows to use the same size for scrollbars as we would in // the native theme. - switch (part) { - case kScrollbarDownArrow: - case kScrollbarLeftArrow: - case kScrollbarRightArrow: - case kScrollbarUpArrow: - case kScrollbarHorizontalThumb: - case kScrollbarVerticalThumb: - case kScrollbarHorizontalTrack: - case kScrollbarVerticalTrack: - return NativeThemeWin::instance()->GetPartSize(part, state, extra); - default: - break; - } + if (IsScrollbarPart(part)) + return NativeThemeWin::instance()->GetPartSize(part, state, extra); return NativeThemeAura::GetPartSize(part, state, extra); } diff --git a/ui/native_theme/native_theme_aurawin.h b/ui/native_theme/native_theme_aurawin.h index 163d1ed..a51ee4a 100644 --- a/ui/native_theme/native_theme_aurawin.h +++ b/ui/native_theme/native_theme_aurawin.h @@ -28,6 +28,11 @@ class NATIVE_THEME_EXPORT NativeThemeAuraWin : public NativeThemeAura { virtual gfx::Size GetPartSize(Part part, State state, const ExtraParams& extra) const OVERRIDE; + virtual void Paint(SkCanvas* canvas, + Part part, + State state, + const gfx::Rect& rect, + const ExtraParams& extra) const OVERRIDE; virtual void PaintArrowButton(SkCanvas* gc, const gfx::Rect& rect, Part direction, diff --git a/ui/native_theme/native_theme_win.cc b/ui/native_theme/native_theme_win.cc index 311648f..43d38f3 100644 --- a/ui/native_theme/native_theme_win.cc +++ b/ui/native_theme/native_theme_win.cc @@ -127,14 +127,6 @@ RECT InsetRect(const RECT* rect, int size) { return result.ToRECT(); } -// Returns true if using a high contrast theme. -bool UsingHighContrastTheme() { - HIGHCONTRAST result; - result.cbSize = sizeof(HIGHCONTRAST); - return SystemParametersInfo(SPI_GETHIGHCONTRAST, result.cbSize, &result, 0) && - (result.dwFlags & HCF_HIGHCONTRASTON) == HCF_HIGHCONTRASTON; -} - } // namespace namespace ui { @@ -145,6 +137,18 @@ bool NativeThemeWin::IsThemingActive() const { return false; } +bool NativeThemeWin::IsUsingHighContrastTheme() const { + if (is_using_high_contrast_valid_) + return is_using_high_contrast_; + HIGHCONTRAST result; + result.cbSize = sizeof(HIGHCONTRAST); + is_using_high_contrast_ = + SystemParametersInfo(SPI_GETHIGHCONTRAST, result.cbSize, &result, 0) && + (result.dwFlags & HCF_HIGHCONTRASTON) == HCF_HIGHCONTRASTON; + is_using_high_contrast_valid_ = true; + return is_using_high_contrast_; +} + HRESULT NativeThemeWin::GetThemeColor(ThemeName theme, int part_id, int state_id, @@ -352,7 +356,9 @@ NativeThemeWin::NativeThemeWin() set_theme_properties_(NULL), is_theme_active_(NULL), get_theme_int_(NULL), - color_change_listener_(this) { + color_change_listener_(this), + is_using_high_contrast_(false), + is_using_high_contrast_valid_(false) { if (theme_dll_) { draw_theme_ = reinterpret_cast<DrawThemeBackgroundPtr>( GetProcAddress(theme_dll_, "DrawThemeBackground")); @@ -392,6 +398,7 @@ NativeThemeWin::~NativeThemeWin() { void NativeThemeWin::OnSysColorChange() { UpdateSystemColors(); + is_using_high_contrast_valid_ = false; } void NativeThemeWin::UpdateSystemColors() { @@ -571,7 +578,7 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { case kColorId_TreeSelectionBackgroundFocused: return system_colors_[COLOR_HIGHLIGHT]; case kColorId_TreeSelectionBackgroundUnfocused: - return system_colors_[UsingHighContrastTheme() ? + return system_colors_[IsUsingHighContrastTheme() ? COLOR_MENUHIGHLIGHT : COLOR_BTNFACE]; case kColorId_TreeArrow: return system_colors_[COLOR_WINDOWTEXT]; @@ -588,7 +595,7 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { case kColorId_TableSelectionBackgroundFocused: return system_colors_[COLOR_HIGHLIGHT]; case kColorId_TableSelectionBackgroundUnfocused: - return system_colors_[UsingHighContrastTheme() ? + return system_colors_[IsUsingHighContrastTheme() ? COLOR_MENUHIGHLIGHT : COLOR_BTNFACE]; case kColorId_TableGroupingIndicatorColor: return system_colors_[COLOR_GRAYTEXT]; diff --git a/ui/native_theme/native_theme_win.h b/ui/native_theme/native_theme_win.h index 5542f20..408818f 100644 --- a/ui/native_theme/native_theme_win.h +++ b/ui/native_theme/native_theme_win.h @@ -54,6 +54,9 @@ class NATIVE_THEME_EXPORT NativeThemeWin : public NativeTheme, bool IsThemingActive() const; + // Returns true if a high contrast theme is being used. + bool IsUsingHighContrastTheme() const; + HRESULT GetThemeColor(ThemeName theme, int part_id, int state_id, @@ -356,6 +359,12 @@ class NATIVE_THEME_EXPORT NativeThemeWin : public NativeTheme, gfx::ScopedSysColorChangeListener color_change_listener_; mutable std::map<int, SkColor> system_colors_; + // Is a high contrast theme active? + mutable bool is_using_high_contrast_; + + // Is |is_using_high_contrast_| valid? + mutable bool is_using_high_contrast_valid_; + DISALLOW_COPY_AND_ASSIGN(NativeThemeWin); }; |