| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "views/window/custom_frame_view.h" | 5 #include "views/window/custom_frame_view.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas.h" | 7 #include "app/gfx/canvas.h" |
| 8 #include "app/gfx/font.h" | 8 #include "app/gfx/font.h" |
| 9 #include "app/gfx/path.h" | 9 #include "app/gfx/path.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 *title_thickness = std::max(title_font_->height(), | 292 *title_thickness = std::max(title_font_->height(), |
| 293 min_titlebar_height - *title_top_spacing - title_bottom_spacing); | 293 min_titlebar_height - *title_top_spacing - title_bottom_spacing); |
| 294 return *title_top_spacing + *title_thickness + title_bottom_spacing + | 294 return *title_top_spacing + *title_thickness + title_bottom_spacing + |
| 295 BottomEdgeThicknessWithinNonClientHeight(); | 295 BottomEdgeThicknessWithinNonClientHeight(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void CustomFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { | 298 void CustomFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { |
| 299 // Window frame mode. | 299 // Window frame mode. |
| 300 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 300 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 301 | 301 |
| 302 SkBitmap* theme_frame; | 302 SkBitmap* frame_image; |
| 303 SkColor frame_color; | 303 SkColor frame_color; |
| 304 | 304 |
| 305 if (frame_->IsActive()) { | 305 if (frame_->IsActive()) { |
| 306 theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME); | 306 frame_image = rb.GetBitmapNamed(IDR_FRAME); |
| 307 frame_color = ResourceBundle::frame_color; | 307 frame_color = ResourceBundle::frame_color; |
| 308 } else { | 308 } else { |
| 309 theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME_INACTIVE); | 309 frame_image = rb.GetBitmapNamed(IDR_FRAME_INACTIVE); |
| 310 frame_color = ResourceBundle::frame_color_inactive; | 310 frame_color = ResourceBundle::frame_color_inactive; |
| 311 } | 311 } |
| 312 | 312 |
| 313 SkBitmap* top_left_corner = rb.GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER); | 313 SkBitmap* top_left_corner = rb.GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER); |
| 314 SkBitmap* top_right_corner = | 314 SkBitmap* top_right_corner = |
| 315 rb.GetBitmapNamed(IDR_WINDOW_TOP_RIGHT_CORNER); | 315 rb.GetBitmapNamed(IDR_WINDOW_TOP_RIGHT_CORNER); |
| 316 SkBitmap* top_edge = rb.GetBitmapNamed(IDR_WINDOW_TOP_CENTER); | 316 SkBitmap* top_edge = rb.GetBitmapNamed(IDR_WINDOW_TOP_CENTER); |
| 317 SkBitmap* right_edge = rb.GetBitmapNamed(IDR_WINDOW_RIGHT_SIDE); | 317 SkBitmap* right_edge = rb.GetBitmapNamed(IDR_WINDOW_RIGHT_SIDE); |
| 318 SkBitmap* left_edge = rb.GetBitmapNamed(IDR_WINDOW_LEFT_SIDE); | 318 SkBitmap* left_edge = rb.GetBitmapNamed(IDR_WINDOW_LEFT_SIDE); |
| 319 SkBitmap* bottom_left_corner = | 319 SkBitmap* bottom_left_corner = |
| 320 rb.GetBitmapNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER); | 320 rb.GetBitmapNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER); |
| 321 SkBitmap* bottom_right_corner = | 321 SkBitmap* bottom_right_corner = |
| 322 rb.GetBitmapNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER); | 322 rb.GetBitmapNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER); |
| 323 SkBitmap* bottom_edge = rb.GetBitmapNamed(IDR_WINDOW_BOTTOM_CENTER); | 323 SkBitmap* bottom_edge = rb.GetBitmapNamed(IDR_WINDOW_BOTTOM_CENTER); |
| 324 | 324 |
| 325 // Fill with the frame color first so we have a constant background for | 325 // Fill with the frame color first so we have a constant background for |
| 326 // areas not covered by the theme image. | 326 // areas not covered by the theme image. |
| 327 canvas->FillRectInt(frame_color, 0, 0, width(), theme_frame->height()); | 327 canvas->FillRectInt(frame_color, 0, 0, width(), frame_image->height()); |
| 328 // Now fill down the sides | 328 // Now fill down the sides |
| 329 canvas->FillRectInt(frame_color, | 329 canvas->FillRectInt(frame_color, |
| 330 0, theme_frame->height(), | 330 0, frame_image->height(), |
| 331 left_edge->width(), height() - theme_frame->height()); | 331 left_edge->width(), height() - frame_image->height()); |
| 332 canvas->FillRectInt(frame_color, | 332 canvas->FillRectInt(frame_color, |
| 333 width() - right_edge->width(), theme_frame->height(), | 333 width() - right_edge->width(), frame_image->height(), |
| 334 right_edge->width(), height() - theme_frame->height()); | 334 right_edge->width(), height() - frame_image->height()); |
| 335 // Now fill the bottom area. | 335 // Now fill the bottom area. |
| 336 canvas->FillRectInt(frame_color, | 336 canvas->FillRectInt(frame_color, |
| 337 left_edge->width(), height() - bottom_edge->height(), | 337 left_edge->width(), height() - bottom_edge->height(), |
| 338 width() - left_edge->width() - right_edge->width(), | 338 width() - left_edge->width() - right_edge->width(), |
| 339 bottom_edge->height()); | 339 bottom_edge->height()); |
| 340 | 340 |
| 341 // Draw the theme frame. | 341 // Draw the theme frame. |
| 342 canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); | 342 canvas->TileImageInt(*frame_image, 0, 0, width(), frame_image->height()); |
| 343 | 343 |
| 344 // Top. | 344 // Top. |
| 345 canvas->DrawBitmapInt(*top_left_corner, 0, 0); | 345 canvas->DrawBitmapInt(*top_left_corner, 0, 0); |
| 346 canvas->TileImageInt(*top_edge, top_left_corner->width(), 0, | 346 canvas->TileImageInt(*top_edge, top_left_corner->width(), 0, |
| 347 width() - top_right_corner->width(), top_edge->height()); | 347 width() - top_right_corner->width(), top_edge->height()); |
| 348 canvas->DrawBitmapInt(*top_right_corner, | 348 canvas->DrawBitmapInt(*top_right_corner, |
| 349 width() - top_right_corner->width(), 0); | 349 width() - top_right_corner->width(), 0); |
| 350 | 350 |
| 351 // Right. | 351 // Right. |
| 352 canvas->TileImageInt(*right_edge, width() - right_edge->width(), | 352 canvas->TileImageInt(*right_edge, width() - right_edge->width(), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 369 // Left. | 369 // Left. |
| 370 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), | 370 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), |
| 371 left_edge->width(), | 371 left_edge->width(), |
| 372 height() - top_left_corner->height() - bottom_left_corner->height()); | 372 height() - top_left_corner->height() - bottom_left_corner->height()); |
| 373 } | 373 } |
| 374 | 374 |
| 375 void CustomFrameView::PaintMaximizedFrameBorder( | 375 void CustomFrameView::PaintMaximizedFrameBorder( |
| 376 gfx::Canvas* canvas) { | 376 gfx::Canvas* canvas) { |
| 377 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 377 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 378 | 378 |
| 379 SkBitmap* theme_frame = frame_->IsActive() ? | 379 SkBitmap* frame_image = frame_->IsActive() ? |
| 380 rb.GetBitmapNamed(IDR_THEME_FRAME) : | 380 rb.GetBitmapNamed(IDR_FRAME) : |
| 381 rb.GetBitmapNamed(IDR_THEME_FRAME_INACTIVE); | 381 rb.GetBitmapNamed(IDR_FRAME_INACTIVE); |
| 382 | 382 |
| 383 canvas->TileImageInt(*theme_frame, 0, FrameBorderThickness(), width(), | 383 canvas->TileImageInt(*frame_image, 0, FrameBorderThickness(), width(), |
| 384 theme_frame->height()); | 384 frame_image->height()); |
| 385 | 385 |
| 386 // The bottom of the titlebar actually comes from the top of the Client Edge | 386 // The bottom of the titlebar actually comes from the top of the Client Edge |
| 387 // graphic, with the actual client edge clipped off the bottom. | 387 // graphic, with the actual client edge clipped off the bottom. |
| 388 SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER); | 388 SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER); |
| 389 int edge_height = titlebar_bottom->height() - kClientEdgeThickness; | 389 int edge_height = titlebar_bottom->height() - kClientEdgeThickness; |
| 390 canvas->TileImageInt(*titlebar_bottom, 0, | 390 canvas->TileImageInt(*titlebar_bottom, 0, |
| 391 frame_->GetClientView()->y() - edge_height, width(), edge_height); | 391 frame_->GetClientView()->y() - edge_height, width(), edge_height); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void CustomFrameView::PaintTitleBar(gfx::Canvas* canvas) { | 394 void CustomFrameView::PaintTitleBar(gfx::Canvas* canvas) { |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); | 591 title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); |
| 592 #elif defined(OS_LINUX) | 592 #elif defined(OS_LINUX) |
| 593 // TODO: need to resolve what font this is. | 593 // TODO: need to resolve what font this is. |
| 594 title_font_ = new gfx::Font(); | 594 title_font_ = new gfx::Font(); |
| 595 #endif | 595 #endif |
| 596 initialized = true; | 596 initialized = true; |
| 597 } | 597 } |
| 598 } | 598 } |
| 599 | 599 |
| 600 } // namespace views | 600 } // namespace views |
| OLD | NEW |