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

Side by Side Diff: ash/common/system/chromeos/palette/palette_tray.cc

Issue 2276233002: ash/chromeos: Add shift-alt-p shortcut to open palette. (Closed)
Patch Set: Address comment, rebase Created 4 years, 3 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 unified diff | Download patch
OLDNEW
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/common/system/chromeos/palette/palette_tray.h" 5 #include "ash/common/system/chromeos/palette/palette_tray.h"
6 6
7 #include "ash/common/shelf/shelf_constants.h" 7 #include "ash/common/shelf/shelf_constants.h"
8 #include "ash/common/shelf/wm_shelf.h" 8 #include "ash/common/shelf/wm_shelf.h"
9 #include "ash/common/shelf/wm_shelf_util.h" 9 #include "ash/common/shelf/wm_shelf_util.h"
10 #include "ash/common/shell_window_ids.h" 10 #include "ash/common/shell_window_ids.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 bool PaletteTray::PerformAction(const ui::Event& event) { 164 bool PaletteTray::PerformAction(const ui::Event& event) {
165 if (bubble_) { 165 if (bubble_) {
166 bubble_.reset(); 166 bubble_.reset();
167 return true; 167 return true;
168 } 168 }
169 169
170 return OpenBubble(); 170 return OpenBubble();
171 } 171 }
172 172
173 bool PaletteTray::OpenBubble() { 173 bool PaletteTray::OpenBubble() {
174 if (bubble_)
175 return false;
176
174 views::TrayBubbleView::InitParams init_params( 177 views::TrayBubbleView::InitParams init_params(
175 views::TrayBubbleView::ANCHOR_TYPE_TRAY, GetAnchorAlignment(), 178 views::TrayBubbleView::ANCHOR_TYPE_TRAY, GetAnchorAlignment(),
176 kPaletteWidth, kPaletteWidth); 179 kPaletteWidth, kPaletteWidth);
177 init_params.first_item_has_no_margin = true; 180 init_params.first_item_has_no_margin = true;
178 init_params.can_activate = true; 181 init_params.can_activate = true;
179 init_params.close_on_deactivate = true; 182 init_params.close_on_deactivate = true;
180 183
181 DCHECK(tray_container()); 184 DCHECK(tray_container());
182 185
183 // Create view, customize it. 186 // Create view, customize it.
184 views::TrayBubbleView* bubble_view = 187 views::TrayBubbleView* bubble_view =
185 views::TrayBubbleView::Create(tray_container(), this, &init_params); 188 views::TrayBubbleView::Create(tray_container(), this, &init_params);
186 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 189 bubble_view->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
187 bubble_view->UseCompactMargins(); 190 bubble_view->UseCompactMargins();
188 bubble_view->set_margins(gfx::Insets(bubble_view->margins().top(), 0, 0, 0)); 191 bubble_view->set_margins(gfx::Insets(bubble_view->margins().top(), 0, 0, 0));
189 192
190 // Add child views. 193 // Add child views.
191 bubble_view->AddChildView(new TitleView(this)); 194 bubble_view->AddChildView(new TitleView(this));
192 bubble_view->AddChildView(CreateSeparator(views::Separator::HORIZONTAL)); 195 bubble_view->AddChildView(CreateSeparator(views::Separator::HORIZONTAL));
193 AddToolsToView(bubble_view); 196 AddToolsToView(bubble_view);
194 197
195 // Show the bubble. 198 // Show the bubble.
196 bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view)); 199 bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view));
197 200
198 SetDrawBackgroundAsActive(true); 201 SetDrawBackgroundAsActive(true);
199
200 return true; 202 return true;
201 } 203 }
202 204
203 void PaletteTray::AddToolsToView(views::View* host) { 205 void PaletteTray::AddToolsToView(views::View* host) {
204 std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews(); 206 std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews();
205 207
206 // There may not be any registered tools. 208 // There may not be any registered tools.
207 if (!views.size()) 209 if (!views.size())
208 return; 210 return;
209 211
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 WmShell::Get()->GetSessionStateDelegate(); 354 WmShell::Get()->GetSessionStateDelegate();
353 355
354 SetVisible(!session_state_delegate->IsScreenLocked() && 356 SetVisible(!session_state_delegate->IsScreenLocked() &&
355 session_state_delegate->GetSessionState() == 357 session_state_delegate->GetSessionState() ==
356 SessionStateDelegate::SESSION_STATE_ACTIVE && 358 SessionStateDelegate::SESSION_STATE_ACTIVE &&
357 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() != 359 WmShell::Get()->system_tray_delegate()->GetUserLoginStatus() !=
358 LoginStatus::KIOSK_APP); 360 LoginStatus::KIOSK_APP);
359 } 361 }
360 362
361 } // namespace ash 363 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698