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

Side by Side Diff: ash/common/system/cast/tray_cast.cc

Issue 2465403002: Some more fixes to cros system tray icons (esp. screen tray items) (Closed)
Patch Set: commentary Created 4 years, 1 month 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/cast/tray_cast.h" 5 #include "ash/common/system/cast/tray_cast.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/wm_shelf_util.h" 9 #include "ash/common/shelf/wm_shelf_util.h"
10 #include "ash/common/system/chromeos/screen_security/screen_tray_item.h" 10 #include "ash/common/system/chromeos/screen_security/screen_tray_item.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 return select_view_; 341 return select_view_;
342 return nullptr; 342 return nullptr;
343 } 343 }
344 344
345 // Exposes an icon in the tray. |TrayCast| manages the visiblity of this. 345 // Exposes an icon in the tray. |TrayCast| manages the visiblity of this.
346 class CastTrayView : public TrayItemView { 346 class CastTrayView : public TrayItemView {
347 public: 347 public:
348 explicit CastTrayView(SystemTrayItem* tray_item); 348 explicit CastTrayView(SystemTrayItem* tray_item);
349 ~CastTrayView() override; 349 ~CastTrayView() override;
350 350
351 // Called when the tray alignment changes so that the icon can recenter
352 // itself.
353 void UpdateAlignment(ShelfAlignment alignment);
354
355 private: 351 private:
356 DISALLOW_COPY_AND_ASSIGN(CastTrayView); 352 DISALLOW_COPY_AND_ASSIGN(CastTrayView);
357 }; 353 };
358 354
359 CastTrayView::CastTrayView(SystemTrayItem* tray_item) 355 CastTrayView::CastTrayView(SystemTrayItem* tray_item)
360 : TrayItemView(tray_item) { 356 : TrayItemView(tray_item) {
361 CreateImageView(); 357 CreateImageView();
362 if (MaterialDesignController::UseMaterialDesignSystemIcons()) { 358 if (MaterialDesignController::UseMaterialDesignSystemIcons()) {
363 image_view()->SetImage( 359 image_view()->SetImage(
364 gfx::CreateVectorIcon(kSystemTrayCastIcon, kTrayIconColor)); 360 gfx::CreateVectorIcon(kSystemTrayCastIcon, kTrayIconColor));
365 } else { 361 } else {
366 image_view()->SetImage(ui::ResourceBundle::GetSharedInstance() 362 image_view()->SetImage(ui::ResourceBundle::GetSharedInstance()
367 .GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE) 363 .GetImageNamed(IDR_AURA_UBER_TRAY_SCREENSHARE)
368 .ToImageSkia()); 364 .ToImageSkia());
369 } 365 }
370 } 366 }
371 367
372 CastTrayView::~CastTrayView() {} 368 CastTrayView::~CastTrayView() {}
373 369
374 void CastTrayView::UpdateAlignment(ShelfAlignment alignment) {
375 // Center the item dependent on the orientation of the shelf.
376 views::BoxLayout::Orientation layout = IsHorizontalAlignment(alignment)
377 ? views::BoxLayout::kHorizontal
378 : views::BoxLayout::kVertical;
379 SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0));
380 Layout();
381 }
382
383 // This view displays a list of cast receivers that can be clicked on and casted 370 // This view displays a list of cast receivers that can be clicked on and casted
384 // to. It is activated by clicking on the chevron inside of 371 // to. It is activated by clicking on the chevron inside of
385 // |CastSelectDefaultView|. 372 // |CastSelectDefaultView|.
386 class CastDetailedView : public TrayDetailsView { 373 class CastDetailedView : public TrayDetailsView {
387 public: 374 public:
388 CastDetailedView(SystemTrayItem* owner, 375 CastDetailedView(SystemTrayItem* owner,
389 LoginStatus login, 376 LoginStatus login,
390 const CastConfigDelegate::ReceiversAndActivities& 377 const CastConfigDelegate::ReceiversAndActivities&
391 receivers_and_activities); 378 receivers_and_activities);
392 ~CastDetailedView() override; 379 ~CastDetailedView() override;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 if (tray_) 661 if (tray_)
675 tray_->SetVisible(false); 662 tray_->SetVisible(false);
676 } 663 }
677 } 664 }
678 665
679 void TrayCast::OnCastingSessionStartedOrStopped(bool started) { 666 void TrayCast::OnCastingSessionStartedOrStopped(bool started) {
680 is_casting_ = started; 667 is_casting_ = started;
681 UpdatePrimaryView(); 668 UpdatePrimaryView();
682 } 669 }
683 670
684 void TrayCast::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
685 if (tray_)
686 tray_->UpdateAlignment(alignment);
687 }
688
689 } // namespace ash 671 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/cast/tray_cast.h ('k') | ash/common/system/chromeos/media_security/multi_profile_media_tray_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698