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 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 /////////////////////////////////////////////////////////////////////////////// | 82 /////////////////////////////////////////////////////////////////////////////// |
| 83 // CustomFrameView, public: | 83 // CustomFrameView, public: |
| 84 | 84 |
| 85 CustomFrameView::CustomFrameView() | 85 CustomFrameView::CustomFrameView() |
| 86 : frame_(NULL), | 86 : frame_(NULL), |
| 87 window_icon_(NULL), | 87 window_icon_(NULL), |
| 88 minimize_button_(NULL), | 88 minimize_button_(NULL), |
| 89 maximize_button_(NULL), | 89 maximize_button_(NULL), |
| 90 restore_button_(NULL), | 90 restore_button_(NULL), |
| 91 close_button_(NULL), | 91 close_button_(NULL), |
| 92 should_show_maximize_button_(false), | |
| 93 frame_background_(new FrameBackground()), | 92 frame_background_(new FrameBackground()), |
| 94 minimum_title_bar_x_(0), | 93 minimum_title_bar_x_(0), |
| 95 maximum_title_bar_x_(-1) { | 94 maximum_title_bar_x_(-1) { |
| 96 } | 95 } |
| 97 | 96 |
| 98 CustomFrameView::~CustomFrameView() { | 97 CustomFrameView::~CustomFrameView() { |
| 99 } | 98 } |
| 100 | 99 |
| 101 void CustomFrameView::Init(Widget* frame) { | 100 void CustomFrameView::Init(Widget* frame) { |
| 102 frame_ = frame; | 101 frame_ = frame; |
| 103 | 102 |
| 104 close_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_CLOSE, | 103 close_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_CLOSE, |
| 105 IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P); | 104 IDR_CLOSE, IDR_CLOSE_H, IDR_CLOSE_P); |
| 106 minimize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MINIMIZE, | 105 minimize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MINIMIZE, |
| 107 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P); | 106 IDR_MINIMIZE, IDR_MINIMIZE_H, IDR_MINIMIZE_P); |
| 108 maximize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MAXIMIZE, | 107 maximize_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_MAXIMIZE, |
| 109 IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P); | 108 IDR_MAXIMIZE, IDR_MAXIMIZE_H, IDR_MAXIMIZE_P); |
| 110 restore_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_RESTORE, | 109 restore_button_ = InitWindowCaptionButton(IDS_APP_ACCNAME_RESTORE, |
| 111 IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P); | 110 IDR_RESTORE, IDR_RESTORE_H, IDR_RESTORE_P); |
| 112 | 111 |
| 113 should_show_maximize_button_ = frame_->widget_delegate()->CanMaximize(); | |
| 114 | |
| 115 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { | 112 if (frame_->widget_delegate()->ShouldShowWindowIcon()) { |
| 116 window_icon_ = new ImageButton(this); | 113 window_icon_ = new ImageButton(this); |
| 117 AddChildView(window_icon_); | 114 AddChildView(window_icon_); |
| 118 } | 115 } |
| 119 } | 116 } |
| 120 | 117 |
| 121 /////////////////////////////////////////////////////////////////////////////// | 118 /////////////////////////////////////////////////////////////////////////////// |
| 122 // CustomFrameView, NonClientFrameView implementation: | 119 // CustomFrameView, NonClientFrameView implementation: |
| 123 | 120 |
| 124 gfx::Rect CustomFrameView::GetBoundsForClientView() const { | 121 gfx::Rect CustomFrameView::GetBoundsForClientView() const { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 | 174 |
| 178 void CustomFrameView::GetWindowMask(const gfx::Size& size, | 175 void CustomFrameView::GetWindowMask(const gfx::Size& size, |
| 179 gfx::Path* window_mask) { | 176 gfx::Path* window_mask) { |
| 180 DCHECK(window_mask); | 177 DCHECK(window_mask); |
| 181 if (frame_->IsMaximized() || !ShouldShowTitleBarAndBorder()) | 178 if (frame_->IsMaximized() || !ShouldShowTitleBarAndBorder()) |
| 182 return; | 179 return; |
| 183 | 180 |
| 184 GetDefaultWindowMask(size, window_mask); | 181 GetDefaultWindowMask(size, window_mask); |
| 185 } | 182 } |
| 186 | 183 |
| 187 void CustomFrameView::ResetWindowControls() { | 184 void CustomFrameView::ResetWindowControls() { |
|
sky
2014/09/09 15:42:32
Currently ResetWindowControls is:
// Tells the w
jackhou1
2014/09/10 00:49:15
Done.
Is it okay to have an empty implementation
| |
| 188 restore_button_->SetState(CustomButton::STATE_NORMAL); | 185 restore_button_->SetState(CustomButton::STATE_NORMAL); |
| 189 minimize_button_->SetState(CustomButton::STATE_NORMAL); | 186 minimize_button_->SetState(CustomButton::STATE_NORMAL); |
| 190 maximize_button_->SetState(CustomButton::STATE_NORMAL); | 187 maximize_button_->SetState(CustomButton::STATE_NORMAL); |
| 191 // The close button isn't affected by this constraint. | 188 // The close button isn't affected by this constraint. |
| 189 | |
| 190 LayoutWindowControls(); | |
| 192 } | 191 } |
| 193 | 192 |
| 194 void CustomFrameView::UpdateWindowIcon() { | 193 void CustomFrameView::UpdateWindowIcon() { |
| 195 if (window_icon_) | 194 if (window_icon_) |
| 196 window_icon_->SchedulePaint(); | 195 window_icon_->SchedulePaint(); |
| 197 } | 196 } |
| 198 | 197 |
| 199 void CustomFrameView::UpdateWindowTitle() { | 198 void CustomFrameView::UpdateWindowTitle() { |
| 200 if (frame_->widget_delegate()->ShouldShowWindowTitle()) | 199 if (frame_->widget_delegate()->ShouldShowWindowTitle()) |
| 201 SchedulePaintInRect(title_bounds_); | 200 SchedulePaintInRect(title_bounds_); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 ImageButton* CustomFrameView::GetImageButton(views::FrameButton frame_button) { | 594 ImageButton* CustomFrameView::GetImageButton(views::FrameButton frame_button) { |
| 596 ImageButton* button = NULL; | 595 ImageButton* button = NULL; |
| 597 switch (frame_button) { | 596 switch (frame_button) { |
| 598 case views::FRAME_BUTTON_MINIMIZE: { | 597 case views::FRAME_BUTTON_MINIMIZE: { |
| 599 button = minimize_button_; | 598 button = minimize_button_; |
| 600 break; | 599 break; |
| 601 } | 600 } |
| 602 case views::FRAME_BUTTON_MAXIMIZE: { | 601 case views::FRAME_BUTTON_MAXIMIZE: { |
| 603 bool is_restored = !frame_->IsMaximized() && !frame_->IsMinimized(); | 602 bool is_restored = !frame_->IsMaximized() && !frame_->IsMinimized(); |
| 604 button = is_restored ? maximize_button_ : restore_button_; | 603 button = is_restored ? maximize_button_ : restore_button_; |
| 605 if (!should_show_maximize_button_) { | 604 // If we should not show the maximize/restore button, then we return |
| 606 // If we should not show the maximize/restore button, then we return | 605 // NULL as we don't want this button to become visible and to be laid |
| 607 // NULL as we don't want this button to become visible and to be laid | 606 // out. |
| 608 // out. | 607 bool should_show = frame_->widget_delegate()->CanMaximize(); |
| 609 button->SetVisible(false); | 608 button->SetVisible(should_show); |
| 609 if (!should_show) | |
| 610 return NULL; | 610 return NULL; |
| 611 } | 611 |
| 612 break; | 612 break; |
| 613 } | 613 } |
| 614 case views::FRAME_BUTTON_CLOSE: { | 614 case views::FRAME_BUTTON_CLOSE: { |
| 615 button = close_button_; | 615 button = close_button_; |
| 616 break; | 616 break; |
| 617 } | 617 } |
| 618 } | 618 } |
| 619 return button; | 619 return button; |
| 620 } | 620 } |
| 621 | 621 |
| 622 } // namespace views | 622 } // namespace views |
| OLD | NEW |