| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/bitmap_scroll_bar.h" | 5 #include "views/controls/scrollbar/bitmap_scroll_bar.h" |
| 6 | 6 |
| 7 #include "app/gfx/chrome_canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 12 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
| 13 #include "views/controls/menu/menu.h" | 13 #include "views/controls/menu/menu.h" |
| 14 #include "views/controls/scroll_view.h" | 14 #include "views/controls/scroll_view.h" |
| 15 #include "views/widget/widget.h" | 15 #include "views/widget/widget.h" |
| 16 | 16 |
| 17 #undef min | 17 #undef min |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // View overrides: | 133 // View overrides: |
| 134 virtual gfx::Size GetPreferredSize() { | 134 virtual gfx::Size GetPreferredSize() { |
| 135 return gfx::Size(background_bitmap()->width(), | 135 return gfx::Size(background_bitmap()->width(), |
| 136 start_cap_bitmap()->height() + | 136 start_cap_bitmap()->height() + |
| 137 end_cap_bitmap()->height() + | 137 end_cap_bitmap()->height() + |
| 138 grippy_bitmap()->height()); | 138 grippy_bitmap()->height()); |
| 139 } | 139 } |
| 140 | 140 |
| 141 protected: | 141 protected: |
| 142 // View overrides: | 142 // View overrides: |
| 143 virtual void Paint(ChromeCanvas* canvas) { | 143 virtual void Paint(gfx::Canvas* canvas) { |
| 144 canvas->DrawBitmapInt(*start_cap_bitmap(), 0, 0); | 144 canvas->DrawBitmapInt(*start_cap_bitmap(), 0, 0); |
| 145 int top_cap_height = start_cap_bitmap()->height(); | 145 int top_cap_height = start_cap_bitmap()->height(); |
| 146 int bottom_cap_height = end_cap_bitmap()->height(); | 146 int bottom_cap_height = end_cap_bitmap()->height(); |
| 147 int thumb_body_height = height() - top_cap_height - bottom_cap_height; | 147 int thumb_body_height = height() - top_cap_height - bottom_cap_height; |
| 148 canvas->TileImageInt(*background_bitmap(), 0, top_cap_height, | 148 canvas->TileImageInt(*background_bitmap(), 0, top_cap_height, |
| 149 background_bitmap()->width(), thumb_body_height); | 149 background_bitmap()->width(), thumb_body_height); |
| 150 canvas->DrawBitmapInt(*end_cap_bitmap(), 0, | 150 canvas->DrawBitmapInt(*end_cap_bitmap(), 0, |
| 151 height() - bottom_cap_height); | 151 height() - bottom_cap_height); |
| 152 | 152 |
| 153 // Paint the grippy over the track. | 153 // Paint the grippy over the track. |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 /////////////////////////////////////////////////////////////////////////////// | 384 /////////////////////////////////////////////////////////////////////////////// |
| 385 // BitmapScrollBar, View implementation: | 385 // BitmapScrollBar, View implementation: |
| 386 | 386 |
| 387 gfx::Size BitmapScrollBar::GetPreferredSize() { | 387 gfx::Size BitmapScrollBar::GetPreferredSize() { |
| 388 // In this case, we're returning the desired width of the scrollbar and its | 388 // In this case, we're returning the desired width of the scrollbar and its |
| 389 // minimum allowable height. | 389 // minimum allowable height. |
| 390 gfx::Size button_prefsize = prev_button_->GetPreferredSize(); | 390 gfx::Size button_prefsize = prev_button_->GetPreferredSize(); |
| 391 return gfx::Size(button_prefsize.width(), button_prefsize.height() * 2); | 391 return gfx::Size(button_prefsize.width(), button_prefsize.height() * 2); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void BitmapScrollBar::Paint(ChromeCanvas* canvas) { | 394 void BitmapScrollBar::Paint(gfx::Canvas* canvas) { |
| 395 // Paint the track. | 395 // Paint the track. |
| 396 gfx::Rect track_bounds = GetTrackBounds(); | 396 gfx::Rect track_bounds = GetTrackBounds(); |
| 397 canvas->TileImageInt(*images_[THUMB_TRACK][thumb_track_state_], | 397 canvas->TileImageInt(*images_[THUMB_TRACK][thumb_track_state_], |
| 398 track_bounds.x(), track_bounds.y(), | 398 track_bounds.x(), track_bounds.y(), |
| 399 track_bounds.width(), track_bounds.height()); | 399 track_bounds.width(), track_bounds.height()); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void BitmapScrollBar::Layout() { | 402 void BitmapScrollBar::Layout() { |
| 403 // Size and place the two scroll buttons. | 403 // Size and place the two scroll buttons. |
| 404 if (show_scroll_buttons_) { | 404 if (show_scroll_buttons_) { |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 thumb_position = thumb_position - (thumb_->GetSize() / 2); | 698 thumb_position = thumb_position - (thumb_->GetSize() / 2); |
| 699 return (thumb_position * contents_size_) / GetTrackSize(); | 699 return (thumb_position * contents_size_) / GetTrackSize(); |
| 700 } | 700 } |
| 701 | 701 |
| 702 void BitmapScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { | 702 void BitmapScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { |
| 703 thumb_track_state_ = state; | 703 thumb_track_state_ = state; |
| 704 SchedulePaint(); | 704 SchedulePaint(); |
| 705 } | 705 } |
| 706 | 706 |
| 707 } // namespace views | 707 } // namespace views |
| OLD | NEW |