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

Side by Side Diff: views/controls/scrollbar/native_scroll_bar_views.cc

Issue 8122013: Allow CanvasSkia to bind to an existing SkCanvas. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 1 more fix Created 9 years, 2 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/scrollbar/native_scroll_bar_views.h" 5 #include "views/controls/scrollbar/native_scroll_bar_views.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/keycodes/keyboard_codes.h" 8 #include "ui/base/keycodes/keyboard_codes.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/canvas_skia.h" 10 #include "ui/gfx/canvas_skia.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return native_theme->GetPartSize(GetNativeThemePart(), 91 return native_theme->GetPartSize(GetNativeThemePart(),
92 GetNativeThemeState(), 92 GetNativeThemeState(),
93 GetNativeThemeParams()); 93 GetNativeThemeParams());
94 } 94 }
95 95
96 void ScrollBarButton::OnPaint(gfx::Canvas* canvas) { 96 void ScrollBarButton::OnPaint(gfx::Canvas* canvas) {
97 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance(); 97 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance();
98 gfx::Rect bounds; 98 gfx::Rect bounds;
99 bounds.set_size(GetPreferredSize()); 99 bounds.set_size(GetPreferredSize());
100 100
101 native_theme->Paint(canvas->AsCanvasSkia(), 101 native_theme->Paint(canvas->GetSkCanvas(),
102 GetNativeThemePart(), 102 GetNativeThemePart(),
103 GetNativeThemeState(), 103 GetNativeThemeState(),
104 bounds, 104 bounds,
105 GetNativeThemeParams()); 105 GetNativeThemeParams());
106 } 106 }
107 107
108 gfx::NativeTheme::ExtraParams 108 gfx::NativeTheme::ExtraParams
109 ScrollBarButton::GetNativeThemeParams() const { 109 ScrollBarButton::GetNativeThemeParams() const {
110 gfx::NativeTheme::ExtraParams params; 110 gfx::NativeTheme::ExtraParams params;
111 111
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 gfx::Size ScrollBarThumb::GetPreferredSize() { 176 gfx::Size ScrollBarThumb::GetPreferredSize() {
177 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance(); 177 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance();
178 return native_theme->GetPartSize(GetNativeThemePart(), 178 return native_theme->GetPartSize(GetNativeThemePart(),
179 GetNativeThemeState(), 179 GetNativeThemeState(),
180 GetNativeThemeParams()); 180 GetNativeThemeParams());
181 } 181 }
182 182
183 void ScrollBarThumb::OnPaint(gfx::Canvas* canvas) { 183 void ScrollBarThumb::OnPaint(gfx::Canvas* canvas) {
184 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance(); 184 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance();
185 185
186 native_theme->Paint(canvas->AsCanvasSkia(), 186 native_theme->Paint(canvas->GetSkCanvas(),
187 GetNativeThemePart(), 187 GetNativeThemePart(),
188 GetNativeThemeState(), 188 GetNativeThemeState(),
189 GetLocalBounds(), 189 GetLocalBounds(),
190 GetNativeThemeParams()); 190 GetNativeThemeParams());
191 } 191 }
192 192
193 gfx::NativeTheme::ExtraParams 193 gfx::NativeTheme::ExtraParams
194 ScrollBarThumb::GetNativeThemeParams() const { 194 ScrollBarThumb::GetNativeThemeParams() const {
195 gfx::NativeTheme::ExtraParams params; 195 gfx::NativeTheme::ExtraParams params;
196 196
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 void NativeScrollBarViews::OnPaint(gfx::Canvas* canvas) { 295 void NativeScrollBarViews::OnPaint(gfx::Canvas* canvas) {
296 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance(); 296 const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance();
297 gfx::Rect bounds = GetTrackBounds(); 297 gfx::Rect bounds = GetTrackBounds();
298 298
299 params_.scrollbar_track.track_x = bounds.x(); 299 params_.scrollbar_track.track_x = bounds.x();
300 params_.scrollbar_track.track_y = bounds.y(); 300 params_.scrollbar_track.track_y = bounds.y();
301 params_.scrollbar_track.track_width = bounds.width(); 301 params_.scrollbar_track.track_width = bounds.width();
302 params_.scrollbar_track.track_height = bounds.height(); 302 params_.scrollbar_track.track_height = bounds.height();
303 303
304 304
305 native_theme->Paint(canvas->AsCanvasSkia(), 305 native_theme->Paint(canvas->GetSkCanvas(),
306 part_, 306 part_,
307 state_, 307 state_,
308 bounds, 308 bounds,
309 params_); 309 params_);
310 } 310 }
311 311
312 gfx::Size NativeScrollBarViews::GetPreferredSize() { 312 gfx::Size NativeScrollBarViews::GetPreferredSize() {
313 if (native_scroll_bar_->IsHorizontal()) 313 if (native_scroll_bar_->IsHorizontal())
314 return gfx::Size(0, GetHorizontalScrollBarHeight()); 314 return gfx::Size(0, GetHorizontalScrollBarHeight());
315 return gfx::Size(GetVerticalScrollBarWidth(), 0); 315 return gfx::Size(GetVerticalScrollBarWidth(), 0);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 } else { 378 } else {
379 bounds.set_y(bounds.y() + size.height()); 379 bounds.set_y(bounds.y() + size.height());
380 bounds.set_height(std::max(0, bounds.height() - 2 * size.height())); 380 bounds.set_height(std::max(0, bounds.height() - 2 * size.height()));
381 bounds.set_width(thumb->GetPreferredSize().width()); 381 bounds.set_width(thumb->GetPreferredSize().width());
382 } 382 }
383 383
384 return bounds; 384 return bounds;
385 } 385 }
386 386
387 } // namespace views 387 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698