Chromium Code Reviews| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "third_party/skia/include/core/SkPaint.h" | 8 #include "third_party/skia/include/core/SkPaint.h" |
| 9 #include "third_party/skia/include/core/SkPath.h" | 9 #include "third_party/skia/include/core/SkPath.h" |
| 10 #include "ui/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
| 11 #include "ui/compositor/layer.h" | |
| 11 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
| 12 #include "ui/gfx/color_palette.h" | 13 #include "ui/gfx/color_palette.h" |
| 13 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 14 #include "ui/views/bubble/bubble_border.h" | 15 #include "ui/views/bubble/bubble_border.h" |
| 15 #include "ui/views/controls/menu/menu_config.h" | 16 #include "ui/views/controls/menu/menu_config.h" |
| 16 #include "ui/views/controls/menu/menu_controller.h" | 17 #include "ui/views/controls/menu/menu_controller.h" |
| 17 #include "ui/views/controls/menu/menu_item_view.h" | 18 #include "ui/views/controls/menu/menu_item_view.h" |
| 18 #include "ui/views/controls/menu/submenu_view.h" | 19 #include "ui/views/controls/menu/submenu_view.h" |
| 19 #include "ui/views/round_rect_painter.h" | 20 #include "ui/views/round_rect_painter.h" |
| 20 | 21 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 // that ScrollRectToVisible works. | 129 // that ScrollRectToVisible works. |
| 129 // | 130 // |
| 130 // NOTE: It is possible to use ScrollView directly (after making it deal with | 131 // NOTE: It is possible to use ScrollView directly (after making it deal with |
| 131 // 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 |
| 132 // 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 |
| 133 // what ScrollView does, so we use a one off variant. | 134 // what ScrollView does, so we use a one off variant. |
| 134 | 135 |
| 135 class MenuScrollViewContainer::MenuScrollView : public View { | 136 class MenuScrollViewContainer::MenuScrollView : public View { |
| 136 public: | 137 public: |
| 137 explicit MenuScrollView(View* child) { | 138 explicit MenuScrollView(View* child) { |
| 139 SetPaintToLayer(true); | |
|
varkha
2016/03/22 14:30:01
I wonder if this should be an optional behavior tr
bruthig
2016/03/22 21:45:29
I will consider this once I have the other issues
bruthig
2016/04/12 19:09:51
It is not straightforward for the owner of the men
| |
| 140 layer()->SetMasksToBounds(true); | |
| 141 layer()->SetFillsBoundsOpaquely(false); | |
|
Evan Stade
2016/03/18 19:07:02
is this correct/necessary?
bruthig
2016/03/18 19:26:43
Yeah it's necessary. Without it the child menu it
Evan Stade
2016/03/18 19:34:40
that seems better as opaquely filling bounds allow
bruthig
2016/03/22 21:45:29
So I've played around with this for 2 days now and
bruthig
2016/04/12 19:09:51
It has turned in to a bit of a rabbit hole trying
| |
| 138 AddChildView(child); | 142 AddChildView(child); |
| 139 } | 143 } |
| 140 | 144 |
| 141 void ScrollRectToVisible(const gfx::Rect& rect) override { | 145 void ScrollRectToVisible(const gfx::Rect& rect) override { |
| 142 // NOTE: this assumes we only want to scroll in the y direction. | 146 // NOTE: this assumes we only want to scroll in the y direction. |
| 143 | 147 |
| 144 // If the rect is already visible, do not scroll. | 148 // If the rect is already visible, do not scroll. |
| 145 if (GetLocalBounds().Contains(rect)) | 149 if (GetLocalBounds().Contains(rect)) |
| 146 return; | 150 return; |
| 147 | 151 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 case MENU_ANCHOR_BUBBLE_ABOVE: | 322 case MENU_ANCHOR_BUBBLE_ABOVE: |
| 319 return BubbleBorder::BOTTOM_CENTER; | 323 return BubbleBorder::BOTTOM_CENTER; |
| 320 case MENU_ANCHOR_BUBBLE_BELOW: | 324 case MENU_ANCHOR_BUBBLE_BELOW: |
| 321 return BubbleBorder::TOP_CENTER; | 325 return BubbleBorder::TOP_CENTER; |
| 322 default: | 326 default: |
| 323 return BubbleBorder::NONE; | 327 return BubbleBorder::NONE; |
| 324 } | 328 } |
| 325 } | 329 } |
| 326 | 330 |
| 327 } // namespace views | 331 } // namespace views |
| OLD | NEW |