| 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/common/system/chromeos/palette/palette_tray.h" | 5 #include "ash/common/system/chromeos/palette/palette_tray.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/shelf/shelf_constants.h" | 8 #include "ash/common/shelf/shelf_constants.h" |
| 9 #include "ash/common/shelf/wm_shelf.h" | 9 #include "ash/common/shelf/wm_shelf.h" |
| 10 #include "ash/common/shelf/wm_shelf_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 155 |
| 156 PaletteTray::PaletteTray(WmShelf* wm_shelf) | 156 PaletteTray::PaletteTray(WmShelf* wm_shelf) |
| 157 : TrayBackgroundView(wm_shelf), | 157 : TrayBackgroundView(wm_shelf), |
| 158 palette_tool_manager_(new PaletteToolManager(this)), | 158 palette_tool_manager_(new PaletteToolManager(this)), |
| 159 weak_factory_(this) { | 159 weak_factory_(this) { |
| 160 // PaletteTray should only be instantiated if the palette feature is enabled. | 160 // PaletteTray should only be instantiated if the palette feature is enabled. |
| 161 DCHECK(IsPaletteFeatureEnabled()); | 161 DCHECK(IsPaletteFeatureEnabled()); |
| 162 | 162 |
| 163 PaletteTool::RegisterToolInstances(palette_tool_manager_.get()); | 163 PaletteTool::RegisterToolInstances(palette_tool_manager_.get()); |
| 164 | 164 |
| 165 SetContentsBackground(); | 165 SetContentsBackground(true); |
| 166 | 166 |
| 167 SetLayoutManager(new views::FillLayout()); | 167 SetLayoutManager(new views::FillLayout()); |
| 168 icon_ = new views::ImageView(); | 168 icon_ = new views::ImageView(); |
| 169 UpdateTrayIcon(); | 169 UpdateTrayIcon(); |
| 170 | 170 |
| 171 SetIconBorderForShelfAlignment(); | 171 SetIconBorderForShelfAlignment(); |
| 172 tray_container()->AddChildView(icon_); | 172 tray_container()->AddChildView(icon_); |
| 173 | 173 |
| 174 WmShell::Get()->AddShellObserver(this); | 174 WmShell::Get()->AddShellObserver(this); |
| 175 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); | 175 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 | 252 |
| 253 // Add palette tools. | 253 // Add palette tools. |
| 254 // TODO(tdanderson|jdufault): Use SystemMenuButton to get the material design | 254 // TODO(tdanderson|jdufault): Use SystemMenuButton to get the material design |
| 255 // ripples. | 255 // ripples. |
| 256 std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews(); | 256 std::vector<PaletteToolView> views = palette_tool_manager_->CreateViews(); |
| 257 for (const PaletteToolView& view : views) | 257 for (const PaletteToolView& view : views) |
| 258 bubble_view->AddChildView(view.view); | 258 bubble_view->AddChildView(view.view); |
| 259 | 259 |
| 260 // Show the bubble. | 260 // Show the bubble. |
| 261 bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view)); | 261 bubble_.reset(new ash::TrayBubbleWrapper(this, bubble_view)); |
| 262 SetDrawBackgroundAsActive(true); | 262 SetIsActive(true); |
| 263 return true; | 263 return true; |
| 264 } | 264 } |
| 265 | 265 |
| 266 bool PaletteTray::ContainsPointInScreen(const gfx::Point& point) { | 266 bool PaletteTray::ContainsPointInScreen(const gfx::Point& point) { |
| 267 if (icon_ && icon_->GetBoundsInScreen().Contains(point)) | 267 if (icon_ && icon_->GetBoundsInScreen().Contains(point)) |
| 268 return true; | 268 return true; |
| 269 | 269 |
| 270 return bubble_ && bubble_->bubble_view()->GetBoundsInScreen().Contains(point); | 270 return bubble_ && bubble_->bubble_view()->GetBoundsInScreen().Contains(point); |
| 271 } | 271 } |
| 272 | 272 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 293 return l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE); | 293 return l10n_util::GetStringUTF16(IDS_ASH_STYLUS_TOOLS_TITLE); |
| 294 } | 294 } |
| 295 | 295 |
| 296 void PaletteTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) { | 296 void PaletteTray::HideBubbleWithView(const views::TrayBubbleView* bubble_view) { |
| 297 if (bubble_->bubble_view() == bubble_view) | 297 if (bubble_->bubble_view() == bubble_view) |
| 298 HidePalette(); | 298 HidePalette(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 void PaletteTray::BubbleViewDestroyed() { | 301 void PaletteTray::BubbleViewDestroyed() { |
| 302 palette_tool_manager_->NotifyViewsDestroyed(); | 302 palette_tool_manager_->NotifyViewsDestroyed(); |
| 303 SetDrawBackgroundAsActive(false); | 303 SetIsActive(false); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void PaletteTray::OnMouseEnteredView() {} | 306 void PaletteTray::OnMouseEnteredView() {} |
| 307 | 307 |
| 308 void PaletteTray::OnMouseExitedView() {} | 308 void PaletteTray::OnMouseExitedView() {} |
| 309 | 309 |
| 310 base::string16 PaletteTray::GetAccessibleNameForBubble() { | 310 base::string16 PaletteTray::GetAccessibleNameForBubble() { |
| 311 return GetAccessibleNameForTray(); | 311 return GetAccessibleNameForTray(); |
| 312 } | 312 } |
| 313 | 313 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 } else { | 457 } else { |
| 458 UpdateIconVisibility(); | 458 UpdateIconVisibility(); |
| 459 } | 459 } |
| 460 } | 460 } |
| 461 | 461 |
| 462 void PaletteTray::UpdateIconVisibility() { | 462 void PaletteTray::UpdateIconVisibility() { |
| 463 SetVisible(IsInUserSession()); | 463 SetVisible(IsInUserSession()); |
| 464 } | 464 } |
| 465 | 465 |
| 466 } // namespace ash | 466 } // namespace ash |
| OLD | NEW |