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

Side by Side Diff: ash/wm/frame_painter.cc

Issue 9956063: Merge 130064 - Changes the maximize button to only minimize for panels. This resulted (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1084/src/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/frame_painter.h ('k') | ash/wm/panel_frame_view.cc » ('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 "ash/wm/frame_painter.h" 5 #include "ash/wm/frame_painter.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_window_ids.h" 8 #include "ash/shell_window_ids.h"
9 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "base/logging.h" // DCHECK 10 #include "base/logging.h" // DCHECK
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 int FramePainter::kInactiveWindowOpacity = 166; 126 int FramePainter::kInactiveWindowOpacity = 166;
127 int FramePainter::kSoloWindowOpacity = 230; 127 int FramePainter::kSoloWindowOpacity = 230;
128 std::set<FramePainter*>* FramePainter::instances_ = NULL; 128 std::set<FramePainter*>* FramePainter::instances_ = NULL;
129 129
130 /////////////////////////////////////////////////////////////////////////////// 130 ///////////////////////////////////////////////////////////////////////////////
131 // FramePainter, public: 131 // FramePainter, public:
132 132
133 FramePainter::FramePainter() 133 FramePainter::FramePainter()
134 : frame_(NULL), 134 : frame_(NULL),
135 window_icon_(NULL), 135 window_icon_(NULL),
136 maximize_button_(NULL), 136 size_button_(NULL),
137 close_button_(NULL), 137 close_button_(NULL),
138 window_(NULL), 138 window_(NULL),
139 button_separator_(NULL), 139 button_separator_(NULL),
140 top_left_corner_(NULL), 140 top_left_corner_(NULL),
141 top_edge_(NULL), 141 top_edge_(NULL),
142 top_right_corner_(NULL), 142 top_right_corner_(NULL),
143 header_left_edge_(NULL), 143 header_left_edge_(NULL),
144 header_right_edge_(NULL), 144 header_right_edge_(NULL),
145 previous_theme_frame_(NULL), 145 previous_theme_frame_(NULL),
146 previous_opacity_(0), 146 previous_opacity_(0),
147 crossfade_theme_frame_(NULL), 147 crossfade_theme_frame_(NULL),
148 crossfade_opacity_(0), 148 crossfade_opacity_(0),
149 crossfade_animation_(NULL) { 149 crossfade_animation_(NULL),
150 size_button_behavior_(SIZE_BUTTON_MAXIMIZES) {
150 if (!instances_) 151 if (!instances_)
151 instances_ = new std::set<FramePainter*>(); 152 instances_ = new std::set<FramePainter*>();
152 instances_->insert(this); 153 instances_->insert(this);
153 } 154 }
154 155
155 FramePainter::~FramePainter() { 156 FramePainter::~FramePainter() {
156 // Sometimes we are destroyed before the window closes, so ensure we clean up. 157 // Sometimes we are destroyed before the window closes, so ensure we clean up.
157 if (window_) 158 if (window_)
158 window_->RemoveObserver(this); 159 window_->RemoveObserver(this);
159 instances_->erase(this); 160 instances_->erase(this);
160 } 161 }
161 162
162 void FramePainter::Init(views::Widget* frame, 163 void FramePainter::Init(views::Widget* frame,
163 views::View* window_icon, 164 views::View* window_icon,
164 views::ImageButton* maximize_button, 165 views::ImageButton* maximize_button,
165 views::ImageButton* close_button) { 166 views::ImageButton* close_button,
167 SizeButtonBehavior behavior) {
166 DCHECK(frame); 168 DCHECK(frame);
167 // window_icon may be NULL. 169 // window_icon may be NULL.
168 DCHECK(maximize_button); 170 DCHECK(maximize_button);
169 DCHECK(close_button); 171 DCHECK(close_button);
170 frame_ = frame; 172 frame_ = frame;
171 window_icon_ = window_icon; 173 window_icon_ = window_icon;
172 maximize_button_ = maximize_button; 174 size_button_ = maximize_button;
173 close_button_ = close_button; 175 close_button_ = close_button;
176 size_button_behavior_ = behavior;
174 177
175 // Window frame image parts. 178 // Window frame image parts.
176 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 179 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
177 button_separator_ = 180 button_separator_ =
178 rb.GetImageNamed(IDR_AURA_WINDOW_BUTTON_SEPARATOR).ToSkBitmap(); 181 rb.GetImageNamed(IDR_AURA_WINDOW_BUTTON_SEPARATOR).ToSkBitmap();
179 top_left_corner_ = 182 top_left_corner_ =
180 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP_LEFT).ToSkBitmap(); 183 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP_LEFT).ToSkBitmap();
181 top_edge_ = 184 top_edge_ =
182 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP).ToSkBitmap(); 185 rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_TOP).ToSkBitmap();
183 top_right_corner_ = 186 top_right_corner_ =
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 return frame_component; 254 return frame_component;
252 255
253 int client_component = frame_->client_view()->NonClientHitTest(point); 256 int client_component = frame_->client_view()->NonClientHitTest(point);
254 if (client_component != HTNOWHERE) 257 if (client_component != HTNOWHERE)
255 return client_component; 258 return client_component;
256 259
257 // Then see if the point is within any of the window controls. 260 // Then see if the point is within any of the window controls.
258 if (close_button_->visible() && 261 if (close_button_->visible() &&
259 close_button_->GetMirroredBounds().Contains(point)) 262 close_button_->GetMirroredBounds().Contains(point))
260 return HTCLOSE; 263 return HTCLOSE;
261 if (maximize_button_->visible() && 264 if (size_button_->visible() &&
262 maximize_button_->GetMirroredBounds().Contains(point)) 265 size_button_->GetMirroredBounds().Contains(point))
263 return HTMAXBUTTON; 266 return HTMAXBUTTON;
264 267
265 // Caption is a safe default. 268 // Caption is a safe default.
266 return HTCAPTION; 269 return HTCAPTION;
267 } 270 }
268 271
269 gfx::Size FramePainter::GetMinimumSize(views::NonClientFrameView* view) { 272 gfx::Size FramePainter::GetMinimumSize(views::NonClientFrameView* view) {
270 gfx::Size min_size = frame_->client_view()->GetMinimumSize(); 273 gfx::Size min_size = frame_->client_view()->GetMinimumSize();
271 // Ensure we can display the top of the caption area. 274 // Ensure we can display the top of the caption area.
272 gfx::Rect client_bounds = view->GetBoundsForClientView(); 275 gfx::Rect client_bounds = view->GetBoundsForClientView();
273 min_size.Enlarge(0, client_bounds.y()); 276 min_size.Enlarge(0, client_bounds.y());
274 // Ensure we have enough space for the window icon and buttons. We allow 277 // Ensure we have enough space for the window icon and buttons. We allow
275 // the title string to collapse to zero width. 278 // the title string to collapse to zero width.
276 int title_width = GetTitleOffsetX() + 279 int title_width = GetTitleOffsetX() +
277 maximize_button_->width() + 280 size_button_->width() +
278 button_separator_->width() + 281 button_separator_->width() +
279 close_button_->width(); 282 close_button_->width();
280 if (title_width > min_size.width()) 283 if (title_width > min_size.width())
281 min_size.set_width(title_width); 284 min_size.set_width(title_width);
282 return min_size; 285 return min_size;
283 } 286 }
284 287
285 void FramePainter::PaintHeader(views::NonClientFrameView* view, 288 void FramePainter::PaintHeader(views::NonClientFrameView* view,
286 gfx::Canvas* canvas, 289 gfx::Canvas* canvas,
287 HeaderMode header_mode, 290 HeaderMode header_mode,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 void FramePainter::PaintTitleBar(views::NonClientFrameView* view, 406 void FramePainter::PaintTitleBar(views::NonClientFrameView* view,
404 gfx::Canvas* canvas, 407 gfx::Canvas* canvas,
405 const gfx::Font& title_font) { 408 const gfx::Font& title_font) {
406 // The window icon is painted by its own views::View. 409 // The window icon is painted by its own views::View.
407 views::WidgetDelegate* delegate = frame_->widget_delegate(); 410 views::WidgetDelegate* delegate = frame_->widget_delegate();
408 if (delegate && delegate->ShouldShowWindowTitle()) { 411 if (delegate && delegate->ShouldShowWindowTitle()) {
409 int title_x = GetTitleOffsetX(); 412 int title_x = GetTitleOffsetX();
410 gfx::Rect title_bounds( 413 gfx::Rect title_bounds(
411 title_x, 414 title_x,
412 kTitleOffsetY, 415 kTitleOffsetY,
413 std::max(0, maximize_button_->x() - kTitleLogoSpacing - title_x), 416 std::max(0, size_button_->x() - kTitleLogoSpacing - title_x),
414 title_font.GetHeight()); 417 title_font.GetHeight());
415 canvas->DrawStringInt(delegate->GetWindowTitle(), 418 canvas->DrawStringInt(delegate->GetWindowTitle(),
416 title_font, 419 title_font,
417 kTitleTextColor, 420 kTitleTextColor,
418 view->GetMirroredXForRect(title_bounds), 421 view->GetMirroredXForRect(title_bounds),
419 title_bounds.y(), 422 title_bounds.y(),
420 title_bounds.width(), 423 title_bounds.width(),
421 title_bounds.height(), 424 title_bounds.height(),
422 gfx::Canvas::NO_SUBPIXEL_RENDERING); 425 gfx::Canvas::NO_SUBPIXEL_RENDERING);
423 } 426 }
424 } 427 }
425 428
426 void FramePainter::LayoutHeader(views::NonClientFrameView* view, 429 void FramePainter::LayoutHeader(views::NonClientFrameView* view,
427 bool maximized_layout) { 430 bool maximized_layout) {
428 // The maximized layout uses shorter buttons. 431 // The maximized layout uses shorter buttons.
429 if (maximized_layout) { 432 if (maximized_layout) {
430 SetButtonImages(close_button_, 433 SetButtonImages(close_button_,
431 IDR_AURA_WINDOW_MAXIMIZED_CLOSE, 434 IDR_AURA_WINDOW_MAXIMIZED_CLOSE,
432 IDR_AURA_WINDOW_MAXIMIZED_CLOSE_H, 435 IDR_AURA_WINDOW_MAXIMIZED_CLOSE_H,
433 IDR_AURA_WINDOW_MAXIMIZED_CLOSE_P); 436 IDR_AURA_WINDOW_MAXIMIZED_CLOSE_P);
434 SetButtonImages(maximize_button_, 437 // TODO: need images for SIZE_BUTTON_MINIMIZES.
438 SetButtonImages(size_button_,
435 IDR_AURA_WINDOW_MAXIMIZED_RESTORE, 439 IDR_AURA_WINDOW_MAXIMIZED_RESTORE,
436 IDR_AURA_WINDOW_MAXIMIZED_RESTORE_H, 440 IDR_AURA_WINDOW_MAXIMIZED_RESTORE_H,
437 IDR_AURA_WINDOW_MAXIMIZED_RESTORE_P); 441 IDR_AURA_WINDOW_MAXIMIZED_RESTORE_P);
438 } else { 442 } else {
439 SetButtonImages(close_button_, 443 SetButtonImages(close_button_,
440 IDR_AURA_WINDOW_CLOSE, 444 IDR_AURA_WINDOW_CLOSE,
441 IDR_AURA_WINDOW_CLOSE_H, 445 IDR_AURA_WINDOW_CLOSE_H,
442 IDR_AURA_WINDOW_CLOSE_P); 446 IDR_AURA_WINDOW_CLOSE_P);
443 SetButtonImages(maximize_button_, 447 // TODO: need images for SIZE_BUTTON_MINIMIZES.
448 SetButtonImages(size_button_,
444 IDR_AURA_WINDOW_MAXIMIZE, 449 IDR_AURA_WINDOW_MAXIMIZE,
445 IDR_AURA_WINDOW_MAXIMIZE_H, 450 IDR_AURA_WINDOW_MAXIMIZE_H,
446 IDR_AURA_WINDOW_MAXIMIZE_P); 451 IDR_AURA_WINDOW_MAXIMIZE_P);
447 } 452 }
448 453
449 gfx::Size close_size = close_button_->GetPreferredSize(); 454 gfx::Size close_size = close_button_->GetPreferredSize();
450 close_button_->SetBounds( 455 close_button_->SetBounds(
451 view->width() - close_size.width() - kCloseButtonOffsetX, 456 view->width() - close_size.width() - kCloseButtonOffsetX,
452 kCloseButtonOffsetY, 457 kCloseButtonOffsetY,
453 close_size.width(), 458 close_size.width(),
454 close_size.height()); 459 close_size.height());
455 460
456 gfx::Size maximize_size = maximize_button_->GetPreferredSize(); 461 gfx::Size size_button_size = size_button_->GetPreferredSize();
457 maximize_button_->SetBounds( 462 size_button_->SetBounds(
458 close_button_->x() - button_separator_->width() - maximize_size.width(), 463 close_button_->x() - button_separator_->width() -
464 size_button_size.width(),
459 close_button_->y(), 465 close_button_->y(),
460 maximize_size.width(), 466 size_button_size.width(),
461 maximize_size.height()); 467 size_button_size.height());
462 468
463 if (window_icon_) 469 if (window_icon_)
464 window_icon_->SetBoundsRect( 470 window_icon_->SetBoundsRect(
465 gfx::Rect(kIconOffsetX, kIconOffsetY, kIconSize, kIconSize)); 471 gfx::Rect(kIconOffsetX, kIconOffsetY, kIconSize, kIconSize));
466 } 472 }
467 473
468 /////////////////////////////////////////////////////////////////////////////// 474 ///////////////////////////////////////////////////////////////////////////////
469 // aura::WindowObserver overrides: 475 // aura::WindowObserver overrides:
470 476
471 void FramePainter::OnWindowPropertyChanged(aura::Window* window, 477 void FramePainter::OnWindowPropertyChanged(aura::Window* window,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 if (*it != ignore && IsVisibleNormalWindow(*it)) { 562 if (*it != ignore && IsVisibleNormalWindow(*it)) {
557 normal_window_count++; 563 normal_window_count++;
558 if (normal_window_count > 1) 564 if (normal_window_count > 1)
559 return false; 565 return false;
560 } 566 }
561 } 567 }
562 return normal_window_count == 1; 568 return normal_window_count == 1;
563 } 569 }
564 570
565 } // namespace ash 571 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/frame_painter.h ('k') | ash/wm/panel_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698