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

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

Issue 2099793002: mash: Migrate some system user files to common. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 4 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 side-by-side diff with in-line comments
Download patch
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
deleted file mode 100644
index 76f8fd1996f99f5b1cfba48d9b35190814b3f17b..0000000000000000000000000000000000000000
--- a/ash/system/user/button_from_view.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-// 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/common/ash_constants.h"
-#include "ash/common/system/tray/tray_constants.h"
-#include "ash/common/system/tray/tray_utils.h"
-#include "base/strings/string_util.h"
-#include "base/strings/utf_string_conversions.h"
-#include "ui/accessibility/ax_view_state.h"
-#include "ui/gfx/canvas.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,
- const gfx::Insets& tab_frame_inset)
- : CustomButton(listener),
- content_(content),
- highlight_on_hover_(highlight_on_hover),
- button_hovered_(false),
- show_border_(false),
- tab_frame_inset_(tab_frame_inset) {
- set_notify_enter_exit_on_child(true);
- SetLayoutManager(
- new views::BoxLayout(views::BoxLayout::kHorizontal, 1, 1, 0));
- AddChildView(content_);
- ShowActive();
- // Only make it focusable when we are active/interested in clicks.
- if (listener)
- SetFocusForPlatform();
-}
-
-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::OnPaint(gfx::Canvas* canvas) {
- View::OnPaint(canvas);
- if (HasFocus()) {
- gfx::Rect rect(GetLocalBounds());
- rect.Inset(tab_frame_inset_);
- canvas->DrawSolidFocusRect(rect, kFocusBorderColor);
- }
-}
-
-void ButtonFromView::OnFocus() {
- View::OnFocus();
- // Adding focus frame.
- SchedulePaint();
-}
-
-void ButtonFromView::OnBlur() {
- View::OnBlur();
- // Removing focus frame.
- SchedulePaint();
-}
-
-void ButtonFromView::GetAccessibleState(ui::AXViewState* state) {
- state->role = ui::AX_ROLE_BUTTON;
- std::vector<base::string16> labels;
- for (int i = 0; i < child_count(); ++i)
- GetAccessibleLabelFromDescendantViews(child_at(i), labels);
- state->name = base::JoinString(labels, base::ASCIIToUTF16(" "));
-}
-
-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

Powered by Google App Engine
This is Rietveld 408576698