| Index: ash/system/tray/tray_background_view.cc
|
| diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
|
| index e8b0f2fafe035b6f43f0a13f16798aa05605c4a0..c534e9c701ef19ec70005b5230f36514d5305a77 100644
|
| --- a/ash/system/tray/tray_background_view.cc
|
| +++ b/ash/system/tray/tray_background_view.cc
|
| @@ -21,7 +21,7 @@
|
| #include "ui/accessibility/ax_view_state.h"
|
| #include "ui/aura/window.h"
|
| #include "ui/aura/window_event_dispatcher.h"
|
| -#include "ui/base/resource/resource_bundle.h"
|
| +#include "ui/base/nine_image_painter_factory.h"
|
| #include "ui/base/ui_base_switches_util.h"
|
| #include "ui/compositor/layer.h"
|
| #include "ui/compositor/layer_animation_element.h"
|
| @@ -31,6 +31,7 @@
|
| #include "ui/gfx/canvas.h"
|
| #include "ui/gfx/image/image_skia.h"
|
| #include "ui/gfx/image/image_skia_operations.h"
|
| +#include "ui/gfx/nine_image_painter.h"
|
| #include "ui/gfx/rect.h"
|
| #include "ui/gfx/screen.h"
|
| #include "ui/gfx/skia_util.h"
|
| @@ -100,53 +101,6 @@ class TrayBackground : public views::Background {
|
| explicit TrayBackground(TrayBackgroundView* tray_background_view) :
|
| tray_background_view_(tray_background_view) {
|
| set_alpha(kTrayBackgroundAlpha);
|
| - ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| - leading_images_[kImageHorizontal][kImageTypeDefault] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_LEFT).ToImageSkia();
|
| - middle_images_[kImageHorizontal][kImageTypeDefault] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_CENTER).ToImageSkia();
|
| - trailing_images_[kImageHorizontal][kImageTypeDefault] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_RIGHT).ToImageSkia();
|
| -
|
| - leading_images_[kImageHorizontal][kImageTypeOnBlack] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_LEFT_ONBLACK).ToImageSkia();
|
| - middle_images_[kImageHorizontal][kImageTypeOnBlack] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_CENTER_ONBLACK).ToImageSkia();
|
| - trailing_images_[kImageHorizontal][kImageTypeOnBlack] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_RIGHT_ONBLACK).ToImageSkia();
|
| -
|
| - leading_images_[kImageHorizontal][kImageTypePressed] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_LEFT_PRESSED).ToImageSkia();
|
| - middle_images_[kImageHorizontal][kImageTypePressed] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_CENTER_PRESSED).ToImageSkia();
|
| - trailing_images_[kImageHorizontal][kImageTypePressed] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_HORIZ_RIGHT_PRESSED).ToImageSkia();
|
| -
|
| - leading_images_[kImageVertical][kImageTypeDefault] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_VERTICAL_TOP).ToImageSkia();
|
| - middle_images_[kImageVertical][kImageTypeDefault] =
|
| - rb.GetImageNamed(
|
| - IDR_AURA_TRAY_BG_VERTICAL_CENTER).ToImageSkia();
|
| - trailing_images_[kImageVertical][kImageTypeDefault] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_VERTICAL_BOTTOM).ToImageSkia();
|
| -
|
| - leading_images_[kImageVertical][kImageTypeOnBlack] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_VERTICAL_TOP_ONBLACK).ToImageSkia();
|
| - middle_images_[kImageVertical][kImageTypeOnBlack] =
|
| - rb.GetImageNamed(
|
| - IDR_AURA_TRAY_BG_VERTICAL_CENTER_ONBLACK).ToImageSkia();
|
| - trailing_images_[kImageVertical][kImageTypeOnBlack] =
|
| - rb.GetImageNamed(
|
| - IDR_AURA_TRAY_BG_VERTICAL_BOTTOM_ONBLACK).ToImageSkia();
|
| -
|
| - leading_images_[kImageVertical][kImageTypePressed] =
|
| - rb.GetImageNamed(IDR_AURA_TRAY_BG_VERTICAL_TOP_PRESSED).ToImageSkia();
|
| - middle_images_[kImageVertical][kImageTypePressed] =
|
| - rb.GetImageNamed(
|
| - IDR_AURA_TRAY_BG_VERTICAL_CENTER_PRESSED).ToImageSkia();
|
| - trailing_images_[kImageVertical][kImageTypePressed] =
|
| - rb.GetImageNamed(
|
| - IDR_AURA_TRAY_BG_VERTICAL_BOTTOM_PRESSED).ToImageSkia();
|
| }
|
|
|
| ~TrayBackground() override {}
|
| @@ -163,6 +117,20 @@ class TrayBackground : public views::Background {
|
|
|
| // Overridden from views::Background.
|
| void Paint(gfx::Canvas* canvas, views::View* view) const override {
|
| + const int kGridSizeForPainter = 9;
|
| + const int kImages[kNumOrientations][kNumStates][kGridSizeForPainter] = {
|
| + { // Horizontal
|
| + IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ),
|
| + IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_ONBLACK),
|
| + IMAGE_GRID_HORIZONTAL(IDR_AURA_TRAY_BG_HORIZ_PRESSED),
|
| + },
|
| + { // Vertical
|
| + IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL),
|
| + IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_ONBLACK),
|
| + IMAGE_GRID_VERTICAL(IDR_AURA_TRAY_BG_VERTICAL_PRESSED),
|
| + }
|
| + };
|
| +
|
| int orientation = kImageHorizontal;
|
| ShelfWidget* shelf_widget = GetShelfWidget();
|
| if (shelf_widget &&
|
| @@ -177,57 +145,14 @@ class TrayBackground : public views::Background {
|
| else
|
| state = kImageTypeDefault;
|
|
|
| - const gfx::ImageSkia* leading = leading_images_[orientation][state];
|
| - const gfx::ImageSkia* middle = middle_images_[orientation][state];
|
| - const gfx::ImageSkia* trailing = trailing_images_[orientation][state];
|
| -
|
| - gfx::Rect bounds(view->GetLocalBounds());
|
| - gfx::Point leading_location, trailing_location;
|
| - gfx::Rect middle_bounds;
|
| -
|
| - if (orientation == kImageHorizontal) {
|
| - leading_location = gfx::Point(0, 0);
|
| - trailing_location = gfx::Point(bounds.width() - trailing->width(), 0);
|
| - middle_bounds = gfx::Rect(
|
| - leading->width(),
|
| - 0,
|
| - bounds.width() - (leading->width() + trailing->width()),
|
| - bounds.height());
|
| - } else {
|
| - leading_location = gfx::Point(0, 0);
|
| - trailing_location = gfx::Point(0, bounds.height() - trailing->height());
|
| - middle_bounds = gfx::Rect(
|
| - 0,
|
| - leading->height(),
|
| - bounds.width(),
|
| - bounds.height() - (leading->height() + trailing->height()));
|
| - }
|
| -
|
| - canvas->DrawImageInt(*leading,
|
| - leading_location.x(),
|
| - leading_location.y());
|
| -
|
| - canvas->DrawImageInt(*trailing,
|
| - trailing_location.x(),
|
| - trailing_location.y());
|
| -
|
| - canvas->TileImageInt(*middle,
|
| - middle_bounds.x(),
|
| - middle_bounds.y(),
|
| - middle_bounds.width(),
|
| - middle_bounds.height());
|
| + ui::CreateNineImagePainter(kImages[orientation][state])
|
| + ->Paint(canvas, view->GetLocalBounds());
|
| }
|
|
|
| SkColor color_;
|
| // Reference to the TrayBackgroundView for which this is a background.
|
| TrayBackgroundView* tray_background_view_;
|
|
|
| - // References to the images used as backgrounds, they are owned by the
|
| - // resource bundle class.
|
| - const gfx::ImageSkia* leading_images_[kNumOrientations][kNumStates];
|
| - const gfx::ImageSkia* middle_images_[kNumOrientations][kNumStates];
|
| - const gfx::ImageSkia* trailing_images_[kNumOrientations][kNumStates];
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(TrayBackground);
|
| };
|
|
|
|
|