#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
#include "ui/compositor/layer_delegate.h"
+#include "ui/gfx/rect.h"
-namespace ui {
-class Layer;
+namespace aura {
+class Window;
}
-namespace views {
-class Painter;
-class View;
+namespace ui {
+class Layer;
}
namespace chromeos {
-// FocusRingLayer draws a focus ring for a given view.
+// A delegate interface implemented by the object that owns a FocusRingLayer.
+class FocusRingLayerDelegate {
+ public:
+ virtual void OnDeviceScaleFactorChanged() = 0;
+
+ protected:
+ virtual ~FocusRingLayerDelegate();
+};
+
+// FocusRingLayer draws a focus ring at a given global rectangle.
class FocusRingLayer : public ui::LayerDelegate {
public:
- FocusRingLayer();
+ explicit FocusRingLayer(FocusRingLayerDelegate* delegate);
virtual ~FocusRingLayer();
- // Updates the focus ring layer for the view or clears it if |view| is NULL.
- void SetForView(views::View* view);
+ // Move the focus ring layer to the given bounds in the coordinates of
+ // the given root window.
+ void Set(aura::Window* root_window, const gfx::Rect& bounds);
+
+ ui::Layer* layer() { return layer_.get(); }
+ aura::Window* root_window() { return root_window_; }
+
+ protected:
+ // Updates |root_window_| and creates |layer_| if it doesn't exist,
+ // or if the root window has changed. Moves the layer to the top if
+ // it wasn't there already.
+ void CreateOrUpdateLayer(aura::Window* root_window, const char* layer_name);
private:
// ui::LayerDelegate overrides:
- virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE;
- virtual void OnDeviceScaleFactorChanged(float device_scale_factor) OVERRIDE;
- virtual base::Closure PrepareForLayerBoundsChange() OVERRIDE;
+ virtual void OnPaintLayer(gfx::Canvas* canvas) override;
+ virtual void OnDelegatedFrameDamage(
+ const gfx::Rect& damage_rect_in_dip) override;
+ virtual void OnDeviceScaleFactorChanged(float device_scale_factor) override;
+ virtual base::Closure PrepareForLayerBoundsChange() override;
+ // The object that owns this layer.
+ FocusRingLayerDelegate* delegate_;
+
+ // The current root window containing the focused object.
+ aura::Window* root_window_;
+
+ // The current layer.
scoped_ptr<ui::Layer> layer_;
- scoped_ptr<views::Painter> ring_painter_;
+
+ // The bounding rectangle of the focused object, in |root_window_|
+ // coordinates.
+ gfx::Rect focus_ring_;
DISALLOW_COPY_AND_ASSIGN(FocusRingLayer);
};