| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shelf/shelf_button.h" | 5 #include "ash/common/shelf/shelf_button.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/ash_constants.h" | 9 #include "ash/common/ash_constants.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
| 23 #include "ui/compositor/scoped_layer_animation_settings.h" | 23 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 24 #include "ui/events/event_constants.h" | 24 #include "ui/events/event_constants.h" |
| 25 #include "ui/gfx/animation/animation_delegate.h" | 25 #include "ui/gfx/animation/animation_delegate.h" |
| 26 #include "ui/gfx/animation/throb_animation.h" | 26 #include "ui/gfx/animation/throb_animation.h" |
| 27 #include "ui/gfx/canvas.h" | 27 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/geometry/vector2d.h" | 28 #include "ui/gfx/geometry/vector2d.h" |
| 29 #include "ui/gfx/image/image.h" | 29 #include "ui/gfx/image/image.h" |
| 30 #include "ui/gfx/image/image_skia_operations.h" | 30 #include "ui/gfx/image/image_skia_operations.h" |
| 31 #include "ui/gfx/skbitmap_operations.h" | 31 #include "ui/gfx/skbitmap_operations.h" |
| 32 #include "ui/views/animation/ink_drop_impl.h" |
| 32 #include "ui/views/animation/square_ink_drop_ripple.h" | 33 #include "ui/views/animation/square_ink_drop_ripple.h" |
| 33 #include "ui/views/controls/image_view.h" | 34 #include "ui/views/controls/image_view.h" |
| 34 | 35 |
| 35 namespace { | 36 namespace { |
| 36 | 37 |
| 37 // Size of the bar. This is along the opposite axis of the shelf. For example, | 38 // Size of the bar. This is along the opposite axis of the shelf. For example, |
| 38 // if the shelf is aligned horizontally then this is the height of the bar. | 39 // if the shelf is aligned horizontally then this is the height of the bar. |
| 39 const int kBarSize = 3; | 40 const int kBarSize = 3; |
| 40 const int kIconSize = 32; | 41 const int kIconSize = 32; |
| 41 const int kAttentionThrobDurationMS = 800; | 42 const int kAttentionThrobDurationMS = 800; |
| 42 const int kMaxAnimationSeconds = 10; | 43 const int kMaxAnimationSeconds = 10; |
| 43 const int kIndicatorOffsetFromBottom = 2; | 44 const int kIndicatorOffsetFromBottom = 2; |
| 44 const int kIndicatorRadius = 2; | 45 const int kIndicatorRadius = 2; |
| 45 const SkColor kIndicatorColor = SK_ColorWHITE; | 46 const SkColor kIndicatorColor = SK_ColorWHITE; |
| 46 // Canvas scale to ensure that the activity indicator is not pixelated even at | 47 // Canvas scale to ensure that the activity indicator is not pixelated even at |
| 47 // the highest possible device scale factors. | 48 // the highest possible device scale factors. |
| 48 const int kIndicatorCanvasScale = 5; | 49 const int kIndicatorCanvasScale = 5; |
| 49 | 50 |
| 50 // Shelf item ripple constants. | 51 // Shelf item ripple constants. |
| 51 const int kInkDropSmallSize = 48; | 52 const int kInkDropSmallSize = 48; |
| 52 const int kInkDropLargeSize = 60; | 53 const int kInkDropLargeSize = 60; |
| 53 const int kInkDropLargeCornerRadius = 4; | |
| 54 | 54 |
| 55 // Padding from the edge of the shelf to the application icon when the shelf | 55 // Padding from the edge of the shelf to the application icon when the shelf |
| 56 // is horizontally and vertically aligned, respectively. | 56 // is horizontally and vertically aligned, respectively. |
| 57 const int kIconPaddingHorizontal = 5; | 57 const int kIconPaddingHorizontal = 5; |
| 58 const int kIconPaddingHorizontalMD = 7; | 58 const int kIconPaddingHorizontalMD = 7; |
| 59 const int kIconPaddingVertical = 6; | 59 const int kIconPaddingVertical = 6; |
| 60 const int kIconPaddingVerticalMD = 8; | 60 const int kIconPaddingVerticalMD = 8; |
| 61 | 61 |
| 62 // Paints an activity indicator on |canvas| whose |size| is specified in DIP. | 62 // Paints an activity indicator on |canvas| whose |size| is specified in DIP. |
| 63 void PaintIndicatorOnCanvas(gfx::Canvas* canvas, const gfx::Size& size) { | 63 void PaintIndicatorOnCanvas(gfx::Canvas* canvas, const gfx::Size& size) { |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 GetInkDropBaseColor(), ink_drop_visible_opacity()); | 513 GetInkDropBaseColor(), ink_drop_visible_opacity()); |
| 514 } | 514 } |
| 515 | 515 |
| 516 bool ShelfButton::ShouldEnterPushedState(const ui::Event& event) { | 516 bool ShelfButton::ShouldEnterPushedState(const ui::Event& event) { |
| 517 if (!shelf_view_->ShouldEventActivateButton(this, event)) | 517 if (!shelf_view_->ShouldEventActivateButton(this, event)) |
| 518 return false; | 518 return false; |
| 519 | 519 |
| 520 return CustomButton::ShouldEnterPushedState(event); | 520 return CustomButton::ShouldEnterPushedState(event); |
| 521 } | 521 } |
| 522 | 522 |
| 523 bool ShelfButton::ShouldShowInkDropHighlight() const { | 523 std::unique_ptr<views::InkDrop> ShelfButton::CreateInkDrop() { |
| 524 return false; | 524 std::unique_ptr<views::InkDropImpl> ink_drop = |
| 525 CustomButton::CreateDefaultInkDropImpl(); |
| 526 ink_drop->SetShowHighlightOnHover(false); |
| 527 return std::move(ink_drop); |
| 525 } | 528 } |
| 526 | 529 |
| 527 void ShelfButton::NotifyClick(const ui::Event& event) { | 530 void ShelfButton::NotifyClick(const ui::Event& event) { |
| 528 CustomButton::NotifyClick(event); | 531 CustomButton::NotifyClick(event); |
| 529 if (listener_) | 532 if (listener_) |
| 530 listener_->ButtonPressed(this, event, GetInkDrop()); | 533 listener_->ButtonPressed(this, event, GetInkDrop()); |
| 531 } | 534 } |
| 532 | 535 |
| 533 void ShelfButton::UpdateState() { | 536 void ShelfButton::UpdateState() { |
| 534 UpdateBar(); | 537 UpdateBar(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 bar_->SetHorizontalAlignment(views::ImageView::TRAILING); | 597 bar_->SetHorizontalAlignment(views::ImageView::TRAILING); |
| 595 bar_->SetVerticalAlignment(views::ImageView::CENTER); | 598 bar_->SetVerticalAlignment(views::ImageView::CENTER); |
| 596 break; | 599 break; |
| 597 } | 600 } |
| 598 bar_->SchedulePaint(); | 601 bar_->SchedulePaint(); |
| 599 } | 602 } |
| 600 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); | 603 bar_->SetVisible(bar_id != 0 && state_ != STATE_NORMAL); |
| 601 } | 604 } |
| 602 | 605 |
| 603 } // namespace ash | 606 } // namespace ash |
| OLD | NEW |