Index: ui/aura/window.h |
diff --git a/ui/aura/window.h b/ui/aura/window.h |
index ea3846109e62f27969fc8d2256a643845ae0406d..62e5e9ce355d67208c2c5c38bd70b18a98b4683f 100644 |
--- a/ui/aura/window.h |
+++ b/ui/aura/window.h |
@@ -16,6 +16,7 @@ |
#include "base/strings/string16.h" |
#include "ui/aura/aura_export.h" |
#include "ui/aura/client/window_types.h" |
+#include "ui/aura/window_layer_type.h" |
#include "ui/aura/window_observer.h" |
#include "ui/compositor/layer_animator.h" |
#include "ui/compositor/layer_delegate.h" |
@@ -31,6 +32,7 @@ |
namespace gfx { |
class Display; |
class Transform; |
+class Vector2d; |
} |
namespace ui { |
@@ -73,6 +75,9 @@ class AURA_EXPORT Window : public ui::LayerDelegate, |
// Initializes the window. This creates the window's layer. |
void Init(ui::LayerType layer_type); |
+ // TODO(sky): replace other Init() with this once m32 is more baked. |
+ void InitWithWindowLayerType(WindowLayerType layer_type); |
+ |
// Creates a new layer for the window. Erases the layer-owned bounds, so the |
// caller may wish to set new bounds and other state on the window/layer. |
// Returns the old layer, which can be used for animations. Caller owns the |
@@ -106,7 +111,7 @@ class AURA_EXPORT Window : public ui::LayerDelegate, |
WindowDelegate* delegate() { return delegate_; } |
const WindowDelegate* delegate() const { return delegate_; } |
- const gfx::Rect& bounds() const; |
+ const gfx::Rect& bounds() const { return bounds_; } |
Window* parent() { return parent_; } |
const Window* parent() const { return parent_; } |
@@ -406,6 +411,22 @@ class AURA_EXPORT Window : public ui::LayerDelegate, |
// to. |
void RemoveChildImpl(Window* child, Window* new_parent); |
+ // If this Window has a layer the layer's parent is set to NULL, otherwise |
+ // UnparentLayers() is invoked on all the children. |offset| is the offset |
+ // relative to the nearest ancestor with a layer. |
+ void UnparentLayers(bool has_layerless_ancestor, |
+ const gfx::Vector2d& offset); |
+ |
+ // If this Window has a layer it is added to |parent| and the origin set to |
+ // |offset|. Otherwise this recurses through the children invoking |
+ // ReparentLayers(). The net effect is both setting the parent of layers to |
+ // |parent| as well as updating bounds of windows with a layerless ancestor. |
+ void ReparentLayers(ui::Layer* parent, const gfx::Vector2d& offset); |
+ |
+ // Offsets the first encountered Windows with layers by |offset|. This |
+ // recurses through all layerless Windows, stopping at windows with layers. |
+ void OffsetLayerBounds(const gfx::Vector2d& offset); |
+ |
// Called when this window's parent has changed. |
void OnParentChanged(); |
@@ -468,11 +489,12 @@ class AURA_EXPORT Window : public ui::LayerDelegate, |
// Notifies this window and its parent hierarchy. |
void NotifyWindowVisibilityChangedUp(aura::Window* target, bool visible); |
- // Invoked from the closure returned by PrepareForLayerBoundsChange() after |
- // the bounds of the layer has changed. |old_bounds| is the previous bounds of |
- // the layer, and |contained_mouse| is true if the mouse was previously within |
- // the window's bounds. |
- void OnLayerBoundsChanged(const gfx::Rect& old_bounds, bool contained_mouse); |
+ // Invoked when the bounds of the window changes. This may be invoked directly |
+ // by us, or from the closure returned by PrepareForLayerBoundsChange() after |
+ // the bounds of the layer has changed. |old_bounds| is the previous bounds, |
+ // and |contained_mouse| is true if the mouse was previously within the |
+ // window's bounds. |
+ void OnWindowBoundsChanged(const gfx::Rect& old_bounds, bool contained_mouse); |
// Overridden from ui::LayerDelegate: |
virtual void OnPaintLayer(gfx::Canvas* canvas) OVERRIDE; |
@@ -488,6 +510,22 @@ class AURA_EXPORT Window : public ui::LayerDelegate, |
// Returns true if the mouse is currently within our bounds. |
bool ContainsMouse(); |
+ // Returns the first ancestor (starting at |this|) with a layer. |offset| is |
+ // set to the offset from |this| to the first ancestor with a layer. |
+ Window* GetAncestorWithLayer(gfx::Vector2d* offset) { |
+ return const_cast<Window*>( |
+ const_cast<const Window*>(this)->GetAncestorWithLayer(offset)); |
+ } |
+ const Window* GetAncestorWithLayer(gfx::Vector2d* offset) const; |
+ |
+ bool is_layerless() const { return layer_ == NULL; } |
Ben Goodger (Google)
2013/12/02 22:12:52
do we really want this? vs. !!layer()?
if we do,
|
+ |
+ // Bounds of this window relative to the parent. This is cached as the bounds |
+ // of the Layer and Window are not necessarily the same. In particular bounds |
+ // of the Layer are relative to the first ancestor with a Layer, where as this |
+ // is relative to the parent Window. |
+ gfx::Rect bounds_; |
+ |
WindowEventDispatcher* dispatcher_; |
client::WindowType type_; |