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

Side by Side Diff: ui/views/controls/scrollbar/bitmap_scroll_bar.cc

Issue 9332006: ui/gfx: Make the first version of Canvas::TileImageInt take a gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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) 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/controls/scrollbar/bitmap_scroll_bar.h" 5 #include "ui/views/controls/scrollbar/bitmap_scroll_bar.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 grippy_bitmap()->height()); 117 grippy_bitmap()->height());
118 } 118 }
119 119
120 protected: 120 protected:
121 // View overrides: 121 // View overrides:
122 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 122 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
123 canvas->DrawBitmapInt(*start_cap_bitmap(), 0, 0); 123 canvas->DrawBitmapInt(*start_cap_bitmap(), 0, 0);
124 int top_cap_height = start_cap_bitmap()->height(); 124 int top_cap_height = start_cap_bitmap()->height();
125 int bottom_cap_height = end_cap_bitmap()->height(); 125 int bottom_cap_height = end_cap_bitmap()->height();
126 int thumb_body_height = height() - top_cap_height - bottom_cap_height; 126 int thumb_body_height = height() - top_cap_height - bottom_cap_height;
127 canvas->TileImageInt(*background_bitmap(), 0, top_cap_height, 127 canvas->TileImage(*background_bitmap(), gfx::Rect(0, top_cap_height,
128 background_bitmap()->width(), thumb_body_height); 128 background_bitmap()->width(), thumb_body_height));
129 canvas->DrawBitmapInt(*end_cap_bitmap(), 0, 129 canvas->DrawBitmapInt(*end_cap_bitmap(), 0,
130 height() - bottom_cap_height); 130 height() - bottom_cap_height);
131 131
132 // Paint the grippy over the track. 132 // Paint the grippy over the track.
133 int grippy_x = (width() - grippy_bitmap()->width()) / 2; 133 int grippy_x = (width() - grippy_bitmap()->width()) / 2;
134 int grippy_y = (thumb_body_height - grippy_bitmap()->height()) / 2; 134 int grippy_y = (thumb_body_height - grippy_bitmap()->height()) / 2;
135 canvas->DrawBitmapInt(*grippy_bitmap(), grippy_x, grippy_y); 135 canvas->DrawBitmapInt(*grippy_bitmap(), grippy_x, grippy_y);
136 } 136 }
137 137
138 private: 138 private:
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 thumb->SetVisible(true); 286 thumb->SetVisible(true);
287 } 287 }
288 } 288 }
289 289
290 /////////////////////////////////////////////////////////////////////////////// 290 ///////////////////////////////////////////////////////////////////////////////
291 // BitmapScrollBar, View implementation: 291 // BitmapScrollBar, View implementation:
292 292
293 void BitmapScrollBar::OnPaint(gfx::Canvas* canvas) { 293 void BitmapScrollBar::OnPaint(gfx::Canvas* canvas) {
294 // Paint the track. 294 // Paint the track.
295 gfx::Rect track_bounds = GetTrackBounds(); 295 gfx::Rect track_bounds = GetTrackBounds();
296 canvas->TileImageInt(*images_[THUMB_TRACK][GetThumbTrackState()], 296 canvas->TileImage(*images_[THUMB_TRACK][GetThumbTrackState()],
297 track_bounds.x(), track_bounds.y(), 297 gfx::Rect(track_bounds.x(), track_bounds.y(),
Peter Kasting 2012/02/06 22:32:39 Nit: Just pass GetTrackBounds() directly and drop
tfarina 2012/02/06 23:12:16 Done.
298 track_bounds.width(), track_bounds.height()); 298 track_bounds.width(), track_bounds.height()));
299 } 299 }
300 300
301 /////////////////////////////////////////////////////////////////////////////// 301 ///////////////////////////////////////////////////////////////////////////////
302 // BitmapScrollBar, ButtonListener implementation: 302 // BitmapScrollBar, ButtonListener implementation:
303 303
304 void BitmapScrollBar::ButtonPressed(Button* sender, const views::Event& event) { 304 void BitmapScrollBar::ButtonPressed(Button* sender, const views::Event& event) {
305 if (sender == prev_button_) { 305 if (sender == prev_button_) {
306 ScrollByAmount(SCROLL_PREV_LINE); 306 ScrollByAmount(SCROLL_PREV_LINE);
307 } else if (sender == next_button_) { 307 } else if (sender == next_button_) {
308 ScrollByAmount(SCROLL_NEXT_LINE); 308 ScrollByAmount(SCROLL_NEXT_LINE);
309 } 309 }
310 } 310 }
311 311
312 } // namespace views 312 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698