OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "apps/ui/views/app_window_frame_view.h" | 5 #include "apps/ui/views/app_window_frame_view.h" |
6 | 6 |
7 #include "apps/ui/native_app_window.h" | 7 #include "apps/ui/native_app_window.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "extensions/common/draggable_region.h" | 9 #include "extensions/common/draggable_region.h" |
10 #include "grit/theme_resources.h" | 10 #include "grit/theme_resources.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 maximize_button_(NULL), | 44 maximize_button_(NULL), |
45 restore_button_(NULL), | 45 restore_button_(NULL), |
46 minimize_button_(NULL), | 46 minimize_button_(NULL), |
47 resize_inside_bounds_size_(0), | 47 resize_inside_bounds_size_(0), |
48 resize_outside_bounds_size_(0), | 48 resize_outside_bounds_size_(0), |
49 resize_area_corner_size_(0) {} | 49 resize_area_corner_size_(0) {} |
50 | 50 |
51 AppWindowFrameView::~AppWindowFrameView() {} | 51 AppWindowFrameView::~AppWindowFrameView() {} |
52 | 52 |
53 void AppWindowFrameView::Init(views::Widget* frame, | 53 void AppWindowFrameView::Init(views::Widget* frame, |
| 54 const SkColor& frame_color, |
54 int resize_inside_bounds_size, | 55 int resize_inside_bounds_size, |
55 int resize_outside_bounds_size, | 56 int resize_outside_bounds_size, |
56 int resize_outside_scale_for_touch, | 57 int resize_outside_scale_for_touch, |
57 int resize_area_corner_size) { | 58 int resize_area_corner_size) { |
58 frame_ = frame; | 59 frame_ = frame; |
| 60 frame_color_ = frame_color; |
59 resize_inside_bounds_size_ = resize_inside_bounds_size; | 61 resize_inside_bounds_size_ = resize_inside_bounds_size; |
60 resize_outside_bounds_size_ = resize_outside_bounds_size; | 62 resize_outside_bounds_size_ = resize_outside_bounds_size; |
61 resize_area_corner_size_ = resize_area_corner_size; | 63 resize_area_corner_size_ = resize_area_corner_size; |
62 | 64 |
63 if (!window_->IsFrameless()) { | 65 if (!window_->IsFrameless()) { |
64 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 66 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
65 close_button_ = new views::ImageButton(this); | 67 close_button_ = new views::ImageButton(this); |
66 close_button_->SetImage( | 68 close_button_->SetImage( |
67 views::CustomButton::STATE_NORMAL, | 69 views::CustomButton::STATE_NORMAL, |
68 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia()); | 70 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 std::max(0, client_bounds.y() - kCaptionHeight), | 151 std::max(0, client_bounds.y() - kCaptionHeight), |
150 std::max(header_width, client_bounds.width()), | 152 std::max(header_width, client_bounds.width()), |
151 client_bounds.height() + kCaptionHeight); | 153 client_bounds.height() + kCaptionHeight); |
152 } | 154 } |
153 | 155 |
154 int AppWindowFrameView::NonClientHitTest(const gfx::Point& point) { | 156 int AppWindowFrameView::NonClientHitTest(const gfx::Point& point) { |
155 if (frame_->IsFullscreen()) | 157 if (frame_->IsFullscreen()) |
156 return HTCLIENT; | 158 return HTCLIENT; |
157 | 159 |
158 gfx::Rect expanded_bounds = bounds(); | 160 gfx::Rect expanded_bounds = bounds(); |
159 if (resize_outside_bounds_size_) | 161 if (resize_outside_bounds_size_) { |
160 expanded_bounds.Inset(gfx::Insets(-resize_outside_bounds_size_, | 162 expanded_bounds.Inset(gfx::Insets(-resize_outside_bounds_size_, |
161 -resize_outside_bounds_size_, | 163 -resize_outside_bounds_size_, |
162 -resize_outside_bounds_size_, | 164 -resize_outside_bounds_size_, |
163 -resize_outside_bounds_size_)); | 165 -resize_outside_bounds_size_)); |
| 166 } |
164 // Points outside the (possibly expanded) bounds can be discarded. | 167 // Points outside the (possibly expanded) bounds can be discarded. |
165 if (!expanded_bounds.Contains(point)) | 168 if (!expanded_bounds.Contains(point)) |
166 return HTNOWHERE; | 169 return HTNOWHERE; |
167 | 170 |
168 // Check the frame first, as we allow a small area overlapping the contents | 171 // Check the frame first, as we allow a small area overlapping the contents |
169 // to be used for resize handles. | 172 // to be used for resize handles. |
170 bool can_ever_resize = frame_->widget_delegate() | 173 bool can_ever_resize = frame_->widget_delegate() |
171 ? frame_->widget_delegate()->CanResize() | 174 ? frame_->widget_delegate()->CanResize() |
172 : false; | 175 : false; |
173 // Don't allow overlapping resize handles when the window is maximized or | 176 // Don't allow overlapping resize handles when the window is maximized or |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 } else { | 293 } else { |
291 close_button_->SetImage( | 294 close_button_->SetImage( |
292 views::CustomButton::STATE_NORMAL, | 295 views::CustomButton::STATE_NORMAL, |
293 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_U).ToImageSkia()); | 296 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_U).ToImageSkia()); |
294 } | 297 } |
295 | 298 |
296 // TODO(jeremya): different look for inactive? | 299 // TODO(jeremya): different look for inactive? |
297 SkPaint paint; | 300 SkPaint paint; |
298 paint.setAntiAlias(false); | 301 paint.setAntiAlias(false); |
299 paint.setStyle(SkPaint::kFill_Style); | 302 paint.setStyle(SkPaint::kFill_Style); |
300 paint.setColor(SK_ColorWHITE); | 303 paint.setColor(frame_color_); |
301 gfx::Path path; | 304 gfx::Path path; |
302 path.moveTo(0, 0); | 305 path.moveTo(0, 0); |
303 path.lineTo(width(), 0); | 306 path.lineTo(width(), 0); |
304 path.lineTo(width(), kCaptionHeight); | 307 path.lineTo(width(), kCaptionHeight); |
305 path.lineTo(0, kCaptionHeight); | 308 path.lineTo(0, kCaptionHeight); |
306 path.close(); | 309 path.close(); |
307 canvas->DrawPath(path, paint); | 310 canvas->DrawPath(path, paint); |
308 } | 311 } |
309 | 312 |
310 const char* AppWindowFrameView::GetClassName() const { return kViewClassName; } | 313 const char* AppWindowFrameView::GetClassName() const { return kViewClassName; } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 frame_->Close(); | 351 frame_->Close(); |
349 else if (sender == maximize_button_) | 352 else if (sender == maximize_button_) |
350 frame_->Maximize(); | 353 frame_->Maximize(); |
351 else if (sender == restore_button_) | 354 else if (sender == restore_button_) |
352 frame_->Restore(); | 355 frame_->Restore(); |
353 else if (sender == minimize_button_) | 356 else if (sender == minimize_button_) |
354 frame_->Minimize(); | 357 frame_->Minimize(); |
355 } | 358 } |
356 | 359 |
357 } // namespace apps | 360 } // namespace apps |
OLD | NEW |