Index: ash/common/system/tray/tray_bar_button_with_title.cc |
diff --git a/ash/common/system/tray/tray_bar_button_with_title.cc b/ash/common/system/tray/tray_bar_button_with_title.cc |
deleted file mode 100644 |
index 1d8d48f66325a569e46cbf76837e390263a69ab5..0000000000000000000000000000000000000000 |
--- a/ash/common/system/tray/tray_bar_button_with_title.cc |
+++ /dev/null |
@@ -1,105 +0,0 @@ |
-// Copyright 2013 The Chromium Authors. All rights reserved. |
-// Use of this source code is governed by a BSD-style license that can be |
-// found in the LICENSE file. |
- |
-#include "ash/common/system/tray/tray_bar_button_with_title.h" |
- |
-#include <memory> |
- |
-#include "ash/common/system/tray/tray_constants.h" |
-#include "ui/base/resource/resource_bundle.h" |
-#include "ui/gfx/image/image_skia.h" |
-#include "ui/resources/grit/ui_resources.h" |
-#include "ui/views/controls/label.h" |
-#include "ui/views/painter.h" |
-#include "ui/views/resources/grit/views_resources.h" |
- |
-namespace ash { |
-namespace { |
- |
-const int kBarImagesActive[] = { |
- IDR_SLIDER_ACTIVE_LEFT, IDR_SLIDER_ACTIVE_CENTER, IDR_SLIDER_ACTIVE_RIGHT, |
-}; |
- |
-const int kBarImagesDisabled[] = { |
- IDR_SLIDER_DISABLED_LEFT, IDR_SLIDER_DISABLED_CENTER, |
- IDR_SLIDER_DISABLED_RIGHT, |
-}; |
- |
-} // namespace |
- |
-class TrayBarButtonWithTitle::TrayBarButton : public views::View { |
- public: |
- TrayBarButton(const int bar_active_images[], const int bar_disabled_images[]) |
- : views::View(), |
- bar_active_images_(bar_active_images), |
- bar_disabled_images_(bar_disabled_images), |
- painter_(new views::HorizontalPainter(bar_active_images_)) {} |
- ~TrayBarButton() override {} |
- |
- // Overriden from views::View: |
- void OnPaint(gfx::Canvas* canvas) override { |
- painter_->Paint(canvas, size()); |
- } |
- |
- void Update(bool control_on) { |
- painter_.reset(new views::HorizontalPainter( |
- control_on ? bar_active_images_ : bar_disabled_images_)); |
- SchedulePaint(); |
- } |
- |
- private: |
- const int* bar_active_images_; |
- const int* bar_disabled_images_; |
- std::unique_ptr<views::HorizontalPainter> painter_; |
- |
- DISALLOW_COPY_AND_ASSIGN(TrayBarButton); |
-}; |
- |
-TrayBarButtonWithTitle::TrayBarButtonWithTitle(views::ButtonListener* listener, |
- int title_id, |
- int width) |
- : views::CustomButton(listener), |
- image_(new TrayBarButton(kBarImagesActive, kBarImagesDisabled)), |
- title_(NULL), |
- width_(width) { |
- AddChildView(image_); |
- if (title_id != -1) { |
- title_ = new views::Label; |
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
- base::string16 text = rb.GetLocalizedString(title_id); |
- title_->SetText(text); |
- AddChildView(title_); |
- } |
- |
- image_height_ = ui::ResourceBundle::GetSharedInstance() |
- .GetImageNamed(kBarImagesActive[0]) |
- .ToImageSkia() |
- ->height(); |
-} |
- |
-TrayBarButtonWithTitle::~TrayBarButtonWithTitle() {} |
- |
-void TrayBarButtonWithTitle::UpdateButton(bool control_on) { |
- image_->Update(control_on); |
-} |
- |
-gfx::Size TrayBarButtonWithTitle::GetPreferredSize() const { |
- return gfx::Size(width_, kTrayPopupItemHeight); |
-} |
- |
-void TrayBarButtonWithTitle::Layout() { |
- gfx::Rect rect(GetContentsBounds()); |
- int bar_image_y = rect.height() / 2 - image_height_ / 2; |
- gfx::Rect bar_image_rect(rect.x(), bar_image_y, rect.width(), image_height_); |
- image_->SetBoundsRect(bar_image_rect); |
- if (title_) { |
- // The image_ has some empty space below the bar image, move the title |
- // a little bit up to look closer to the bar. |
- gfx::Size title_size = title_->GetPreferredSize(); |
- title_->SetBounds(rect.x(), bar_image_y + image_height_ - 3, rect.width(), |
- title_size.height()); |
- } |
-} |
- |
-} // namespace ash |