touch_hud_debug.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright 2013 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_TOUCH_TOUCH_HUD_DEBUG_H_
  5. #define ASH_TOUCH_TOUCH_HUD_DEBUG_H_
  6. #include <stdint.h>
  7. #include <map>
  8. #include <memory>
  9. #include "ash/ash_export.h"
  10. #include "ash/touch/touch_observer_hud.h"
  11. namespace views {
  12. class Label;
  13. class View;
  14. } // namespace views
  15. namespace ash {
  16. class TouchHudCanvas;
  17. class TouchLog;
  18. // A heads-up display to show touch traces on the screen and log touch events.
  19. // As a derivative of TouchObserverHud, objects of this class manage their own
  20. // lifetime.
  21. class ASH_EXPORT TouchHudDebug : public TouchObserverHud {
  22. public:
  23. enum Mode {
  24. FULLSCREEN,
  25. REDUCED_SCALE,
  26. INVISIBLE,
  27. };
  28. explicit TouchHudDebug(aura::Window* initial_root);
  29. TouchHudDebug(const TouchHudDebug&) = delete;
  30. TouchHudDebug& operator=(const TouchHudDebug&) = delete;
  31. // Changes the display mode (e.g. scale, visibility). Calling this repeatedly
  32. // cycles between a fixed number of display modes.
  33. void ChangeToNextMode();
  34. Mode mode() const { return mode_; }
  35. // TouchObserverHud:
  36. void Clear() override;
  37. private:
  38. ~TouchHudDebug() override;
  39. void SetMode(Mode mode);
  40. void UpdateTouchPointLabel(int index);
  41. // TouchObserverHud:
  42. void OnTouchEvent(ui::TouchEvent* event) override;
  43. void OnDisplayMetricsChanged(const display::Display& display,
  44. uint32_t metrics) override;
  45. void SetHudForRootWindowController(RootWindowController* controller) override;
  46. void UnsetHudForRootWindowController(
  47. RootWindowController* controller) override;
  48. static const int kMaxTouchPoints = 32;
  49. Mode mode_;
  50. std::unique_ptr<TouchLog> touch_log_;
  51. TouchHudCanvas* canvas_;
  52. views::View* label_container_;
  53. views::Label* touch_labels_[kMaxTouchPoints];
  54. };
  55. } // namespace ash
  56. #endif // ASH_TOUCH_TOUCH_HUD_DEBUG_H_