summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 08:12:10 +0000
committerpkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 08:12:10 +0000
commit30b3965b1eec6ffb588c3dc65fc5f92d000aca83 (patch)
tree03ee420265786875d79df24f42e25f869c429d33
parent78bed5cc602b080f5ad67a959c43d47f4c95377a (diff)
downloadchromium_src-30b3965b1eec6ffb588c3dc65fc5f92d000aca83.zip
chromium_src-30b3965b1eec6ffb588c3dc65fc5f92d000aca83.tar.gz
chromium_src-30b3965b1eec6ffb588c3dc65fc5f92d000aca83.tar.bz2
Make windows animate to their respective light bars when they are minimized and the shelf is auto hidden.
BUG=259027 Test=Manual, see bug Review URL: https://chromiumcodereview.appspot.com/19100006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212280 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/wm/gestures/system_pinch_handler.cc8
-rw-r--r--ash/wm/window_animations.cc78
-rw-r--r--ash/wm/window_animations.h7
-rw-r--r--ash/wm/workspace/frame_maximize_button.cc15
4 files changed, 70 insertions, 38 deletions
diff --git a/ash/wm/gestures/system_pinch_handler.cc b/ash/wm/gestures/system_pinch_handler.cc
index 39a733b..a0f5d12 100644
--- a/ash/wm/gestures/system_pinch_handler.cc
+++ b/ash/wm/gestures/system_pinch_handler.cc
@@ -9,6 +9,7 @@
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/wm/property_util.h"
+#include "ash/wm/window_animations.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/snap_sizer.h"
#include "ui/aura/window.h"
@@ -129,11 +130,8 @@ gfx::Rect SystemPinchHandler::GetPhantomWindowScreenBounds(
return window->bounds();
}
- Launcher* launcher = Launcher::ForWindow(window);
- gfx::Rect rect = launcher->GetScreenBoundsOfItemIconForWindow(target_);
- if (rect.IsEmpty())
- rect = launcher->shelf_widget()->GetWindowBoundsInScreen();
- else
+ gfx::Rect rect = GetMinimizeAnimationTargetBoundsInScreen(target_);
+ if (!rect.IsEmpty())
rect.Inset(-8, -8);
phantom_state_ = PHANTOM_WINDOW_MINIMIZED;
return rect;
diff --git a/ash/wm/window_animations.cc b/ash/wm/window_animations.cc
index dc6ff2e..0278a93 100644
--- a/ash/wm/window_animations.cc
+++ b/ash/wm/window_animations.cc
@@ -11,6 +11,8 @@
#include "ash/launcher/launcher.h"
#include "ash/screen_ash.h"
+#include "ash/shelf/shelf_layout_manager.h"
+#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/workspace_animations.h"
@@ -71,33 +73,16 @@ int64 Round64(float f) {
} // namespace
-gfx::Rect GetMinimizeRectForWindow(aura::Window* window) {
- Launcher* launcher = Launcher::ForWindow(window);
- // Launcher is created lazily and can be NULL.
- if (!launcher)
- return gfx::Rect();
- gfx::Rect target_bounds = Launcher::ForWindow(window)->
- GetScreenBoundsOfItemIconForWindow(window);
- if (target_bounds.IsEmpty()) {
- // Assume the launcher is overflowed, zoom off to the bottom right of the
- // work area.
- gfx::Rect work_area =
- Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
- target_bounds.SetRect(work_area.right(), work_area.bottom(), 0, 0);
- }
- target_bounds =
- ScreenAsh::ConvertRectFromScreen(window->parent(), target_bounds);
- return target_bounds;
-}
-
void AddLayerAnimationsForMinimize(aura::Window* window, bool show) {
// Recalculate the transform at restore time since the launcher item may have
// moved while the window was minimized.
gfx::Rect bounds = window->bounds();
- gfx::Rect target_bounds = GetMinimizeRectForWindow(window);
+ gfx::Rect target_bounds = GetMinimizeAnimationTargetBoundsInScreen(window);
+ target_bounds =
+ ScreenAsh::ConvertRectFromScreen(window->parent(), target_bounds);
- float scale_x = static_cast<float>(target_bounds.height()) / bounds.width();
- float scale_y = static_cast<float>(target_bounds.width()) / bounds.height();
+ float scale_x = static_cast<float>(target_bounds.width()) / bounds.width();
+ float scale_y = static_cast<float>(target_bounds.height()) / bounds.height();
scoped_ptr<ui::InterpolatedTransform> scale(
new ui::InterpolatedScale(gfx::Point3F(1, 1, 1),
@@ -522,4 +507,53 @@ void SetTransformForScaleAnimation(ui::Layer* layer,
layer->SetTransform(transform);
}
+gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(aura::Window* window) {
+ Launcher* launcher = Launcher::ForWindow(window);
+ // Launcher is created lazily and can be NULL.
+ if (!launcher)
+ return gfx::Rect();
+ gfx::Rect item_rect = launcher->
+ GetScreenBoundsOfItemIconForWindow(window);
+
+ // The launcher item is visible and has an icon.
+ if (!item_rect.IsEmpty())
+ return item_rect;
+
+ // If both the icon width and height are 0, then there is no icon in the
+ // launcher for |window| or the icon is hidden in the overflow menu. If the
+ // launcher is auto hidden, one of the height or width will be 0 but the
+ // position in the launcher and the major dimension are still reported
+ // correctly and the window can be animated to the launcher item's light
+ // bar.
+ if (item_rect.width() != 0 || item_rect.height() != 0) {
+ internal::ShelfLayoutManager* layout_manager =
+ internal::ShelfLayoutManager::ForLauncher(window);
+ if (layout_manager->visibility_state() == SHELF_AUTO_HIDE) {
+ gfx::Rect shelf_bounds =
+ launcher->shelf_widget()->GetWindowBoundsInScreen();
+ switch (layout_manager->GetAlignment()) {
+ case SHELF_ALIGNMENT_BOTTOM:
+ item_rect.set_y(shelf_bounds.y());
+ break;
+ case SHELF_ALIGNMENT_LEFT:
+ item_rect.set_x(shelf_bounds.right());
+ break;
+ case SHELF_ALIGNMENT_RIGHT:
+ item_rect.set_x(shelf_bounds.x());
+ break;
+ case SHELF_ALIGNMENT_TOP:
+ item_rect.set_y(shelf_bounds.bottom());
+ break;
+ }
+ return item_rect;
+ }
+ }
+
+ // Assume the launcher is overflowed, zoom off to the bottom right of the
+ // work area.
+ gfx::Rect work_area =
+ Shell::GetScreen()->GetDisplayNearestWindow(window).work_area();
+ return gfx::Rect(work_area.right(), work_area.bottom(), 0, 0);
+}
+
} // namespace ash
diff --git a/ash/wm/window_animations.h b/ash/wm/window_animations.h
index 3f28b23..d56f2b2 100644
--- a/ash/wm/window_animations.h
+++ b/ash/wm/window_animations.h
@@ -69,7 +69,12 @@ ASH_EXPORT void SetTransformForScaleAnimation(
ui::Layer* layer,
LayerScaleAnimationDirection type);
-} // namespace ash
+// Returns the approximate bounds to which |window| will be animated when it
+// is minimized. The bounds are approximate because the minimize animation
+// involves rotation.
+ASH_EXPORT gfx::Rect GetMinimizeAnimationTargetBoundsInScreen(
+ aura::Window* window);
+} // namespace ash
#endif // ASH_WM_WINDOW_ANIMATIONS_H_
diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc
index 23ca750..f5ca589 100644
--- a/ash/wm/workspace/frame_maximize_button.cc
+++ b/ash/wm/workspace/frame_maximize_button.cc
@@ -12,6 +12,7 @@
#include "ash/touch/touch_uma.h"
#include "ash/wm/maximize_bubble_controller.h"
#include "ash/wm/property_util.h"
+#include "ash/wm/window_animations.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "ash/wm/workspace/phantom_window_controller.h"
@@ -490,19 +491,13 @@ gfx::Rect FrameMaximizeButton::ScreenBoundsForType(
window->parent(),
ScreenAsh::GetMaximizedWindowBoundsInParent(window));
case SNAP_MINIMIZE: {
- Launcher* launcher = Launcher::ForWindow(window);
- // Launcher is created lazily and can be NULL.
- if (!launcher)
- return gfx::Rect();
- gfx::Rect item_rect(launcher->GetScreenBoundsOfItemIconForWindow(
- window));
- if (!item_rect.IsEmpty()) {
+ gfx::Rect rect = GetMinimizeAnimationTargetBoundsInScreen(window);
+ if (!rect.IsEmpty()) {
// PhantomWindowController insets slightly, outset it so the phantom
// doesn't appear inset.
- item_rect.Inset(-8, -8);
- return item_rect;
+ rect.Inset(-8, -8);
}
- return launcher->shelf_widget()->GetWindowBoundsInScreen();
+ return rect;
}
case SNAP_RESTORE: {
const gfx::Rect* restore = GetRestoreBoundsInScreen(window);