| 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 #include <vector> | |
| 9 | 8 |
| 10 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 11 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
| 12 #include "grit/ui_strings.h" | 11 #include "grit/ui_strings.h" |
| 13 #include "ui/base/hit_test.h" | 12 #include "ui/base/hit_test.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 16 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 17 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
| 18 #include "ui/gfx/image/image.h" | 17 #include "ui/gfx/image/image.h" |
| 19 #include "ui/gfx/path.h" | 18 #include "ui/gfx/path.h" |
| 20 #include "ui/gfx/rect.h" | |
| 21 #include "ui/views/color_constants.h" | 19 #include "ui/views/color_constants.h" |
| 22 #include "ui/views/controls/button/image_button.h" | 20 #include "ui/views/controls/button/image_button.h" |
| 23 #include "ui/views/views_delegate.h" | 21 #include "ui/views/views_delegate.h" |
| 24 #include "ui/views/widget/native_widget_aura.h" | 22 #include "ui/views/widget/native_widget_aura.h" |
| 25 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 26 #include "ui/views/widget/widget_delegate.h" | 24 #include "ui/views/widget/widget_delegate.h" |
| 27 #include "ui/views/window/client_view.h" | 25 #include "ui/views/window/client_view.h" |
| 28 #include "ui/views/window/frame_background.h" | 26 #include "ui/views/window/frame_background.h" |
| 29 #include "ui/views/window/window_button_order_provider.h" | |
| 30 #include "ui/views/window/window_resources.h" | 27 #include "ui/views/window/window_resources.h" |
| 31 #include "ui/views/window/window_shape.h" | 28 #include "ui/views/window/window_shape.h" |
| 32 | 29 |
| 33 namespace views { | 30 namespace views { |
| 34 | 31 |
| 35 namespace { | 32 namespace { |
| 36 | 33 |
| 37 // The frame border is only visible in restored mode and is hardcoded to 4 px on | 34 // The frame border is only visible in restored mode and is hardcoded to 4 px on |
| 38 // each side regardless of the system window border size. | 35 // each side regardless of the system window border size. |
| 39 const int kFrameBorderThickness = 4; | 36 const int kFrameBorderThickness = 4; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 63 const SkColor kDefaultColorFrame = SkColorSetRGB(66, 116, 201); | 60 const SkColor kDefaultColorFrame = SkColorSetRGB(66, 116, 201); |
| 64 const SkColor kDefaultColorFrameInactive = SkColorSetRGB(161, 182, 228); | 61 const SkColor kDefaultColorFrameInactive = SkColorSetRGB(161, 182, 228); |
| 65 #endif | 62 #endif |
| 66 | 63 |
| 67 const gfx::FontList& GetTitleFontList() { | 64 const gfx::FontList& GetTitleFontList() { |
| 68 static const gfx::FontList title_font_list = | 65 static const gfx::FontList title_font_list = |
| 69 NativeWidgetAura::GetWindowTitleFontList(); | 66 NativeWidgetAura::GetWindowTitleFontList(); |
| 70 return title_font_list; | 67 return title_font_list; |
| 71 } | 68 } |
| 72 | 69 |
| 73 void LayoutButton(ImageButton* button, const gfx::Rect& bounds) { | |
| 74 button->SetVisible(true); | |
| 75 button->SetImageAlignment(ImageButton::ALIGN_LEFT, | |
| 76 ImageButton::ALIGN_BOTTOM); | |
| 77 button->SetBoundsRect(bounds); | |
| 78 } | |
| 79 | |
| 80 } // namespace | 70 } // namespace |
| 81 | 71 |
| 82 /////////////////////////////////////////////////////////////////////////////// | 72 /////////////////////////////////////////////////////////////////////////////// |
| 83 // CustomFrameView, public: | 73 // CustomFrameView, public: |
| 84 | 74 |
| 85 CustomFrameView::CustomFrameView() | 75 CustomFrameView::CustomFrameView() |
| 86 : frame_(NULL), | 76 : frame_(NULL), |
| 87 window_icon_(NULL), | 77 window_icon_(NULL), |
| 88 minimize_button_(NULL), | 78 minimize_button_(NULL), |
| 89 maximize_button_(NULL), | 79 maximize_button_(NULL), |
| 90 restore_button_(NULL), | 80 restore_button_(NULL), |
| 91 close_button_(NULL), | 81 close_button_(NULL), |
| 92 should_show_maximize_button_(false), | 82 should_show_maximize_button_(false), |
| 93 frame_background_(new FrameBackground()), | 83 frame_background_(new FrameBackground()) { |
| 94 minimum_title_bar_x_(0), | |
| 95 maximum_title_bar_x_(-1) { | |
| 96 } | 84 } |
| 97 | 85 |
| 98 CustomFrameView::~CustomFrameView() { | 86 CustomFrameView::~CustomFrameView() { |
| 99 } | 87 } |
| 100 | 88 |
| 101 void CustomFrameView::Init(Widget* frame) { | 89 void CustomFrameView::Init(Widget* frame) { |
| 102 frame_ = frame; | 90 frame_ = frame; |
| 103 | 91 |
| 104 close_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_CLOSE, | 92 close_button_ = new ImageButton(this); |
| 105 IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P); | 93 close_button_->SetAccessibleName( |
| 94 l10n_util::GetStringUTF16(IDS_APP_ACCNAME_CLOSE)); |
| 95 |
| 96 // Close button images will be set in LayoutWindowControls(). |
| 97 AddChildView(close_button_); |
| 98 |
| 106 minimize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MINIMIZE, | 99 minimize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MINIMIZE, |
| 107 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P); | 100 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P); |
| 101 |
| 108 maximize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MAXIMIZE, | 102 maximize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MAXIMIZE, |
| 109 IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P); | 103 IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P); |
| 104 |
| 110 restore_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_RESTORE, | 105 restore_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_RESTORE, |
| 111 IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P); | 106 IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P); |
| 112 | 107 |
| 113 should_show_maximize_button_ = frame_->widget_delegate()->CanMaximize(); | 108 should_show_maximize_button_ = frame_->widget_delegate()->CanMaximize(); |
| 114 | 109 |
| 115 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { | 110 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { |
| 116 window_icon_ = new ImageButton(this); | 111 window_icon_ = new ImageButton(this); |
| 117 AddChildView(window_icon_); | 112 AddChildView(window_icon_); |
| 118 } | 113 } |
| 119 } | 114 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 268 |
| 274 int CustomFrameView::NonClientTopBorderHeight() const { | 269 int CustomFrameView::NonClientTopBorderHeight() const { |
| 275 return std::max(FrameBorderThickness() + IconSize(), | 270 return std::max(FrameBorderThickness() + IconSize(), |
| 276 CaptionButtonY() + kCaptionButtonHeightWithPadding) + | 271 CaptionButtonY() + kCaptionButtonHeightWithPadding) + |
| 277 TitlebarBottomThickness(); | 272 TitlebarBottomThickness(); |
| 278 } | 273 } |
| 279 | 274 |
| 280 int CustomFrameView::CaptionButtonY() const { | 275 int CustomFrameView::CaptionButtonY() const { |
| 281 // Maximized buttons start at window top so that even if their images aren't | 276 // Maximized buttons start at window top so that even if their images aren't |
| 282 // drawn flush with the screen edge, they still obey Fitts' Law. | 277 // drawn flush with the screen edge, they still obey Fitts' Law. |
| 283 return frame_->IsMaximized() ? FrameBorderThickness() : kFrameBorderThickness; | 278 return frame_->IsMaximized() ? FrameBorderThickness() : kFrameShadowThickness; |
| 284 } | 279 } |
| 285 | 280 |
| 286 int CustomFrameView::TitlebarBottomThickness() const { | 281 int CustomFrameView::TitlebarBottomThickness() const { |
| 287 return kTitlebarTopAndBottomEdgeThickness + | 282 return kTitlebarTopAndBottomEdgeThickness + |
| 288 (ShouldShowClientEdge() ? kClientEdgeThickness : 0); | 283 (ShouldShowClientEdge() ? kClientEdgeThickness : 0); |
| 289 } | 284 } |
| 290 | 285 |
| 291 int CustomFrameView::IconSize() const { | 286 int CustomFrameView::IconSize() const { |
| 292 #if defined(OS_WIN) | 287 #if defined(OS_WIN) |
| 293 // This metric scales up if either the titlebar height or the titlebar font | 288 // This metric scales up if either the titlebar height or the titlebar font |
| (...skipping 17 matching lines...) Expand all Loading... |
| 311 // from below the 3D edge. | 306 // from below the 3D edge. |
| 312 int unavailable_px_at_top = frame_->IsMaximized() ? | 307 int unavailable_px_at_top = frame_->IsMaximized() ? |
| 313 frame_thickness : kTitlebarTopAndBottomEdgeThickness; | 308 frame_thickness : kTitlebarTopAndBottomEdgeThickness; |
| 314 // When the icon is shorter than the minimum space we reserve for the caption | 309 // When the icon is shorter than the minimum space we reserve for the caption |
| 315 // button, we vertically center it. We want to bias rounding to put extra | 310 // button, we vertically center it. We want to bias rounding to put extra |
| 316 // space above the icon, since the 3D edge (+ client edge, for restored | 311 // space above the icon, since the 3D edge (+ client edge, for restored |
| 317 // windows) below looks (to the eye) more like additional space than does the | 312 // windows) below looks (to the eye) more like additional space than does the |
| 318 // 3D edge (or nothing at all, for maximized windows) above; hence the +1. | 313 // 3D edge (or nothing at all, for maximized windows) above; hence the +1. |
| 319 int y = unavailable_px_at_top + (NonClientTopBorderHeight() - | 314 int y = unavailable_px_at_top + (NonClientTopBorderHeight() - |
| 320 unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2; | 315 unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2; |
| 321 return gfx::Rect(frame_thickness + kIconLeftSpacing + minimum_title_bar_x_, | 316 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); |
| 322 y, size, size); | |
| 323 } | 317 } |
| 324 | 318 |
| 325 bool CustomFrameView::ShouldShowTitleBarAndBorder() const { | 319 bool CustomFrameView::ShouldShowTitleBarAndBorder() const { |
| 326 if (frame_->IsFullscreen()) | 320 if (frame_->IsFullscreen()) |
| 327 return false; | 321 return false; |
| 328 | 322 |
| 329 if (ViewsDelegate::views_delegate) { | 323 if (ViewsDelegate::views_delegate) { |
| 330 return !ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar( | 324 return !ViewsDelegate::views_delegate->WindowManagerProvidesTitleBar( |
| 331 frame_->IsMaximized()); | 325 frame_->IsMaximized()); |
| 332 } | 326 } |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 SkColor CustomFrameView::GetFrameColor() const { | 460 SkColor CustomFrameView::GetFrameColor() const { |
| 467 return frame_->IsActive() ? kDefaultColorFrame : kDefaultColorFrameInactive; | 461 return frame_->IsActive() ? kDefaultColorFrame : kDefaultColorFrameInactive; |
| 468 } | 462 } |
| 469 | 463 |
| 470 const gfx::ImageSkia* CustomFrameView::GetFrameImage() const { | 464 const gfx::ImageSkia* CustomFrameView::GetFrameImage() const { |
| 471 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 465 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
| 472 frame_->IsActive() ? IDR_FRAME : IDR_FRAME_INACTIVE).ToImageSkia(); | 466 frame_->IsActive() ? IDR_FRAME : IDR_FRAME_INACTIVE).ToImageSkia(); |
| 473 } | 467 } |
| 474 | 468 |
| 475 void CustomFrameView::LayoutWindowControls() { | 469 void CustomFrameView::LayoutWindowControls() { |
| 476 minimum_title_bar_x_ = 0; | 470 close_button_->SetImageAlignment(ImageButton::ALIGN_LEFT, |
| 477 maximum_title_bar_x_ = width(); | 471 ImageButton::ALIGN_BOTTOM); |
| 478 | |
| 479 if (bounds().IsEmpty()) | |
| 480 return; | |
| 481 | |
| 482 int caption_y = CaptionButtonY(); | 472 int caption_y = CaptionButtonY(); |
| 483 bool is_maximized = frame_->IsMaximized(); | 473 bool is_maximized = frame_->IsMaximized(); |
| 484 // There should always be the same number of non-shadow pixels visible to the | 474 // There should always be the same number of non-shadow pixels visible to the |
| 485 // side of the caption buttons. In maximized mode we extend the edge button | 475 // side of the caption buttons. In maximized mode we extend the rightmost |
| 486 // to the screen corner to obey Fitts' Law. | 476 // button to the screen corner to obey Fitts' Law. |
| 487 int extra_width = is_maximized ? | 477 int right_extra_width = is_maximized ? |
| 488 (kFrameBorderThickness - kFrameShadowThickness) : 0; | 478 (kFrameBorderThickness - kFrameShadowThickness) : 0; |
| 489 int next_button_x = FrameBorderThickness(); | 479 gfx::Size close_button_size = close_button_->GetPreferredSize(); |
| 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()); |
| 490 | 484 |
| 485 // When the window is restored, we show a maximized button; otherwise, we show |
| 486 // a restore button. |
| 491 bool is_restored = !is_maximized && !frame_->IsMinimized(); | 487 bool is_restored = !is_maximized && !frame_->IsMinimized(); |
| 492 ImageButton* invisible_button = is_restored ? restore_button_ | 488 ImageButton* invisible_button = is_restored ? restore_button_ |
| 493 : maximize_button_; | 489 : maximize_button_; |
| 494 invisible_button->SetVisible(false); | 490 invisible_button->SetVisible(false); |
| 495 | 491 |
| 496 WindowButtonOrderProvider* button_order = | 492 ImageButton* visible_button = is_restored ? maximize_button_ |
| 497 WindowButtonOrderProvider::GetInstance(); | 493 : restore_button_; |
| 498 std::vector<views::FrameButton> leading_buttons = | 494 FramePartImage normal_part, hot_part, pushed_part; |
| 499 button_order->GetLeadingButtons(); | 495 int next_button_x; |
| 500 std::vector<views::FrameButton> trailing_buttons = | 496 if (should_show_maximize_button_) { |
| 501 button_order->GetTrailingButtons(); | 497 visible_button->SetVisible(true); |
| 502 | 498 visible_button->SetImageAlignment(ImageButton::ALIGN_LEFT, |
| 503 ImageButton* button = NULL; | 499 ImageButton::ALIGN_BOTTOM); |
| 504 for (std::vector<views::FrameButton>::const_iterator it = | 500 gfx::Size visible_button_size = visible_button->GetPreferredSize(); |
| 505 leading_buttons.begin(); it != leading_buttons.end(); ++it) { | 501 visible_button->SetBounds(close_button_->x() - visible_button_size.width(), |
| 506 button = GetImageButton(*it); | 502 caption_y, visible_button_size.width(), |
| 507 if (!button) | 503 visible_button_size.height()); |
| 508 continue; | 504 next_button_x = visible_button->x(); |
| 509 gfx::Rect target_bounds(gfx::Point(next_button_x, caption_y), | 505 } else { |
| 510 button->GetPreferredSize()); | 506 visible_button->SetVisible(false); |
| 511 if (it == leading_buttons.begin()) | 507 next_button_x = close_button_->x(); |
| 512 target_bounds.set_width(target_bounds.width() + extra_width); | |
| 513 LayoutButton(button, target_bounds); | |
| 514 next_button_x += button->width(); | |
| 515 minimum_title_bar_x_ = std::min(width(), next_button_x); | |
| 516 } | 508 } |
| 517 | 509 |
| 518 // Trailing buttions are laid out in a RTL fashion | 510 minimize_button_->SetVisible(true); |
| 519 next_button_x = width() - FrameBorderThickness(); | 511 minimize_button_->SetImageAlignment(ImageButton::ALIGN_LEFT, |
| 520 for (std::vector<views::FrameButton>::const_reverse_iterator it = | 512 ImageButton::ALIGN_BOTTOM); |
| 521 trailing_buttons.rbegin(); it != trailing_buttons.rend(); ++it) { | 513 gfx::Size minimize_button_size = minimize_button_->GetPreferredSize(); |
| 522 button = GetImageButton(*it); | 514 minimize_button_->SetBounds( |
| 523 if (!button) | 515 next_button_x - minimize_button_size.width(), caption_y, |
| 524 continue; | 516 minimize_button_size.width(), |
| 525 gfx::Rect target_bounds(gfx::Point(next_button_x, caption_y), | 517 minimize_button_size.height()); |
| 526 button->GetPreferredSize()); | 518 |
| 527 if (it == trailing_buttons.rbegin()) | 519 normal_part = IDR_CLOSE; |
| 528 target_bounds.set_width(target_bounds.width() + extra_width); | 520 hot_part = IDR_CLOSE_H; |
| 529 target_bounds.Offset(-target_bounds.width(), 0); | 521 pushed_part = IDR_CLOSE_P; |
| 530 LayoutButton(button, target_bounds); | 522 |
| 531 next_button_x = button->x(); | 523 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 532 maximum_title_bar_x_ = std::max(minimum_title_bar_x_, next_button_x); | 524 |
| 533 } | 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()); |
| 534 } | 531 } |
| 535 | 532 |
| 536 void CustomFrameView::LayoutTitleBar() { | 533 void CustomFrameView::LayoutTitleBar() { |
| 537 DCHECK_GE(maximum_title_bar_x_, 0); | |
| 538 // The window title position is calculated based on the icon position, even | 534 // The window title position is calculated based on the icon position, even |
| 539 // when there is no icon. | 535 // when there is no icon. |
| 540 gfx::Rect icon_bounds(IconBounds()); | 536 gfx::Rect icon_bounds(IconBounds()); |
| 541 bool show_window_icon = window_icon_ != NULL; | 537 bool show_window_icon = window_icon_ != NULL; |
| 542 if (show_window_icon) | 538 if (show_window_icon) |
| 543 window_icon_->SetBoundsRect(icon_bounds); | 539 window_icon_->SetBoundsRect(icon_bounds); |
| 544 | 540 |
| 545 // The offset between the window left edge and the title text. | 541 // The offset between the window left edge and the title text. |
| 546 int title_x = show_window_icon ? icon_bounds.right() + kTitleIconOffsetX | 542 int title_x = show_window_icon ? icon_bounds.right() + kTitleIconOffsetX |
| 547 : icon_bounds.x(); | 543 : icon_bounds.x(); |
| 548 int title_height = GetTitleFontList().GetHeight(); | 544 int title_height = GetTitleFontList().GetHeight(); |
| 549 // We bias the title position so that when the difference between the icon and | 545 // We bias the title position so that when the difference between the icon and |
| 550 // title heights is odd, the extra pixel of the title is above the vertical | 546 // title heights is odd, the extra pixel of the title is above the vertical |
| 551 // midline rather than below. This compensates for how the icon is already | 547 // midline rather than below. This compensates for how the icon is already |
| 552 // biased downwards (see IconBounds()) and helps prevent descenders on the | 548 // biased downwards (see IconBounds()) and helps prevent descenders on the |
| 553 // title from overlapping the 3D edge at the bottom of the titlebar. | 549 // title from overlapping the 3D edge at the bottom of the titlebar. |
| 554 title_bounds_.SetRect(title_x, | 550 title_bounds_.SetRect(title_x, |
| 555 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), | 551 icon_bounds.y() + ((icon_bounds.height() - title_height - 1) / 2), |
| 556 std::max(0, maximum_title_bar_x_ - kTitleCaptionSpacing - | 552 std::max(0, minimize_button_->x() - kTitleCaptionSpacing - |
| 557 title_x), title_height); | 553 title_x), title_height); |
| 558 } | 554 } |
| 559 | 555 |
| 560 void CustomFrameView::LayoutClientView() { | 556 void CustomFrameView::LayoutClientView() { |
| 561 if (!ShouldShowTitleBarAndBorder()) { | 557 if (!ShouldShowTitleBarAndBorder()) { |
| 562 client_view_bounds_ = bounds(); | 558 client_view_bounds_ = bounds(); |
| 563 return; | 559 return; |
| 564 } | 560 } |
| 565 | 561 |
| 566 int top_height = NonClientTopBorderHeight(); | 562 int top_height = NonClientTopBorderHeight(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 581 button->SetImage(CustomButton::STATE_NORMAL, | 577 button->SetImage(CustomButton::STATE_NORMAL, |
| 582 rb.GetImageNamed(normal_image_id).ToImageSkia()); | 578 rb.GetImageNamed(normal_image_id).ToImageSkia()); |
| 583 button->SetImage(CustomButton::STATE_HOVERED, | 579 button->SetImage(CustomButton::STATE_HOVERED, |
| 584 rb.GetImageNamed(hot_image_id).ToImageSkia()); | 580 rb.GetImageNamed(hot_image_id).ToImageSkia()); |
| 585 button->SetImage(CustomButton::STATE_PRESSED, | 581 button->SetImage(CustomButton::STATE_PRESSED, |
| 586 rb.GetImageNamed(pushed_image_id).ToImageSkia()); | 582 rb.GetImageNamed(pushed_image_id).ToImageSkia()); |
| 587 AddChildView(button); | 583 AddChildView(button); |
| 588 return button; | 584 return button; |
| 589 } | 585 } |
| 590 | 586 |
| 591 ImageButton* CustomFrameView::GetImageButton(views::FrameButton frame_button) { | |
| 592 ImageButton* button = NULL; | |
| 593 switch (frame_button) { | |
| 594 case views::FRAME_BUTTON_MINIMIZE: { | |
| 595 button = minimize_button_; | |
| 596 break; | |
| 597 } | |
| 598 case views::FRAME_BUTTON_MAXIMIZE: { | |
| 599 bool is_restored = !frame_->IsMaximized() && !frame_->IsMinimized(); | |
| 600 button = is_restored ? maximize_button_ : restore_button_; | |
| 601 if (!should_show_maximize_button_) { | |
| 602 // If we should not show the maximize/restore button, then we return | |
| 603 // NULL as we don't want this button to become visible and to be laid | |
| 604 // out. | |
| 605 button->SetVisible(false); | |
| 606 return NULL; | |
| 607 } | |
| 608 break; | |
| 609 } | |
| 610 case views::FRAME_BUTTON_CLOSE: { | |
| 611 button = close_button_; | |
| 612 break; | |
| 613 } | |
| 614 } | |
| 615 return button; | |
| 616 } | |
| 617 | |
| 618 } // namespace views | 587 } // namespace views |
| OLD | NEW |