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

Unified Diff: ash/system/tray/tray_views.cc

Issue 9753019: ash: Add a bluetooth entry in the uber tray. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/tray/tray_views.h ('k') | ash/system/tray_accessibility.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/tray_views.cc
diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9e84c10145bfab8ae0d7b183270af5e08bf2b812
--- /dev/null
+++ b/ash/system/tray/tray_views.cc
@@ -0,0 +1,89 @@
+// Copyright (c) 2012 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/system/tray/tray_views.h"
+
+#include "ash/system/tray/tray_constants.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/layout/box_layout.h"
+#include "ui/views/layout/fill_layout.h"
+
+namespace ash {
+namespace internal {
+
+namespace {
+const int kIconPaddingLeft = 5;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// FixedWidthImageView
+
+FixedWidthImageView::FixedWidthImageView() {
+ SetHorizontalAlignment(views::ImageView::CENTER);
+ SetVerticalAlignment(views::ImageView::CENTER);
+}
+
+FixedWidthImageView::~FixedWidthImageView() {
+}
+
+gfx::Size FixedWidthImageView::GetPreferredSize() {
+ gfx::Size size = views::ImageView::GetPreferredSize();
+ return gfx::Size(kTrayPopupDetailsIconWidth, size.height());
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// HoverHighlightView
+
+HoverHighlightView::HoverHighlightView(ViewClickListener* listener)
+ : listener_(listener) {
+ set_notify_enter_exit_on_child(true);
+}
+
+HoverHighlightView::~HoverHighlightView() {
+}
+
+void HoverHighlightView::AddIconAndLabel(const SkBitmap& image,
+ const string16& text,
+ gfx::Font::FontStyle style) {
+ SetLayoutManager(new views::BoxLayout(
+ views::BoxLayout::kHorizontal, 0, 3, kIconPaddingLeft));
+ views::ImageView* image_view = new FixedWidthImageView;
+ image_view->SetImage(image);
+ AddChildView(image_view);
+
+ views::Label* label = new views::Label(text);
+ label->SetFont(label->font().DeriveFont(0, style));
+ AddChildView(label);
+}
+
+void HoverHighlightView::AddLabel(const string16& text) {
+ SetLayoutManager(new views::FillLayout());
+ views::Label* label = new views::Label(text);
+ label->set_border(views::Border::CreateEmptyBorder(
+ 5, kTrayPopupDetailsIconWidth + kIconPaddingLeft, 5, 0));
+ label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ AddChildView(label);
+}
+
+bool HoverHighlightView::OnMousePressed(const views::MouseEvent& event) {
+ if (!listener_)
+ return false;
+ listener_->ClickedOn(this);
+ return true;
+}
+
+void HoverHighlightView::OnMouseEntered(const views::MouseEvent& event) {
+ set_background(views::Background::CreateSolidBackground(
+ ash::kHoverBackgroundColor));
+ SchedulePaint();
+}
+
+void HoverHighlightView::OnMouseExited(const views::MouseEvent& event) {
+ set_background(NULL);
+ SchedulePaint();
+}
+
+} // namespace internal
+} // namespace ash
« no previous file with comments | « ash/system/tray/tray_views.h ('k') | ash/system/tray_accessibility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698