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 
5 #ifndef CHROME_BROWSER_VR_ELEMENTS_VECTOR_ICON_BUTTON_H_
6 #define CHROME_BROWSER_VR_ELEMENTS_VECTOR_ICON_BUTTON_H_
7 
8 #include <memory>
9 
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "chrome/browser/vr/elements/button.h"
13 #include "chrome/browser/vr/vr_ui_export.h"
14 #include "ui/gfx/vector_icon_types.h"
15 
16 namespace vr {
17 
18 class VectorIcon;
19 
20 // A vector button has rect as a background and a vector icon as the
21 // foreground. When hovered, background and foreground both move forward on Z
22 // axis.
23 class VR_UI_EXPORT VectorIconButton : public Button {
24  public:
25   VectorIconButton(base::RepeatingCallback<void()> click_handler,
26                    const gfx::VectorIcon& icon,
27                    AudioDelegate* audio_delegate);
28   ~VectorIconButton() override;
29 
foreground()30   VectorIcon* foreground() const { return foreground_; }
31 
32   void SetIcon(const gfx::VectorIcon& icon);
33   void SetIconTranslation(float x, float y);
34   void SetIconScaleFactor(float factor);
icon_scale_factor()35   float icon_scale_factor() const { return icon_scale_factor_; }
36 
37  private:
38   void OnStateUpdated() override;
39   void OnSetDrawPhase() override;
40   void OnSetName() override;
41   void OnSetSize(const gfx::SizeF& size) override;
42 
43   // This button will automatically scale down the given icon to fit the button.
44   // This value is used to determine the amount of scaling and can be set
45   // externally to create a smaller or larger icon.
46   float icon_scale_factor_;
47   VectorIcon* foreground_;
48   DISALLOW_COPY_AND_ASSIGN(VectorIconButton);
49 };
50 
51 }  // namespace vr
52 
53 #endif  // CHROME_BROWSER_VR_ELEMENTS_VECTOR_ICON_BUTTON_H_
54