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

ash / accessibility / ui / accessibility_highlight_layer.h [blame]

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_ACCESSIBILITY_UI_ACCESSIBILITY_HIGHLIGHT_LAYER_H_
#define ASH_ACCESSIBILITY_UI_ACCESSIBILITY_HIGHLIGHT_LAYER_H_

#include <vector>

#include "ash/accessibility/ui/accessibility_layer.h"
#include "ash/ash_export.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/rect.h"

namespace ash {

// A subclass of LayerDelegate that can highlight regions on the screen.
class ASH_EXPORT AccessibilityHighlightLayer : public AccessibilityLayer {
 public:
  explicit AccessibilityHighlightLayer(AccessibilityLayerDelegate* delegate);

  AccessibilityHighlightLayer(const AccessibilityHighlightLayer&) = delete;
  AccessibilityHighlightLayer& operator=(const AccessibilityHighlightLayer&) =
      delete;

  ~AccessibilityHighlightLayer() override;

  // Create the layer and update its bounds and position in the hierarchy.
  void Set(const std::vector<gfx::Rect>& rects, SkColor color);

  // AccessibilityLayer overrides:
  int GetInset() const override;

  std::vector<gfx::Rect> rects_for_test() { return rects_; }

  SkColor color_for_test() { return highlight_color_; }

 private:
  // ui::LayerDelegate overrides:
  void OnPaintLayer(const ui::PaintContext& context) override;

  // The current rects to be highlighted, relative to the
  // AccessibilityPanelContainer window.
  std::vector<gfx::Rect> rects_;

  // The highlight color.
  SkColor highlight_color_;
};

}  // namespace ash

#endif  // ASH_ACCESSIBILITY_UI_ACCESSIBILITY_HIGHLIGHT_LAYER_H_