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/chrome_canvas.h" |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/compiler_specific.h" |
9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
10 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
11 #include "third_party/skia/include/core/SkBitmap.h" | 12 #include "third_party/skia/include/core/SkBitmap.h" |
12 #include "views/controls/menu/menu.h" | 13 #include "views/controls/menu/menu.h" |
13 #include "views/controls/scroll_view.h" | 14 #include "views/controls/scroll_view.h" |
14 #include "views/widget/widget.h" | 15 #include "views/widget/widget.h" |
15 | 16 |
16 #undef min | 17 #undef min |
17 #undef max | 18 #undef max |
18 | 19 |
(...skipping 11 matching lines...) Expand all Loading... |
30 // | 31 // |
31 // A button that activates on mouse pressed rather than released, and that | 32 // A button that activates on mouse pressed rather than released, and that |
32 // continues to fire the clicked action as the mouse button remains pressed | 33 // continues to fire the clicked action as the mouse button remains pressed |
33 // down on the button. | 34 // down on the button. |
34 // | 35 // |
35 /////////////////////////////////////////////////////////////////////////////// | 36 /////////////////////////////////////////////////////////////////////////////// |
36 class AutorepeatButton : public ImageButton { | 37 class AutorepeatButton : public ImageButton { |
37 public: | 38 public: |
38 AutorepeatButton(ButtonListener* listener) | 39 AutorepeatButton(ButtonListener* listener) |
39 : ImageButton(listener), | 40 : ImageButton(listener), |
40 repeater_(NewCallback<AutorepeatButton>(this, | 41 ALLOW_THIS_IN_INITIALIZER_LIST(repeater_( |
41 &AutorepeatButton::NotifyClick)) { | 42 NewCallback<AutorepeatButton>(this, |
| 43 &AutorepeatButton::NotifyClick))) { |
42 } | 44 } |
43 virtual ~AutorepeatButton() {} | 45 virtual ~AutorepeatButton() {} |
44 | 46 |
45 protected: | 47 protected: |
46 virtual bool OnMousePressed(const MouseEvent& event) { | 48 virtual bool OnMousePressed(const MouseEvent& event) { |
47 Button::NotifyClick(event.GetFlags()); | 49 Button::NotifyClick(event.GetFlags()); |
48 repeater_.Start(); | 50 repeater_.Start(); |
49 return true; | 51 return true; |
50 } | 52 } |
51 | 53 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 }; | 250 }; |
249 | 251 |
250 } // anonymous namespace | 252 } // anonymous namespace |
251 | 253 |
252 /////////////////////////////////////////////////////////////////////////////// | 254 /////////////////////////////////////////////////////////////////////////////// |
253 // BitmapScrollBar, public: | 255 // BitmapScrollBar, public: |
254 | 256 |
255 BitmapScrollBar::BitmapScrollBar(bool horizontal, bool show_scroll_buttons) | 257 BitmapScrollBar::BitmapScrollBar(bool horizontal, bool show_scroll_buttons) |
256 : contents_size_(0), | 258 : contents_size_(0), |
257 contents_scroll_offset_(0), | 259 contents_scroll_offset_(0), |
258 prev_button_(new AutorepeatButton(this)), | 260 ALLOW_THIS_IN_INITIALIZER_LIST(prev_button_(new AutorepeatButton(this))), |
259 next_button_(new AutorepeatButton(this)), | 261 ALLOW_THIS_IN_INITIALIZER_LIST(next_button_(new AutorepeatButton(this))), |
260 thumb_(new BitmapScrollBarThumb(this)), | 262 ALLOW_THIS_IN_INITIALIZER_LIST(thumb_(new BitmapScrollBarThumb(this))), |
261 thumb_track_state_(CustomButton::BS_NORMAL), | 263 thumb_track_state_(CustomButton::BS_NORMAL), |
262 last_scroll_amount_(SCROLL_NONE), | 264 last_scroll_amount_(SCROLL_NONE), |
263 repeater_(NewCallback<BitmapScrollBar>(this, | 265 ALLOW_THIS_IN_INITIALIZER_LIST(repeater_( |
264 &BitmapScrollBar::TrackClicked)), | 266 NewCallback<BitmapScrollBar>(this, |
| 267 &BitmapScrollBar::TrackClicked))), |
265 context_menu_mouse_position_(0), | 268 context_menu_mouse_position_(0), |
266 show_scroll_buttons_(show_scroll_buttons), | 269 show_scroll_buttons_(show_scroll_buttons), |
267 ScrollBar(horizontal) { | 270 ScrollBar(horizontal) { |
268 if (!show_scroll_buttons_) { | 271 if (!show_scroll_buttons_) { |
269 prev_button_->SetVisible(false); | 272 prev_button_->SetVisible(false); |
270 next_button_->SetVisible(false); | 273 next_button_->SetVisible(false); |
271 } | 274 } |
272 | 275 |
273 AddChildView(prev_button_); | 276 AddChildView(prev_button_); |
274 AddChildView(next_button_); | 277 AddChildView(next_button_); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 thumb_position = thumb_position - (thumb_->GetSize() / 2); | 697 thumb_position = thumb_position - (thumb_->GetSize() / 2); |
695 return (thumb_position * contents_size_) / GetTrackSize(); | 698 return (thumb_position * contents_size_) / GetTrackSize(); |
696 } | 699 } |
697 | 700 |
698 void BitmapScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { | 701 void BitmapScrollBar::SetThumbTrackState(CustomButton::ButtonState state) { |
699 thumb_track_state_ = state; | 702 thumb_track_state_ = state; |
700 SchedulePaint(); | 703 SchedulePaint(); |
701 } | 704 } |
702 | 705 |
703 } // namespace views | 706 } // namespace views |
OLD | NEW |