Chromium Code Reviews| 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..d043920ddc9a4565a26bb5ca926d7fd79d021a2e 100644 |
| --- a/ash/system/palette/palette_tray.cc |
| +++ b/ash/system/palette/palette_tray.cc |
| @@ -163,68 +163,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 +218,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(); |
| } |
| @@ -324,6 +262,10 @@ void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
| HideBubbleWithView(bubble_view); |
| } |
| +bool PaletteTray::ProcessGestureEventForBubble(ui::GestureEvent* event) { |
| + return drag_controller()->ProcessGestureEvent(event, this); |
| +} |
| + |
| void PaletteTray::HidePalette() { |
| is_bubble_auto_opened_ = false; |
| num_actions_in_bubble_ = 0; |
| @@ -385,6 +327,81 @@ 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 GetBubbleView() != nullptr; |
|
msw
2017/07/14 02:00:45
nit: can this assume ShowBubble will actually show
minch1
2017/07/14 19:45:17
Done.
|
| +} |
| + |
| +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_.reset(new ash::TrayBubbleWrapper(this, bubble_view)); |
| + SetIsActive(true); |
| +} |
| + |
| +views::TrayBubbleView* PaletteTray::GetBubbleView() { |
| + return bubble_ ? bubble_->bubble_view() : nullptr; |
| +} |
| + |
| +void PaletteTray::OnGestureEvent(ui::GestureEvent* event) { |
| + if (!drag_controller()->ProcessGestureEvent(event, this)) |
| + TrayBackgroundView::OnGestureEvent(event); |
| +} |
| + |
| void PaletteTray::UpdateTrayIcon() { |
| icon_->SetImage(CreateVectorIcon( |
| palette_tool_manager_->GetActiveTrayIcon( |