| Index: ash/system/palette/palette_tray.cc
|
| diff --git a/ash/system/palette/palette_tray.cc b/ash/system/palette/palette_tray.cc
|
| index c7da960ac4c17e251bf3cd51e389534e0df41df2..9c623809206254639f95e353559ed7b9ac8109d0 100644
|
| --- a/ash/system/palette/palette_tray.cc
|
| +++ b/ash/system/palette/palette_tray.cc
|
| @@ -153,6 +153,9 @@ PaletteTray::PaletteTray(Shelf* shelf)
|
|
|
| Shell::Get()->AddShellObserver(this);
|
| ui::InputDeviceManager::GetInstance()->AddObserver(this);
|
| +
|
| + if (!drag_controller())
|
| + set_drag_controller(base::MakeUnique<TrayDragController>(shelf));
|
| }
|
|
|
| PaletteTray::~PaletteTray() {
|
| @@ -163,68 +166,6 @@ PaletteTray::~PaletteTray() {
|
| Shell::Get()->RemoveShellObserver(this);
|
| }
|
|
|
| -bool PaletteTray::PerformAction(const ui::Event& event) {
|
| - if (bubble_) {
|
| - if (num_actions_in_bubble_ == 0)
|
| - RecordPaletteOptionsUsage(PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION);
|
| - HidePalette();
|
| - return true;
|
| - }
|
| -
|
| - return ShowPalette();
|
| -}
|
| -
|
| -bool PaletteTray::ShowPalette() {
|
| - if (bubble_)
|
| - return false;
|
| -
|
| - DCHECK(tray_container());
|
| -
|
| - views::TrayBubbleView::InitParams init_params;
|
| - init_params.delegate = this;
|
| - init_params.parent_window = GetBubbleWindowContainer();
|
| - init_params.anchor_view = GetBubbleAnchor();
|
| - init_params.anchor_alignment = GetAnchorAlignment();
|
| - init_params.min_width = kPaletteWidth;
|
| - init_params.max_width = kPaletteWidth;
|
| - init_params.close_on_deactivate = true;
|
| -
|
| - // TODO(tdanderson): Refactor into common row layout code.
|
| - // TODO(tdanderson|jdufault): Add material design ripple effects to the menu
|
| - // rows.
|
| -
|
| - // Create and customize bubble view.
|
| - views::TrayBubbleView* bubble_view = new views::TrayBubbleView(init_params);
|
| - bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets());
|
| - bubble_view->set_margins(
|
| - gfx::Insets(kPalettePaddingOnTop, 0, kPalettePaddingOnBottom, 0));
|
| -
|
| - // Add title.
|
| - auto* title_view = new TitleView(this);
|
| - title_view->SetBorder(views::CreateEmptyBorder(
|
| - gfx::Insets(0, kPaddingBetweenTitleAndLeftEdge, 0, 0)));
|
| - bubble_view->AddChildView(title_view);
|
| -
|
| - // Add horizontal separator.
|
| - views::Separator* separator = new views::Separator();
|
| - separator->SetColor(kPaletteSeparatorColor);
|
| - separator->SetBorder(views::CreateEmptyBorder(gfx::Insets(
|
| - kPaddingBetweenTitleAndSeparator, 0, kMenuSeparatorVerticalPadding, 0)));
|
| - bubble_view->AddChildView(separator);
|
| -
|
| - // Add palette tools.
|
| - // TODO(tdanderson|jdufault): Use SystemMenuButton to get the material design
|
| - // ripples.
|
| - std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews();
|
| - for (const PaletteToolView& view : views)
|
| - bubble_view->AddChildView(view.view);
|
| -
|
| - // Show the bubble.
|
| - bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view));
|
| - SetIsActive(true);
|
| - return true;
|
| -}
|
| -
|
| bool PaletteTray::ContainsPointInScreen(const gfx::Point& point) {
|
| if (icon_ && icon_->GetBoundsInScreen().Contains(point))
|
| return true;
|
| @@ -280,7 +221,7 @@ void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) {
|
| if (palette_delegate->ShouldAutoOpenPalette()) {
|
| if (stylus_state == ui::StylusState::REMOVED && !bubble_) {
|
| is_bubble_auto_opened_ = true;
|
| - ShowPalette();
|
| + ShowBubble();
|
| } else if (stylus_state == ui::StylusState::INSERTED && bubble_) {
|
| HidePalette();
|
| }
|
| @@ -385,6 +326,76 @@ void PaletteTray::Initialize() {
|
| &PaletteTray::OnPaletteEnabledPrefChanged, weak_factory_.GetWeakPtr()));
|
| }
|
|
|
| +bool PaletteTray::PerformAction(const ui::Event& event) {
|
| + if (bubble_) {
|
| + if (num_actions_in_bubble_ == 0)
|
| + RecordPaletteOptionsUsage(PaletteTrayOptions::PALETTE_CLOSED_NO_ACTION);
|
| + HidePalette();
|
| + return true;
|
| + }
|
| +
|
| + ShowBubble();
|
| + return true;
|
| +}
|
| +
|
| +void PaletteTray::CloseBubble() {
|
| + HidePalette();
|
| +}
|
| +
|
| +void PaletteTray::ShowBubble() {
|
| + if (bubble_)
|
| + return;
|
| +
|
| + DCHECK(tray_container());
|
| +
|
| + views::TrayBubbleView::InitParams init_params;
|
| + init_params.delegate = this;
|
| + init_params.parent_window = GetBubbleWindowContainer();
|
| + init_params.anchor_view = GetBubbleAnchor();
|
| + init_params.anchor_alignment = GetAnchorAlignment();
|
| + init_params.min_width = kPaletteWidth;
|
| + init_params.max_width = kPaletteWidth;
|
| + init_params.close_on_deactivate = true;
|
| +
|
| + // TODO(tdanderson): Refactor into common row layout code.
|
| + // TODO(tdanderson|jdufault): Add material design ripple effects to the menu
|
| + // rows.
|
| +
|
| + // Create and customize bubble view.
|
| + views::TrayBubbleView* bubble_view = new views::TrayBubbleView(init_params);
|
| + bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets());
|
| + bubble_view->set_margins(
|
| + gfx::Insets(kPalettePaddingOnTop, 0, kPalettePaddingOnBottom, 0));
|
| +
|
| + // Add title.
|
| + auto* title_view = new TitleView(this);
|
| + title_view->SetBorder(views::CreateEmptyBorder(
|
| + gfx::Insets(0, kPaddingBetweenTitleAndLeftEdge, 0, 0)));
|
| + bubble_view->AddChildView(title_view);
|
| +
|
| + // Add horizontal separator.
|
| + views::Separator* separator = new views::Separator();
|
| + separator->SetColor(kPaletteSeparatorColor);
|
| + separator->SetBorder(views::CreateEmptyBorder(gfx::Insets(
|
| + kPaddingBetweenTitleAndSeparator, 0, kMenuSeparatorVerticalPadding, 0)));
|
| + bubble_view->AddChildView(separator);
|
| +
|
| + // Add palette tools.
|
| + // TODO(tdanderson|jdufault): Use SystemMenuButton to get the material design
|
| + // ripples.
|
| + std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews();
|
| + for (const PaletteToolView& view : views)
|
| + bubble_view->AddChildView(view.view);
|
| +
|
| + // Show the bubble.
|
| + bubble_ = base::MakeUnique<ash::TrayBubbleWrapper>(this, bubble_view);
|
| + SetIsActive(true);
|
| +}
|
| +
|
| +views::TrayBubbleView* PaletteTray::GetBubbleView() {
|
| + return bubble_ ? bubble_->bubble_view() : nullptr;
|
| +}
|
| +
|
| void PaletteTray::UpdateTrayIcon() {
|
| icon_->SetImage(CreateVectorIcon(
|
| palette_tool_manager_->GetActiveTrayIcon(
|
|
|