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/frame_painter.h" | 5 #include "ash/wm/frame_painter.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/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "base/logging.h" // DCHECK | 10 #include "base/logging.h" // DCHECK |
11 #include "grit/ui_resources.h" | 11 #include "grit/ui_resources.h" |
12 #include "grit/ui_resources_standard.h" | 12 #include "grit/ui_resources_standard.h" |
13 #include "third_party/skia/include/core/SkCanvas.h" | 13 #include "third_party/skia/include/core/SkCanvas.h" |
14 #include "third_party/skia/include/core/SkColor.h" | 14 #include "third_party/skia/include/core/SkColor.h" |
15 #include "third_party/skia/include/core/SkPaint.h" | 15 #include "third_party/skia/include/core/SkPaint.h" |
16 #include "third_party/skia/include/core/SkPath.h" | 16 #include "third_party/skia/include/core/SkPath.h" |
17 #include "third_party/skia/include/core/SkShader.h" | 17 #include "third_party/skia/include/core/SkShader.h" |
18 #include "ui/aura/client/aura_constants.h" | 18 #include "ui/aura/client/aura_constants.h" |
19 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
20 #include "ui/base/animation/slide_animation.h" | 20 #include "ui/base/animation/slide_animation.h" |
21 #include "ui/base/hit_test.h" | 21 #include "ui/base/hit_test.h" |
| 22 #include "ui/base/layout.h" |
22 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
23 #include "ui/base/theme_provider.h" | 24 #include "ui/base/theme_provider.h" |
24 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
25 #include "ui/gfx/font.h" | 26 #include "ui/gfx/font.h" |
26 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
27 #include "ui/views/controls/button/image_button.h" | 28 #include "ui/views/controls/button/image_button.h" |
28 #include "ui/views/widget/widget.h" | 29 #include "ui/views/widget/widget.h" |
29 #include "ui/views/widget/widget_delegate.h" | 30 #include "ui/views/widget/widget_delegate.h" |
30 | 31 |
31 namespace { | 32 namespace { |
32 // TODO(jamescook): Border is specified to be a single pixel overlapping | 33 // TODO(jamescook): Border is specified to be a single pixel overlapping |
33 // the web content and may need to be built into the shadow layers instead. | 34 // the web content and may need to be built into the shadow layers instead. |
34 const int kBorderThickness = 0; | 35 const int kBorderThickness = 0; |
35 // In the window corners, the resize areas don't actually expand bigger, but the | 36 // In the window corners, the resize areas don't actually expand bigger, but the |
36 // 16 px at the end of each edge triggers diagonal resizing. | 37 // 16 px at the end of each edge triggers diagonal resizing. |
37 const int kResizeAreaCornerSize = 16; | 38 const int kResizeAreaCornerSize = 16; |
38 // Ash windows do not have a traditional visible window frame. Window content | 39 // Ash windows do not have a traditional visible window frame. Window content |
39 // extends to the edge of the window. We consider a small region outside the | 40 // extends to the edge of the window. We consider a small region outside the |
40 // window bounds and an even smaller region overlapping the window to be the | 41 // window bounds and an even smaller region overlapping the window to be the |
41 // "non-client" area and use it for resizing. | 42 // "non-client" area and use it for resizing. |
| 43 const int kResizeOutsideBoundsSizeTouch = 30; |
42 const int kResizeOutsideBoundsSize = 6; | 44 const int kResizeOutsideBoundsSize = 6; |
43 const int kResizeInsideBoundsSize = 1; | 45 const int kResizeInsideBoundsSize = 1; |
44 // Space between left edge of window and popup window icon. | 46 // Space between left edge of window and popup window icon. |
45 const int kIconOffsetX = 4; | 47 const int kIconOffsetX = 4; |
46 // Space between top of window and popup window icon. | 48 // Space between top of window and popup window icon. |
47 const int kIconOffsetY = 6; | 49 const int kIconOffsetY = 6; |
48 // Height and width of window icon. | 50 // Height and width of window icon. |
49 const int kIconSize = 16; | 51 const int kIconSize = 16; |
50 // Space between the title text and the caption buttons. | 52 // Space between the title text and the caption buttons. |
51 const int kTitleLogoSpacing = 5; | 53 const int kTitleLogoSpacing = 5; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP).ToSkBitmap(); | 196 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP).ToSkBitmap(); |
195 top_right_corner_ = | 197 top_right_corner_ = |
196 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP_RIGHT).ToSkBitmap(); | 198 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP_RIGHT).ToSkBitmap(); |
197 header_left_edge_ = | 199 header_left_edge_ = |
198 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_LEFT).ToSkBitmap(); | 200 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_LEFT).ToSkBitmap(); |
199 header_right_edge_ = | 201 header_right_edge_ = |
200 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_RIGHT).ToSkBitmap(); | 202 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_RIGHT).ToSkBitmap(); |
201 | 203 |
202 window_ = frame->GetNativeWindow(); | 204 window_ = frame->GetNativeWindow(); |
203 // Ensure we get resize cursors for a few pixels outside our bounds. | 205 // Ensure we get resize cursors for a few pixels outside our bounds. |
| 206 int outside_bounds = ui::DisplayLayout() == ui::LAYOUT_TOUCH ? |
| 207 kResizeOutsideBoundsSizeTouch : |
| 208 kResizeOutsideBoundsSize; |
204 window_->set_hit_test_bounds_override_outer( | 209 window_->set_hit_test_bounds_override_outer( |
205 gfx::Insets(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize, | 210 gfx::Insets(-outside_bounds, -outside_bounds, |
206 -kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize)); | 211 -outside_bounds, -outside_bounds)); |
207 // Ensure we get resize cursors just inside our bounds as well. | 212 // Ensure we get resize cursors just inside our bounds as well. |
208 window_->set_hit_test_bounds_override_inner( | 213 window_->set_hit_test_bounds_override_inner( |
209 gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize, | 214 gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize, |
210 kResizeInsideBoundsSize, kResizeInsideBoundsSize)); | 215 kResizeInsideBoundsSize, kResizeInsideBoundsSize)); |
211 | 216 |
212 // Watch for maximize/restore/fullscreen state changes. Observer removes | 217 // Watch for maximize/restore/fullscreen state changes. Observer removes |
213 // itself in OnWindowDestroying() below, or in the destructor if we go away | 218 // itself in OnWindowDestroying() below, or in the destructor if we go away |
214 // before the window. | 219 // before the window. |
215 window_->AddObserver(this); | 220 window_->AddObserver(this); |
216 } | 221 } |
(...skipping 13 matching lines...) Expand all Loading... |
230 const gfx::Rect& client_bounds) const { | 235 const gfx::Rect& client_bounds) const { |
231 return gfx::Rect(std::max(0, client_bounds.x() - kBorderThickness), | 236 return gfx::Rect(std::max(0, client_bounds.x() - kBorderThickness), |
232 std::max(0, client_bounds.y() - top_height), | 237 std::max(0, client_bounds.y() - top_height), |
233 client_bounds.width() + (2 * kBorderThickness), | 238 client_bounds.width() + (2 * kBorderThickness), |
234 client_bounds.height() + top_height + kBorderThickness); | 239 client_bounds.height() + top_height + kBorderThickness); |
235 } | 240 } |
236 | 241 |
237 int FramePainter::NonClientHitTest(views::NonClientFrameView* view, | 242 int FramePainter::NonClientHitTest(views::NonClientFrameView* view, |
238 const gfx::Point& point) { | 243 const gfx::Point& point) { |
239 gfx::Rect expanded_bounds = view->bounds(); | 244 gfx::Rect expanded_bounds = view->bounds(); |
240 expanded_bounds.Inset(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize); | 245 int outside_bounds = ui::DisplayLayout() == ui::LAYOUT_TOUCH ? |
| 246 kResizeOutsideBoundsSizeTouch : |
| 247 kResizeOutsideBoundsSize; |
| 248 expanded_bounds.Inset(-outside_bounds, -outside_bounds); |
241 if (!expanded_bounds.Contains(point)) | 249 if (!expanded_bounds.Contains(point)) |
242 return HTNOWHERE; | 250 return HTNOWHERE; |
243 | 251 |
244 // No avatar button. | 252 // No avatar button. |
245 | 253 |
246 // Check the frame first, as we allow a small area overlapping the contents | 254 // Check the frame first, as we allow a small area overlapping the contents |
247 // to be used for resize handles. | 255 // to be used for resize handles. |
248 bool can_ever_resize = frame_->widget_delegate() ? | 256 bool can_ever_resize = frame_->widget_delegate() ? |
249 frame_->widget_delegate()->CanResize() : | 257 frame_->widget_delegate()->CanResize() : |
250 false; | 258 false; |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 for (std::set<FramePainter*>::const_iterator it = instances_->begin(); | 621 for (std::set<FramePainter*>::const_iterator it = instances_->begin(); |
614 it != instances_->end(); | 622 it != instances_->end(); |
615 ++it) { | 623 ++it) { |
616 FramePainter* painter = *it; | 624 FramePainter* painter = *it; |
617 if (IsVisibleNormalWindow(painter->window_)) | 625 if (IsVisibleNormalWindow(painter->window_)) |
618 painter->frame_->non_client_view()->SchedulePaint(); | 626 painter->frame_->non_client_view()->SchedulePaint(); |
619 } | 627 } |
620 } | 628 } |
621 | 629 |
622 } // namespace ash | 630 } // namespace ash |
OLD | NEW |