OLD | NEW |
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/controls/menu/menu_scroll_view_container.h" | 5 #include "ui/views/controls/menu/menu_scroll_view_container.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkPaint.h" | 7 #include "third_party/skia/include/core/SkPaint.h" |
8 #include "third_party/skia/include/core/SkPath.h" | 8 #include "third_party/skia/include/core/SkPath.h" |
9 #include "ui/accessibility/ax_view_state.h" | 9 #include "ui/accessibility/ax_view_state.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 class MenuScrollButton : public View { | 34 class MenuScrollButton : public View { |
35 public: | 35 public: |
36 MenuScrollButton(SubmenuView* host, bool is_up) | 36 MenuScrollButton(SubmenuView* host, bool is_up) |
37 : host_(host), | 37 : host_(host), |
38 is_up_(is_up), | 38 is_up_(is_up), |
39 // Make our height the same as that of other MenuItemViews. | 39 // Make our height the same as that of other MenuItemViews. |
40 pref_height_(MenuItemView::pref_menu_height()) { | 40 pref_height_(MenuItemView::pref_menu_height()) { |
41 } | 41 } |
42 | 42 |
43 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 43 virtual gfx::Size GetPreferredSize() const override { |
44 return gfx::Size( | 44 return gfx::Size( |
45 host_->GetMenuItem()->GetMenuConfig().scroll_arrow_height * 2 - 1, | 45 host_->GetMenuItem()->GetMenuConfig().scroll_arrow_height * 2 - 1, |
46 pref_height_); | 46 pref_height_); |
47 } | 47 } |
48 | 48 |
49 virtual bool CanDrop(const OSExchangeData& data) OVERRIDE { | 49 virtual bool CanDrop(const OSExchangeData& data) override { |
50 DCHECK(host_->GetMenuItem()->GetMenuController()); | 50 DCHECK(host_->GetMenuItem()->GetMenuController()); |
51 return true; // Always return true so that drop events are targeted to us. | 51 return true; // Always return true so that drop events are targeted to us. |
52 } | 52 } |
53 | 53 |
54 virtual void OnDragEntered(const ui::DropTargetEvent& event) OVERRIDE { | 54 virtual void OnDragEntered(const ui::DropTargetEvent& event) override { |
55 DCHECK(host_->GetMenuItem()->GetMenuController()); | 55 DCHECK(host_->GetMenuItem()->GetMenuController()); |
56 host_->GetMenuItem()->GetMenuController()->OnDragEnteredScrollButton( | 56 host_->GetMenuItem()->GetMenuController()->OnDragEnteredScrollButton( |
57 host_, is_up_); | 57 host_, is_up_); |
58 } | 58 } |
59 | 59 |
60 virtual int OnDragUpdated(const ui::DropTargetEvent& event) OVERRIDE { | 60 virtual int OnDragUpdated(const ui::DropTargetEvent& event) override { |
61 return ui::DragDropTypes::DRAG_NONE; | 61 return ui::DragDropTypes::DRAG_NONE; |
62 } | 62 } |
63 | 63 |
64 virtual void OnDragExited() OVERRIDE { | 64 virtual void OnDragExited() override { |
65 DCHECK(host_->GetMenuItem()->GetMenuController()); | 65 DCHECK(host_->GetMenuItem()->GetMenuController()); |
66 host_->GetMenuItem()->GetMenuController()->OnDragExitedScrollButton(host_); | 66 host_->GetMenuItem()->GetMenuController()->OnDragExitedScrollButton(host_); |
67 } | 67 } |
68 | 68 |
69 virtual int OnPerformDrop(const ui::DropTargetEvent& event) OVERRIDE { | 69 virtual int OnPerformDrop(const ui::DropTargetEvent& event) override { |
70 return ui::DragDropTypes::DRAG_NONE; | 70 return ui::DragDropTypes::DRAG_NONE; |
71 } | 71 } |
72 | 72 |
73 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 73 virtual void OnPaint(gfx::Canvas* canvas) override { |
74 const MenuConfig& config = host_->GetMenuItem()->GetMenuConfig(); | 74 const MenuConfig& config = host_->GetMenuItem()->GetMenuConfig(); |
75 | 75 |
76 // The background. | 76 // The background. |
77 gfx::Rect item_bounds(0, 0, width(), height()); | 77 gfx::Rect item_bounds(0, 0, width(), height()); |
78 NativeTheme::ExtraParams extra; | 78 NativeTheme::ExtraParams extra; |
79 extra.menu_item.is_selected = false; | 79 extra.menu_item.is_selected = false; |
80 GetNativeTheme()->Paint(canvas->sk_canvas(), | 80 GetNativeTheme()->Paint(canvas->sk_canvas(), |
81 NativeTheme::kMenuItemBackground, | 81 NativeTheme::kMenuItemBackground, |
82 NativeTheme::kNormal, item_bounds, extra); | 82 NativeTheme::kNormal, item_bounds, extra); |
83 | 83 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // null scrollbars), but clicking on a child of ScrollView forces the window to | 132 // null scrollbars), but clicking on a child of ScrollView forces the window to |
133 // become active, which we don't want. As we really only need a fraction of | 133 // become active, which we don't want. As we really only need a fraction of |
134 // what ScrollView does, so we use a one off variant. | 134 // what ScrollView does, so we use a one off variant. |
135 | 135 |
136 class MenuScrollViewContainer::MenuScrollView : public View { | 136 class MenuScrollViewContainer::MenuScrollView : public View { |
137 public: | 137 public: |
138 explicit MenuScrollView(View* child) { | 138 explicit MenuScrollView(View* child) { |
139 AddChildView(child); | 139 AddChildView(child); |
140 } | 140 } |
141 | 141 |
142 virtual void ScrollRectToVisible(const gfx::Rect& rect) OVERRIDE { | 142 virtual void ScrollRectToVisible(const gfx::Rect& rect) override { |
143 // NOTE: this assumes we only want to scroll in the y direction. | 143 // NOTE: this assumes we only want to scroll in the y direction. |
144 | 144 |
145 // If the rect is already visible, do not scroll. | 145 // If the rect is already visible, do not scroll. |
146 if (GetLocalBounds().Contains(rect)) | 146 if (GetLocalBounds().Contains(rect)) |
147 return; | 147 return; |
148 | 148 |
149 // Scroll just enough so that the rect is visible. | 149 // Scroll just enough so that the rect is visible. |
150 int dy = 0; | 150 int dy = 0; |
151 if (rect.bottom() > GetLocalBounds().bottom()) | 151 if (rect.bottom() > GetLocalBounds().bottom()) |
152 dy = rect.bottom() - GetLocalBounds().bottom(); | 152 dy = rect.bottom() - GetLocalBounds().bottom(); |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 case MENU_ANCHOR_BUBBLE_ABOVE: | 325 case MENU_ANCHOR_BUBBLE_ABOVE: |
326 return BubbleBorder::BOTTOM_CENTER; | 326 return BubbleBorder::BOTTOM_CENTER; |
327 case MENU_ANCHOR_BUBBLE_BELOW: | 327 case MENU_ANCHOR_BUBBLE_BELOW: |
328 return BubbleBorder::TOP_CENTER; | 328 return BubbleBorder::TOP_CENTER; |
329 default: | 329 default: |
330 return BubbleBorder::NONE; | 330 return BubbleBorder::NONE; |
331 } | 331 } |
332 } | 332 } |
333 | 333 |
334 } // namespace views | 334 } // namespace views |
OLD | NEW |