#ifndef ASH_SHELF_SHELF_WIDGET_H_
#define ASH_SHELF_SHELF_WIDGET_H_
#include <memory>
#include "ash/accessibility/accessibility_observer.h"
#include "ash/ash_export.h"
#include "ash/controls/contextual_tooltip.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/public/cpp/shelf_types.h"
#include "ash/shelf/desk_button_widget.h"
#include "ash/shelf/hotseat_transition_animator.h"
#include "ash/shelf/hotseat_widget.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_background_animator.h"
#include "ash/shelf/shelf_component.h"
#include "ash/shelf/shelf_layout_manager_observer.h"
#include "ash/shelf/shelf_observer.h"
#include "ash/wm/overview/overview_observer.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "ui/views/widget/widget.h"
namespace ash {
enum class AnimationChangeType;
class DragHandle;
class HotseatWidget;
class LoginShelfView;
class Shelf;
class ShelfLayoutManager;
class ShelfNavigationWidget;
class ShelfView;
class ShelfWidgetDelegateView;
class StatusAreaWidget;
class ASH_EXPORT ShelfWidget : public SessionObserver,
public ShelfComponent,
public ShelfLayoutManagerObserver,
public ShelfObserver,
public views::Widget,
public OverviewObserver {
public:
explicit ShelfWidget(Shelf* shelf);
ShelfWidget(const ShelfWidget&) = delete;
ShelfWidget& operator=(const ShelfWidget&) = delete;
~ShelfWidget() override;
void Initialize(aura::Window* shelf_container);
void Shutdown();
const Shelf* shelf() const { return shelf_; }
void RegisterHotseatWidget(HotseatWidget* hotseat_widget);
ShelfLayoutManager* shelf_layout_manager() { return shelf_layout_manager_; }
ShelfNavigationWidget* navigation_widget() const {
return shelf_->navigation_widget();
}
HotseatWidget* hotseat_widget() const { return shelf_->hotseat_widget(); }
DeskButtonWidget* desk_button_widget() const {
return shelf_->desk_button_widget();
}
StatusAreaWidget* status_area_widget() const {
return shelf_->status_area_widget();
}
void PostCreateShelf();
bool IsShowingMenu() const;
gfx::Rect GetScreenBoundsOfItemIconForWindow(aura::Window* window);
gfx::Rect GetVisibleShelfBounds() const;
LoginShelfView* GetLoginShelfView();
void OnMouseEvent(ui::MouseEvent* event) override;
void OnGestureEvent(ui::GestureEvent* event) override;
void OnScrollEvent(ui::ScrollEvent* event) override;
bool OnNativeWidgetActivationChanged(bool active) override;
void CalculateTargetBounds() override;
gfx::Rect GetTargetBounds() const override;
void UpdateLayout(bool animate) override;
void UpdateTargetBoundsForGesture(int shelf_position) override;
void OnOverviewModeStarting() override;
void OnOverviewModeEnding(OverviewSession* overview_session) override;
void set_target_bounds(gfx::Rect target_bounds) {
target_bounds_ = target_bounds;
}
void WillDeleteShelfLayoutManager() override;
void OnHotseatStateChanged(HotseatState old_state,
HotseatState new_state) override;
void OnBackgroundTypeChanged(ShelfBackgroundType background_type,
AnimationChangeType change_type) override;
void OnSessionStateChanged(session_manager::SessionState state) override;
void OnUserSessionAdded(const AccountId& account_id) override;
SkColor GetShelfBackgroundColor() const;
base::ScopedClosureRunner ForceShowHotseatInTabletMode();
bool IsHotseatForcedShowInTabletMode() const;
ui::Layer* GetOpaqueBackground();
ui::Layer* GetAnimatingBackground();
ui::Layer* GetAnimatingDragHandle();
DragHandle* GetDragHandle();
void ScheduleShowDragHandleNudge();
void HideDragHandleNudge(contextual_tooltip::DismissNudgeReason context);
void SetLoginShelfButtonOpacity(float target_opacity);
ui::Layer* GetDelegateViewOpaqueBackgroundLayerForTesting();
ShelfView* shelf_view_for_testing() const {
return hotseat_widget()->GetShelfView();
}
ShelfBackgroundAnimator* background_animator_for_testing() {
return &background_animator_;
}
HotseatTransitionAnimator* hotseat_transition_animator() {
return hotseat_transition_animator_.get();
}
private:
friend class ShelfWidgetDelegateView;
void HideIfShown();
void ShowIfHidden();
ShelfView* GetShelfView();
const ShelfView* GetShelfView() const;
void ResetForceShowHotseat();
raw_ptr<Shelf> shelf_;
gfx::Rect target_bounds_;
ShelfBackgroundAnimator background_animator_;
std::unique_ptr<ShelfLayoutManager> shelf_layout_manager_owned_;
raw_ptr<ShelfLayoutManager> shelf_layout_manager_;
std::unique_ptr<ui::ImplicitAnimationObserver> hide_animation_observer_;
raw_ptr<ShelfWidgetDelegateView, DanglingUntriaged> delegate_view_;
std::unique_ptr<HotseatTransitionAnimator> hotseat_transition_animator_;
raw_ptr<LoginShelfView> login_shelf_view_;
ScopedSessionObserver scoped_session_observer_;
size_t force_show_hotseat_count_ = 0;
base::WeakPtrFactory<ShelfWidget> weak_ptr_factory_{this};
};
}
#endif