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

Side by Side Diff: chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc

Issue 10447053: Converts remainder of ui and chrome/browser/ui/views/frame to use ImageSkia (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
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 "chrome/browser/ui/views/frame/app_panel_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/app_panel_browser_frame_view.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/ui/views/frame/browser_frame.h" 9 #include "chrome/browser/ui/views/frame/browser_frame.h"
10 #include "chrome/browser/ui/views/frame/browser_view.h" 10 #include "chrome/browser/ui/views/frame/browser_view.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // AppPanelBrowserFrameView, TabIconView::TabContentsProvider implementation: 240 // AppPanelBrowserFrameView, TabIconView::TabContentsProvider implementation:
241 241
242 bool AppPanelBrowserFrameView::ShouldTabIconViewAnimate() const { 242 bool AppPanelBrowserFrameView::ShouldTabIconViewAnimate() const {
243 // This function is queried during the creation of the window as the 243 // This function is queried during the creation of the window as the
244 // TabIconView we host is initialized, so we need to NULL check the selected 244 // TabIconView we host is initialized, so we need to NULL check the selected
245 // WebContents because in this condition there is not yet a selected tab. 245 // WebContents because in this condition there is not yet a selected tab.
246 WebContents* current_tab = browser_view()->GetSelectedWebContents(); 246 WebContents* current_tab = browser_view()->GetSelectedWebContents();
247 return current_tab ? current_tab->IsLoading() : false; 247 return current_tab ? current_tab->IsLoading() : false;
248 } 248 }
249 249
250 SkBitmap AppPanelBrowserFrameView::GetFaviconForTabIconView() { 250 gfx::ImageSkia AppPanelBrowserFrameView::GetFaviconForTabIconView() {
251 return frame()->widget_delegate()->GetWindowIcon(); 251 return frame()->widget_delegate()->GetWindowIcon();
252 } 252 }
253 253
254 /////////////////////////////////////////////////////////////////////////////// 254 ///////////////////////////////////////////////////////////////////////////////
255 // AppPanelBrowserFrameView, private: 255 // AppPanelBrowserFrameView, private:
256 256
257 int AppPanelBrowserFrameView::FrameBorderThickness() const { 257 int AppPanelBrowserFrameView::FrameBorderThickness() const {
258 return frame()->IsMaximized() ? 0 : kFrameBorderThickness; 258 return frame()->IsMaximized() ? 0 : kFrameBorderThickness;
259 } 259 }
260 260
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 // border + padding (or nothing at all, for maximized windows) above; hence 304 // border + padding (or nothing at all, for maximized windows) above; hence
305 // the +1. 305 // the +1.
306 int y = unavailable_px_at_top + (NonClientTopBorderHeight() - 306 int y = unavailable_px_at_top + (NonClientTopBorderHeight() -
307 unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2; 307 unavailable_px_at_top - size - TitlebarBottomThickness() + 1) / 2;
308 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size); 308 return gfx::Rect(frame_thickness + kIconLeftSpacing, y, size, size);
309 } 309 }
310 310
311 void AppPanelBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) { 311 void AppPanelBrowserFrameView::PaintRestoredFrameBorder(gfx::Canvas* canvas) {
312 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 312 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
313 313
314 SkBitmap* top_left_corner = rb.GetBitmapNamed(IDR_WINDOW_TOP_LEFT_CORNER); 314 gfx::ImageSkia* top_left_corner =
315 SkBitmap* top_right_corner = 315 rb.GetImageSkiaNamed(IDR_WINDOW_TOP_LEFT_CORNER);
316 rb.GetBitmapNamed(IDR_WINDOW_TOP_RIGHT_CORNER); 316 gfx::ImageSkia* top_right_corner =
317 SkBitmap* top_edge = rb.GetBitmapNamed(IDR_WINDOW_TOP_CENTER); 317 rb.GetImageSkiaNamed(IDR_WINDOW_TOP_RIGHT_CORNER);
318 SkBitmap* right_edge = rb.GetBitmapNamed(IDR_WINDOW_RIGHT_SIDE); 318 gfx::ImageSkia* top_edge = rb.GetImageSkiaNamed(IDR_WINDOW_TOP_CENTER);
319 SkBitmap* left_edge = rb.GetBitmapNamed(IDR_WINDOW_LEFT_SIDE); 319 gfx::ImageSkia* right_edge = rb.GetImageSkiaNamed(IDR_WINDOW_RIGHT_SIDE);
320 SkBitmap* bottom_left_corner = 320 gfx::ImageSkia* left_edge = rb.GetImageSkiaNamed(IDR_WINDOW_LEFT_SIDE);
321 rb.GetBitmapNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER); 321 gfx::ImageSkia* bottom_left_corner =
322 SkBitmap* bottom_right_corner = 322 rb.GetImageSkiaNamed(IDR_WINDOW_BOTTOM_LEFT_CORNER);
323 rb.GetBitmapNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER); 323 gfx::ImageSkia* bottom_right_corner =
324 SkBitmap* bottom_edge = rb.GetBitmapNamed(IDR_WINDOW_BOTTOM_CENTER); 324 rb.GetImageSkiaNamed(IDR_WINDOW_BOTTOM_RIGHT_CORNER);
325 gfx::ImageSkia* bottom_edge = rb.GetImageSkiaNamed(IDR_WINDOW_BOTTOM_CENTER);
325 326
326 // Window frame mode and color. 327 // Window frame mode and color.
327 SkBitmap* theme_frame; 328 gfx::ImageSkia* theme_frame;
328 SkColor frame_color; 329 SkColor frame_color;
329 if (ShouldPaintAsActive()) { 330 if (ShouldPaintAsActive()) {
330 theme_frame = rb.GetBitmapNamed(IDR_FRAME_APP_PANEL); 331 theme_frame = rb.GetImageSkiaNamed(IDR_FRAME_APP_PANEL);
331 frame_color = kFrameColorAppPanel; 332 frame_color = kFrameColorAppPanel;
332 } else { 333 } else {
333 theme_frame = rb.GetBitmapNamed(IDR_FRAME_APP_PANEL); 334 theme_frame = rb.GetImageSkiaNamed(IDR_FRAME_APP_PANEL);
334 frame_color = kFrameColorAppPanelInactive; 335 frame_color = kFrameColorAppPanelInactive;
335 } 336 }
336 337
337 // Fill with the frame color first so we have a constant background for 338 // Fill with the frame color first so we have a constant background for
338 // areas not covered by the theme image. 339 // areas not covered by the theme image.
339 canvas->FillRect(gfx::Rect(0, 0, width(), theme_frame->height()), 340 canvas->FillRect(gfx::Rect(0, 0, width(), theme_frame->height()),
340 frame_color); 341 frame_color);
341 342
342 int remaining_height = height() - theme_frame->height(); 343 int remaining_height = height() - theme_frame->height();
343 if (remaining_height > 0) { 344 if (remaining_height > 0) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 385
385 // Left. 386 // Left.
386 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), 387 canvas->TileImageInt(*left_edge, 0, top_left_corner->height(),
387 left_edge->width(), 388 left_edge->width(),
388 height() - top_left_corner->height() - bottom_left_corner->height()); 389 height() - top_left_corner->height() - bottom_left_corner->height());
389 } 390 }
390 391
391 void AppPanelBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) { 392 void AppPanelBrowserFrameView::PaintMaximizedFrameBorder(gfx::Canvas* canvas) {
392 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 393 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
393 394
394 SkBitmap* frame_image = rb.GetBitmapNamed(IDR_FRAME_APP_PANEL); 395 gfx::ImageSkia* frame_image = rb.GetImageSkiaNamed(IDR_FRAME_APP_PANEL);
395 canvas->TileImageInt(*frame_image, 0, FrameBorderThickness(), width(), 396 canvas->TileImageInt(*frame_image, 0, FrameBorderThickness(), width(),
396 frame_image->height()); 397 frame_image->height());
397 398
398 // The bottom of the titlebar actually comes from the top of the Client Edge 399 // The bottom of the titlebar actually comes from the top of the Client Edge
399 // graphic, with the actual client edge clipped off the bottom. 400 // graphic, with the actual client edge clipped off the bottom.
400 SkBitmap* titlebar_bottom = rb.GetBitmapNamed(IDR_APP_TOP_CENTER); 401 gfx::ImageSkia* titlebar_bottom = rb.GetImageSkiaNamed(IDR_APP_TOP_CENTER);
401 int edge_height = titlebar_bottom->height() - kClientEdgeThickness; 402 int edge_height = titlebar_bottom->height() - kClientEdgeThickness;
402 canvas->TileImageInt(*titlebar_bottom, 0, 403 canvas->TileImageInt(*titlebar_bottom, 0,
403 frame()->client_view()->y() - edge_height, 404 frame()->client_view()->y() - edge_height,
404 width(), edge_height); 405 width(), edge_height);
405 } 406 }
406 407
407 void AppPanelBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) { 408 void AppPanelBrowserFrameView::PaintTitleBar(gfx::Canvas* canvas) {
408 // The window icon is painted by the TabIconView. 409 // The window icon is painted by the TabIconView.
409 views::WidgetDelegate* d = frame()->widget_delegate(); 410 views::WidgetDelegate* d = frame()->widget_delegate();
410 canvas->DrawStringInt(d->GetWindowTitle(), BrowserFrame::GetTitleFont(), 411 canvas->DrawStringInt(d->GetWindowTitle(), BrowserFrame::GetTitleFont(),
411 SK_ColorBLACK, GetMirroredXForRect(title_bounds_), title_bounds_.y(), 412 SK_ColorBLACK, GetMirroredXForRect(title_bounds_), title_bounds_.y(),
412 title_bounds_.width(), title_bounds_.height()); 413 title_bounds_.width(), title_bounds_.height());
413 } 414 }
414 415
415 void AppPanelBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { 416 void AppPanelBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
416 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); 417 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
417 int client_area_top = client_area_bounds.y(); 418 int client_area_top = client_area_bounds.y();
418 419
419 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 420 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
420 SkBitmap* top_left = rb.GetBitmapNamed(IDR_APP_TOP_LEFT); 421 gfx::ImageSkia* top_left = rb.GetImageSkiaNamed(IDR_APP_TOP_LEFT);
421 SkBitmap* top = rb.GetBitmapNamed(IDR_APP_TOP_CENTER); 422 gfx::ImageSkia* top = rb.GetImageSkiaNamed(IDR_APP_TOP_CENTER);
422 SkBitmap* top_right = rb.GetBitmapNamed(IDR_APP_TOP_RIGHT); 423 gfx::ImageSkia* top_right = rb.GetImageSkiaNamed(IDR_APP_TOP_RIGHT);
423 SkBitmap* right = rb.GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); 424 gfx::ImageSkia* right = rb.GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE);
424 SkBitmap* bottom_right = 425 gfx::ImageSkia* bottom_right =
425 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER); 426 rb.GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER);
426 SkBitmap* bottom = rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_CENTER); 427 gfx::ImageSkia* bottom = rb.GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER);
427 SkBitmap* bottom_left = 428 gfx::ImageSkia* bottom_left =
428 rb.GetBitmapNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER); 429 rb.GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER);
429 SkBitmap* left = rb.GetBitmapNamed(IDR_CONTENT_LEFT_SIDE); 430 gfx::ImageSkia* left = rb.GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE);
430 431
431 // Top. 432 // Top.
432 int top_edge_y = client_area_top - top->height(); 433 int top_edge_y = client_area_top - top->height();
433 canvas->DrawBitmapInt(*top_left, client_area_bounds.x() - top_left->width(), 434 canvas->DrawBitmapInt(*top_left, client_area_bounds.x() - top_left->width(),
434 top_edge_y); 435 top_edge_y);
435 canvas->TileImageInt(*top, client_area_bounds.x(), top_edge_y, 436 canvas->TileImageInt(*top, client_area_bounds.x(), top_edge_y,
436 client_area_bounds.width(), top->height()); 437 client_area_bounds.width(), top->height());
437 canvas->DrawBitmapInt(*top_right, client_area_bounds.right(), top_edge_y); 438 canvas->DrawBitmapInt(*top_right, client_area_bounds.right(), top_edge_y);
438 439
439 // Right. 440 // Right.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 504 }
504 505
505 gfx::Rect AppPanelBrowserFrameView::CalculateClientAreaBounds(int width, 506 gfx::Rect AppPanelBrowserFrameView::CalculateClientAreaBounds(int width,
506 int height) const { 507 int height) const {
507 int top_height = NonClientTopBorderHeight(); 508 int top_height = NonClientTopBorderHeight();
508 int border_thickness = NonClientBorderThickness(); 509 int border_thickness = NonClientBorderThickness();
509 return gfx::Rect(border_thickness, top_height, 510 return gfx::Rect(border_thickness, top_height,
510 std::max(0, width - (2 * border_thickness)), 511 std::max(0, width - (2 * border_thickness)),
511 std::max(0, height - top_height - border_thickness)); 512 std::max(0, height - top_height - border_thickness));
512 } 513 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/app_panel_browser_frame_view.h ('k') | chrome/browser/ui/views/frame/browser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698