| 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 "base/logging.h" // DCHECK | 7 #include "base/logging.h" // DCHECK |
| 8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
| 9 #include "third_party/skia/include/core/SkCanvas.h" | 9 #include "third_party/skia/include/core/SkCanvas.h" |
| 10 #include "third_party/skia/include/core/SkColor.h" | 10 #include "third_party/skia/include/core/SkColor.h" |
| 11 #include "third_party/skia/include/core/SkPaint.h" | 11 #include "third_party/skia/include/core/SkPaint.h" |
| 12 #include "third_party/skia/include/core/SkPath.h" | 12 #include "third_party/skia/include/core/SkPath.h" |
| 13 #include "third_party/skia/include/core/SkShader.h" | 13 #include "third_party/skia/include/core/SkShader.h" |
| 14 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 15 #include "ui/base/hit_test.h" | 15 #include "ui/base/hit_test.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/base/theme_provider.h" | 17 #include "ui/base/theme_provider.h" |
| 18 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
| 19 #include "ui/gfx/font.h" | 19 #include "ui/gfx/font.h" |
| 20 #include "ui/gfx/image/image.h" | 20 #include "ui/gfx/image/image.h" |
| 21 #include "ui/views/controls/button/image_button.h" | 21 #include "ui/views/controls/button/image_button.h" |
| 22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 23 #include "ui/views/widget/widget_delegate.h" | 23 #include "ui/views/widget/widget_delegate.h" |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 // Size of border along top edge, used for resize handle computations. | |
| 27 const int kTopThickness = 1; | |
| 28 // TODO(jamescook): Border is specified to be a single pixel overlapping | 26 // TODO(jamescook): Border is specified to be a single pixel overlapping |
| 29 // the web content and may need to be built into the shadow layers instead. | 27 // the web content and may need to be built into the shadow layers instead. |
| 30 const int kBorderThickness = 0; | 28 const int kBorderThickness = 0; |
| 31 // Ash windows do not have a traditional visible window frame. Window content | 29 // Ash windows do not have a traditional visible window frame. Window content |
| 32 // extends to the edge of the window. We consider a small region outside the | 30 // extends to the edge of the window. We consider a small region outside the |
| 33 // window bounds and an even smaller region overlapping the window to be the | 31 // window bounds and an even smaller region overlapping the window to be the |
| 34 // "non-client" area and use it for resizing. | 32 // "non-client" area and use it for resizing. |
| 35 const int kResizeOutsideBoundsSize = 6; | 33 const int kResizeOutsideBoundsSize = 6; |
| 36 const int kResizeInsideBoundsSize = 1; | 34 const int kResizeInsideBoundsSize = 1; |
| 37 // In the window corners, the resize areas don't actually expand bigger, but the | 35 // In the window corners, the resize areas don't actually expand bigger, but the |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 const gfx::Point& point) { | 166 const gfx::Point& point) { |
| 169 gfx::Rect expanded_bounds = view->bounds(); | 167 gfx::Rect expanded_bounds = view->bounds(); |
| 170 expanded_bounds.Inset(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize); | 168 expanded_bounds.Inset(-kResizeOutsideBoundsSize, -kResizeOutsideBoundsSize); |
| 171 if (!expanded_bounds.Contains(point)) | 169 if (!expanded_bounds.Contains(point)) |
| 172 return HTNOWHERE; | 170 return HTNOWHERE; |
| 173 | 171 |
| 174 // No avatar button. | 172 // No avatar button. |
| 175 | 173 |
| 176 // Check the frame first, as we allow a small area overlapping the contents | 174 // Check the frame first, as we allow a small area overlapping the contents |
| 177 // to be used for resize handles. | 175 // to be used for resize handles. |
| 178 bool can_resize = frame_->widget_delegate() ? | 176 bool can_ever_resize = frame_->widget_delegate() ? |
| 179 frame_->widget_delegate()->CanResize() : | 177 frame_->widget_delegate()->CanResize() : |
| 180 false; | 178 false; |
| 179 // Don't allow overlapping resize handles when the window is maximized, as it |
| 180 // can't be resized in that state. |
| 181 int resize_border = frame_->IsMaximized() ? 0 : kResizeInsideBoundsSize; |
| 181 int frame_component = view->GetHTComponentForFrame(point, | 182 int frame_component = view->GetHTComponentForFrame(point, |
| 182 kResizeInsideBoundsSize, | 183 resize_border, |
| 183 kResizeInsideBoundsSize, | 184 resize_border, |
| 184 kResizeAreaCornerSize, | 185 kResizeAreaCornerSize, |
| 185 kResizeAreaCornerSize, | 186 kResizeAreaCornerSize, |
| 186 can_resize); | 187 can_ever_resize); |
| 187 if (frame_component != HTNOWHERE) | 188 if (frame_component != HTNOWHERE) |
| 188 return frame_component; | 189 return frame_component; |
| 189 | 190 |
| 190 int client_component = frame_->client_view()->NonClientHitTest(point); | 191 int client_component = frame_->client_view()->NonClientHitTest(point); |
| 191 if (client_component != HTNOWHERE) | 192 if (client_component != HTNOWHERE) |
| 192 return client_component; | 193 return client_component; |
| 193 | 194 |
| 194 // Then see if the point is within any of the window controls. | 195 // Then see if the point is within any of the window controls. |
| 195 if (close_button_->visible() && | 196 if (close_button_->visible() && |
| 196 close_button_->GetMirroredBounds().Contains(point)) | 197 close_button_->GetMirroredBounds().Contains(point)) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 theme_provider->GetBitmapNamed(pushed_bitmap_id)); | 373 theme_provider->GetBitmapNamed(pushed_bitmap_id)); |
| 373 } | 374 } |
| 374 | 375 |
| 375 int FramePainter::GetTitleOffsetX() const { | 376 int FramePainter::GetTitleOffsetX() const { |
| 376 return window_icon_ ? | 377 return window_icon_ ? |
| 377 window_icon_->bounds().right() + kTitleIconOffsetX : | 378 window_icon_->bounds().right() + kTitleIconOffsetX : |
| 378 kTitleNoIconOffsetX; | 379 kTitleNoIconOffsetX; |
| 379 } | 380 } |
| 380 | 381 |
| 381 } // namespace ash | 382 } // namespace ash |
| OLD | NEW |