suggestion_chip_container_view.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2018 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_APP_LIST_VIEWS_SUGGESTION_CHIP_CONTAINER_VIEW_H_
  5. #define ASH_APP_LIST_VIEWS_SUGGESTION_CHIP_CONTAINER_VIEW_H_
  6. #include <vector>
  7. #include "ash/app_list/views/search_result_container_view.h"
  8. #include "ash/app_list/views/search_result_suggestion_chip_view.h"
  9. namespace ash {
  10. class ContentsView;
  11. // A container that holds the suggestion chips.
  12. class SuggestionChipContainerView : public SearchResultContainerView {
  13. public:
  14. explicit SuggestionChipContainerView(ContentsView* contents_view);
  15. SuggestionChipContainerView(const SuggestionChipContainerView&) = delete;
  16. SuggestionChipContainerView& operator=(const SuggestionChipContainerView&) =
  17. delete;
  18. ~SuggestionChipContainerView() override;
  19. // SearchResultContainerView:
  20. SearchResultSuggestionChipView* GetResultViewAt(size_t index) override;
  21. int DoUpdate() override;
  22. const char* GetClassName() const override;
  23. // views::View:
  24. void Layout() override;
  25. bool OnKeyPressed(const ui::KeyEvent& event) override;
  26. // Suggestion chips become unfocusable if |disabled| is true. This is used to
  27. // trap focus within the folder when it is opened.
  28. void DisableFocusForShowingActiveFolder(bool disabled);
  29. // Called when tablet mode starts and ends.
  30. void OnTabletModeChanged(bool started);
  31. // Sets whether blur is disabled on suggestion chip views.
  32. void SetBlurDisabled(bool blur_disabled);
  33. private:
  34. // Enables or disables suggestion chips blur depending on the container state.
  35. void UpdateBlurState();
  36. ContentsView* contents_view_ = nullptr; // Not owned
  37. views::BoxLayout* layout_manager_ = nullptr; // Not owned
  38. // Whether tablet mode is active - tracked by OnTabletModeChanged().
  39. bool in_tablet_mode_ = false;
  40. // Whether suggestion chip blur has been explicitly disabled.
  41. bool blur_disabled_ = false;
  42. std::vector<SearchResultSuggestionChipView*> suggestion_chip_views_; // Owned
  43. };
  44. } // namespace ash
  45. #endif // ASH_APP_LIST_VIEWS_SUGGESTION_CHIP_CONTAINER_VIEW_H_