Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1133)

Unified Diff: ash/common/system/chromeos/palette/palette_tray.cc

Issue 2234203002: Auto open and close the palette on an eject event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tool-note
Patch Set: Rebase on master Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/common/system/chromeos/palette/palette_tray.cc
diff --git a/ash/common/system/chromeos/palette/palette_tray.cc b/ash/common/system/chromeos/palette/palette_tray.cc
index 1a13c9c4ba9ffe9af7800b322415cdbfa9d066d7..9b5535d11f67d5005cc012c604111b3128a276c0 100644
--- a/ash/common/system/chromeos/palette/palette_tray.cc
+++ b/ash/common/system/chromeos/palette/palette_tray.cc
@@ -4,10 +4,12 @@
#include "ash/common/system/chromeos/palette/palette_tray.h"
+#include "ash/common/palette_delegate.h"
#include "ash/common/shelf/shelf_constants.h"
#include "ash/common/shelf/wm_shelf.h"
#include "ash/common/shelf/wm_shelf_util.h"
#include "ash/common/shell_window_ids.h"
+#include "ash/common/system/chromeos/palette/eject_controller.h"
#include "ash/common/system/chromeos/palette/palette_tool_manager.h"
#include "ash/common/system/chromeos/palette/palette_utils.h"
#include "ash/common/system/tray/system_tray_delegate.h"
@@ -22,6 +24,7 @@
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
+#include "ui/events/devices/stylus_state.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
@@ -121,6 +124,9 @@ class TitleView : public views::View, public views::ButtonListener {
PaletteTray::PaletteTray(WmShelf* wm_shelf)
: TrayBackgroundView(wm_shelf),
palette_tool_manager_(new PaletteToolManager(this)) {
+ eject_controller_.reset(new EjectController(
+ base::Bind(&PaletteTray::OnStylusEject, base::Unretained(this))));
+
PaletteTool::RegisterToolInstances(palette_tool_manager_.get());
SetContentsBackground();
@@ -210,7 +216,7 @@ void PaletteTray::SessionStateChanged(
}
void PaletteTray::ClickedOutsideBubble() {
- HidePalette();
+ bubble_.reset();
}
base::string16 PaletteTray::GetAccessibleNameForTray() {
@@ -315,6 +321,17 @@ void PaletteTray::UpdateTrayIcon() {
icon_->SetImage(CreateVectorIcon(icon, kShelfIconSize, kShelfIconColor));
}
+void PaletteTray::OnStylusEject(ui::StylusState stylus_state) {
+ if (!WmShell::Get()->palette_delegate()->ShouldAutoOpenPalette())
+ return;
+
+ if (stylus_state == ui::StylusState::REMOVED && !bubble_)
+ OpenBubble();
+
+ if (stylus_state == ui::StylusState::INSERTED && bubble_)
oshima 2016/08/24 23:38:50 nit: else if? You may keep it if you prefer this
jdufault 2016/08/24 23:54:07 Done.
+ bubble_.reset();
+}
+
void PaletteTray::UpdateIconVisibility() {
if (!IsPaletteEnabled())
return;

Powered by Google App Engine
This is Rietveld 408576698