| 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 "chrome/browser/ui/views/extensions/shell_window_frame_view.h" | 5 #include "apps/ui/views/shell_window_frame_view.h" |
| 6 | 6 |
| 7 #include "apps/native_app_window.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/views/apps/native_app_window_views.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" |
| 11 #include "grit/ui_strings.h" // Accessibility names | 11 #include "grit/ui_strings.h" // Accessibility names |
| 12 #include "third_party/skia/include/core/SkPaint.h" | 12 #include "third_party/skia/include/core/SkPaint.h" |
| 13 #include "ui/base/hit_test.h" | 13 #include "ui/base/hit_test.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/canvas.h" | 16 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 18 #include "ui/gfx/path.h" | 18 #include "ui/gfx/path.h" |
| 19 #include "ui/views/controls/button/image_button.h" | 19 #include "ui/views/controls/button/image_button.h" |
| 20 #include "ui/views/layout/grid_layout.h" | 20 #include "ui/views/layout/grid_layout.h" |
| 21 #include "ui/views/views_delegate.h" | 21 #include "ui/views/views_delegate.h" |
| 22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 23 | 23 #include "ui/views/widget/widget_delegate.h" |
| 24 #if defined(OS_WIN) && !defined(USE_AURA) | |
| 25 #include "chrome/browser/shell_integration.h" | |
| 26 #include "chrome/browser/web_applications/web_app.h" | |
| 27 #include "ui/base/win/shell.h" | |
| 28 #endif | |
| 29 | |
| 30 #if defined(USE_ASH) | |
| 31 #include "ash/ash_constants.h" | |
| 32 #include "chrome/browser/ui/ash/ash_util.h" | |
| 33 #include "ui/aura/env.h" | |
| 34 #endif | |
| 35 | 24 |
| 36 #if defined(USE_AURA) | 25 #if defined(USE_AURA) |
| 26 #include "ui/aura/env.h" |
| 37 #include "ui/aura/window.h" | 27 #include "ui/aura/window.h" |
| 38 #endif | 28 #endif |
| 39 | 29 |
| 40 namespace { | 30 namespace { |
| 41 const int kResizeInsideBoundsSize = 5; | |
| 42 const int kResizeAreaCornerSize = 16; | |
| 43 | |
| 44 // Height of the chrome-style caption, in pixels. | 31 // Height of the chrome-style caption, in pixels. |
| 45 const int kCaptionHeight = 25; | 32 const int kCaptionHeight = 25; |
| 46 } // namespace | 33 } // namespace |
| 47 | 34 |
| 35 namespace apps { |
| 48 | 36 |
| 49 const char ShellWindowFrameView::kViewClassName[] = | 37 const char ShellWindowFrameView::kViewClassName[] = |
| 50 "browser/ui/views/extensions/ShellWindowFrameView"; | 38 "browser/ui/views/extensions/ShellWindowFrameView"; |
| 51 | 39 |
| 52 ShellWindowFrameView::ShellWindowFrameView(NativeAppWindowViews* window) | 40 ShellWindowFrameView::ShellWindowFrameView(NativeAppWindow* window) |
| 53 : window_(window), | 41 : window_(window), |
| 54 frame_(NULL), | 42 frame_(NULL), |
| 55 close_button_(NULL) { | 43 close_button_(NULL), |
| 44 maximize_button_(NULL), |
| 45 restore_button_(NULL), |
| 46 minimize_button_(NULL), |
| 47 resize_inside_bounds_size_(0), |
| 48 resize_area_corner_size_(0) { |
| 56 } | 49 } |
| 57 | 50 |
| 58 ShellWindowFrameView::~ShellWindowFrameView() { | 51 ShellWindowFrameView::~ShellWindowFrameView() { |
| 59 } | 52 } |
| 60 | 53 |
| 61 void ShellWindowFrameView::Init(views::Widget* frame) { | 54 void ShellWindowFrameView::Init(views::Widget* frame, |
| 55 int resize_inside_bounds_size, |
| 56 int resize_outside_bounds_size, |
| 57 int resize_outside_scale_for_touch, |
| 58 int resize_area_corner_size) { |
| 62 frame_ = frame; | 59 frame_ = frame; |
| 60 resize_inside_bounds_size_ = resize_inside_bounds_size; |
| 61 resize_area_corner_size_ = resize_area_corner_size; |
| 63 | 62 |
| 64 if (!window_->frameless()) { | 63 if (!window_->IsFrameless()) { |
| 65 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 64 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 66 close_button_ = new views::ImageButton(this); | 65 close_button_ = new views::ImageButton(this); |
| 67 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | 66 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
| 68 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia()); | 67 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia()); |
| 69 close_button_->SetImage(views::CustomButton::STATE_HOVERED, | 68 close_button_->SetImage(views::CustomButton::STATE_HOVERED, |
| 70 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_H).ToImageSkia()); | 69 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_H).ToImageSkia()); |
| 71 close_button_->SetImage(views::CustomButton::STATE_PRESSED, | 70 close_button_->SetImage(views::CustomButton::STATE_PRESSED, |
| 72 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_P).ToImageSkia()); | 71 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_P).ToImageSkia()); |
| 73 close_button_->SetAccessibleName( | 72 close_button_->SetAccessibleName( |
| 74 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); | 73 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 101 minimize_button_->SetImage(views::CustomButton::STATE_HOVERED, | 100 minimize_button_->SetImage(views::CustomButton::STATE_HOVERED, |
| 102 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_H).ToImageSkia()); | 101 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_H).ToImageSkia()); |
| 103 minimize_button_->SetImage(views::CustomButton::STATE_PRESSED, | 102 minimize_button_->SetImage(views::CustomButton::STATE_PRESSED, |
| 104 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_P).ToImageSkia()); | 103 rb.GetNativeImageNamed(IDR_APP_WINDOW_MINIMIZE_P).ToImageSkia()); |
| 105 minimize_button_->SetAccessibleName( | 104 minimize_button_->SetAccessibleName( |
| 106 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); | 105 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_MINIMIZE)); |
| 107 AddChildView(minimize_button_); | 106 AddChildView(minimize_button_); |
| 108 } | 107 } |
| 109 | 108 |
| 110 #if defined(USE_AURA) | 109 #if defined(USE_AURA) |
| 111 int resize_inside_bounds_size = kResizeInsideBoundsSize; | |
| 112 aura::Window* window = frame->GetNativeWindow(); | 110 aura::Window* window = frame->GetNativeWindow(); |
| 113 #if defined(USE_ASH) | 111 // Some Aura implementations (Ash) allow resize handles outside the window. |
| 114 if (chrome::IsNativeWindowInAsh(window)) { | 112 if (resize_outside_bounds_size > 0) { |
| 115 gfx::Insets mouse_insets = gfx::Insets(-ash::kResizeOutsideBoundsSize, | 113 gfx::Insets mouse_insets = gfx::Insets(-resize_outside_bounds_size, |
| 116 -ash::kResizeOutsideBoundsSize, | 114 -resize_outside_bounds_size, |
| 117 -ash::kResizeOutsideBoundsSize, | 115 -resize_outside_bounds_size, |
| 118 -ash::kResizeOutsideBoundsSize); | 116 -resize_outside_bounds_size); |
| 119 gfx::Insets touch_insets = mouse_insets.Scale( | 117 gfx::Insets touch_insets = |
| 120 ash::kResizeOutsideBoundsScaleForTouch); | 118 mouse_insets.Scale(resize_outside_scale_for_touch); |
| 121 // Ensure we get resize cursors for a few pixels outside our bounds. | 119 // Ensure we get resize cursors for a few pixels outside our bounds. |
| 122 window->SetHitTestBoundsOverrideOuter(mouse_insets, touch_insets); | 120 window->SetHitTestBoundsOverrideOuter(mouse_insets, touch_insets); |
| 123 | |
| 124 // If the window is in ash, the inside area used for resizing will be | |
| 125 // smaller due to the fact that outside area is also used for resizing. | |
| 126 resize_inside_bounds_size = ash::kResizeInsideBoundsSize; | |
| 127 } | 121 } |
| 128 #endif | |
| 129 // Ensure we get resize cursors just inside our bounds as well. | 122 // Ensure we get resize cursors just inside our bounds as well. |
| 130 // TODO(jeremya): do we need to update these when in fullscreen/maximized? | 123 // TODO(jeremya): do we need to update these when in fullscreen/maximized? |
| 131 window->set_hit_test_bounds_override_inner( | 124 window->set_hit_test_bounds_override_inner( |
| 132 gfx::Insets(resize_inside_bounds_size, resize_inside_bounds_size, | 125 gfx::Insets(resize_inside_bounds_size_, resize_inside_bounds_size_, |
| 133 resize_inside_bounds_size, resize_inside_bounds_size)); | 126 resize_inside_bounds_size_, resize_inside_bounds_size_)); |
| 134 #endif | 127 #endif |
| 135 } | 128 } |
| 136 | 129 |
| 137 // views::NonClientFrameView implementation. | 130 // views::NonClientFrameView implementation. |
| 138 | 131 |
| 139 gfx::Rect ShellWindowFrameView::GetBoundsForClientView() const { | 132 gfx::Rect ShellWindowFrameView::GetBoundsForClientView() const { |
| 140 if (window_->frameless() || frame_->IsFullscreen()) | 133 if (window_->IsFrameless() || frame_->IsFullscreen()) |
| 141 return bounds(); | 134 return bounds(); |
| 142 return gfx::Rect(0, kCaptionHeight, width(), | 135 return gfx::Rect(0, kCaptionHeight, width(), |
| 143 std::max(0, height() - kCaptionHeight)); | 136 std::max(0, height() - kCaptionHeight)); |
| 144 } | 137 } |
| 145 | 138 |
| 146 gfx::Rect ShellWindowFrameView::GetWindowBoundsForClientBounds( | 139 gfx::Rect ShellWindowFrameView::GetWindowBoundsForClientBounds( |
| 147 const gfx::Rect& client_bounds) const { | 140 const gfx::Rect& client_bounds) const { |
| 148 if (window_->frameless()) { | 141 if (window_->IsFrameless()) { |
| 149 gfx::Rect window_bounds = client_bounds; | 142 gfx::Rect window_bounds = client_bounds; |
| 150 // Enforce minimum size (1, 1) in case that client_bounds is passed with | 143 // Enforce minimum size (1, 1) in case that client_bounds is passed with |
| 151 // empty size. This could occur when the frameless window is being | 144 // empty size. This could occur when the frameless window is being |
| 152 // initialized. | 145 // initialized. |
| 153 if (window_bounds.IsEmpty()) { | 146 if (window_bounds.IsEmpty()) { |
| 154 window_bounds.set_width(1); | 147 window_bounds.set_width(1); |
| 155 window_bounds.set_height(1); | 148 window_bounds.set_height(1); |
| 156 } | 149 } |
| 157 return window_bounds; | 150 return window_bounds; |
| 158 } | 151 } |
| 159 | 152 |
| 160 int closeButtonOffsetX = | 153 int closeButtonOffsetX = |
| 161 (kCaptionHeight - close_button_->height()) / 2; | 154 (kCaptionHeight - close_button_->height()) / 2; |
| 162 int header_width = close_button_->width() + closeButtonOffsetX * 2; | 155 int header_width = close_button_->width() + closeButtonOffsetX * 2; |
| 163 return gfx::Rect(client_bounds.x(), | 156 return gfx::Rect(client_bounds.x(), |
| 164 std::max(0, client_bounds.y() - kCaptionHeight), | 157 std::max(0, client_bounds.y() - kCaptionHeight), |
| 165 std::max(header_width, client_bounds.width()), | 158 std::max(header_width, client_bounds.width()), |
| 166 client_bounds.height() + kCaptionHeight); | 159 client_bounds.height() + kCaptionHeight); |
| 167 } | 160 } |
| 168 | 161 |
| 169 int ShellWindowFrameView::NonClientHitTest(const gfx::Point& point) { | 162 int ShellWindowFrameView::NonClientHitTest(const gfx::Point& point) { |
| 170 if (frame_->IsFullscreen()) | 163 if (frame_->IsFullscreen()) |
| 171 return HTCLIENT; | 164 return HTCLIENT; |
| 172 | 165 |
| 173 int resize_inside_bounds_size = kResizeInsideBoundsSize; | 166 gfx::Rect expanded_bounds = bounds(); |
| 174 int resize_area_corner_size = kResizeAreaCornerSize; | 167 #if defined(USE_AURA) |
| 175 | 168 // Some Aura implementations (Ash) optionally allow resize handles just |
| 176 #if defined(USE_ASH) | 169 // outside the window bounds. |
| 177 aura::Window* window = frame_->GetNativeWindow(); | 170 aura::Window* window = frame_->GetNativeWindow(); |
| 178 if (chrome::IsNativeWindowInAsh(window)) { | 171 if (aura::Env::GetInstance()->is_touch_down()) |
| 179 gfx::Rect expanded_bounds = bounds(); | 172 expanded_bounds.Inset(window->hit_test_bounds_override_outer_touch()); |
| 180 int outside_bounds = ash::kResizeOutsideBoundsSize; | 173 else |
| 181 if (aura::Env::GetInstance()->is_touch_down()) | 174 expanded_bounds.Inset(window->hit_test_bounds_override_outer_mouse()); |
| 182 outside_bounds *= ash::kResizeOutsideBoundsScaleForTouch; | |
| 183 expanded_bounds.Inset(-outside_bounds, -outside_bounds); | |
| 184 if (!expanded_bounds.Contains(point)) | |
| 185 return HTNOWHERE; | |
| 186 | |
| 187 resize_inside_bounds_size = ash::kResizeInsideBoundsSize; | |
| 188 resize_area_corner_size = ash::kResizeAreaCornerSize; | |
| 189 } | |
| 190 #endif | 175 #endif |
| 176 // Points outside the (possibly expanded) bounds can be discarded. |
| 177 if (!expanded_bounds.Contains(point)) |
| 178 return HTNOWHERE; |
| 191 | 179 |
| 192 // Check the frame first, as we allow a small area overlapping the contents | 180 // Check the frame first, as we allow a small area overlapping the contents |
| 193 // to be used for resize handles. | 181 // to be used for resize handles. |
| 194 bool can_ever_resize = frame_->widget_delegate() ? | 182 bool can_ever_resize = frame_->widget_delegate() ? |
| 195 frame_->widget_delegate()->CanResize() : | 183 frame_->widget_delegate()->CanResize() : |
| 196 false; | 184 false; |
| 197 // Don't allow overlapping resize handles when the window is maximized or | 185 // Don't allow overlapping resize handles when the window is maximized or |
| 198 // fullscreen, as it can't be resized in those states. | 186 // fullscreen, as it can't be resized in those states. |
| 199 int resize_border = | 187 int resize_border = |
| 200 (frame_->IsMaximized() || frame_->IsFullscreen()) ? 0 : | 188 (frame_->IsMaximized() || frame_->IsFullscreen()) ? 0 : |
| 201 resize_inside_bounds_size; | 189 resize_inside_bounds_size_; |
| 202 int frame_component = GetHTComponentForFrame(point, | 190 int frame_component = GetHTComponentForFrame(point, |
| 203 resize_border, | 191 resize_border, |
| 204 resize_border, | 192 resize_border, |
| 205 resize_area_corner_size, | 193 resize_area_corner_size_, |
| 206 resize_area_corner_size, | 194 resize_area_corner_size_, |
| 207 can_ever_resize); | 195 can_ever_resize); |
| 208 if (frame_component != HTNOWHERE) | 196 if (frame_component != HTNOWHERE) |
| 209 return frame_component; | 197 return frame_component; |
| 210 | 198 |
| 211 // Check for possible draggable region in the client area for the frameless | 199 // Check for possible draggable region in the client area for the frameless |
| 212 // window. | 200 // window. |
| 213 if (window_->frameless() && | 201 if (window_->IsFrameless()) { |
| 214 window_->draggable_region() && | 202 SkRegion* draggable_region = window_->GetDraggableRegion(); |
| 215 window_->draggable_region()->contains(point.x(), point.y())) | 203 if (draggable_region && draggable_region->contains(point.x(), point.y())) |
| 216 return HTCAPTION; | 204 return HTCAPTION; |
| 205 } |
| 217 | 206 |
| 218 int client_component = frame_->client_view()->NonClientHitTest(point); | 207 int client_component = frame_->client_view()->NonClientHitTest(point); |
| 219 if (client_component != HTNOWHERE) | 208 if (client_component != HTNOWHERE) |
| 220 return client_component; | 209 return client_component; |
| 221 | 210 |
| 222 // Then see if the point is within any of the window controls. | 211 // Then see if the point is within any of the window controls. |
| 223 if (close_button_ && close_button_->visible() && | 212 if (close_button_ && close_button_->visible() && |
| 224 close_button_->GetMirroredBounds().Contains(point)) | 213 close_button_->GetMirroredBounds().Contains(point)) |
| 225 return HTCLOSE; | 214 return HTCLOSE; |
| 226 | 215 |
| 227 // Caption is a safe default. | 216 // Caption is a safe default. |
| 228 return HTCAPTION; | 217 return HTCAPTION; |
| 229 } | 218 } |
| 230 | 219 |
| 231 void ShellWindowFrameView::GetWindowMask(const gfx::Size& size, | 220 void ShellWindowFrameView::GetWindowMask(const gfx::Size& size, |
| 232 gfx::Path* window_mask) { | 221 gfx::Path* window_mask) { |
| 233 // We got nothing to say about no window mask. | 222 // We got nothing to say about no window mask. |
| 234 } | 223 } |
| 235 | 224 |
| 236 // views::View implementation. | 225 // views::View implementation. |
| 237 | 226 |
| 238 gfx::Size ShellWindowFrameView::GetPreferredSize() { | 227 gfx::Size ShellWindowFrameView::GetPreferredSize() { |
| 239 gfx::Size pref = frame_->client_view()->GetPreferredSize(); | 228 gfx::Size pref = frame_->client_view()->GetPreferredSize(); |
| 240 gfx::Rect bounds(0, 0, pref.width(), pref.height()); | 229 gfx::Rect bounds(0, 0, pref.width(), pref.height()); |
| 241 return frame_->non_client_view()->GetWindowBoundsForClientBounds( | 230 return frame_->non_client_view()->GetWindowBoundsForClientBounds( |
| 242 bounds).size(); | 231 bounds).size(); |
| 243 } | 232 } |
| 244 | 233 |
| 245 void ShellWindowFrameView::Layout() { | 234 void ShellWindowFrameView::Layout() { |
| 246 if (window_->frameless()) | 235 if (window_->IsFrameless()) |
| 247 return; | 236 return; |
| 248 gfx::Size close_size = close_button_->GetPreferredSize(); | 237 gfx::Size close_size = close_button_->GetPreferredSize(); |
| 249 const int kButtonOffsetY = 0; | 238 const int kButtonOffsetY = 0; |
| 250 const int kButtonSpacing = 1; | 239 const int kButtonSpacing = 1; |
| 251 const int kRightMargin = 3; | 240 const int kRightMargin = 3; |
| 252 | 241 |
| 253 close_button_->SetBounds( | 242 close_button_->SetBounds( |
| 254 width() - kRightMargin - close_size.width(), | 243 width() - kRightMargin - close_size.width(), |
| 255 kButtonOffsetY, | 244 kButtonOffsetY, |
| 256 close_size.width(), | 245 close_size.width(), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 283 | 272 |
| 284 gfx::Size minimize_size = minimize_button_->GetPreferredSize(); | 273 gfx::Size minimize_size = minimize_button_->GetPreferredSize(); |
| 285 minimize_button_->SetBounds( | 274 minimize_button_->SetBounds( |
| 286 maximize_button_->x() - kButtonSpacing - minimize_size.width(), | 275 maximize_button_->x() - kButtonSpacing - minimize_size.width(), |
| 287 kButtonOffsetY, | 276 kButtonOffsetY, |
| 288 minimize_size.width(), | 277 minimize_size.width(), |
| 289 minimize_size.height()); | 278 minimize_size.height()); |
| 290 } | 279 } |
| 291 | 280 |
| 292 void ShellWindowFrameView::OnPaint(gfx::Canvas* canvas) { | 281 void ShellWindowFrameView::OnPaint(gfx::Canvas* canvas) { |
| 293 if (window_->frameless()) | 282 if (window_->IsFrameless()) |
| 294 return; | 283 return; |
| 295 | 284 |
| 296 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 285 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 297 if (ShouldPaintAsActive()) { | 286 if (ShouldPaintAsActive()) { |
| 298 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | 287 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
| 299 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia()); | 288 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE).ToImageSkia()); |
| 300 } else { | 289 } else { |
| 301 close_button_->SetImage(views::CustomButton::STATE_NORMAL, | 290 close_button_->SetImage(views::CustomButton::STATE_NORMAL, |
| 302 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_U).ToImageSkia()); | 291 rb.GetNativeImageNamed(IDR_APP_WINDOW_CLOSE_U).ToImageSkia()); |
| 303 } | 292 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 318 path.close(); | 307 path.close(); |
| 319 canvas->DrawPath(path, paint); | 308 canvas->DrawPath(path, paint); |
| 320 } | 309 } |
| 321 | 310 |
| 322 const char* ShellWindowFrameView::GetClassName() const { | 311 const char* ShellWindowFrameView::GetClassName() const { |
| 323 return kViewClassName; | 312 return kViewClassName; |
| 324 } | 313 } |
| 325 | 314 |
| 326 gfx::Size ShellWindowFrameView::GetMinimumSize() { | 315 gfx::Size ShellWindowFrameView::GetMinimumSize() { |
| 327 gfx::Size min_size = frame_->client_view()->GetMinimumSize(); | 316 gfx::Size min_size = frame_->client_view()->GetMinimumSize(); |
| 328 if (window_->frameless()) | 317 if (window_->IsFrameless()) |
| 329 return min_size; | 318 return min_size; |
| 330 | 319 |
| 331 // Ensure we can display the top of the caption area. | 320 // Ensure we can display the top of the caption area. |
| 332 gfx::Rect client_bounds = GetBoundsForClientView(); | 321 gfx::Rect client_bounds = GetBoundsForClientView(); |
| 333 min_size.Enlarge(0, client_bounds.y()); | 322 min_size.Enlarge(0, client_bounds.y()); |
| 334 // Ensure we have enough space for the window icon and buttons. We allow | 323 // Ensure we have enough space for the window icon and buttons. We allow |
| 335 // the title string to collapse to zero width. | 324 // the title string to collapse to zero width. |
| 336 int closeButtonOffsetX = | 325 int closeButtonOffsetX = |
| 337 (kCaptionHeight - close_button_->height()) / 2; | 326 (kCaptionHeight - close_button_->height()) / 2; |
| 338 int header_width = close_button_->width() + closeButtonOffsetX * 2; | 327 int header_width = close_button_->width() + closeButtonOffsetX * 2; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 351 if (max_size.height()) | 340 if (max_size.height()) |
| 352 max_size.Enlarge(0, height() - client_size.height()); | 341 max_size.Enlarge(0, height() - client_size.height()); |
| 353 | 342 |
| 354 return max_size; | 343 return max_size; |
| 355 } | 344 } |
| 356 | 345 |
| 357 // views::ButtonListener implementation. | 346 // views::ButtonListener implementation. |
| 358 | 347 |
| 359 void ShellWindowFrameView::ButtonPressed(views::Button* sender, | 348 void ShellWindowFrameView::ButtonPressed(views::Button* sender, |
| 360 const ui::Event& event) { | 349 const ui::Event& event) { |
| 361 DCHECK(!window_->frameless()); | 350 DCHECK(!window_->IsFrameless()); |
| 362 if (sender == close_button_) | 351 if (sender == close_button_) |
| 363 frame_->Close(); | 352 frame_->Close(); |
| 364 else if (sender == maximize_button_) | 353 else if (sender == maximize_button_) |
| 365 frame_->Maximize(); | 354 frame_->Maximize(); |
| 366 else if (sender == restore_button_) | 355 else if (sender == restore_button_) |
| 367 frame_->Restore(); | 356 frame_->Restore(); |
| 368 else if (sender == minimize_button_) | 357 else if (sender == minimize_button_) |
| 369 frame_->Minimize(); | 358 frame_->Minimize(); |
| 370 } | 359 } |
| 360 |
| 361 } // namespace apps |
| OLD | NEW |