| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 SchedulePaint(); | 214 SchedulePaint(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 /////////////////////////////////////////////////////////////////////////////// | 217 /////////////////////////////////////////////////////////////////////////////// |
| 218 // CustomFrameView, View overrides: | 218 // CustomFrameView, View overrides: |
| 219 | 219 |
| 220 void CustomFrameView::OnPaint(gfx::Canvas* canvas) { | 220 void CustomFrameView::OnPaint(gfx::Canvas* canvas) { |
| 221 if (!ShouldShowTitleBarAndBorder()) | 221 if (!ShouldShowTitleBarAndBorder()) |
| 222 return; | 222 return; |
| 223 | 223 |
| 224 frame_background_->set_frame_color(GetFrameColor()); |
| 225 frame_background_->set_use_custom_frame(true); |
| 226 frame_background_->set_is_active(ShouldPaintAsActive()); |
| 227 frame_background_->set_incognito(false); |
| 228 const gfx::ImageSkia frame_image = GetFrameImage(); |
| 229 frame_background_->set_theme_image(frame_image); |
| 230 frame_background_->set_top_area_height(frame_image.height()); |
| 231 |
| 224 if (frame_->IsMaximized()) | 232 if (frame_->IsMaximized()) |
| 225 PaintMaximizedFrameBorder(canvas); | 233 PaintMaximizedFrameBorder(canvas); |
| 226 else | 234 else |
| 227 PaintRestoredFrameBorder(canvas); | 235 PaintRestoredFrameBorder(canvas); |
| 228 PaintTitleBar(canvas); | 236 PaintTitleBar(canvas); |
| 229 if (ShouldShowClientEdge()) | 237 if (ShouldShowClientEdge()) |
| 230 PaintRestoredClientEdge(canvas); | 238 PaintRestoredClientEdge(canvas); |
| 231 } | 239 } |
| 232 | 240 |
| 233 void CustomFrameView::Layout() { | 241 void CustomFrameView::Layout() { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 360 } |
| 353 | 361 |
| 354 return true; | 362 return true; |
| 355 } | 363 } |
| 356 | 364 |
| 357 bool CustomFrameView::ShouldShowClientEdge() const { | 365 bool CustomFrameView::ShouldShowClientEdge() const { |
| 358 return !frame_->IsMaximized() && ShouldShowTitleBarAndBorder(); | 366 return !frame_->IsMaximized() && ShouldShowTitleBarAndBorder(); |
| 359 } | 367 } |
| 360 | 368 |
| 361 void CustomFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { | 369 void CustomFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { |
| 362 frame_background_->set_frame_color(GetFrameColor()); | |
| 363 const gfx::ImageSkia frame_image = GetFrameImage(); | |
| 364 frame_background_->set_theme_image(frame_image); | |
| 365 frame_background_->set_top_area_height(frame_image.height()); | |
| 366 | |
| 367 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 370 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 368 | 371 |
| 369 frame_background_->SetCornerImages( | 372 frame_background_->SetCornerImages( |
| 370 rb.GetImageNamed(IDR_WINDOW_TOP_LEFT_CORNER).ToImageSkia(), | 373 rb.GetImageNamed(IDR_WINDOW_TOP_LEFT_CORNER).ToImageSkia(), |
| 371 rb.GetImageNamed(IDR_WINDOW_TOP_RIGHT_CORNER).ToImageSkia(), | 374 rb.GetImageNamed(IDR_WINDOW_TOP_RIGHT_CORNER).ToImageSkia(), |
| 372 rb.GetImageNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER).ToImageSkia(), | 375 rb.GetImageNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER).ToImageSkia(), |
| 373 rb.GetImageNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER).ToImageSkia()); | 376 rb.GetImageNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER).ToImageSkia()); |
| 374 frame_background_->SetSideImages( | 377 frame_background_->SetSideImages( |
| 375 rb.GetImageNamed(IDR_WINDOW_LEFT_SIDE).ToImageSkia(), | 378 rb.GetImageNamed(IDR_WINDOW_LEFT_SIDE).ToImageSkia(), |
| 376 rb.GetImageNamed(IDR_WINDOW_TOP_CENTER).ToImageSkia(), | 379 rb.GetImageNamed(IDR_WINDOW_TOP_CENTER).ToImageSkia(), |
| 377 rb.GetImageNamed(IDR_WINDOW_RIGHT_SIDE).ToImageSkia(), | 380 rb.GetImageNamed(IDR_WINDOW_RIGHT_SIDE).ToImageSkia(), |
| 378 rb.GetImageNamed(IDR_WINDOW_BOTTOM_CENTER).ToImageSkia()); | 381 rb.GetImageNamed(IDR_WINDOW_BOTTOM_CENTER).ToImageSkia()); |
| 379 | 382 |
| 380 frame_background_->PaintRestored(canvas, this); | 383 frame_background_->PaintRestored(canvas, this); |
| 381 } | 384 } |
| 382 | 385 |
| 383 void CustomFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { | 386 void CustomFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { |
| 384 const gfx::ImageSkia frame_image = GetFrameImage(); | |
| 385 frame_background_->set_theme_image(frame_image); | |
| 386 frame_background_->set_top_area_height(frame_image.height()); | |
| 387 frame_background_->PaintMaximized(canvas, this); | 387 frame_background_->PaintMaximized(canvas, this); |
| 388 | 388 |
| 389 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 389 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 390 | 390 |
| 391 // TODO(jamescook): Migrate this into FrameBackground. | 391 // TODO(jamescook): Migrate this into FrameBackground. |
| 392 // The bottom of the titlebar actually comes from the top of the Client Edge | 392 // The bottom of the titlebar actually comes from the top of the Client Edge |
| 393 // graphic, with the actual client edge clipped off the bottom. | 393 // graphic, with the actual client edge clipped off the bottom. |
| 394 const gfx::ImageSkia* titlebar_bottom = rb.GetImageNamed( | 394 const gfx::ImageSkia* titlebar_bottom = rb.GetImageNamed( |
| 395 IDR_APP_TOP_CENTER).ToImageSkia(); | 395 IDR_APP_TOP_CENTER).ToImageSkia(); |
| 396 int edge_height = titlebar_bottom->height() - | 396 int edge_height = titlebar_bottom->height() - |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 } | 638 } |
| 639 case views::FRAME_BUTTON_CLOSE: { | 639 case views::FRAME_BUTTON_CLOSE: { |
| 640 button = close_button_; | 640 button = close_button_; |
| 641 break; | 641 break; |
| 642 } | 642 } |
| 643 } | 643 } |
| 644 return button; | 644 return button; |
| 645 } | 645 } |
| 646 | 646 |
| 647 } // namespace views | 647 } // namespace views |
| OLD | NEW |