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