| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/views/constrained_window_impl.h" | 5 #include "chrome/browser/views/constrained_window_impl.h" |
| 6 | 6 |
| 7 #include "base/gfx/rect.h" | 7 #include "base/gfx/rect.h" |
| 8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
| 9 #include "chrome/app/theme/theme_resources.h" | 9 #include "chrome/app/theme/theme_resources.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/profile.h" | 11 #include "chrome/browser/profile.h" |
| 12 #include "chrome/browser/tab_contents/tab_contents.h" | 12 #include "chrome/browser/tab_contents/tab_contents.h" |
| 13 #include "chrome/browser/tab_contents/web_contents.h" | 13 #include "chrome/browser/tab_contents/web_contents.h" |
| 14 #include "chrome/browser/tab_contents/web_contents_view.h" | 14 #include "chrome/browser/tab_contents/web_contents_view.h" |
| 15 #include "chrome/browser/toolbar_model.h" | 15 #include "chrome/browser/toolbar_model.h" |
| 16 #include "chrome/browser/views/frame/browser_view.h" |
| 16 #include "chrome/browser/web_app.h" | 17 #include "chrome/browser/web_app.h" |
| 17 #include "chrome/browser/window_sizer.h" | 18 #include "chrome/browser/window_sizer.h" |
| 18 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
| 19 #include "chrome/common/gfx/chrome_canvas.h" | 20 #include "chrome/common/gfx/chrome_canvas.h" |
| 20 #include "chrome/common/gfx/chrome_font.h" | 21 #include "chrome/common/gfx/chrome_font.h" |
| 21 #include "chrome/common/gfx/path.h" | 22 #include "chrome/common/gfx/path.h" |
| 22 #include "chrome/common/gfx/text_elider.h" | 23 #include "chrome/common/gfx/text_elider.h" |
| 23 #include "chrome/common/l10n_util.h" | 24 #include "chrome/common/l10n_util.h" |
| 24 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 25 #include "chrome/common/pref_service.h" | 26 #include "chrome/common/pref_service.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // Overridden from views::View: | 210 // Overridden from views::View: |
| 210 virtual void Paint(ChromeCanvas* canvas); | 211 virtual void Paint(ChromeCanvas* canvas); |
| 211 virtual void Layout(); | 212 virtual void Layout(); |
| 212 virtual gfx::Size GetPreferredSize(); | 213 virtual gfx::Size GetPreferredSize(); |
| 213 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); | 214 virtual void ViewHierarchyChanged(bool is_add, View *parent, View *child); |
| 214 | 215 |
| 215 // Overridden from views::BaseButton::ButtonListener: | 216 // Overridden from views::BaseButton::ButtonListener: |
| 216 virtual void ButtonPressed(views::BaseButton* sender); | 217 virtual void ButtonPressed(views::BaseButton* sender); |
| 217 | 218 |
| 218 private: | 219 private: |
| 220 // Returns the thickness of the border that makes up the window frame edges. |
| 221 // This does not include any client edge. |
| 222 int FrameBorderThickness() const; |
| 223 |
| 224 // Returns the thickness of the entire nonclient left, right, and bottom |
| 225 // borders, including both the window frame and any client edge. |
| 226 int NonClientBorderThickness() const; |
| 227 |
| 219 // Returns the height of the entire nonclient top border, including the window | 228 // Returns the height of the entire nonclient top border, including the window |
| 220 // frame, any title area, and any connected client edge. | 229 // frame, any title area, and any connected client edge. |
| 221 int NonClientTopBorderHeight() const; | 230 int NonClientTopBorderHeight() const; |
| 222 | 231 |
| 232 // Calculates multiple values related to title layout. Returns the height of |
| 233 // the entire titlebar including any connected client edge. |
| 234 int TitleCoordinates(int* title_top_spacing, |
| 235 int* title_thickness) const; |
| 236 |
| 223 // Paints different parts of the window to the incoming canvas. | 237 // Paints different parts of the window to the incoming canvas. |
| 224 void PaintFrameBorder(ChromeCanvas* canvas); | 238 void PaintFrameBorder(ChromeCanvas* canvas); |
| 225 void PaintTitleBar(ChromeCanvas* canvas); | 239 void PaintTitleBar(ChromeCanvas* canvas); |
| 226 void PaintClientEdge(ChromeCanvas* canvas); | 240 void PaintClientEdge(ChromeCanvas* canvas); |
| 227 | 241 |
| 228 // Layout various sub-components of this view. | 242 // Layout various sub-components of this view. |
| 229 void LayoutWindowControls(); | 243 void LayoutWindowControls(); |
| 230 void LayoutTitleBar(); | 244 void LayoutTitleBar(); |
| 231 void LayoutClientView(); | 245 void LayoutClientView(); |
| 232 | 246 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 245 | 259 |
| 246 static void InitClass(); | 260 static void InitClass(); |
| 247 | 261 |
| 248 // The font to be used to render the titlebar text. | 262 // The font to be used to render the titlebar text. |
| 249 static ChromeFont title_font_; | 263 static ChromeFont title_font_; |
| 250 | 264 |
| 251 DISALLOW_EVIL_CONSTRUCTORS(ConstrainedWindowNonClientView); | 265 DISALLOW_EVIL_CONSTRUCTORS(ConstrainedWindowNonClientView); |
| 252 }; | 266 }; |
| 253 | 267 |
| 254 ChromeFont ConstrainedWindowNonClientView::title_font_; | 268 ChromeFont ConstrainedWindowNonClientView::title_font_; |
| 255 static const int kWindowLeftSpacing = 5; | |
| 256 static const int kWindowControlsTopOffset = 1; | |
| 257 static const int kWindowControlsRightOffset = 4; | |
| 258 static const int kTitleTopOffset = 6; | |
| 259 static const int kTitleBottomSpacing = 5; | |
| 260 static const int kNoTitleTopSpacing = 8; | |
| 261 static const int kResizeAreaSize = 5; | |
| 262 static const int kResizeAreaNorthSize = 3; | |
| 263 static const int kResizeAreaCornerSize = 16; | |
| 264 static const int kWindowHorizontalBorderSize = 5; | |
| 265 static const int kWindowVerticalBorderSize = 5; | |
| 266 static const int kWindowIconSize = 16; | |
| 267 | 269 |
| 268 namespace { | 270 namespace { |
| 271 // The frame border is only visible in restored mode and is hardcoded to 4 px on |
| 272 // each side regardless of the system window border size. |
| 273 const int kFrameBorderThickness = 4; |
| 274 // Various edges of the frame border have a 1 px shadow along their edges; in a |
| 275 // few cases we shift elements based on this amount for visual appeal. |
| 276 const int kFrameShadowThickness = 1; |
| 277 // In the window corners, the resize areas don't actually expand bigger, but the |
| 278 // 16 px at the end of each edge triggers diagonal resizing. |
| 279 const int kResizeAreaCornerSize = 16; |
| 280 // The titlebar never shrinks to less than 20 px tall, including the height of |
| 281 // the frame border and client edge. |
| 282 const int kTitlebarMinimumHeight = 20; |
| 283 // The icon is inset 2 px from the left frame border. |
| 284 const int kIconLeftSpacing = 2; |
| 285 // The title text starts 2 px below the bottom of the top frame border. |
| 286 const int kTitleTopSpacing = 2; |
| 287 // There is a 5 px gap between the title text and the caption buttons. |
| 288 const int kTitleCaptionSpacing = 5; |
| 289 // The caption buttons are always drawn 1 px down from the visible top of the |
| 290 // window (the true top in restored mode, or the top of the screen in maximized |
| 291 // mode). |
| 292 const int kCaptionTopSpacing = 1; |
| 293 |
| 269 const SkColor kContentsBorderShadow = SkColorSetARGB(51, 0, 0, 0); | 294 const SkColor kContentsBorderShadow = SkColorSetARGB(51, 0, 0, 0); |
| 270 const SkColor kContentsBorderColor = SkColorSetRGB(219, 235, 255); | 295 const SkColor kContentsBorderColor = SkColorSetRGB(219, 235, 255); |
| 271 } | 296 } |
| 272 | 297 |
| 273 //////////////////////////////////////////////////////////////////////////////// | 298 //////////////////////////////////////////////////////////////////////////////// |
| 274 // ConstrainedWindowNonClientView, public: | 299 // ConstrainedWindowNonClientView, public: |
| 275 | 300 |
| 276 ConstrainedWindowNonClientView::ConstrainedWindowNonClientView( | 301 ConstrainedWindowNonClientView::ConstrainedWindowNonClientView( |
| 277 ConstrainedWindowImpl* container, TabContents* owner) | 302 ConstrainedWindowImpl* container, TabContents* owner) |
| 278 : NonClientView(), | 303 : NonClientView(), |
| (...skipping 29 matching lines...) Expand all Loading... |
| 308 SchedulePaint(title_bounds_, false); | 333 SchedulePaint(title_bounds_, false); |
| 309 } | 334 } |
| 310 | 335 |
| 311 //////////////////////////////////////////////////////////////////////////////// | 336 //////////////////////////////////////////////////////////////////////////////// |
| 312 // ConstrainedWindowNonClientView, views::NonClientView implementation: | 337 // ConstrainedWindowNonClientView, views::NonClientView implementation: |
| 313 | 338 |
| 314 gfx::Rect ConstrainedWindowNonClientView::CalculateClientAreaBounds( | 339 gfx::Rect ConstrainedWindowNonClientView::CalculateClientAreaBounds( |
| 315 int width, | 340 int width, |
| 316 int height) const { | 341 int height) const { |
| 317 int top_height = NonClientTopBorderHeight(); | 342 int top_height = NonClientTopBorderHeight(); |
| 318 return gfx::Rect(kWindowHorizontalBorderSize, top_height, | 343 int border_thickness = NonClientBorderThickness(); |
| 319 std::max(0, width - (2 * kWindowHorizontalBorderSize)), | 344 return gfx::Rect(border_thickness, top_height, |
| 320 std::max(0, height - top_height - kWindowVerticalBorderSize)); | 345 std::max(0, width - (2 * border_thickness)), |
| 346 std::max(0, height - top_height - border_thickness)); |
| 321 } | 347 } |
| 322 | 348 |
| 323 gfx::Size ConstrainedWindowNonClientView::CalculateWindowSizeForClientSize( | 349 gfx::Size ConstrainedWindowNonClientView::CalculateWindowSizeForClientSize( |
| 324 int width, | 350 int width, |
| 325 int height) const { | 351 int height) const { |
| 326 return gfx::Size(width + (2 * kWindowHorizontalBorderSize), | 352 int border_thickness = NonClientBorderThickness(); |
| 327 height + NonClientTopBorderHeight() + kWindowVerticalBorderSize); | 353 return gfx::Size(width + (2 * border_thickness), |
| 354 height + NonClientTopBorderHeight() + border_thickness); |
| 328 } | 355 } |
| 329 | 356 |
| 330 CPoint ConstrainedWindowNonClientView::GetSystemMenuPoint() const { | 357 CPoint ConstrainedWindowNonClientView::GetSystemMenuPoint() const { |
| 331 // Doesn't matter what we return, since this is only used when the user clicks | 358 // Doesn't matter what we return, since this is only used when the user clicks |
| 332 // a window icon, and we never have an icon. | 359 // a window icon, and we never have an icon. |
| 333 return CPoint(); | 360 return CPoint(); |
| 334 } | 361 } |
| 335 | 362 |
| 336 int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) { | 363 int ConstrainedWindowNonClientView::NonClientHitTest(const gfx::Point& point) { |
| 337 // First see if it's within the grow box area, since that overlaps the client | 364 // First see if it's within the grow box area, since that overlaps the client |
| 338 // bounds. | 365 // bounds. |
| 339 int frame_component = container_->client_view()->NonClientHitTest(point); | 366 int frame_component = container_->client_view()->NonClientHitTest(point); |
| 340 if (frame_component != HTNOWHERE) | 367 if (frame_component != HTNOWHERE) |
| 341 return frame_component; | 368 return frame_component; |
| 342 | 369 |
| 343 // Then see if the point is within any of the window controls. | 370 // Then see if the point is within any of the window controls. |
| 344 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) | 371 if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) |
| 345 return HTCLOSE; | 372 return HTCLOSE; |
| 346 | 373 |
| 347 int window_component = GetHTComponentForFrame(point, kResizeAreaNorthSize, | 374 int window_component = GetHTComponentForFrame(point, FrameBorderThickness(), |
| 348 kResizeAreaSize, kResizeAreaCornerSize, | 375 NonClientBorderThickness(), kResizeAreaCornerSize, |
| 349 container_->window_delegate()->CanResize()); | 376 container_->window_delegate()->CanResize()); |
| 350 // Fall back to the caption if no other component matches. | 377 // Fall back to the caption if no other component matches. |
| 351 return ((window_component == HTNOWHERE) && bounds().Contains(point)) ? | 378 return ((window_component == HTNOWHERE) && bounds().Contains(point)) ? |
| 352 HTCAPTION : window_component; | 379 HTCAPTION : window_component; |
| 353 } | 380 } |
| 354 | 381 |
| 355 void ConstrainedWindowNonClientView::GetWindowMask(const gfx::Size& size, | 382 void ConstrainedWindowNonClientView::GetWindowMask(const gfx::Size& size, |
| 356 gfx::Path* window_mask) { | 383 gfx::Path* window_mask) { |
| 357 DCHECK(window_mask); | 384 DCHECK(window_mask); |
| 358 | 385 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 389 } | 416 } |
| 390 | 417 |
| 391 void ConstrainedWindowNonClientView::Layout() { | 418 void ConstrainedWindowNonClientView::Layout() { |
| 392 LayoutWindowControls(); | 419 LayoutWindowControls(); |
| 393 LayoutTitleBar(); | 420 LayoutTitleBar(); |
| 394 LayoutClientView(); | 421 LayoutClientView(); |
| 395 } | 422 } |
| 396 | 423 |
| 397 gfx::Size ConstrainedWindowNonClientView::GetPreferredSize() { | 424 gfx::Size ConstrainedWindowNonClientView::GetPreferredSize() { |
| 398 gfx::Size prefsize(container_->client_view()->GetPreferredSize()); | 425 gfx::Size prefsize(container_->client_view()->GetPreferredSize()); |
| 399 prefsize.Enlarge(2 * kWindowHorizontalBorderSize, | 426 int border_thickness = NonClientBorderThickness(); |
| 400 NonClientTopBorderHeight() + kWindowVerticalBorderSize); | 427 prefsize.Enlarge(2 * border_thickness, |
| 428 NonClientTopBorderHeight() + border_thickness); |
| 401 return prefsize; | 429 return prefsize; |
| 402 } | 430 } |
| 403 | 431 |
| 404 void ConstrainedWindowNonClientView::ViewHierarchyChanged(bool is_add, | 432 void ConstrainedWindowNonClientView::ViewHierarchyChanged(bool is_add, |
| 405 View *parent, | 433 View *parent, |
| 406 View *child) { | 434 View *child) { |
| 407 // Add our Client View as we are added to the Container so that if we are | 435 // Add our Client View as we are added to the Container so that if we are |
| 408 // subsequently resized all the parent-child relationships are established. | 436 // subsequently resized all the parent-child relationships are established. |
| 409 if (is_add && GetWidget() && child == this) | 437 if (is_add && GetWidget() && child == this) |
| 410 AddChildView(container_->client_view()); | 438 AddChildView(container_->client_view()); |
| 411 } | 439 } |
| 412 | 440 |
| 413 //////////////////////////////////////////////////////////////////////////////// | 441 //////////////////////////////////////////////////////////////////////////////// |
| 414 // ConstrainedWindowNonClientView, views::BaseButton::Button | 442 // ConstrainedWindowNonClientView, views::BaseButton::Button |
| 415 // implementation: | 443 // implementation: |
| 416 | 444 |
| 417 void ConstrainedWindowNonClientView::ButtonPressed(views::BaseButton* sender) { | 445 void ConstrainedWindowNonClientView::ButtonPressed(views::BaseButton* sender) { |
| 418 if (sender == close_button_) | 446 if (sender == close_button_) |
| 419 container_->ExecuteSystemMenuCommand(SC_CLOSE); | 447 container_->ExecuteSystemMenuCommand(SC_CLOSE); |
| 420 } | 448 } |
| 421 | 449 |
| 422 //////////////////////////////////////////////////////////////////////////////// | 450 //////////////////////////////////////////////////////////////////////////////// |
| 423 // ConstrainedWindowNonClientView, private: | 451 // ConstrainedWindowNonClientView, private: |
| 424 | 452 |
| 453 int ConstrainedWindowNonClientView::FrameBorderThickness() const { |
| 454 return kFrameBorderThickness; |
| 455 } |
| 456 |
| 457 int ConstrainedWindowNonClientView::NonClientBorderThickness() const { |
| 458 return FrameBorderThickness() + kClientEdgeThickness; |
| 459 } |
| 460 |
| 425 int ConstrainedWindowNonClientView::NonClientTopBorderHeight() const { | 461 int ConstrainedWindowNonClientView::NonClientTopBorderHeight() const { |
| 426 return kTitleTopOffset + title_font_.height() + kTitleBottomSpacing; | 462 int title_top_spacing, title_thickness; |
| 463 return TitleCoordinates(&title_top_spacing, &title_thickness); |
| 464 } |
| 465 |
| 466 int ConstrainedWindowNonClientView::TitleCoordinates( |
| 467 int* title_top_spacing, |
| 468 int* title_thickness) const { |
| 469 int frame_thickness = FrameBorderThickness(); |
| 470 int min_titlebar_height = kTitlebarMinimumHeight + frame_thickness; |
| 471 *title_top_spacing = frame_thickness + kTitleTopSpacing; |
| 472 // The bottom spacing should be the same apparent height as the top spacing, |
| 473 // plus have the client edge tacked on. |
| 474 int title_bottom_spacing = *title_top_spacing + kClientEdgeThickness; |
| 475 *title_thickness = std::max(title_font_.height(), |
| 476 min_titlebar_height - *title_top_spacing - title_bottom_spacing); |
| 477 return *title_top_spacing + *title_thickness + title_bottom_spacing; |
| 427 } | 478 } |
| 428 | 479 |
| 429 void ConstrainedWindowNonClientView::PaintFrameBorder(ChromeCanvas* canvas) { | 480 void ConstrainedWindowNonClientView::PaintFrameBorder(ChromeCanvas* canvas) { |
| 430 SkBitmap* top_left_corner = resources_->GetPartBitmap(FRAME_TOP_LEFT_CORNER); | 481 SkBitmap* top_left_corner = resources_->GetPartBitmap(FRAME_TOP_LEFT_CORNER); |
| 431 SkBitmap* top_right_corner = | 482 SkBitmap* top_right_corner = |
| 432 resources_->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); | 483 resources_->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); |
| 433 SkBitmap* top_edge = resources_->GetPartBitmap(FRAME_TOP_EDGE); | 484 SkBitmap* top_edge = resources_->GetPartBitmap(FRAME_TOP_EDGE); |
| 434 SkBitmap* right_edge = resources_->GetPartBitmap(FRAME_RIGHT_EDGE); | 485 SkBitmap* right_edge = resources_->GetPartBitmap(FRAME_RIGHT_EDGE); |
| 435 SkBitmap* left_edge = resources_->GetPartBitmap(FRAME_LEFT_EDGE); | 486 SkBitmap* left_edge = resources_->GetPartBitmap(FRAME_LEFT_EDGE); |
| 436 SkBitmap* bottom_left_corner = | 487 SkBitmap* bottom_left_corner = |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 void ConstrainedWindowNonClientView::PaintTitleBar(ChromeCanvas* canvas) { | 524 void ConstrainedWindowNonClientView::PaintTitleBar(ChromeCanvas* canvas) { |
| 474 canvas->DrawStringInt(container_->GetWindowTitle(), title_font_, | 525 canvas->DrawStringInt(container_->GetWindowTitle(), title_font_, |
| 475 GetTitleColor(), MirroredLeftPointForRect(title_bounds_), | 526 GetTitleColor(), MirroredLeftPointForRect(title_bounds_), |
| 476 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); | 527 title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); |
| 477 } | 528 } |
| 478 | 529 |
| 479 void ConstrainedWindowNonClientView::PaintClientEdge(ChromeCanvas* canvas) { | 530 void ConstrainedWindowNonClientView::PaintClientEdge(ChromeCanvas* canvas) { |
| 480 gfx::Rect client_edge_bounds(CalculateClientAreaBounds(width(), height())); | 531 gfx::Rect client_edge_bounds(CalculateClientAreaBounds(width(), height())); |
| 481 client_edge_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness); | 532 client_edge_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness); |
| 482 gfx::Rect frame_shadow_bounds(client_edge_bounds); | 533 gfx::Rect frame_shadow_bounds(client_edge_bounds); |
| 483 frame_shadow_bounds.Inset(-1, -1); | 534 frame_shadow_bounds.Inset(-kFrameShadowThickness, -kFrameShadowThickness); |
| 484 | 535 |
| 485 canvas->FillRectInt(kContentsBorderShadow, frame_shadow_bounds.x(), | 536 canvas->FillRectInt(kContentsBorderShadow, frame_shadow_bounds.x(), |
| 486 frame_shadow_bounds.y(), frame_shadow_bounds.width(), | 537 frame_shadow_bounds.y(), frame_shadow_bounds.width(), |
| 487 frame_shadow_bounds.height()); | 538 frame_shadow_bounds.height()); |
| 488 | 539 |
| 489 canvas->FillRectInt(kContentsBorderColor, client_edge_bounds.x(), | 540 canvas->FillRectInt(kContentsBorderColor, client_edge_bounds.x(), |
| 490 client_edge_bounds.y(), client_edge_bounds.width(), | 541 client_edge_bounds.y(), client_edge_bounds.width(), |
| 491 client_edge_bounds.height()); | 542 client_edge_bounds.height()); |
| 492 } | 543 } |
| 493 | 544 |
| 494 void ConstrainedWindowNonClientView::LayoutWindowControls() { | 545 void ConstrainedWindowNonClientView::LayoutWindowControls() { |
| 495 gfx::Size close_button_size = close_button_->GetPreferredSize(); | 546 gfx::Size close_button_size = close_button_->GetPreferredSize(); |
| 496 close_button_->SetBounds( | 547 close_button_->SetBounds( |
| 497 width() - close_button_size.width() - kWindowControlsRightOffset, | 548 width() - close_button_size.width() - FrameBorderThickness(), |
| 498 kWindowControlsTopOffset, close_button_size.width(), | 549 kCaptionTopSpacing, close_button_size.width(), |
| 499 close_button_size.height()); | 550 close_button_size.height()); |
| 500 } | 551 } |
| 501 | 552 |
| 502 void ConstrainedWindowNonClientView::LayoutTitleBar() { | 553 void ConstrainedWindowNonClientView::LayoutTitleBar() { |
| 503 // Size the title. | 554 // Size the title. |
| 504 int title_x = kWindowLeftSpacing; | 555 int title_x = FrameBorderThickness() + kIconLeftSpacing; |
| 505 int title_top_spacing = NonClientTopBorderHeight(); | 556 int title_top_spacing, title_thickness; |
| 506 title_bounds_.SetRect(title_x, kTitleTopOffset, | 557 TitleCoordinates(&title_top_spacing, &title_thickness); |
| 507 close_button_->x() - kWindowLeftSpacing - title_x, | 558 title_bounds_.SetRect(title_x, |
| 508 title_font_.height()); | 559 title_top_spacing + ((title_thickness - title_font_.height()) / 2), |
| 560 std::max(0, close_button_->x() - kTitleCaptionSpacing - title_x), |
| 561 title_font_.height()); |
| 509 } | 562 } |
| 510 | 563 |
| 511 void ConstrainedWindowNonClientView::LayoutClientView() { | 564 void ConstrainedWindowNonClientView::LayoutClientView() { |
| 512 container_->client_view()->SetBounds(CalculateClientAreaBounds(width(), | 565 container_->client_view()->SetBounds(CalculateClientAreaBounds(width(), |
| 513 height())); | 566 height())); |
| 514 } | 567 } |
| 515 | 568 |
| 516 // static | 569 // static |
| 517 void ConstrainedWindowNonClientView::InitClass() { | 570 void ConstrainedWindowNonClientView::InitClass() { |
| 518 static bool initialized = false; | 571 static bool initialized = false; |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( | 746 ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( |
| 694 TabContents* parent, | 747 TabContents* parent, |
| 695 const gfx::Rect& initial_bounds, | 748 const gfx::Rect& initial_bounds, |
| 696 views::View* contents_view, | 749 views::View* contents_view, |
| 697 views::WindowDelegate* window_delegate) { | 750 views::WindowDelegate* window_delegate) { |
| 698 ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent, | 751 ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent, |
| 699 window_delegate); | 752 window_delegate); |
| 700 window->InitAsDialog(initial_bounds); | 753 window->InitAsDialog(initial_bounds); |
| 701 return window; | 754 return window; |
| 702 } | 755 } |
| OLD | NEW |