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

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: Make PaletteDelegate pure virtual once more 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
« no previous file with comments | « ash/common/system/chromeos/palette/palette_tray.h ('k') | ash/common/test/test_palette_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a485f171ee8b5811481f45b364c574b1290033f9 100644
--- a/ash/common/system/chromeos/palette/palette_tray.cc
+++ b/ash/common/system/chromeos/palette/palette_tray.cc
@@ -4,6 +4,7 @@
#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"
@@ -22,6 +23,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"
@@ -134,6 +136,10 @@ PaletteTray::PaletteTray(WmShelf* wm_shelf)
WmShell::Get()->AddShellObserver(this);
WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this);
+ if (WmShell::Get()->palette_delegate()) {
+ WmShell::Get()->palette_delegate()->SetStylusStateChangedCallback(
+ base::Bind(&PaletteTray::OnStylusStateChanged, base::Unretained(this)));
stevenjb 2016/08/25 22:48:56 Need to pass this as a weak_ptr. It's always iffy
jdufault 2016/08/25 23:09:15 Done.
+ }
UpdateIconVisibility();
}
@@ -210,7 +216,7 @@ void PaletteTray::SessionStateChanged(
}
void PaletteTray::ClickedOutsideBubble() {
- HidePalette();
+ bubble_.reset();
}
base::string16 PaletteTray::GetAccessibleNameForTray() {
@@ -315,6 +321,16 @@ void PaletteTray::UpdateTrayIcon() {
icon_->SetImage(CreateVectorIcon(icon, kShelfIconSize, kShelfIconColor));
}
+void PaletteTray::OnStylusStateChanged(ui::StylusState stylus_state) {
+ if (!WmShell::Get()->palette_delegate()->ShouldAutoOpenPalette())
+ return;
+
+ if (stylus_state == ui::StylusState::REMOVED && !bubble_)
+ OpenBubble();
+ else if (stylus_state == ui::StylusState::INSERTED && bubble_)
+ bubble_.reset();
+}
+
void PaletteTray::UpdateIconVisibility() {
if (!IsPaletteEnabled())
return;
« no previous file with comments | « ash/common/system/chromeos/palette/palette_tray.h ('k') | ash/common/test/test_palette_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698