1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_SCROLL_VIEW_CONTAINER_H_ 6 #define UI_VIEWS_CONTROLS_MENU_MENU_SCROLL_VIEW_CONTAINER_H_ 7 8 #include "base/macros.h" 9 #include "ui/views/bubble/bubble_border.h" 10 #include "ui/views/controls/menu/menu_types.h" 11 #include "ui/views/view.h" 12 13 namespace views { 14 15 class MenuItemView; 16 class SubmenuView; 17 18 // MenuScrollViewContainer contains the SubmenuView (through a MenuScrollView) 19 // and two scroll buttons. The scroll buttons are only visible and enabled if 20 // the preferred height of the SubmenuView is bigger than our bounds. 21 class MenuScrollViewContainer : public View { 22 public: 23 METADATA_HEADER(MenuScrollViewContainer); 24 25 explicit MenuScrollViewContainer(SubmenuView* content_view); 26 27 // Returns the buttons for scrolling up/down. scroll_down_button()28 View* scroll_down_button() const { return scroll_down_button_; } scroll_up_button()29 View* scroll_up_button() const { return scroll_up_button_; } 30 31 // External function to check if the bubble border is used. 32 bool HasBubbleBorder() const; 33 34 // View overrides. 35 gfx::Size CalculatePreferredSize() const override; 36 void OnPaintBackground(gfx::Canvas* canvas) override; 37 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 38 void OnThemeChanged() override; 39 40 protected: 41 // View override. 42 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; 43 44 private: 45 // Create a default border or bubble border, as appropriate. 46 void CreateBorder(); 47 48 // Create the default border. 49 void CreateDefaultBorder(); 50 51 // Create the bubble border. 52 void CreateBubbleBorder(); 53 54 BubbleBorder::Arrow BubbleBorderTypeFromAnchor(MenuAnchorPosition anchor); 55 56 // Returns the last item in the menu if it is of type HIGHLIGHTED. 57 MenuItemView* GetFootnote() const; 58 59 class MenuScrollView; 60 61 // The scroll buttons. 62 View* scroll_up_button_; 63 View* scroll_down_button_; 64 65 // The scroll view. 66 MenuScrollView* scroll_view_; 67 68 // The content view. 69 SubmenuView* content_view_; 70 71 // If set the currently set border is a bubble border. 72 BubbleBorder::Arrow arrow_ = BubbleBorder::NONE; 73 74 // Weak reference to the currently set border. 75 BubbleBorder* bubble_border_ = nullptr; 76 77 // Corner radius of the background. 78 int corner_radius_ = 0; 79 80 DISALLOW_COPY_AND_ASSIGN(MenuScrollViewContainer); 81 }; 82 83 } // namespace views 84 85 #endif // UI_VIEWS_CONTROLS_MENU_MENU_SCROLL_VIEW_CONTAINER_H_ 86