forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshelf_navigation_widget.h
127 lines (98 loc) · 3.86 KB
/
shelf_navigation_widget.h
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Copyright 2019 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 ASH_SHELF_SHELF_NAVIGATION_WIDGET_H_
#define ASH_SHELF_SHELF_NAVIGATION_WIDGET_H_
#include "ash/ash_export.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/shelf/shelf_component.h"
#include "ui/views/accessible_pane_view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
namespace aura {
class Window;
}
namespace views {
class BoundsAnimator;
}
namespace ui {
class AnimationMetricsReporter;
}
namespace ash {
class BackButton;
class HomeButton;
class NavigationButtonAnimationMetricsReporter;
class Shelf;
class ShelfView;
// The shelf navigation widget holds the home button and (when in tablet mode)
// the back button.
class ASH_EXPORT ShelfNavigationWidget : public ShelfComponent,
public ShelfConfig::Observer,
public views::Widget {
public:
class TestApi {
public:
explicit TestApi(ShelfNavigationWidget* widget);
~TestApi();
// Whether the home button view is visible.
bool IsHomeButtonVisible() const;
// Whether the back button view is visible.
bool IsBackButtonVisible() const;
views::BoundsAnimator* GetBoundsAnimator();
private:
ShelfNavigationWidget* navigation_widget_;
};
ShelfNavigationWidget(Shelf* shelf, ShelfView* shelf_view);
~ShelfNavigationWidget() override;
// Initializes the widget, sets its contents view and basic properties.
void Initialize(aura::Window* container);
// Returns the size that this widget would like to have depending on whether
// tablet mode is on.
gfx::Size GetIdealSize() const;
// views::Widget:
void OnMouseEvent(ui::MouseEvent* event) override;
void OnScrollEvent(ui::ScrollEvent* event) override;
bool OnNativeWidgetActivationChanged(bool active) override;
void OnGestureEvent(ui::GestureEvent* event) override;
// Getter for the back button view - nullptr if the back button should not be
// shown for the current shelf configuration.
BackButton* GetBackButton() const;
// Getter for the home button view - nullptr if the home button should not be
// shown for the current shelf configuration.
HomeButton* GetHomeButton() const;
// Sets whether the last focusable child (instead of the first) should be
// focused when activating this widget.
void SetDefaultLastFocusableChild(bool default_last_focusable_child);
// ShelfConfig::Observer:
void OnShelfConfigUpdated() override;
// ShelfComponent:
void CalculateTargetBounds() override;
gfx::Rect GetTargetBounds() const override;
void UpdateLayout(bool animate) override;
void UpdateTargetBoundsForGesture(int shelf_position) override;
// Called when shelf layout manager detects a locale change. Reloads the
// home and back button tooltips and accessibility name strings.
void HandleLocaleChange();
private:
class Delegate;
void UpdateButtonVisibility(
views::View* button,
bool visible,
bool animate,
ui::AnimationMetricsReporter* animation_metrics_reporter);
Shelf* shelf_ = nullptr;
Delegate* delegate_ = nullptr;
gfx::Rect target_bounds_;
std::unique_ptr<views::BoundsAnimator> bounds_animator_;
// Animation metrics reporter for back button animations. Owned by the
// Widget to ensure it outlives the BackButton view.
std::unique_ptr<NavigationButtonAnimationMetricsReporter>
back_button_metrics_reporter_;
// Animation metrics reporter for home button animations. Owned by the
// Widget to ensure it outlives the HomeButton view.
std::unique_ptr<NavigationButtonAnimationMetricsReporter>
home_button_metrics_reporter_;
DISALLOW_COPY_AND_ASSIGN(ShelfNavigationWidget);
};
} // namespace ash
#endif // ASH_SHELF_SHELF_NAVIGATION_WIDGET_H_