Chromium Code Reviews| 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 "ui/views/window/custom_frame_view.h" | 5 #include "ui/views/window/custom_frame_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
| 11 #include "grit/ui_strings.h" | 11 #include "grit/ui_strings.h" |
| 12 #include "ui/base/hit_test.h" | 12 #include "ui/base/hit_test.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 16 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.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/color_constants.h" | 19 #include "ui/views/color_constants.h" |
| 20 #include "ui/views/controls/button/image_button.h" | 20 #include "ui/views/controls/button/image_button.h" |
| 21 | |
| 22 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 23 #include "ui/views/linux_ui/linux_ui.h" | |
| 24 #endif | |
| 25 | |
| 21 #include "ui/views/views_delegate.h" | 26 #include "ui/views/views_delegate.h" |
| 22 #include "ui/views/widget/native_widget_aura.h" | 27 #include "ui/views/widget/native_widget_aura.h" |
| 23 #include "ui/views/widget/widget.h" | 28 #include "ui/views/widget/widget.h" |
| 24 #include "ui/views/widget/widget_delegate.h" | 29 #include "ui/views/widget/widget_delegate.h" |
| 25 #include "ui/views/window/client_view.h" | 30 #include "ui/views/window/client_view.h" |
| 26 #include "ui/views/window/frame_background.h" | 31 #include "ui/views/window/frame_background.h" |
| 27 #include "ui/views/window/window_resources.h" | 32 #include "ui/views/window/window_resources.h" |
| 28 #include "ui/views/window/window_shape.h" | 33 #include "ui/views/window/window_shape.h" |
| 29 | 34 |
| 30 namespace views { | 35 namespace views { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 // CustomFrameView, public: | 78 // CustomFrameView, public: |
| 74 | 79 |
| 75 CustomFrameView::CustomFrameView() | 80 CustomFrameView::CustomFrameView() |
| 76 : frame_(NULL), | 81 : frame_(NULL), |
| 77 window_icon_(NULL), | 82 window_icon_(NULL), |
| 78 minimize_button_(NULL), | 83 minimize_button_(NULL), |
| 79 maximize_button_(NULL), | 84 maximize_button_(NULL), |
| 80 restore_button_(NULL), | 85 restore_button_(NULL), |
| 81 close_button_(NULL), | 86 close_button_(NULL), |
| 82 should_show_maximize_button_(false), | 87 should_show_maximize_button_(false), |
| 83 frame_background_(new FrameBackground()) { | 88 frame_background_(new FrameBackground()), |
| 89 minimum_title_bar_x_(0), | |
| 90 maximum_title_bar_x_(INT_MAX) { | |
|
flackr
2014/04/25 16:04:18
Rather than initializing this to INT_MAX, since th
jonross
2014/04/29 15:26:04
Done.
| |
| 91 trailing_buttons_.push_back(views::FRAME_BUTTON_MINIMIZE); | |
| 92 trailing_buttons_.push_back(views::FRAME_BUTTON_MAXIMIZE); | |
| 93 trailing_buttons_.push_back(views::FRAME_BUTTON_CLOSE); | |
| 84 } | 94 } |
| 85 | 95 |
| 86 CustomFrameView::~CustomFrameView() { | 96 CustomFrameView::~CustomFrameView() { |
| 87 } | 97 } |
| 88 | 98 |
| 89 void CustomFrameView::Init(Widget* frame) { | 99 void CustomFrameView::Init(Widget* frame) { |
| 90 frame_ = frame; | 100 frame_ = frame; |
| 91 | 101 |
| 92 close_button_ = new ImageButton(this); | 102 close_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_CLOSE, |
| 93 close_button_->SetAccessibleName( | 103 IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P); |
| 94 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); | |
| 95 | |
| 96 // Close button images will be set in LayoutWindowControls(). | |
| 97 AddChildView(close_button_); | |
| 98 | 104 |
| 99 minimize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MINIMIZE, | 105 minimize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MINIMIZE, |
| 100 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P); | 106 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P); |
| 101 | 107 |
| 102 maximize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MAXIMIZE, | 108 maximize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MAXIMIZE, |
| 103 IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P); | 109 IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P); |
| 104 | 110 |
| 105 restore_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_RESTORE, | 111 restore_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_RESTORE, |
| 106 IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P); | 112 IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P); |
| 107 | 113 |
| 108 should_show_maximize_button_ = frame_->widget_delegate()->CanMaximize(); | 114 should_show_maximize_button_ = frame_->widget_delegate()->CanMaximize(); |
| 109 | 115 |
| 110 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { | 116 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { |
| 111 window_icon_ = new ImageButton(this); | 117 window_icon_ = new ImageButton(this); |
| 112 AddChildView(window_icon_); | 118 AddChildView(window_icon_); |
| 113 } | 119 } |
| 120 | |
| 121 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 122 views::LinuxUI* ui = views::LinuxUI::instance(); | |
| 123 if (ui) | |
| 124 ui->AddWindowButtonOrderObserver(this); | |
| 125 #endif | |
| 114 } | 126 } |
| 115 | 127 |
| 116 /////////////////////////////////////////////////////////////////////////////// | 128 /////////////////////////////////////////////////////////////////////////////// |
| 117 // CustomFrameView, NonClientFrameView implementation: | 129 // CustomFrameView, NonClientFrameView implementation: |
| 118 | 130 |
| 119 gfx::Rect CustomFrameView::GetBoundsForClientView() const { | 131 gfx::Rect CustomFrameView::GetBoundsForClientView() const { |
| 120 return client_view_bounds_; | 132 return client_view_bounds_; |
| 121 } | 133 } |
| 122 | 134 |
| 123 gfx::Rect CustomFrameView::GetWindowBoundsForClientBounds( | 135 gfx::Rect CustomFrameView::GetWindowBoundsForClientBounds( |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 gfx::Size CustomFrameView::GetMaximumSize() { | 245 gfx::Size CustomFrameView::GetMaximumSize() { |
| 234 gfx::Size max_size = frame_->client_view()->GetMaximumSize(); | 246 gfx::Size max_size = frame_->client_view()->GetMaximumSize(); |
| 235 gfx::Size converted_size = | 247 gfx::Size converted_size = |
| 236 frame_->non_client_view()->GetWindowBoundsForClientBounds( | 248 frame_->non_client_view()->GetWindowBoundsForClientBounds( |
| 237 gfx::Rect(max_size)).size(); | 249 gfx::Rect(max_size)).size(); |
| 238 return gfx::Size(max_size.width() == 0 ? 0 : converted_size.width(), | 250 return gfx::Size(max_size.width() == 0 ? 0 : converted_size.width(), |
| 239 max_size.height() == 0 ? 0 : converted_size.height()); | 251 max_size.height() == 0 ? 0 : converted_size.height()); |
| 240 } | 252 } |
| 241 | 253 |
| 242 /////////////////////////////////////////////////////////////////////////////// | 254 /////////////////////////////////////////////////////////////////////////////// |
| 243 // CustomFrameView, ButtonListener implementation: | 255 // CustomFrameView, WindowButtonOrderObserver: |
| 256 | |
| 257 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 258 void CustomFrameView::OnWindowButtonOrderingChange( | |
| 259 const std::vector<views::FrameButton>& leading_buttons, | |
| 260 const std::vector<views::FrameButton>& trailing_buttons) { | |
| 261 leading_buttons_ = leading_buttons; | |
| 262 trailing_buttons_ = trailing_buttons; | |
| 263 } | |
| 264 #endif | |
| 265 | |
| 266 /////////////////////////////////////////////////////////////////////////////// | |
| 267 //// CustomFrameView, ButtonListener implementation: | |
| 244 | 268 |
| 245 void CustomFrameView::ButtonPressed(Button* sender, const ui::Event& event) { | 269 void CustomFrameView::ButtonPressed(Button* sender, const ui::Event& event) { |
| 246 if (sender == close_button_) | 270 if (sender == close_button_) |
| 247 frame_->Close(); | 271 frame_->Close(); |
| 248 else if (sender == minimize_button_) | 272 else if (sender == minimize_button_) |
| 249 frame_->Minimize(); | 273 frame_->Minimize(); |
| 250 else if (sender == maximize_button_) | 274 else if (sender == maximize_button_) |
| 251 frame_->Maximize(); | 275 frame_->Maximize(); |
| 252 else if (sender == restore_button_) | 276 else if (sender == restore_button_) |
| 253 frame_->Restore(); | 277 frame_->Restore(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 268 | 292 |
| 269 int CustomFrameView::NonClientTopBorderHeight() const { | 293 int CustomFrameView::NonClientTopBorderHeight() const { |
| 270 return std::max(FrameBorderThickness() + IconSize(), | 294 return std::max(FrameBorderThickness() + IconSize(), |
| 271 CaptionButtonY() + kCaptionButtonHeightWithPadding) + | 295 CaptionButtonY() + kCaptionButtonHeightWithPadding) + |
| 272 TitlebarBottomThickness(); | 296 TitlebarBottomThickness(); |
| 273 } | 297 } |
| 274 | 298 |
| 275 int CustomFrameView::CaptionButtonY() const { | 299 int CustomFrameView::CaptionButtonY() const { |
| 276 // Maximized buttons start at window top so that even if their images aren't | 300 // Maximized buttons start at window top so that even if their images aren't |
| 277 // drawn flush with the screen edge, they still obey Fitts' Law. | 301 // drawn flush with the screen edge, they still obey Fitts' Law. |
| 278 return frame_->IsMaximized() ? FrameBorderThickness() : kFrameShadowThickness; | 302 return frame_->IsMaximized() ? FrameBorderThickness() : kFrameBorderThickness; |
| 279 } | 303 } |
| 280 | 304 |
| 281 int CustomFrameView::TitlebarBottomThickness() const { | 305 int CustomFrameView::TitlebarBottomThickness() const { |
| 282 return kTitlebarTopAndBottomEdgeThickness + | 306 return kTitlebarTopAndBottomEdgeThickness + |
| 283 (ShouldShowClientEdge() ? kClientEdgeThickness : 0); | 307 (ShouldShowClientEdge() ? kClientEdgeThickness : 0); |
| 284 } | 308 } |
| 285 | 309 |
| 286 int CustomFrameView::IconSize() const { | 310 int CustomFrameView::IconSize() const { |
| 287 #if defined(OS_WIN) | 311 #if defined(OS_WIN) |
| 288 // This metric scales up if either the titlebar height or the titlebar font | 312 // This metric scales up if either the titlebar height or the titlebar font |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 306 // from below the 3D edge. | 330 // from below the 3D edge. |
| 307 int unavailable_px_at_top = frame_->IsMaximized() ? | 331 int unavailable_px_at_top = frame_->IsMaximized() ? |
| 308 frame_thickness : kTitlebarTopAndBottomEdgeThickness; | 332 frame_thickness : kTitlebarTopAndBottomEdgeThickness; |
| 309 // When the icon is shorter than the minimum space we reserve for the caption | 333 // When the icon is shorter than the minimum space we reserve for the caption |
| 310 // button, we vertically center it. We want to bias rounding to put extra | 334 // button, we vertically center it. We want to bias rounding to put extra |
| 311 // space above the icon, since the 3D edge (+ client edge, for restored | 335 // space above the icon, since the 3D edge (+ client edge, for restored |
| 312 // windows) below looks (to the eye) more like additional space than does the | 336 // windows) below looks (to the eye) more like additional space than does the |
| 313 // 3D edge (or nothing at all, for maximized windows) above; hence the +1. | 337 // 3D edge (or nothing at all, for maximized windows) above; hence the +1. |
| 314 int y = unavailable_px_at_top + (NonClientTopBorderHeight() - | 338 int y = unavailable_px_at_top + (NonClientTopBorderHeight() - |
| 315 unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2; | 339 unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2; |
| 316 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); | 340 return gfx::Rect(frame_thickness + kIconLeftSpacing + minimum_title_bar_x_, |
| 341 y, size, size); | |
| 317 } | 342 } |
| 318 | 343 |
| 319 bool CustomFrameView::ShouldShowTitleBarAndBorder() const { | 344 bool CustomFrameView::ShouldShowTitleBarAndBorder() const { |
| 320 if (frame_->IsFullscreen()) | 345 if (frame_->IsFullscreen()) |
| 321 return false; | 346 return false; |
| 322 | 347 |
| 323 if (ViewsDelegate::views_delegate) { | 348 if (ViewsDelegate::views_delegate) { |
| 324 return !ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar( | 349 return !ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar( |
| 325 frame_->IsMaximized()); | 350 frame_->IsMaximized()); |
| 326 } | 351 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 | 484 |
| 460 SkColor CustomFrameView::GetFrameColor() const { | 485 SkColor CustomFrameView::GetFrameColor() const { |
| 461 return frame_->IsActive() ? kDefaultColorFrame : kDefaultColorFrameInactive; | 486 return frame_->IsActive() ? kDefaultColorFrame : kDefaultColorFrameInactive; |
| 462 } | 487 } |
| 463 | 488 |
| 464 const gfx::ImageSkia* CustomFrameView::GetFrameImage() const { | 489 const gfx::ImageSkia* CustomFrameView::GetFrameImage() const { |
| 465 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 490 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 466 frame_->IsActive() ? IDR_FRAME : IDR_FRAME_INACTIVE).ToImageSkia(); | 491 frame_->IsActive() ? IDR_FRAME : IDR_FRAME_INACTIVE).ToImageSkia(); |
| 467 } | 492 } |
| 468 | 493 |
| 494 void CustomFrameView::LayoutButton(ImageButton* button, int x, int y) { | |
| 495 button->SetVisible(true); | |
| 496 button->SetImageAlignment(ImageButton::ALIGN_LEFT, | |
| 497 ImageButton::ALIGN_BOTTOM); | |
| 498 gfx::Size button_size = button->GetPreferredSize(); | |
| 499 button->SetBounds(x, y, button_size.width(), button_size.height()); | |
| 500 } | |
| 501 | |
| 469 void CustomFrameView::LayoutWindowControls() { | 502 void CustomFrameView::LayoutWindowControls() { |
| 470 close_button_->SetImageAlignment(ImageButton::ALIGN_LEFT, | 503 minimum_title_bar_x_ = 0; |
| 471 ImageButton::ALIGN_BOTTOM); | 504 maximum_title_bar_x_ = width(); |
| 472 int caption_y = CaptionButtonY(); | 505 int caption_y = CaptionButtonY(); |
| 473 bool is_maximized = frame_->IsMaximized(); | 506 bool is_maximized = frame_->IsMaximized(); |
| 474 // There should always be the same number of non-shadow pixels visible to the | 507 // There should always be the same number of non-shadow pixels visible to the |
| 475 // side of the caption buttons. In maximized mode we extend the rightmost | 508 // side of the caption buttons. In maximized mode we extend the edge button |
| 476 // button to the screen corner to obey Fitts' Law. | 509 // to the screen corner to obey Fitts' Law. |
| 477 int right_extra_width = is_maximized ? | 510 int extra_width = is_maximized ? |
| 478 (kFrameBorderThickness - kFrameShadowThickness) : 0; | 511 (kFrameBorderThickness - kFrameShadowThickness) : 0; |
| 479 gfx::Size close_button_size = close_button_->GetPreferredSize(); | 512 int next_button_x = FrameBorderThickness() + extra_width; |
| 480 close_button_->SetBounds(width() - FrameBorderThickness() - | |
| 481 right_extra_width - close_button_size.width(), caption_y, | |
| 482 close_button_size.width() + right_extra_width, | |
| 483 close_button_size.height()); | |
| 484 | 513 |
| 485 // When the window is restored, we show a maximized button; otherwise, we show | |
| 486 // a restore button. | |
| 487 bool is_restored = !is_maximized && !frame_->IsMinimized(); | 514 bool is_restored = !is_maximized && !frame_->IsMinimized(); |
| 488 ImageButton* invisible_button = is_restored ? restore_button_ | 515 ImageButton* invisible_button = is_restored ? restore_button_ |
| 489 : maximize_button_; | 516 : maximize_button_; |
| 490 invisible_button->SetVisible(false); | 517 invisible_button->SetVisible(false); |
| 491 | 518 |
| 492 ImageButton* visible_button = is_restored ? maximize_button_ | 519 ImageButton* button = NULL; |
| 493 : restore_button_; | 520 for (std::vector<views::FrameButton>::const_iterator it = |
| 494 FramePartImage normal_part, hot_part, pushed_part; | 521 leading_buttons_.begin(); it != leading_buttons_.end(); ++it) { |
| 495 int next_button_x; | 522 button = GetImageButton(*it); |
| 496 if (should_show_maximize_button_) { | 523 if (!button) |
| 497 visible_button->SetVisible(true); | 524 continue; |
| 498 visible_button->SetImageAlignment(ImageButton::ALIGN_LEFT, | 525 LayoutButton(button, next_button_x, caption_y); |
| 499 ImageButton::ALIGN_BOTTOM); | 526 next_button_x += button->width(); |
| 500 gfx::Size visible_button_size = visible_button->GetPreferredSize(); | 527 minimum_title_bar_x_ = next_button_x; |
| 501 visible_button->SetBounds(close_button_->x() - visible_button_size.width(), | |
| 502 caption_y, visible_button_size.width(), | |
| 503 visible_button_size.height()); | |
| 504 next_button_x = visible_button->x(); | |
| 505 } else { | |
| 506 visible_button->SetVisible(false); | |
| 507 next_button_x = close_button_->x(); | |
| 508 } | 528 } |
| 509 | 529 |
| 510 minimize_button_->SetVisible(true); | 530 // Trailing buttions are laid out in a RTL fashion |
| 511 minimize_button_->SetImageAlignment(ImageButton::ALIGN_LEFT, | 531 next_button_x = width() - FrameBorderThickness() - extra_width; |
| 512 ImageButton::ALIGN_BOTTOM); | 532 for (std::vector<views::FrameButton>::const_reverse_iterator it = |
| 513 gfx::Size minimize_button_size = minimize_button_->GetPreferredSize(); | 533 trailing_buttons_.rbegin(); it != trailing_buttons_.rend(); ++it) { |
| 514 minimize_button_->SetBounds( | 534 button = GetImageButton(*it); |
| 515 next_button_x - minimize_button_size.width(), caption_y, | 535 if (!button) |
| 516 minimize_button_size.width(), | 536 continue; |
| 517 minimize_button_size.height()); | 537 gfx::Size button_size = button->GetPreferredSize(); |
| 518 | 538 next_button_x -= button_size.width(); |
| 519 normal_part = IDR_CLOSE; | 539 LayoutButton(button, next_button_x, caption_y); |
| 520 hot_part = IDR_CLOSE_H; | 540 next_button_x = button->x(); |
| 521 pushed_part = IDR_CLOSE_P; | 541 maximum_title_bar_x_ = next_button_x; |
| 522 | 542 } |
| 523 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 524 | |
| 525 close_button_->SetImage(CustomButton::STATE_NORMAL, | |
| 526 rb.GetImageNamed(normal_part).ToImageSkia()); | |
| 527 close_button_->SetImage(CustomButton::STATE_HOVERED, | |
| 528 rb.GetImageNamed(hot_part).ToImageSkia()); | |
| 529 close_button_->SetImage(CustomButton::STATE_PRESSED, | |
| 530 rb.GetImageNamed(pushed_part).ToImageSkia()); | |
| 531 } | 543 } |
| 532 | 544 |
| 533 void CustomFrameView::LayoutTitleBar() { | 545 void CustomFrameView::LayoutTitleBar() { |
| 534 // The window title position is calculated based on the icon position, even | 546 // The window title position is calculated based on the icon position, even |
| 535 // when there is no icon. | 547 // when there is no icon. |
| 536 gfx::Rect icon_bounds(IconBounds()); | 548 gfx::Rect icon_bounds(IconBounds()); |
| 537 bool show_window_icon = window_icon_ != NULL; | 549 bool show_window_icon = window_icon_ != NULL; |
| 538 if (show_window_icon) | 550 if (show_window_icon) |
| 539 window_icon_->SetBoundsRect(icon_bounds); | 551 window_icon_->SetBoundsRect(icon_bounds); |
| 540 | 552 |
| 541 // The offset between the window left edge and the title text. | 553 // The offset between the window left edge and the title text. |
| 542 int title_x = show_window_icon ? icon_bounds.right() + kTitleIconOffsetX | 554 int title_x = show_window_icon ? icon_bounds.right() + kTitleIconOffsetX |
| 543 : icon_bounds.x(); | 555 : icon_bounds.x(); |
| 544 int title_height = GetTitleFontList().GetHeight(); | 556 int title_height = GetTitleFontList().GetHeight(); |
| 545 // We bias the title position so that when the difference between the icon and | 557 // We bias the title position so that when the difference between the icon and |
| 546 // title heights is odd, the extra pixel of the title is above the vertical | 558 // title heights is odd, the extra pixel of the title is above the vertical |
| 547 // midline rather than below. This compensates for how the icon is already | 559 // midline rather than below. This compensates for how the icon is already |
| 548 // biased downwards (see IconBounds()) and helps prevent descenders on the | 560 // biased downwards (see IconBounds()) and helps prevent descenders on the |
| 549 // title from overlapping the 3D edge at the bottom of the titlebar. | 561 // title from overlapping the 3D edge at the bottom of the titlebar. |
| 550 title_bounds_.SetRect(title_x, | 562 title_bounds_.SetRect(title_x, |
| 551 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), | 563 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), |
| 552 std::max(0, minimize_button_->x() - kTitleCaptionSpacing - | 564 std::max(0, maximum_title_bar_x_ - kTitleCaptionSpacing - |
| 553 title_x), title_height); | 565 title_x), title_height); |
| 554 } | 566 } |
| 555 | 567 |
| 556 void CustomFrameView::LayoutClientView() { | 568 void CustomFrameView::LayoutClientView() { |
| 557 if (!ShouldShowTitleBarAndBorder()) { | 569 if (!ShouldShowTitleBarAndBorder()) { |
| 558 client_view_bounds_ = bounds(); | 570 client_view_bounds_ = bounds(); |
| 559 return; | 571 return; |
| 560 } | 572 } |
| 561 | 573 |
| 562 int top_height = NonClientTopBorderHeight(); | 574 int top_height = NonClientTopBorderHeight(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 577 button->SetImage(CustomButton::STATE_NORMAL, | 589 button->SetImage(CustomButton::STATE_NORMAL, |
| 578 rb.GetImageNamed(normal_image_id).ToImageSkia()); | 590 rb.GetImageNamed(normal_image_id).ToImageSkia()); |
| 579 button->SetImage(CustomButton::STATE_HOVERED, | 591 button->SetImage(CustomButton::STATE_HOVERED, |
| 580 rb.GetImageNamed(hot_image_id).ToImageSkia()); | 592 rb.GetImageNamed(hot_image_id).ToImageSkia()); |
| 581 button->SetImage(CustomButton::STATE_PRESSED, | 593 button->SetImage(CustomButton::STATE_PRESSED, |
| 582 rb.GetImageNamed(pushed_image_id).ToImageSkia()); | 594 rb.GetImageNamed(pushed_image_id).ToImageSkia()); |
| 583 AddChildView(button); | 595 AddChildView(button); |
| 584 return button; | 596 return button; |
| 585 } | 597 } |
| 586 | 598 |
| 599 ImageButton* CustomFrameView::GetImageButton(views::FrameButton frame_button) { | |
| 600 ImageButton* button = NULL; | |
| 601 switch (frame_button) { | |
| 602 case views::FRAME_BUTTON_MINIMIZE: { | |
| 603 button = minimize_button_; | |
| 604 break; | |
| 605 } | |
| 606 case views::FRAME_BUTTON_MAXIMIZE: { | |
| 607 bool is_restored = !frame_->IsMaximized() && !frame_->IsMinimized(); | |
| 608 button = is_restored ? maximize_button_ : restore_button_; | |
| 609 if (!should_show_maximize_button_) { | |
| 610 button->SetVisible(false); | |
| 611 return NULL; | |
| 612 } | |
| 613 break; | |
| 614 } | |
| 615 case views::FRAME_BUTTON_CLOSE: { | |
| 616 button = close_button_; | |
| 617 break; | |
| 618 } | |
| 619 } | |
| 620 return button; | |
| 621 } | |
| 622 | |
| 587 } // namespace views | 623 } // namespace views |
| OLD | NEW |