Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: ui/views/window/custom_frame_view.cc

Issue 554183002: Update the maximize button when size constraints change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update NativeWidgetMac. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/window/custom_frame_view.h ('k') | ui/views/window/native_frame_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 void CustomFrameView::UpdateWindowIcon() { 191 void CustomFrameView::UpdateWindowIcon() {
195 if (window_icon_) 192 if (window_icon_)
196 window_icon_->SchedulePaint(); 193 window_icon_->SchedulePaint();
197 } 194 }
198 195
199 void CustomFrameView::UpdateWindowTitle() { 196 void CustomFrameView::UpdateWindowTitle() {
200 if (frame_->widget_delegate()->ShouldShowWindowTitle()) 197 if (frame_->widget_delegate()->ShouldShowWindowTitle())
201 SchedulePaintInRect(title_bounds_); 198 SchedulePaintInRect(title_bounds_);
202 } 199 }
203 200
201 void CustomFrameView::SizeConstraintsChanged() {
202 ResetWindowControls();
203 LayoutWindowControls();
204 }
205
204 /////////////////////////////////////////////////////////////////////////////// 206 ///////////////////////////////////////////////////////////////////////////////
205 // CustomFrameView, View overrides: 207 // CustomFrameView, View overrides:
206 208
207 void CustomFrameView::OnPaint(gfx::Canvas* canvas) { 209 void CustomFrameView::OnPaint(gfx::Canvas* canvas) {
208 if (!ShouldShowTitleBarAndBorder()) 210 if (!ShouldShowTitleBarAndBorder())
209 return; 211 return;
210 212
211 if (frame_->IsMaximized()) 213 if (frame_->IsMaximized())
212 PaintMaximizedFrameBorder(canvas); 214 PaintMaximizedFrameBorder(canvas);
213 else 215 else
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 ImageButton* CustomFrameView::GetImageButton(views::FrameButton frame_button) { 597 ImageButton* CustomFrameView::GetImageButton(views::FrameButton frame_button) {
596 ImageButton* button = NULL; 598 ImageButton* button = NULL;
597 switch (frame_button) { 599 switch (frame_button) {
598 case views::FRAME_BUTTON_MINIMIZE: { 600 case views::FRAME_BUTTON_MINIMIZE: {
599 button = minimize_button_; 601 button = minimize_button_;
600 break; 602 break;
601 } 603 }
602 case views::FRAME_BUTTON_MAXIMIZE: { 604 case views::FRAME_BUTTON_MAXIMIZE: {
603 bool is_restored = !frame_->IsMaximized() && !frame_->IsMinimized(); 605 bool is_restored = !frame_->IsMaximized() && !frame_->IsMinimized();
604 button = is_restored ? maximize_button_ : restore_button_; 606 button = is_restored ? maximize_button_ : restore_button_;
605 if (!should_show_maximize_button_) { 607 // 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 608 // 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 609 // out.
608 // out. 610 bool should_show = frame_->widget_delegate()->CanMaximize();
609 button->SetVisible(false); 611 button->SetVisible(should_show);
612 if (!should_show)
610 return NULL; 613 return NULL;
611 } 614
612 break; 615 break;
613 } 616 }
614 case views::FRAME_BUTTON_CLOSE: { 617 case views::FRAME_BUTTON_CLOSE: {
615 button = close_button_; 618 button = close_button_;
616 break; 619 break;
617 } 620 }
618 } 621 }
619 return button; 622 return button;
620 } 623 }
621 624
622 } // namespace views 625 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/window/custom_frame_view.h ('k') | ui/views/window/native_frame_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698