#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/color/chrome_color_provider_utils.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/toolbar/toolbar_ink_drop_util.h"
#include "components/user_education/common/user_education_class_properties.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/actions/actions.h"
#include "ui/base/menu_source_utils.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/models/image_model.h"
#include "ui/base/models/menu_model.h"
#include "ui/base/ui_base_features.h"
#include "ui/color/color_provider.h"
#include "ui/compositor/paint_recorder.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/text_utils.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/ink_drop_highlight.h"
#include "ui/views/animation/ink_drop_mask.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/label_button_border.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/widget/widget.h"
namespace {
constexpr int kBorderThicknessDpWithLabel = …;
constexpr int kBorderThicknessDpWithoutLabel = …;
class ToolbarButtonHighlightPathGenerator
: public views::HighlightPathGenerator { … };
}
ToolbarButton::ToolbarButton(PressedCallback callback)
: … { … }
ToolbarButton::ToolbarButton(PressedCallback callback,
std::unique_ptr<ui::MenuModel> model,
TabStripModel* tab_strip_model,
bool trigger_menu_on_long_press)
: … { … }
ToolbarButton::~ToolbarButton() = default;
void ToolbarButton::SetHighlight(const std::u16string& highlight_text,
std::optional<SkColor> highlight_color) { … }
void ToolbarButton::SetText(const std::u16string& text) { … }
void ToolbarButton::TouchUiChanged() { … }
void ToolbarButton::ClearHighlight() { … }
int ToolbarButton::GetRoundedCornerRadius() const { … }
float ToolbarButton::GetCornerRadiusFor(ToolbarButton::Edge edge) const { … }
void ToolbarButton::UpdateColorsAndInsets() { … }
SkColor ToolbarButton::GetForegroundColor(ButtonState state) const { … }
void ToolbarButton::UpdateIconsWithColors(const gfx::VectorIcon& icon,
SkColor normal_color,
SkColor hovered_color,
SkColor pressed_color,
SkColor disabled_color) { … }
int ToolbarButton::GetIconSize() const { … }
bool ToolbarButton::ShouldPaintBorder() const { … }
bool ToolbarButton::ShouldBlendHighlightColor() const { … }
bool ToolbarButton::ShouldDirectlyUseHighlightAsBackground() const { … }
std::optional<SkColor> ToolbarButton::GetHighlightTextColor() const { … }
std::optional<SkColor> ToolbarButton::GetHighlightBorderColor() const { … }
void ToolbarButton::SetVectorIcon(const gfx::VectorIcon& icon) { … }
void ToolbarButton::SetVectorIcons(const gfx::VectorIcon& icon,
const gfx::VectorIcon& touch_icon) { … }
void ToolbarButton::UpdateIcon() { … }
void ToolbarButton::UpdateIconsWithStandardColors(const gfx::VectorIcon& icon) { … }
void ToolbarButton::SetLabelSideSpacing(int spacing) { … }
void ToolbarButton::SetLayoutInsetDelta(const gfx::Insets& inset_delta) { … }
void ToolbarButton::SetLeadingMargin(int margin) { … }
void ToolbarButton::SetTrailingMargin(int margin) { … }
void ToolbarButton::ClearPendingMenu() { … }
bool ToolbarButton::IsMenuShowing() const { … }
std::optional<gfx::Insets> ToolbarButton::GetLayoutInsets() const { … }
void ToolbarButton::SetLayoutInsets(const std::optional<gfx::Insets>& insets) { … }
const gfx::Insets ToolbarButton::GetTargetInsets() const { … }
const gfx::Size ToolbarButton::GetTargetSize() const { … }
void ToolbarButton::OnBoundsChanged(const gfx::Rect& previous_bounds) { … }
void ToolbarButton::OnThemeChanged() { … }
gfx::Rect ToolbarButton::GetAnchorBoundsInScreen() const { … }
bool ToolbarButton::OnMousePressed(const ui::MouseEvent& event) { … }
bool ToolbarButton::OnMouseDragged(const ui::MouseEvent& event) { … }
void ToolbarButton::OnMouseReleased(const ui::MouseEvent& event) { … }
void ToolbarButton::OnMouseCaptureLost() { … }
void ToolbarButton::OnMouseExited(const ui::MouseEvent& event) { … }
void ToolbarButton::OnGestureEvent(ui::GestureEvent* event) { … }
void ToolbarButton::GetAccessibleNodeData(ui::AXNodeData* node_data) { … }
std::u16string ToolbarButton::GetTooltipText(const gfx::Point& p) const { … }
void ToolbarButton::ShowContextMenuForViewImpl(View* source,
const gfx::Point& point,
ui::MenuSourceType source_type) { … }
void ToolbarButton::AfterPropertyChange(const void* key, int64_t old_value) { … }
bool ToolbarButton::ShouldShowMenu() { … }
bool ToolbarButton::ShouldShowInkdropAfterIphInteraction() { … }
void ToolbarButton::ShowDropDownMenu(ui::MenuSourceType source_type) { … }
void ToolbarButton::OnMenuClosed() { … }
namespace {
constexpr base::TimeDelta kHighlightAnimationDuration = …;
SkColor FadeWithAnimation(SkColor color, const gfx::Animation& animation) { … }
}
ToolbarButton::HighlightColorAnimation::HighlightColorAnimation(
ToolbarButton* parent)
: … { … }
ToolbarButton::HighlightColorAnimation::~HighlightColorAnimation() = default;
void ToolbarButton::HighlightColorAnimation::Show(
std::optional<SkColor> highlight_color) { … }
void ToolbarButton::HighlightColorAnimation::Hide() { … }
std::optional<SkColor> ToolbarButton::HighlightColorAnimation::GetTextColor()
const { … }
std::optional<SkColor> ToolbarButton::HighlightColorAnimation::GetBorderColor()
const { … }
std::optional<SkColor>
ToolbarButton::HighlightColorAnimation::GetBackgroundColor() const { … }
std::optional<SkColor>
ToolbarButton::HighlightColorAnimation::GetInkDropBaseColor() const { … }
void ToolbarButton::HighlightColorAnimation::AnimationEnded(
const gfx::Animation* animation) { … }
void ToolbarButton::HighlightColorAnimation::AnimationProgressed(
const gfx::Animation* animation) { … }
bool ToolbarButton::HighlightColorAnimation::IsShown() const { … }
void ToolbarButton::HighlightColorAnimation::ClearHighlightColor() { … }
std::unique_ptr<views::ActionViewInterface>
ToolbarButton::GetActionViewInterface() { … }
ToolbarButtonActionViewInterface::ToolbarButtonActionViewInterface(
ToolbarButton* action_view)
: … { … }
void ToolbarButtonActionViewInterface::ActionItemChangedImpl(
actions::ActionItem* action_item) { … }
BEGIN_METADATA(…)