Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1745)

Unified Diff: athena/wm/split_view_controller.cc

Issue 465983002: Add shoftcut (ctrl-f6) to toggle split view (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/wm/split_view_controller.h ('k') | athena/wm/window_manager_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/wm/split_view_controller.cc
diff --git a/athena/wm/split_view_controller.cc b/athena/wm/split_view_controller.cc
index 595a61ae8e0870903d53effa6929c81a828f96bc..36219eb94f20db263d04be3b8b3f62f7a4e4f4a1 100644
--- a/athena/wm/split_view_controller.cc
+++ b/athena/wm/split_view_controller.cc
@@ -6,6 +6,7 @@
#include <cmath>
+#include "athena/common/closure_animation_observer.h"
mfomitchev 2014/08/12 18:52:50 Nice. Not part of this CL, but perhaps ClosureAnim
#include "athena/wm/public/window_list_provider.h"
#include "athena/wm/public/window_manager.h"
#include "base/bind.h"
@@ -15,33 +16,9 @@
#include "ui/events/event_handler.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
+#include "ui/wm/core/window_util.h"
namespace athena {
-namespace {
-
-// An animation observer that runs a callback at the end of the animation, and
-// destroys itself.
-class CallbackAnimationObserver : public ui::ImplicitAnimationObserver {
- public:
- explicit CallbackAnimationObserver(const base::Closure& closure)
- : closure_(closure) {}
-
- virtual ~CallbackAnimationObserver() {}
-
- private:
- // Overridden from ui::ImplicitAnimationObserver:
- virtual void OnImplicitAnimationsCompleted() OVERRIDE {
- if (!closure_.is_null())
- closure_.Run();
- delete this;
- }
-
- const base::Closure closure_;
-
- DISALLOW_COPY_AND_ASSIGN(CallbackAnimationObserver);
-};
-
-} // namespace
SplitViewController::SplitViewController(
aura::Window* container,
@@ -67,13 +44,46 @@ bool SplitViewController::IsSplitViewModeActive() const {
return state_ == ACTIVE;
}
+void SplitViewController::ToggleSplitView() {
+ if (IsSplitViewModeActive()) {
+ const gfx::Transform transform;
mfomitchev 2014/08/12 18:52:50 Can you add a TODO(mfomitchev): Use UpdateLayout()
+ left_window_->SetTransform(transform);
+ right_window_->SetTransform(transform);
+ left_window_->SetBounds(container_->bounds());
+ right_window_->SetBounds(container_->bounds());
+ left_window_ = NULL;
+ right_window_ = NULL;
+ current_activity_window_ = NULL;
+ state_ = INACTIVE;
+ } else if (window_list_provider_->GetWindowList().size() > 1) {
+ left_window_ = GetCurrentActivityWindow();
mfomitchev 2014/08/12 18:52:50 I'd use left_window_ and right_window if they are
mfomitchev 2014/08/13 15:08:47 You can also use ActivateSplitMode() if you land t
+ const aura::Window::Windows& windows =
+ window_list_provider_->GetWindowList();
+ const aura::Window::Windows::const_iterator iter =
+ std::find(windows.begin(), windows.end(), left_window_);
+ // TODO(oshima): Make WindowManagerImpl accessible within athena/wm.
+ right_window_ = (iter == windows.begin() ? *(iter + 1) : * (iter - 1));
+
+ separator_position_ = container_->bounds().width() / 2;
+
+ const gfx::Transform transform;
+ left_window_->SetTransform(transform);
+ right_window_->SetTransform(transform);
+ const gfx::Rect& bounds = container_->bounds();
+ int middle = bounds.width() / 2;
+ left_window_->SetBounds(gfx::Rect(0, 0, middle, bounds.height()));
+ right_window_->SetBounds(gfx::Rect(middle, 0, middle, bounds.height()));
+ state_ = ACTIVE;
+ }
+}
+
void SplitViewController::UpdateLayout(bool animate) {
- if (!left_window_)
+ if (!left_window_)
return;
CHECK(right_window_);
gfx::Transform left_transform;
gfx::Transform right_transform;
- int container_width = container_->GetBoundsInScreen().width();
+ int container_width = container_->bounds().width();
if (state_ == ACTIVE) {
// This method should only be called once in ACTIVE state when
// the left and rightwindows are still full screen and need to be resized.
@@ -106,7 +116,7 @@ void SplitViewController::SetWindowTransform(aura::Window* window,
ui::ScopedLayerAnimationSettings settings(animator);
settings.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
- settings.AddObserver(new CallbackAnimationObserver(
+ settings.AddObserver(new ClosureAnimationObserver(
base::Bind(&SplitViewController::OnAnimationCompleted,
weak_factory_.GetWeakPtr(),
window)));
@@ -150,7 +160,7 @@ void SplitViewController::UpdateSeparatorPositionFromScrollDelta(float delta) {
gfx::Screen* screen = gfx::Screen::GetScreenFor(container_);
const gfx::Rect& display_bounds =
screen->GetDisplayNearestWindow(container_).bounds();
- gfx::Rect container_bounds = container_->GetBoundsInScreen();
+ gfx::Rect container_bounds = container_->bounds();
separator_position_ =
delta > 0 ? ((int)delta) + display_bounds.x() - container_bounds.x()
: display_bounds.right() - container_bounds.x() + delta;
@@ -217,7 +227,7 @@ void SplitViewController::ScrollEnd() {
if (state_ != SCROLLING)
return;
- int container_width = container_->GetBoundsInScreen().width();
+ int container_width = container_->bounds().width();
if (std::abs(container_width / 2 - separator_position_) <=
kMaxDistanceFromMiddle) {
state_ = ACTIVE;
@@ -243,9 +253,9 @@ void SplitViewController::ScrollUpdate(float delta) {
bool SplitViewController::CanScroll() {
// TODO(mfomitchev): return false in vertical orientation, in full screen.
- bool result = (!window_manager_->IsOverviewModeActive() &&
- !IsSplitViewModeActive() &&
- window_list_provider_->GetWindowList().size() >= 2);
+ bool result =
+ (!window_manager_->IsOverviewModeActive() && !IsSplitViewModeActive() &&
+ window_list_provider_->GetWindowList().size() >= 2);
return result;
}
@@ -253,21 +263,14 @@ bool SplitViewController::CanScroll() {
// WindowManagerObserver overrides
void SplitViewController::OnOverviewModeEnter() {
if (state_ == ACTIVE) {
- CHECK(left_window_);
- CHECK(right_window_);
- window_list_provider_->MoveToFront(right_window_);
- window_list_provider_->MoveToFront(left_window_);
- // TODO(mfomitchev): This shouldn't be done here, but the overview mode's
- // transition animation currently looks bad if the starting transform of
- // any window is not gfx::Transform().
- right_window_->SetTransform(gfx::Transform());
+ ToggleSplitView();
mfomitchev 2014/08/12 18:52:50 Not doing MoveToFront() can screw up the window or
} else if (current_activity_window_) {
+ CHECK_EQ(INACTIVE, state_);
mfomitchev 2014/08/12 18:52:50 This may not hold - you can hit the overview hot k
window_list_provider_->MoveToFront(current_activity_window_);
+ left_window_ = NULL;
+ right_window_ = NULL;
+ current_activity_window_ = NULL;
}
- state_ = INACTIVE;
- left_window_ = NULL;
- right_window_ = NULL;
- current_activity_window_ = NULL;
}
void SplitViewController::OnOverviewModeExit() {
« no previous file with comments | « athena/wm/split_view_controller.h ('k') | athena/wm/window_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698