15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/native_theme/native_theme_aurawin.h" 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "third_party/skia/include/core/SkCanvas.h" 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/native_theme/common_theme.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/native_theme/native_theme_win.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace ui { 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace { 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool IsScrollbarPart(NativeTheme::Part part) { 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) switch (part) { 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarDownArrow: 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarLeftArrow: 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarRightArrow: 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarUpArrow: 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarHorizontalThumb: 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarVerticalThumb: 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarHorizontalTrack: 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarVerticalTrack: 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarHorizontalGripper: 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarVerticalGripper: 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) case NativeTheme::kScrollbarCorner: 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return true; 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return false; 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// static 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)NativeTheme* NativeTheme::instance() { 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return NativeThemeAuraWin::instance(); 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// static 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)NativeThemeAura* NativeThemeAura::instance() { 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return NativeThemeAuraWin::instance(); 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// static 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)NativeThemeAuraWin* NativeThemeAuraWin::instance() { 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) CR_DEFINE_STATIC_LOCAL(NativeThemeAuraWin, s_native_theme, ()); 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return &s_native_theme; 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)NativeThemeAuraWin::NativeThemeAuraWin() { 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)NativeThemeAuraWin::~NativeThemeAuraWin() { 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void NativeThemeAuraWin::Paint(SkCanvas* canvas, 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) Part part, 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) State state, 605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Rect& rect, 615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const ExtraParams& extra) const { 625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (IsScrollbarPart(part) && 635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) NativeThemeWin::instance()->IsUsingHighContrastTheme()) { 645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) NativeThemeWin::instance()->Paint(canvas, part, state, rect, extra); 655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return; 665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) } 675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) NativeThemeAura::Paint(canvas, part, state, rect, extra); 695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)gfx::Size NativeThemeAuraWin::GetPartSize(Part part, 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) State state, 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const ExtraParams& extra) const { 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Size part_size = CommonThemeGetPartSize(part, state, extra); 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (!part_size.IsEmpty()) 765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return part_size; 775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // We want aura on windows to use the same size for scrollbars as we would in 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // the native theme. 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) if (IsScrollbarPart(part)) 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return NativeThemeWin::instance()->GetPartSize(part, state, extra); 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return NativeThemeAura::GetPartSize(part, state, extra); 845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} // namespace ui 87