summaryrefslogtreecommitdiffstats
path: root/chromium/ash/system/tray/throbber_view.h
blob: 0f2663280e2f11d824ddd8d65faaab90825ef367 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_SYSTEM_TRAY_THROBBER_VIEW_H_
#define ASH_SYSTEM_TRAY_THROBBER_VIEW_H_

#include "ui/gfx/size.h"
#include "ui/views/controls/throbber.h"
#include "ui/views/view.h"

namespace ash {
namespace internal {

// A SmoothedThrobber with tooltip.
class SystemTrayThrobber : public views::SmoothedThrobber {
 public:
  SystemTrayThrobber(int frame_delay_ms);
  virtual ~SystemTrayThrobber();

  void SetTooltipText(const base::string16& tooltip_text);

  // Overriden from views::View.
  virtual bool GetTooltipText(
        const gfx::Point& p, base::string16* tooltip) const OVERRIDE;

 private:
  // The current tooltip text.
  base::string16 tooltip_text_;

  DISALLOW_COPY_AND_ASSIGN(SystemTrayThrobber);
};

// A View containing a SystemTrayThrobber with animation for starting/stopping.
class ThrobberView : public views::View {
 public:
  ThrobberView();
  virtual ~ThrobberView();

  void Start();
  void Stop();
  void SetTooltipText(const base::string16& tooltip_text);

  // Overriden from views::View.
  virtual gfx::Size GetPreferredSize() OVERRIDE;
  virtual void Layout() OVERRIDE;
  virtual bool GetTooltipText(
      const gfx::Point& p, base::string16* tooltip) const OVERRIDE;

 private:
  // Schedules animation for starting/stopping throbber.
  void ScheduleAnimation(bool start_throbber);

  SystemTrayThrobber* throbber_;

  // The current tooltip text.
  base::string16 tooltip_text_;

  DISALLOW_COPY_AND_ASSIGN(ThrobberView);
};

}  // namespace internal
}  // namespace ash

#endif  // ASH_SYSTEM_TRAY_THROBBER_VIEW_H_