OLD | NEW |
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/screen_util.h" | 7 #include "ash/screen_util.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
10 #include "ash/wm/window_animations.h" | 10 #include "ash/wm/window_animations.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 direction_(direction), | 64 direction_(direction), |
65 image_(NULL) { | 65 image_(NULL) { |
66 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 66 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
67 int image_id = | 67 int image_id = |
68 direction == TOP_BOTTOM ? IDR_AURA_MULTI_WINDOW_RESIZE_H : | 68 direction == TOP_BOTTOM ? IDR_AURA_MULTI_WINDOW_RESIZE_H : |
69 IDR_AURA_MULTI_WINDOW_RESIZE_V; | 69 IDR_AURA_MULTI_WINDOW_RESIZE_V; |
70 image_ = rb.GetImageNamed(image_id).ToImageSkia(); | 70 image_ = rb.GetImageNamed(image_id).ToImageSkia(); |
71 } | 71 } |
72 | 72 |
73 // views::View overrides: | 73 // views::View overrides: |
74 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 74 virtual gfx::Size GetPreferredSize() const override { |
75 return gfx::Size(image_->width(), image_->height()); | 75 return gfx::Size(image_->width(), image_->height()); |
76 } | 76 } |
77 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 77 virtual void OnPaint(gfx::Canvas* canvas) override { |
78 canvas->DrawImageInt(*image_, 0, 0); | 78 canvas->DrawImageInt(*image_, 0, 0); |
79 } | 79 } |
80 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE { | 80 virtual bool OnMousePressed(const ui::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 ui::MouseEvent& event) OVERRIDE { | 86 virtual bool OnMouseDragged(const ui::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, event.flags()); | 89 controller_->Resize(location, event.flags()); |
90 return true; | 90 return true; |
91 } | 91 } |
92 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { | 92 virtual void OnMouseReleased(const ui::MouseEvent& event) override { |
93 controller_->CompleteResize(); | 93 controller_->CompleteResize(); |
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 ui::MouseEvent& event) OVERRIDE { | 99 const ui::MouseEvent& event) override { |
100 int component = (direction_ == LEFT_RIGHT) ? HTRIGHT : HTBOTTOM; | 100 int component = (direction_ == LEFT_RIGHT) ? HTRIGHT : HTBOTTOM; |
101 return ::wm::CompoundEventFilter::CursorForWindowComponent( | 101 return ::wm::CompoundEventFilter::CursorForWindowComponent( |
102 component); | 102 component); |
103 } | 103 } |
104 | 104 |
105 private: | 105 private: |
106 MultiWindowResizeController* controller_; | 106 MultiWindowResizeController* controller_; |
107 const Direction direction_; | 107 const Direction direction_; |
108 const gfx::ImageSkia* image_; | 108 const gfx::ImageSkia* image_; |
109 | 109 |
110 DISALLOW_COPY_AND_ASSIGN(ResizeView); | 110 DISALLOW_COPY_AND_ASSIGN(ResizeView); |
111 }; | 111 }; |
112 | 112 |
113 // MouseWatcherHost implementation for MultiWindowResizeController. Forwards | 113 // MouseWatcherHost implementation for MultiWindowResizeController. Forwards |
114 // Contains() to MultiWindowResizeController. | 114 // Contains() to MultiWindowResizeController. |
115 class MultiWindowResizeController::ResizeMouseWatcherHost : | 115 class MultiWindowResizeController::ResizeMouseWatcherHost : |
116 public views::MouseWatcherHost { | 116 public views::MouseWatcherHost { |
117 public: | 117 public: |
118 ResizeMouseWatcherHost(MultiWindowResizeController* host) : host_(host) {} | 118 ResizeMouseWatcherHost(MultiWindowResizeController* host) : host_(host) {} |
119 | 119 |
120 // MouseWatcherHost overrides: | 120 // MouseWatcherHost overrides: |
121 virtual bool Contains(const gfx::Point& point_in_screen, | 121 virtual bool Contains(const gfx::Point& point_in_screen, |
122 MouseEventType type) OVERRIDE { | 122 MouseEventType type) override { |
123 return host_->IsOverWindows(point_in_screen); | 123 return host_->IsOverWindows(point_in_screen); |
124 } | 124 } |
125 | 125 |
126 private: | 126 private: |
127 MultiWindowResizeController* host_; | 127 MultiWindowResizeController* host_; |
128 | 128 |
129 DISALLOW_COPY_AND_ASSIGN(ResizeMouseWatcherHost); | 129 DISALLOW_COPY_AND_ASSIGN(ResizeMouseWatcherHost); |
130 }; | 130 }; |
131 | 131 |
132 MultiWindowResizeController::ResizeWindows::ResizeWindows() | 132 MultiWindowResizeController::ResizeWindows::ResizeWindows() |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 return false; | 533 return false; |
534 | 534 |
535 gfx::Point window_loc(location_in_screen); | 535 gfx::Point window_loc(location_in_screen); |
536 aura::Window::ConvertPointToTarget( | 536 aura::Window::ConvertPointToTarget( |
537 window->GetRootWindow(), window, &window_loc); | 537 window->GetRootWindow(), window, &window_loc); |
538 return window->ContainsPoint(window_loc) && | 538 return window->ContainsPoint(window_loc) && |
539 window->delegate()->GetNonClientComponent(window_loc) == component; | 539 window->delegate()->GetNonClientComponent(window_loc) == component; |
540 } | 540 } |
541 | 541 |
542 } // namespace ash | 542 } // namespace ash |
OLD | NEW |