summaryrefslogtreecommitdiffstats
path: root/ash/touch/touch_observer_hud.h
blob: 09dd466543e9f6ee7a6eb6d0af36b3fc073af87d (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
66
67
68
// Copyright (c) 2012 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_TOUCH_TOUCH_OBSERVER_HUD_H_
#define ASH_TOUCH_TOUCH_OBSERVER_HUD_H_
#pragma once

#include "ash/shell.h"
#include "ui/aura/event_filter.h"
#include "ui/gfx/point.h"
#include "ui/views/widget/widget.h"

namespace aura {
class MouseEvent;
class KeyEvent;
class Window;
}

namespace views {
class Label;
class Widget;
}

namespace ash {
namespace internal {

class TouchHudCanvas;

// An event filter which handles system level gesture events.
class TouchObserverHUD : public aura::EventFilter,
                         public views::Widget::Observer {
 public:
  TouchObserverHUD();
  virtual ~TouchObserverHUD();

 private:
  void UpdateTouchPointLabel(int index);

  // Overriden from aura::EventFilter:
  virtual bool PreHandleKeyEvent(aura::Window* target,
                                 aura::KeyEvent* event) OVERRIDE;
  virtual bool PreHandleMouseEvent(aura::Window* target,
                                   aura::MouseEvent* event) OVERRIDE;
  virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target,
                                              aura::TouchEvent* event) OVERRIDE;
  virtual ui::GestureStatus PreHandleGestureEvent(
      aura::Window* target,
      aura::GestureEvent* event) OVERRIDE;

  // Overridden from views::Widget::Observer.
  virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE;

  static const int kMaxTouchPoints = 32;

  views::Widget* widget_;
  TouchHudCanvas* canvas_;
  views::Label* touch_labels_[kMaxTouchPoints];
  gfx::Point touch_positions_[kMaxTouchPoints];
  ui::EventType touch_status_[kMaxTouchPoints];

  DISALLOW_COPY_AND_ASSIGN(TouchObserverHUD);
};

}  // namespace internal
}  // namespace ash

#endif  // ASH_TOUCH_TOUCH_OBSERVER_HUD_H_