status_area_widget_delegate.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Copyright (c) 2012 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. #ifndef ASH_SYSTEM_STATUS_AREA_WIDGET_DELEGATE_H_
  5. #define ASH_SYSTEM_STATUS_AREA_WIDGET_DELEGATE_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/public/cpp/shelf_config.h"
  8. #include "ash/public/cpp/shelf_types.h"
  9. #include "ash/system/status_area_widget.h"
  10. #include "ui/gfx/image/image_skia.h"
  11. #include "ui/views/accessible_pane_view.h"
  12. #include "ui/views/widget/widget_delegate.h"
  13. namespace ash {
  14. class FocusCycler;
  15. class Shelf;
  16. // The View for the status area widget.
  17. class ASH_EXPORT StatusAreaWidgetDelegate : public views::AccessiblePaneView,
  18. public views::WidgetDelegate {
  19. public:
  20. explicit StatusAreaWidgetDelegate(Shelf* shelf);
  21. StatusAreaWidgetDelegate(const StatusAreaWidgetDelegate&) = delete;
  22. StatusAreaWidgetDelegate& operator=(const StatusAreaWidgetDelegate&) = delete;
  23. ~StatusAreaWidgetDelegate() override;
  24. // Calculates the bounds that this view should have given its constraints,
  25. // but does not actually update bounds yet.
  26. void CalculateTargetBounds();
  27. // Returns the bounds that this view should have given its constraints.
  28. gfx::Rect GetTargetBounds() const;
  29. // Performs the actual changes in bounds for this view to match its target
  30. // bounds.
  31. void UpdateLayout(bool animate);
  32. // Sets the focus cycler.
  33. void SetFocusCyclerForTesting(const FocusCycler* focus_cycler);
  34. // If |reverse|, indicates backward focusing, otherwise forward focusing.
  35. // Returns true if status area widget delegate should focus out on the
  36. // designated focusing direction, otherwise false.
  37. bool ShouldFocusOut(bool reverse);
  38. // Called by StatusAreaWidget when its collapse state changes.
  39. void OnStatusAreaCollapseStateChanged(
  40. StatusAreaWidget::CollapseState new_collapse_state);
  41. // Clears most of the Widget to prevent destruction problems before ~Widget.
  42. void Shutdown();
  43. // views::AccessiblePaneView:
  44. void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
  45. View* GetDefaultFocusableChild() override;
  46. const char* GetClassName() const override;
  47. views::Widget* GetWidget() override;
  48. const views::Widget* GetWidget() const override;
  49. // ui::EventHandler:
  50. void OnGestureEvent(ui::GestureEvent* event) override;
  51. // views::WidgetDelegate:
  52. bool CanActivate() const override;
  53. void set_default_last_focusable_child(bool default_last_focusable_child) {
  54. default_last_focusable_child_ = default_last_focusable_child;
  55. }
  56. protected:
  57. // views::View:
  58. void ChildPreferredSizeChanged(views::View* child) override;
  59. void ChildVisibilityChanged(views::View* child) override;
  60. private:
  61. // Sets a border on |child|. If |extend_border_to_edge| is true, then an extra
  62. // wide border is added to extend the view's hit region to the edge of the
  63. // screen.
  64. void SetBorderOnChild(views::View* child, bool extend_border_to_edge);
  65. Shelf* const shelf_;
  66. const FocusCycler* focus_cycler_for_testing_;
  67. gfx::Rect target_bounds_;
  68. // When true, the default focus of the status area widget is the last
  69. // focusable child.
  70. bool default_last_focusable_child_ = false;
  71. };
  72. } // namespace ash
  73. #endif // ASH_SYSTEM_STATUS_AREA_WIDGET_DELEGATE_H_