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

Unified Diff: ash/system/user/button_from_view.cc

Issue 210903003: Implemented system tray UI for new account management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge conflicts resolved. Created 6 years, 8 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/user/button_from_view.h ('k') | ash/system/user/config.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/user/button_from_view.cc
diff --git a/ash/system/user/button_from_view.cc b/ash/system/user/button_from_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..64b641d72c0aae006c3e97932f677b5c7cb36262
--- /dev/null
+++ b/ash/system/user/button_from_view.cc
@@ -0,0 +1,71 @@
+// Copyright 2014 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/user/button_from_view.h"
+
+#include "ash/system/tray/tray_constants.h"
+#include "ui/views/background.h"
+#include "ui/views/border.h"
+#include "ui/views/layout/box_layout.h"
+
+namespace ash {
+
+namespace {
+
+// The border color of the user button.
+const SkColor kBorderColor = 0xffdcdcdc;
+
+} // namespace
+
+namespace tray {
+
+ButtonFromView::ButtonFromView(views::View* content,
+ views::ButtonListener* listener,
+ bool highlight_on_hover)
+ : CustomButton(listener),
+ content_(content),
+ highlight_on_hover_(highlight_on_hover),
+ button_hovered_(false),
+ show_border_(false) {
+ set_notify_enter_exit_on_child(true);
+ SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
+ AddChildView(content_);
+ ShowActive();
+}
+
+ButtonFromView::~ButtonFromView() {}
+
+void ButtonFromView::ForceBorderVisible(bool show) {
+ show_border_ = show;
+ ShowActive();
+}
+
+void ButtonFromView::OnMouseEntered(const ui::MouseEvent& event) {
+ button_hovered_ = true;
+ ShowActive();
+}
+
+void ButtonFromView::OnMouseExited(const ui::MouseEvent& event) {
+ button_hovered_ = false;
+ ShowActive();
+}
+
+void ButtonFromView::ShowActive() {
+ bool border_visible =
+ (button_hovered_ && highlight_on_hover_) || show_border_;
+ SkColor border_color = border_visible ? kBorderColor : SK_ColorTRANSPARENT;
+ SetBorder(views::Border::CreateSolidBorder(1, border_color));
+ if (highlight_on_hover_) {
+ SkColor background_color =
+ button_hovered_ ? kHoverBackgroundColor : kBackgroundColor;
+ content_->set_background(
+ views::Background::CreateSolidBackground(background_color));
+ set_background(views::Background::CreateSolidBackground(background_color));
+ }
+ SchedulePaint();
+}
+
+} // namespace tray
+} // namespace ash
« no previous file with comments | « ash/system/user/button_from_view.h ('k') | ash/system/user/config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698