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

Unified Diff: ash/wm/workspace/workspace_window_resizer.cc

Issue 10823199: While dragging a window, show a semi-transparent aura window instead of the standard gray phantom wi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fill bug # Created 8 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 | « ash/wm/workspace/workspace_window_resizer.h ('k') | ash/wm/workspace/workspace_window_resizer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/workspace_window_resizer.cc
diff --git a/ash/wm/workspace/workspace_window_resizer.cc b/ash/wm/workspace/workspace_window_resizer.cc
index ddbe81f6907adad9f015f73a7518ddcb538d0e36..00ee6f9d4baf397f24d0f4217f59cb51b4788961 100644
--- a/ash/wm/workspace/workspace_window_resizer.cc
+++ b/ash/wm/workspace/workspace_window_resizer.cc
@@ -34,6 +34,9 @@ namespace {
// Duration of the animation when snapping the window into place.
const int kSnapDurationMS = 100;
+// The maximum opacity of the drag phantom window.
+const float kMaxOpacity = 0.8f;
+
// Returns true if should snap to the edge.
bool ShouldSnapToEdge(int distance_from_edge, int grid_size) {
return distance_from_edge <= grid_size / 2 &&
@@ -121,7 +124,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location, int event_flags) {
// Show a phantom window for dragging in another root window.
if (HasSecondaryRootWindow())
- UpdateDragPhantomWindow(bounds);
+ UpdateDragPhantomWindow(bounds, in_original_root);
else
drag_phantom_window_controller_.reset();
@@ -133,6 +136,7 @@ void WorkspaceWindowResizer::Drag(const gfx::Point& location, int event_flags) {
}
void WorkspaceWindowResizer::CompleteDrag(int event_flags) {
+ window()->layer()->SetOpacity(details_.initial_opacity);
drag_phantom_window_controller_.reset();
snap_phantom_window_controller_.reset();
if (!did_move_or_resize_ || details_.window_component != HTCAPTION)
@@ -182,6 +186,7 @@ void WorkspaceWindowResizer::CompleteDrag(int event_flags) {
}
void WorkspaceWindowResizer::RevertDrag() {
+ window()->layer()->SetOpacity(details_.initial_opacity);
drag_phantom_window_controller_.reset();
snap_phantom_window_controller_.reset();
@@ -440,7 +445,8 @@ int WorkspaceWindowResizer::PrimaryAxisCoordinate(int x, int y) const {
return 0;
}
-void WorkspaceWindowResizer::UpdateDragPhantomWindow(const gfx::Rect& bounds) {
+void WorkspaceWindowResizer::UpdateDragPhantomWindow(const gfx::Rect& bounds,
+ bool in_original_root) {
if (!did_move_or_resize_ || details_.window_component != HTCAPTION ||
!ShouldAllowMouseWarp()) {
return;
@@ -452,18 +458,36 @@ void WorkspaceWindowResizer::UpdateDragPhantomWindow(const gfx::Rect& bounds) {
const gfx::Rect root_bounds_in_screen(another_root->GetBoundsInScreen());
const gfx::Rect bounds_in_screen =
ScreenAsh::ConvertRectToScreen(window()->parent(), bounds);
- const gfx::Rect phantom(root_bounds_in_screen.Intersect(bounds_in_screen));
-
- if (!phantom.IsEmpty()) {
+ const gfx::Rect bounds_in_another_root =
+ root_bounds_in_screen.Intersect(bounds_in_screen);
+
+ const float fraction_in_another_window =
+ (bounds_in_another_root.width() * bounds_in_another_root.height()) /
+ static_cast<float>(bounds.width() * bounds.height());
+ const float phantom_opacity =
+ !in_original_root ? 1 : (kMaxOpacity * fraction_in_another_window);
+ const float window_opacity =
+ in_original_root ? 1 : (kMaxOpacity * (1 - fraction_in_another_window));
+
+ if (fraction_in_another_window > 0) {
if (!drag_phantom_window_controller_.get()) {
drag_phantom_window_controller_.reset(
new PhantomWindowController(window()));
- drag_phantom_window_controller_->Show(phantom);
+ drag_phantom_window_controller_->set_style(
+ PhantomWindowController::STYLE_WINDOW);
+ // Always show the drag phantom on the |another_root| window.
+ drag_phantom_window_controller_->SetDestinationDisplay(
+ gfx::Screen::GetDisplayMatching(another_root->GetBoundsInScreen()));
+ drag_phantom_window_controller_->Show(bounds_in_screen);
} else {
- drag_phantom_window_controller_->SetBounds(phantom); // no animation
+ // No animation.
+ drag_phantom_window_controller_->SetBounds(bounds_in_screen);
}
+ drag_phantom_window_controller_->SetOpacity(phantom_opacity);
+ window()->layer()->SetOpacity(window_opacity);
} else {
drag_phantom_window_controller_.reset();
+ window()->layer()->SetOpacity(1.0f);
}
}
« no previous file with comments | « ash/wm/workspace/workspace_window_resizer.h ('k') | ash/wm/workspace/workspace_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698