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