| 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 11 matching lines...) Expand all Loading... |
| 22 #include "ui/views/views_delegate.h" | 22 #include "ui/views/views_delegate.h" |
| 23 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 24 #include "ui/views/widget/widget_delegate.h" | 24 #include "ui/views/widget/widget_delegate.h" |
| 25 | 25 |
| 26 #if defined(USE_AURA) | 26 #if defined(USE_AURA) |
| 27 #include "ui/aura/env.h" | 27 #include "ui/aura/env.h" |
| 28 #include "ui/aura/window.h" | 28 #include "ui/aura/window.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 // Height of the chrome-style caption, in pixels. | 32 |
| 33 const int kDefaultResizeInsideBoundsSize = 5; |
| 34 const int kDefaultResizeAreaCornerSize = 16; |
| 33 const int kCaptionHeight = 25; | 35 const int kCaptionHeight = 25; |
| 36 |
| 34 } // namespace | 37 } // namespace |
| 35 | 38 |
| 36 namespace apps { | 39 namespace apps { |
| 37 | 40 |
| 38 const char AppWindowFrameView::kViewClassName[] = | 41 const char AppWindowFrameView::kViewClassName[] = |
| 39 "browser/ui/views/extensions/AppWindowFrameView"; | 42 "browser/ui/views/extensions/AppWindowFrameView"; |
| 40 | 43 |
| 41 AppWindowFrameView::AppWindowFrameView() | 44 AppWindowFrameView::AppWindowFrameView(views::Widget* widget, |
| 42 : widget_(NULL), | 45 NativeAppWindow* window, |
| 43 window_(NULL), | 46 bool draw_frame, |
| 47 const SkColor& frame_color) |
| 48 : widget_(widget), |
| 49 window_(window), |
| 50 draw_frame_(draw_frame), |
| 51 frame_color_(frame_color), |
| 44 close_button_(NULL), | 52 close_button_(NULL), |
| 45 maximize_button_(NULL), | 53 maximize_button_(NULL), |
| 46 restore_button_(NULL), | 54 restore_button_(NULL), |
| 47 minimize_button_(NULL), | 55 minimize_button_(NULL), |
| 48 resize_inside_bounds_size_(0), | 56 resize_inside_bounds_size_(kDefaultResizeInsideBoundsSize), |
| 49 resize_outside_bounds_size_(0), | 57 resize_outside_bounds_size_(0), |
| 50 resize_area_corner_size_(0) {} | 58 resize_area_corner_size_(kDefaultResizeAreaCornerSize) { |
| 51 | |
| 52 AppWindowFrameView::~AppWindowFrameView() {} | |
| 53 | |
| 54 void AppWindowFrameView::Init(views::Widget* widget, | |
| 55 NativeAppWindow* window, | |
| 56 bool draw_frame, | |
| 57 const SkColor& frame_color, | |
| 58 int resize_inside_bounds_size, | |
| 59 int resize_outside_bounds_size, | |
| 60 int resize_outside_scale_for_touch, | |
| 61 int resize_area_corner_size) { | |
| 62 widget_ = widget; | |
| 63 window_ = window; | |
| 64 draw_frame_ = draw_frame; | |
| 65 frame_color_ = frame_color; | |
| 66 resize_inside_bounds_size_ = resize_inside_bounds_size; | |
| 67 resize_outside_bounds_size_ = resize_outside_bounds_size; | |
| 68 resize_area_corner_size_ = resize_area_corner_size; | |
| 69 | |
| 70 if (draw_frame) { | 59 if (draw_frame) { |
| 71 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 60 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 72 close_button_ = new views::ImageButton(this); | 61 close_button_ = new views::ImageButton(this); |
| 73 close_button_->SetImage( | 62 close_button_->SetImage( |
| 74 views::CustomButton::STATE_NORMAL, | 63 views::CustomButton::STATE_NORMAL, |
| 75 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia()); | 64 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia()); |
| 76 close_button_->SetImage( | 65 close_button_->SetImage( |
| 77 views::CustomButton::STATE_HOVERED, | 66 views::CustomButton::STATE_HOVERED, |
| 78 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_H).ToImageSkia()); | 67 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_H).ToImageSkia()); |
| 79 close_button_->SetImage( | 68 close_button_->SetImage( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_H).ToImageSkia()); | 109 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_H).ToImageSkia()); |
| 121 minimize_button_->SetImage( | 110 minimize_button_->SetImage( |
| 122 views::CustomButton::STATE_PRESSED, | 111 views::CustomButton::STATE_PRESSED, |
| 123 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_P).ToImageSkia()); | 112 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_P).ToImageSkia()); |
| 124 minimize_button_->SetAccessibleName( | 113 minimize_button_->SetAccessibleName( |
| 125 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); | 114 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); |
| 126 AddChildView(minimize_button_); | 115 AddChildView(minimize_button_); |
| 127 } | 116 } |
| 128 } | 117 } |
| 129 | 118 |
| 119 AppWindowFrameView::~AppWindowFrameView() {} |
| 120 |
| 121 void AppWindowFrameView::SetResizeSizes(int resize_inside_bounds_size, |
| 122 int resize_outside_bounds_size, |
| 123 int resize_area_corner_size) { |
| 124 resize_inside_bounds_size_ = resize_inside_bounds_size; |
| 125 resize_outside_bounds_size_ = resize_outside_bounds_size; |
| 126 resize_area_corner_size_ = resize_area_corner_size; |
| 127 } |
| 128 |
| 130 // views::NonClientFrameView implementation. | 129 // views::NonClientFrameView implementation. |
| 131 | 130 |
| 132 gfx::Rect AppWindowFrameView::GetBoundsForClientView() const { | 131 gfx::Rect AppWindowFrameView::GetBoundsForClientView() const { |
| 133 if (!draw_frame_ || widget_->IsFullscreen()) | 132 if (!draw_frame_ || widget_->IsFullscreen()) |
| 134 return bounds(); | 133 return bounds(); |
| 135 return gfx::Rect( | 134 return gfx::Rect( |
| 136 0, kCaptionHeight, width(), std::max(0, height() - kCaptionHeight)); | 135 0, kCaptionHeight, width(), std::max(0, height() - kCaptionHeight)); |
| 137 } | 136 } |
| 138 | 137 |
| 139 gfx::Rect AppWindowFrameView::GetWindowBoundsForClientBounds( | 138 gfx::Rect AppWindowFrameView::GetWindowBoundsForClientBounds( |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 widget_->Close(); | 361 widget_->Close(); |
| 363 else if (sender == maximize_button_) | 362 else if (sender == maximize_button_) |
| 364 widget_->Maximize(); | 363 widget_->Maximize(); |
| 365 else if (sender == restore_button_) | 364 else if (sender == restore_button_) |
| 366 widget_->Restore(); | 365 widget_->Restore(); |
| 367 else if (sender == minimize_button_) | 366 else if (sender == minimize_button_) |
| 368 widget_->Minimize(); | 367 widget_->Minimize(); |
| 369 } | 368 } |
| 370 | 369 |
| 371 } // namespace apps | 370 } // namespace apps |
| OLD | NEW |