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

Side by Side Diff: ui/views/native_theme_painter.cc

Issue 10387121: Revert 136996 - ui: Move NativeTheme files into ui/base/native_theme/ directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « ui/views/native_theme_delegate.h ('k') | ui/views/widget/native_widget_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ui/views/native_theme_painter.h" 5 #include "ui/views/native_theme_painter.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/animation/animation.h" 8 #include "ui/base/animation/animation.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/rect.h" 10 #include "ui/gfx/rect.h"
11 #include "ui/views/native_theme_delegate.h" 11 #include "ui/views/native_theme_delegate.h"
12 12
13 namespace views { 13 namespace views {
14 14
15 NativeThemePainter::NativeThemePainter(NativeThemeDelegate* delegate) 15 NativeThemePainter::NativeThemePainter(NativeThemeDelegate* delegate)
16 : delegate_(delegate) { 16 : delegate_(delegate) {
17 DCHECK(delegate_); 17 DCHECK(delegate_);
18 } 18 }
19 19
20 gfx::Size NativeThemePainter::GetPreferredSize() { 20 gfx::Size NativeThemePainter::GetPreferredSize() {
21 const ui::NativeTheme* theme = ui::NativeTheme::instance(); 21 const gfx::NativeTheme* theme = gfx::NativeTheme::instance();
22 ui::NativeTheme::ExtraParams extra; 22 gfx::NativeTheme::ExtraParams extra;
23 ui::NativeTheme::State state = delegate_->GetThemeState(&extra); 23 gfx::NativeTheme::State state = delegate_->GetThemeState(&extra);
24 return theme->GetPartSize(delegate_->GetThemePart(), state, extra); 24 return theme->GetPartSize(delegate_->GetThemePart(), state, extra);
25 } 25 }
26 26
27 void NativeThemePainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { 27 void NativeThemePainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
28 const ui::NativeTheme* native_theme = ui::NativeTheme::instance(); 28 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance();
29 ui::NativeTheme::Part part = delegate_->GetThemePart(); 29 gfx::NativeTheme::Part part = delegate_->GetThemePart();
30 gfx::Rect rect(size); 30 gfx::Rect rect(size);
31 31
32 if (delegate_->GetThemeAnimation() != NULL && 32 if (delegate_->GetThemeAnimation() != NULL &&
33 delegate_->GetThemeAnimation()->is_animating()) { 33 delegate_->GetThemeAnimation()->is_animating()) {
34 // Paint background state. 34 // Paint background state.
35 ui::NativeTheme::ExtraParams prev_extra; 35 gfx::NativeTheme::ExtraParams prev_extra;
36 ui::NativeTheme::State prev_state = 36 gfx::NativeTheme::State prev_state =
37 delegate_->GetBackgroundThemeState(&prev_extra); 37 delegate_->GetBackgroundThemeState(&prev_extra);
38 native_theme->Paint(canvas->sk_canvas(), part, prev_state, rect, 38 native_theme->Paint(canvas->sk_canvas(), part, prev_state, rect,
39 prev_extra); 39 prev_extra);
40 40
41 // Composite foreground state above it. 41 // Composite foreground state above it.
42 ui::NativeTheme::ExtraParams extra; 42 gfx::NativeTheme::ExtraParams extra;
43 ui::NativeTheme::State state = delegate_->GetForegroundThemeState(&extra); 43 gfx::NativeTheme::State state = delegate_->GetForegroundThemeState(&extra);
44 int alpha = delegate_->GetThemeAnimation()->CurrentValueBetween(0, 255); 44 int alpha = delegate_->GetThemeAnimation()->CurrentValueBetween(0, 255);
45 canvas->SaveLayerAlpha(static_cast<uint8>(alpha)); 45 canvas->SaveLayerAlpha(static_cast<uint8>(alpha));
46 native_theme->Paint(canvas->sk_canvas(), part, state, rect, extra); 46 native_theme->Paint(canvas->sk_canvas(), part, state, rect, extra);
47 canvas->Restore(); 47 canvas->Restore();
48 } else { 48 } else {
49 ui::NativeTheme::ExtraParams extra; 49 gfx::NativeTheme::ExtraParams extra;
50 ui::NativeTheme::State state = delegate_->GetThemeState(&extra); 50 gfx::NativeTheme::State state = delegate_->GetThemeState(&extra);
51 native_theme->Paint(canvas->sk_canvas(), part, state, rect, extra); 51 native_theme->Paint(canvas->sk_canvas(), part, state, rect, extra);
52 } 52 }
53 } 53 }
54 54
55 } // namespace views 55 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/native_theme_delegate.h ('k') | ui/views/widget/native_widget_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698