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

Side by Side Diff: apps/ui/views/app_window_frame_view.cc

Issue 166443004: Add frame color option to packaged app windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments Created 6 years, 10 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
OLDNEW
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
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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 std::max(0, client_bounds.y() - kCaptionHeight), 162 std::max(0, client_bounds.y() - kCaptionHeight),
161 std::max(header_width, client_bounds.width()), 163 std::max(header_width, client_bounds.width()),
162 client_bounds.height() + kCaptionHeight); 164 client_bounds.height() + kCaptionHeight);
163 } 165 }
164 166
165 int AppWindowFrameView::NonClientHitTest(const gfx::Point& point) { 167 int AppWindowFrameView::NonClientHitTest(const gfx::Point& point) {
166 if (frame_->IsFullscreen()) 168 if (frame_->IsFullscreen())
167 return HTCLIENT; 169 return HTCLIENT;
168 170
169 gfx::Rect expanded_bounds = bounds(); 171 gfx::Rect expanded_bounds = bounds();
170 if (resize_outside_bounds_size_) 172 if (resize_outside_bounds_size_) {
171 expanded_bounds.Inset(gfx::Insets(-resize_outside_bounds_size_, 173 expanded_bounds.Inset(gfx::Insets(-resize_outside_bounds_size_,
172 -resize_outside_bounds_size_, 174 -resize_outside_bounds_size_,
173 -resize_outside_bounds_size_, 175 -resize_outside_bounds_size_,
174 -resize_outside_bounds_size_)); 176 -resize_outside_bounds_size_));
177 }
175 // Points outside the (possibly expanded) bounds can be discarded. 178 // Points outside the (possibly expanded) bounds can be discarded.
176 if (!expanded_bounds.Contains(point)) 179 if (!expanded_bounds.Contains(point))
177 return HTNOWHERE; 180 return HTNOWHERE;
178 181
179 // Check the frame first, as we allow a small area overlapping the contents 182 // Check the frame first, as we allow a small area overlapping the contents
180 // to be used for resize handles. 183 // to be used for resize handles.
181 bool can_ever_resize = frame_->widget_delegate() 184 bool can_ever_resize = frame_->widget_delegate()
182 ? frame_->widget_delegate()->CanResize() 185 ? frame_->widget_delegate()->CanResize()
183 : false; 186 : false;
184 // Don't allow overlapping resize handles when the window is maximized or 187 // Don't allow overlapping resize handles when the window is maximized or
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } else { 303 } else {
301 close_button_->SetImage( 304 close_button_->SetImage(
302 views::CustomButton::STATE_NORMAL, 305 views::CustomButton::STATE_NORMAL,
303 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_U).ToImageSkia()); 306 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_U).ToImageSkia());
304 } 307 }
305 308
306 // TODO(jeremya): different look for inactive? 309 // TODO(jeremya): different look for inactive?
307 SkPaint paint; 310 SkPaint paint;
308 paint.setAntiAlias(false); 311 paint.setAntiAlias(false);
309 paint.setStyle(SkPaint::kFill_Style); 312 paint.setStyle(SkPaint::kFill_Style);
310 paint.setColor(SK_ColorWHITE); 313 paint.setColor(frame_color_);
311 gfx::Path path; 314 gfx::Path path;
312 path.moveTo(0, 0); 315 path.moveTo(0, 0);
313 path.lineTo(width(), 0); 316 path.lineTo(width(), 0);
314 path.lineTo(width(), kCaptionHeight); 317 path.lineTo(width(), kCaptionHeight);
315 path.lineTo(0, kCaptionHeight); 318 path.lineTo(0, kCaptionHeight);
316 path.close(); 319 path.close();
317 canvas->DrawPath(path, paint); 320 canvas->DrawPath(path, paint);
318 } 321 }
319 322
320 const char* AppWindowFrameView::GetClassName() const { return kViewClassName; } 323 const char* AppWindowFrameView::GetClassName() const { return kViewClassName; }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 frame_->Close(); 361 frame_->Close();
359 else if (sender == maximize_button_) 362 else if (sender == maximize_button_)
360 frame_->Maximize(); 363 frame_->Maximize();
361 else if (sender == restore_button_) 364 else if (sender == restore_button_)
362 frame_->Restore(); 365 frame_->Restore();
363 else if (sender == minimize_button_) 366 else if (sender == minimize_button_)
364 frame_->Minimize(); 367 frame_->Minimize();
365 } 368 }
366 369
367 } // namespace apps 370 } // namespace apps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698