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

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: Use weak ptr 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..7bf9673d1a59b1d45e83434a04886a7c3820bde8 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"
@@ -120,7 +122,8 @@ class TitleView : public views::View, public views::ButtonListener {
PaletteTray::PaletteTray(WmShelf* wm_shelf)
: TrayBackgroundView(wm_shelf),
- palette_tool_manager_(new PaletteToolManager(this)) {
+ palette_tool_manager_(new PaletteToolManager(this)),
+ weak_factory_(this) {
PaletteTool::RegisterToolInstances(palette_tool_manager_.get());
SetContentsBackground();
@@ -134,6 +137,11 @@ 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,
+ weak_factory_.GetWeakPtr()));
+ }
UpdateIconVisibility();
}
@@ -210,7 +218,7 @@ void PaletteTray::SessionStateChanged(
}
void PaletteTray::ClickedOutsideBubble() {
- HidePalette();
+ bubble_.reset();
}
base::string16 PaletteTray::GetAccessibleNameForTray() {
@@ -315,6 +323,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