blob: a61039f3e813653cfd83a5b06aac3fb819da6a6f [file] [log] [blame]
// Copyright 2019 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/login/ui/bottom_status_indicator.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "base/strings/string16.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
namespace ash {
BottomStatusIndicator::BottomStatusIndicator(TappedCallback on_tapped_callback)
: LabelButton(this, base::string16()),
on_tapped_callback_(std::move(on_tapped_callback)) {
label()->SetAutoColorReadabilityEnabled(false);
label()->SetFontList(
views::Label::GetDefaultFontList().DeriveWithSizeDelta(1));
label()->SetSubpixelRenderingEnabled(false);
SetFocusBehavior(FocusBehavior::ALWAYS);
SetVisible(false);
}
BottomStatusIndicator::~BottomStatusIndicator() = default;
void BottomStatusIndicator::SetIcon(const gfx::VectorIcon& vector_icon,
AshColorProvider::ContentLayerType type) {
SetImage(views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(
vector_icon, AshColorProvider::Get()->GetContentLayerColor(
type, AshColorProvider::AshColorMode::kDark)));
}
void BottomStatusIndicator::ButtonPressed(views::Button* sender,
const ui::Event& event) {
DCHECK(sender == this);
DCHECK(on_tapped_callback_);
on_tapped_callback_.Run();
}
void BottomStatusIndicator::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = role_;
node_data->SetName(label()->GetText());
}
} // namespace ash