forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds WmLayoutManager and the aura wrapper AuraLayoutManagerAdapter
No tests as ash_unittests is going to end up testing this by virtue of converting some of the ash LayoutManagers to be WmLayoutManagers and installing on aura::Windows. BUG=603369 TEST=none R=jamescook@chromium.org Review URL: https://codereview.chromium.org/1894593002 Cr-Commit-Position: refs/heads/master@{#387686}
- Loading branch information
sky
authored and
Commit bot
committed
Apr 15, 2016
1 parent
decc15b
commit d607862
Showing
4 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2016 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. | ||
|
||
#include "ash/wm/aura/aura_layout_manager_adapter.h" | ||
|
||
#include "ash/wm/aura/wm_window_aura.h" | ||
#include "ash/wm/common/wm_layout_manager.h" | ||
|
||
namespace ash { | ||
namespace wm { | ||
|
||
AuraLayoutManagerAdapter::AuraLayoutManagerAdapter( | ||
std::unique_ptr<WmLayoutManager> wm_layout_manager) | ||
: wm_layout_manager_(std::move(wm_layout_manager)) {} | ||
|
||
AuraLayoutManagerAdapter::~AuraLayoutManagerAdapter() {} | ||
|
||
void AuraLayoutManagerAdapter::OnWindowResized() { | ||
wm_layout_manager_->OnWindowResized(); | ||
} | ||
|
||
void AuraLayoutManagerAdapter::OnWindowAddedToLayout(aura::Window* child) { | ||
wm_layout_manager_->OnWindowAddedToLayout(WmWindowAura::Get(child)); | ||
} | ||
|
||
void AuraLayoutManagerAdapter::OnWillRemoveWindowFromLayout( | ||
aura::Window* child) { | ||
wm_layout_manager_->OnWillRemoveWindowFromLayout(WmWindowAura::Get(child)); | ||
} | ||
|
||
void AuraLayoutManagerAdapter::OnWindowRemovedFromLayout(aura::Window* child) { | ||
wm_layout_manager_->OnWindowRemovedFromLayout(WmWindowAura::Get(child)); | ||
} | ||
|
||
void AuraLayoutManagerAdapter::OnChildWindowVisibilityChanged( | ||
aura::Window* child, | ||
bool visible) { | ||
wm_layout_manager_->OnChildWindowVisibilityChanged(WmWindowAura::Get(child), | ||
visible); | ||
} | ||
|
||
void AuraLayoutManagerAdapter::SetChildBounds( | ||
aura::Window* child, | ||
const gfx::Rect& requested_bounds) { | ||
wm_layout_manager_->SetChildBounds(WmWindowAura::Get(child), | ||
requested_bounds); | ||
} | ||
|
||
} // namespace wm | ||
} // namespace ash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright 2016 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_WM_AURA_AURA_LAYOUT_MANAGER_ADAPTER_H_ | ||
#define ASH_WM_AURA_AURA_LAYOUT_MANAGER_ADAPTER_H_ | ||
|
||
#include <memory> | ||
|
||
#include "ash/ash_export.h" | ||
#include "base/macros.h" | ||
#include "ui/aura/layout_manager.h" | ||
|
||
namespace ash { | ||
namespace wm { | ||
|
||
class WmLayoutManager; | ||
|
||
// AuraLayoutManagerAdapter is an aura::LayoutManager that calls to | ||
// WmLayoutManager. Use it when you have a WmLayoutManager you want to use | ||
// with an aura::Window. | ||
class ASH_EXPORT AuraLayoutManagerAdapter : public aura::LayoutManager { | ||
public: | ||
explicit AuraLayoutManagerAdapter( | ||
std::unique_ptr<WmLayoutManager> wm_layout_manager); | ||
~AuraLayoutManagerAdapter() override; | ||
|
||
// aura::LayoutManager: | ||
void OnWindowResized() override; | ||
void OnWindowAddedToLayout(aura::Window* child) override; | ||
void OnWillRemoveWindowFromLayout(aura::Window* child) override; | ||
void OnWindowRemovedFromLayout(aura::Window* child) override; | ||
void OnChildWindowVisibilityChanged(aura::Window* child, | ||
bool visible) override; | ||
void SetChildBounds(aura::Window* child, | ||
const gfx::Rect& requested_bounds) override; | ||
|
||
private: | ||
std::unique_ptr<WmLayoutManager> wm_layout_manager_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(AuraLayoutManagerAdapter); | ||
}; | ||
|
||
} // namespace wm | ||
} // namespace ash | ||
|
||
#endif // ASH_WM_AURA_AURA_LAYOUT_MANAGER_ADAPTER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2016 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_WM_COMMON_WM_LAYOUT_MANAGER_H_ | ||
#define ASH_WM_COMMON_WM_LAYOUT_MANAGER_H_ | ||
|
||
#include "ash/ash_export.h" | ||
|
||
namespace gfx { | ||
class Rect; | ||
} | ||
|
||
namespace ash { | ||
namespace wm { | ||
|
||
class WmWindow; | ||
|
||
// Used to position the child WmWindows of a WmWindow. WmLayoutManager is called | ||
// at key points in a WmWindows life cycle thats allow sthe WmLayoutManager to | ||
// position or change child WmWindows. | ||
class ASH_EXPORT WmLayoutManager { | ||
public: | ||
virtual ~WmLayoutManager() {} | ||
|
||
// Invoked when the window the WmLayoutManager is associated with is resized. | ||
virtual void OnWindowResized() = 0; | ||
|
||
// Invoked when a window is added to the window the WmLayoutManager is | ||
// associated with. | ||
virtual void OnWindowAddedToLayout(WmWindow* child) = 0; | ||
|
||
// Invoked prior to removing |child|. | ||
virtual void OnWillRemoveWindowFromLayout(WmWindow* child) = 0; | ||
|
||
// Invoked after removing |child|. | ||
virtual void OnWindowRemovedFromLayout(WmWindow* child) = 0; | ||
|
||
// Invoked when SetVisible() is invoked on |child|. |visible| is the value | ||
// supplied to SetVisible(). If |visible| is true, child->IsVisible() may | ||
// still return false. See description in aura::Window::IsVisible() for | ||
// details. | ||
virtual void OnChildWindowVisibilityChanged(WmWindow* child, | ||
bool visibile) = 0; | ||
|
||
// Invoked when WmWindow::SetBounds() is called on |child|. This allows the | ||
// WmLayoutManager to modify the bounds as appropriate before processing the | ||
// request, including ignoring the request. Implementation must call | ||
// SetChildBoundsDirect() so that an infinite loop does not result. | ||
virtual void SetChildBounds(WmWindow* child, | ||
const gfx::Rect& requested_bounds) = 0; | ||
}; | ||
|
||
} // namespace wm | ||
} // namespace ash | ||
|
||
#endif // ASH_WM_COMMON_WM_LAYOUT_MANAGER_H_ |