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/shelf/overflow_button.h" | 5 #include "ash/shelf/overflow_button.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
10 #include "grit/ash_resources.h" | 10 #include "grit/ash_resources.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 OverflowButton::~OverflowButton() {} | 50 OverflowButton::~OverflowButton() {} |
51 | 51 |
52 void OverflowButton::OnShelfAlignmentChanged() { | 52 void OverflowButton::OnShelfAlignmentChanged() { |
53 SchedulePaint(); | 53 SchedulePaint(); |
54 } | 54 } |
55 | 55 |
56 void OverflowButton::PaintBackground(gfx::Canvas* canvas, int alpha) { | 56 void OverflowButton::PaintBackground(gfx::Canvas* canvas, int alpha) { |
57 gfx::Rect bounds(GetContentsBounds()); | 57 gfx::Rect bounds(GetContentsBounds()); |
58 gfx::Rect rect(0, 0, kButtonHoverSize, kButtonHoverSize); | 58 gfx::Rect rect(0, 0, kButtonHoverSize, kButtonHoverSize); |
59 ShelfLayoutManager* shelf = | 59 ShelfLayoutManager* shelf = |
60 ShelfLayoutManager::ForLauncher(GetWidget()->GetNativeView()); | 60 ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); |
61 | 61 |
62 // Nudge the background a little to line up right. | 62 // Nudge the background a little to line up right. |
63 if (shelf->IsHorizontalAlignment()) { | 63 if (shelf->IsHorizontalAlignment()) { |
64 rect.set_origin(gfx::Point( | 64 rect.set_origin(gfx::Point( |
65 bounds.x() + ((bounds.width() - kButtonHoverSize) / 2) - 1, | 65 bounds.x() + ((bounds.width() - kButtonHoverSize) / 2) - 1, |
66 bounds.y() + kBackgroundOffset - 1)); | 66 bounds.y() + kBackgroundOffset - 1)); |
67 | 67 |
68 } else { | 68 } else { |
69 rect.set_origin(gfx::Point( | 69 rect.set_origin(gfx::Point( |
70 bounds.x() + kBackgroundOffset - 1, | 70 bounds.x() + kBackgroundOffset - 1, |
71 bounds.y() + ((bounds.height() - kButtonHoverSize) / 2) - 1)); | 71 bounds.y() + ((bounds.height() - kButtonHoverSize) / 2) - 1)); |
72 } | 72 } |
73 | 73 |
74 SkPaint paint; | 74 SkPaint paint; |
75 paint.setAntiAlias(true); | 75 paint.setAntiAlias(true); |
76 paint.setStyle(SkPaint::kFill_Style); | 76 paint.setStyle(SkPaint::kFill_Style); |
77 paint.setColor(SkColorSetARGB( | 77 paint.setColor(SkColorSetARGB( |
78 kButtonHoverAlpha * hover_animation_->GetCurrentValue(), | 78 kButtonHoverAlpha * hover_animation_->GetCurrentValue(), |
79 0, 0, 0)); | 79 0, 0, 0)); |
80 | 80 |
81 const SkScalar radius = SkIntToScalar(kButtonCornerRadius); | 81 const SkScalar radius = SkIntToScalar(kButtonCornerRadius); |
82 SkPath path; | 82 SkPath path; |
83 path.addRoundRect(gfx::RectToSkRect(rect), radius, radius); | 83 path.addRoundRect(gfx::RectToSkRect(rect), radius, radius); |
84 canvas->DrawPath(path, paint); | 84 canvas->DrawPath(path, paint); |
85 } | 85 } |
86 | 86 |
87 void OverflowButton::OnPaint(gfx::Canvas* canvas) { | 87 void OverflowButton::OnPaint(gfx::Canvas* canvas) { |
88 ShelfLayoutManager* layout_manager = ShelfLayoutManager::ForLauncher( | 88 ShelfLayoutManager* layout_manager = |
89 GetWidget()->GetNativeView()); | 89 ShelfLayoutManager::ForShelf(GetWidget()->GetNativeView()); |
90 ShelfAlignment alignment = layout_manager->GetAlignment(); | 90 ShelfAlignment alignment = layout_manager->GetAlignment(); |
91 | 91 |
92 gfx::Rect bounds(GetContentsBounds()); | 92 gfx::Rect bounds(GetContentsBounds()); |
93 if (ash::switches::UseAlternateShelfLayout()) { | 93 if (ash::switches::UseAlternateShelfLayout()) { |
94 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 94 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
95 int background_image_id = 0; | 95 int background_image_id = 0; |
96 if (layout_manager->shelf_widget()->launcher()->IsShowingOverflowBubble()) | 96 if (layout_manager->shelf_widget()->shelf()->IsShowingOverflowBubble()) |
97 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; | 97 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; |
98 else if(layout_manager->shelf_widget()->GetDimsShelf()) | 98 else if(layout_manager->shelf_widget()->GetDimsShelf()) |
99 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; | 99 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; |
100 else | 100 else |
101 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; | 101 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; |
102 | 102 |
103 const gfx::ImageSkia* background = | 103 const gfx::ImageSkia* background = |
104 rb.GetImageNamed(background_image_id).ToImageSkia(); | 104 rb.GetImageNamed(background_image_id).ToImageSkia(); |
105 if (alignment == SHELF_ALIGNMENT_LEFT) { | 105 if (alignment == SHELF_ALIGNMENT_LEFT) { |
106 bounds = gfx::Rect( | 106 bounds = gfx::Rect( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 break; | 166 break; |
167 } | 167 } |
168 | 168 |
169 canvas->DrawImageInt(*image, | 169 canvas->DrawImageInt(*image, |
170 bounds.x() + ((bounds.width() - image->width()) / 2), | 170 bounds.x() + ((bounds.width() - image->width()) / 2), |
171 bounds.y() + ((bounds.height() - image->height()) / 2)); | 171 bounds.y() + ((bounds.height() - image->height()) / 2)); |
172 } | 172 } |
173 | 173 |
174 } // namespace internal | 174 } // namespace internal |
175 } // namespace ash | 175 } // namespace ash |
OLD | NEW |