1 // Copyright 2020 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 
5 #ifndef ASH_HUD_DISPLAY_TAB_STRIP_H_
6 #define ASH_HUD_DISPLAY_TAB_STRIP_H_
7 
8 #include "ash/hud_display/hud_constants.h"
9 #include "base/strings/string16.h"
10 #include "ui/views/controls/button/label_button.h"
11 #include "ui/views/metadata/metadata_header_macros.h"
12 #include "ui/views/view.h"
13 
14 namespace gfx {
15 class Canvas;
16 }
17 
18 namespace views {
19 class View;
20 }
21 
22 namespace ash {
23 namespace hud_display {
24 
25 class HUDDisplayView;
26 class HUDTabStrip;
27 
28 class HUDTabButton : public views::LabelButton {
29  public:
30   // Defines tab paint style.
31   enum class Style {
32     LEFT,    // Tab to the left of the active tab.
33     ACTIVE,  // Active tab.
34     RIGHT    // Tab to the right of the active tab.
35   };
36 
37   METADATA_HEADER(HUDTabButton);
38 
39   HUDTabButton(Style style,
40                const DisplayMode display_mode,
41                const base::string16& text);
42   HUDTabButton(const HUDTabButton&) = delete;
43   HUDTabButton& operator=(const HUDTabButton&) = delete;
44 
45   ~HUDTabButton() override = default;
46 
47   void SetStyle(Style style);
48 
display_mode()49   DisplayMode display_mode() const { return display_mode_; }
50 
51  protected:
52   // views::LabelButton:
53   void PaintButtonContents(gfx::Canvas* canvas) override;
54 
55  private:
56   Style style_ = Style::LEFT;
57 
58   // Tab activation sends this display mode to the HUD.
59   DisplayMode display_mode_;
60 };
61 
62 class HUDTabStrip : public views::View {
63  public:
64   METADATA_HEADER(HUDTabStrip);
65 
66   explicit HUDTabStrip(HUDDisplayView* hud);
67 
68   HUDTabStrip(const HUDTabStrip&) = delete;
69   HUDTabStrip& operator=(const HUDTabStrip&) = delete;
70 
71   ~HUDTabStrip() override;
72 
73   HUDTabButton* AddTabButton(const DisplayMode display_mode,
74                              const base::string16& label);
75 
76   // Mark tabs around the active one need repaint to modify borders.
77   void ActivateTab(DisplayMode mode);
78 
79  private:
80   HUDDisplayView* hud_;
81   std::vector<HUDTabButton*> tabs_;  // Ordered list of child tabs.
82 };
83 
84 }  // namespace hud_display
85 }  // namespace ash
86 #endif  // ASH_HUD_DISPLAY_TAB_STRIP_H_
87