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

Side by Side Diff: ash/wm/workspace/multi_window_resize_controller.cc

Issue 10008084: Add ctrl+drag feature for allowing resizing window with exact positioning. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/workspace/multi_window_resize_controller.h" 5 #include "ash/wm/workspace/multi_window_resize_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/root_window_event_filter.h" 9 #include "ash/wm/root_window_event_filter.h"
10 #include "ash/wm/window_animations.h" 10 #include "ash/wm/window_animations.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE { 80 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE {
81 gfx::Point location(event.location()); 81 gfx::Point location(event.location());
82 views::View::ConvertPointToScreen(this, &location); 82 views::View::ConvertPointToScreen(this, &location);
83 controller_->StartResize(location); 83 controller_->StartResize(location);
84 return true; 84 return true;
85 } 85 }
86 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE { 86 virtual bool OnMouseDragged(const views::MouseEvent& event) OVERRIDE {
87 gfx::Point location(event.location()); 87 gfx::Point location(event.location());
88 views::View::ConvertPointToScreen(this, &location); 88 views::View::ConvertPointToScreen(this, &location);
89 controller_->Resize(location); 89 controller_->Resize(location, event.flags());
90 return true; 90 return true;
91 } 91 }
92 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE { 92 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE {
93 controller_->CompleteResize(); 93 controller_->CompleteResize(event.flags());
94 } 94 }
95 virtual void OnMouseCaptureLost() OVERRIDE { 95 virtual void OnMouseCaptureLost() OVERRIDE {
96 controller_->CancelResize(); 96 controller_->CancelResize();
97 } 97 }
98 virtual gfx::NativeCursor GetCursor( 98 virtual gfx::NativeCursor GetCursor(
99 const views::MouseEvent& event) OVERRIDE { 99 const views::MouseEvent& event) OVERRIDE {
100 int component = (direction_ == LEFT_RIGHT) ? HTRIGHT : HTBOTTOM; 100 int component = (direction_ == LEFT_RIGHT) ? HTRIGHT : HTBOTTOM;
101 return RootWindowEventFilter::CursorForWindowComponent(component); 101 return RootWindowEventFilter::CursorForWindowComponent(component);
102 } 102 }
103 103
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 std::vector<aura::Window*> windows; 393 std::vector<aura::Window*> windows;
394 windows.push_back(windows_.window2); 394 windows.push_back(windows_.window2);
395 FindWindowsTouching(windows_.window2, windows_.direction, 395 FindWindowsTouching(windows_.window2, windows_.direction,
396 &windows_.other_windows); 396 &windows_.other_windows);
397 for (size_t i = 0; i < windows_.other_windows.size(); ++i) { 397 for (size_t i = 0; i < windows_.other_windows.size(); ++i) {
398 windows_.other_windows[i]->AddObserver(this); 398 windows_.other_windows[i]->AddObserver(this);
399 windows.push_back(windows_.other_windows[i]); 399 windows.push_back(windows_.other_windows[i]);
400 } 400 }
401 int component = windows_.direction == LEFT_RIGHT ? HTRIGHT : HTBOTTOM; 401 int component = windows_.direction == LEFT_RIGHT ? HTRIGHT : HTBOTTOM;
402 window_resizer_.reset(WorkspaceWindowResizer::Create( 402 window_resizer_.reset(WorkspaceWindowResizer::Create(
403 windows_.window1, parent_location, component, grid_size_, windows)); 403 windows_.window1, parent_location, component, windows));
404 } 404 }
405 405
406 void MultiWindowResizeController::Resize(const gfx::Point& screen_location) { 406 void MultiWindowResizeController::Resize(const gfx::Point& screen_location,
407 int event_flags) {
407 gfx::Point parent_location(screen_location); 408 gfx::Point parent_location(screen_location);
408 aura::Window::ConvertPointToWindow(windows_.window1->GetRootWindow(), 409 aura::Window::ConvertPointToWindow(windows_.window1->GetRootWindow(),
409 windows_.window1->parent(), 410 windows_.window1->parent(),
410 &parent_location); 411 &parent_location);
411 window_resizer_->Drag(parent_location); 412 window_resizer_->Drag(parent_location, event_flags);
412 gfx::Rect bounds = CalculateResizeWidgetBounds(parent_location); 413 gfx::Rect bounds = CalculateResizeWidgetBounds(parent_location);
413 if (windows_.direction == LEFT_RIGHT) 414 if (windows_.direction == LEFT_RIGHT)
414 bounds.set_y(show_bounds_.y()); 415 bounds.set_y(show_bounds_.y());
415 else 416 else
416 bounds.set_x(show_bounds_.x()); 417 bounds.set_x(show_bounds_.x());
417 resize_widget_->SetBounds(bounds); 418 resize_widget_->SetBounds(bounds);
418 } 419 }
419 420
420 void MultiWindowResizeController::CompleteResize() { 421 void MultiWindowResizeController::CompleteResize(int event_flags) {
421 window_resizer_->CompleteDrag(); 422 window_resizer_->CompleteDrag(event_flags);
422 window_resizer_.reset(); 423 window_resizer_.reset();
423 424
424 // Mouse may still be over resizer, if not hide. 425 // Mouse may still be over resizer, if not hide.
425 gfx::Point screen_loc = gfx::Screen::GetCursorScreenPoint(); 426 gfx::Point screen_loc = gfx::Screen::GetCursorScreenPoint();
426 if (!resize_widget_->GetWindowScreenBounds().Contains(screen_loc)) 427 if (!resize_widget_->GetWindowScreenBounds().Contains(screen_loc))
427 Hide(); 428 Hide();
428 } 429 }
429 430
430 void MultiWindowResizeController::CancelResize() { 431 void MultiWindowResizeController::CancelResize() {
431 if (!window_resizer_.get()) 432 if (!window_resizer_.get())
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 488
488 gfx::Point window_loc(screen_location); 489 gfx::Point window_loc(screen_location);
489 aura::Window::ConvertPointToWindow( 490 aura::Window::ConvertPointToWindow(
490 window->GetRootWindow(), window, &window_loc); 491 window->GetRootWindow(), window, &window_loc);
491 return window->HitTest(window_loc) && 492 return window->HitTest(window_loc) &&
492 window->delegate()->GetNonClientComponent(window_loc) == component; 493 window->delegate()->GetNonClientComponent(window_loc) == component;
493 } 494 }
494 495
495 } // namespace internal 496 } // namespace internal
496 } // namespace ash 497 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/multi_window_resize_controller.h ('k') | ash/wm/workspace/workspace_event_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698