| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/system/palette/palette_tray.h" | 5 #include "ash/system/palette/palette_tray.h" |
| 6 | 6 |
| 7 #include "ash/public/cpp/shell_window_ids.h" | 7 #include "ash/public/cpp/shell_window_ids.h" |
| 8 #include "ash/resources/grit/ash_resources.h" | 8 #include "ash/resources/grit/ash_resources.h" |
| 9 #include "ash/resources/vector_icons/vector_icons.h" | 9 #include "ash/resources/vector_icons/vector_icons.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 DCHECK(tray_container()); | 173 DCHECK(tray_container()); |
| 174 | 174 |
| 175 views::TrayBubbleView::InitParams init_params(GetAnchorAlignment(), | 175 views::TrayBubbleView::InitParams init_params(GetAnchorAlignment(), |
| 176 kPaletteWidth, kPaletteWidth); | 176 kPaletteWidth, kPaletteWidth); |
| 177 init_params.can_activate = true; | 177 init_params.can_activate = true; |
| 178 init_params.close_on_deactivate = true; | 178 init_params.close_on_deactivate = true; |
| 179 | 179 |
| 180 DCHECK(tray_container()); | 180 DCHECK(tray_container()); |
| 181 | 181 |
| 182 // The views::TrayBubbleView ctor will cause a shelf auto hide update check. | |
| 183 // Make sure to block auto hiding before that check happens. | |
| 184 should_block_shelf_auto_hide_ = true; | |
| 185 | |
| 186 // TODO(tdanderson): Refactor into common row layout code. | 182 // TODO(tdanderson): Refactor into common row layout code. |
| 187 // TODO(tdanderson|jdufault): Add material design ripple effects to the menu | 183 // TODO(tdanderson|jdufault): Add material design ripple effects to the menu |
| 188 // rows. | 184 // rows. |
| 189 | 185 |
| 190 // Create and customize bubble view. | 186 // Create and customize bubble view. |
| 191 views::TrayBubbleView* bubble_view = | 187 views::TrayBubbleView* bubble_view = |
| 192 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params); | 188 views::TrayBubbleView::Create(GetBubbleAnchor(), this, &init_params); |
| 193 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); | 189 bubble_view->set_anchor_view_insets(GetBubbleAnchorInsets()); |
| 194 bubble_view->set_margins( | 190 bubble_view->set_margins( |
| 195 gfx::Insets(kPalettePaddingOnTop, 0, kPalettePaddingOnBottom, 0)); | 191 gfx::Insets(kPalettePaddingOnTop, 0, kPalettePaddingOnBottom, 0)); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 ->GetRootWindowController() | 304 ->GetRootWindowController() |
| 309 ->ConfigureWidgetInitParamsForContainer( | 305 ->ConfigureWidgetInitParamsForContainer( |
| 310 bubble_widget, kShellWindowId_SettingBubbleContainer, params); | 306 bubble_widget, kShellWindowId_SettingBubbleContainer, params); |
| 311 } | 307 } |
| 312 | 308 |
| 313 void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) { | 309 void PaletteTray::HideBubble(const views::TrayBubbleView* bubble_view) { |
| 314 HideBubbleWithView(bubble_view); | 310 HideBubbleWithView(bubble_view); |
| 315 } | 311 } |
| 316 | 312 |
| 317 void PaletteTray::HidePalette() { | 313 void PaletteTray::HidePalette() { |
| 318 should_block_shelf_auto_hide_ = false; | |
| 319 is_bubble_auto_opened_ = false; | 314 is_bubble_auto_opened_ = false; |
| 320 num_actions_in_bubble_ = 0; | 315 num_actions_in_bubble_ = 0; |
| 321 bubble_.reset(); | 316 bubble_.reset(); |
| 322 | 317 |
| 323 shelf()->UpdateAutoHideState(); | 318 shelf()->UpdateAutoHideState(); |
| 324 } | 319 } |
| 325 | 320 |
| 326 void PaletteTray::HidePaletteImmediately() { | 321 void PaletteTray::HidePaletteImmediately() { |
| 327 if (bubble_) | 322 if (bubble_) |
| 328 bubble_->bubble_widget()->SetVisibilityChangedAnimationsEnabled(false); | 323 bubble_->bubble_widget()->SetVisibilityChangedAnimationsEnabled(false); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 343 | 338 |
| 344 void PaletteTray::RecordPaletteModeCancellation(PaletteModeCancelType type) { | 339 void PaletteTray::RecordPaletteModeCancellation(PaletteModeCancelType type) { |
| 345 if (type == PaletteModeCancelType::PALETTE_MODE_CANCEL_TYPE_COUNT) | 340 if (type == PaletteModeCancelType::PALETTE_MODE_CANCEL_TYPE_COUNT) |
| 346 return; | 341 return; |
| 347 | 342 |
| 348 UMA_HISTOGRAM_ENUMERATION( | 343 UMA_HISTOGRAM_ENUMERATION( |
| 349 "Ash.Shelf.Palette.ModeCancellation", type, | 344 "Ash.Shelf.Palette.ModeCancellation", type, |
| 350 PaletteModeCancelType::PALETTE_MODE_CANCEL_TYPE_COUNT); | 345 PaletteModeCancelType::PALETTE_MODE_CANCEL_TYPE_COUNT); |
| 351 } | 346 } |
| 352 | 347 |
| 353 bool PaletteTray::ShouldBlockShelfAutoHide() const { | |
| 354 return should_block_shelf_auto_hide_; | |
| 355 } | |
| 356 | |
| 357 void PaletteTray::OnActiveToolChanged() { | 348 void PaletteTray::OnActiveToolChanged() { |
| 358 ++num_actions_in_bubble_; | 349 ++num_actions_in_bubble_; |
| 359 UpdateTrayIcon(); | 350 UpdateTrayIcon(); |
| 360 } | 351 } |
| 361 | 352 |
| 362 WmWindow* PaletteTray::GetWindow() { | 353 WmWindow* PaletteTray::GetWindow() { |
| 363 return shelf()->GetWindow(); | 354 return shelf()->GetWindow(); |
| 364 } | 355 } |
| 365 | 356 |
| 366 void PaletteTray::AnchorUpdated() { | 357 void PaletteTray::AnchorUpdated() { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 397 UpdateIconVisibility(); | 388 UpdateIconVisibility(); |
| 398 } | 389 } |
| 399 } | 390 } |
| 400 | 391 |
| 401 void PaletteTray::UpdateIconVisibility() { | 392 void PaletteTray::UpdateIconVisibility() { |
| 402 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && | 393 SetVisible(is_palette_enabled_ && palette_utils::HasStylusInput() && |
| 403 IsInUserSession()); | 394 IsInUserSession()); |
| 404 } | 395 } |
| 405 | 396 |
| 406 } // namespace ash | 397 } // namespace ash |
| OLD | NEW |