#ifndef ASH_SHELF_SHELF_NAVIGATION_WIDGET_H_
#define ASH_SHELF_SHELF_NAVIGATION_WIDGET_H_
#include <memory>
#include "ash/ash_export.h"
#include "ash/shelf/shelf_component.h"
#include "base/memory/raw_ptr.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 ash {
class BackButton;
class HomeButton;
enum class HotseatState;
class NavigationButtonAnimationMetricsReporter;
class Shelf;
class ShelfView;
class ASH_EXPORT ShelfNavigationWidget : public ShelfComponent,
public views::Widget {
public:
class TestApi {
public:
explicit TestApi(ShelfNavigationWidget* widget);
~TestApi();
bool IsHomeButtonVisible() const;
bool IsBackButtonVisible() const;
views::BoundsAnimator* GetBoundsAnimator();
private:
raw_ptr<ShelfNavigationWidget, ExperimentalAsh> navigation_widget_;
};
ShelfNavigationWidget(Shelf* shelf, ShelfView* shelf_view);
ShelfNavigationWidget(const ShelfNavigationWidget&) = delete;
ShelfNavigationWidget& operator=(const ShelfNavigationWidget&) = delete;
~ShelfNavigationWidget() override;
void Initialize(aura::Window* container);
void OnMouseEvent(ui::MouseEvent* event) override;
void OnScrollEvent(ui::ScrollEvent* event) override;
bool OnNativeWidgetActivationChanged(bool active) override;
void OnGestureEvent(ui::GestureEvent* event) override;
BackButton* GetBackButton() const;
HomeButton* GetHomeButton() const;
void SetDefaultLastFocusableChild(bool default_last_focusable_child);
void CalculateTargetBounds() override;
gfx::Rect GetTargetBounds() const override;
void UpdateLayout(bool animate) override;
void UpdateTargetBoundsForGesture(int shelf_position) override;
gfx::Rect GetVisibleBounds() const;
void PrepareForGettingFocus(bool last_element);
void HandleLocaleChange();
const views::BoundsAnimator* bounds_animator_for_test() const {
return bounds_animator_.get();
}
private:
class Delegate;
void UpdateButtonVisibility(
views::View* button,
bool visible,
bool animate,
NavigationButtonAnimationMetricsReporter* metrics_reporter,
HotseatState target_hotseat_state);
gfx::Rect CalculateClipRectAfterRTL() const;
gfx::Size CalculateIdealSize(bool only_visible_area) const;
int CalculateButtonCount() const;
raw_ptr<Shelf, ExperimentalAsh> shelf_ = nullptr;
raw_ptr<Delegate, ExperimentalAsh> delegate_ = nullptr;
gfx::Rect clip_rect_after_rtl_;
gfx::Rect target_bounds_;
std::unique_ptr<views::BoundsAnimator> bounds_animator_;
std::unique_ptr<NavigationButtonAnimationMetricsReporter>
back_button_metrics_reporter_;
std::unique_ptr<NavigationButtonAnimationMetricsReporter>
home_button_metrics_reporter_;
};
}
#endif