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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = | 88 ShelfLayoutManager* layout_manager = |
89 ShelfLayoutManager::ForShelf(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 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
94 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 94 int background_image_id = 0; |
95 int background_image_id = 0; | 95 if (layout_manager->shelf_widget()->shelf()->IsShowingOverflowBubble()) |
96 if (layout_manager->shelf_widget()->shelf()->IsShowingOverflowBubble()) | 96 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; |
97 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_PRESSED; | 97 else if(layout_manager->shelf_widget()->GetDimsShelf()) |
98 else if(layout_manager->shelf_widget()->GetDimsShelf()) | 98 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; |
99 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_ON_BLACK; | 99 else |
100 else | 100 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; |
101 background_image_id = IDR_AURA_NOTIFICATION_BACKGROUND_NORMAL; | |
102 | 101 |
103 const gfx::ImageSkia* background = | 102 const gfx::ImageSkia* background = |
104 rb.GetImageNamed(background_image_id).ToImageSkia(); | 103 rb.GetImageNamed(background_image_id).ToImageSkia(); |
105 if (alignment == SHELF_ALIGNMENT_LEFT) { | 104 if (alignment == SHELF_ALIGNMENT_LEFT) { |
106 bounds = gfx::Rect( | 105 bounds = gfx::Rect( |
107 bounds.right() - background->width() - | 106 bounds.right() - background->width() - |
108 ShelfLayoutManager::kShelfItemInset, | 107 ShelfLayoutManager::kShelfItemInset, |
109 bounds.y() + (bounds.height() - background->height()) / 2, | 108 bounds.y() + (bounds.height() - background->height()) / 2, |
110 background->width(), background->height()); | 109 background->width(), background->height()); |
111 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { | 110 } else if (alignment == SHELF_ALIGNMENT_RIGHT) { |
112 bounds = gfx::Rect( | 111 bounds = gfx::Rect( |
113 bounds.x() + ShelfLayoutManager::kShelfItemInset, | 112 bounds.x() + ShelfLayoutManager::kShelfItemInset, |
114 bounds.y() + (bounds.height() - background->height()) / 2, | 113 bounds.y() + (bounds.height() - background->height()) / 2, |
115 background->width(), background->height()); | 114 background->width(), background->height()); |
116 } else { | |
117 bounds = gfx::Rect( | |
118 bounds.x() + (bounds.width() - background->width()) / 2, | |
119 bounds.y() + ShelfLayoutManager::kShelfItemInset, | |
120 background->width(), background->height()); | |
121 } | |
122 canvas->DrawImageInt(*background, bounds.x(), bounds.y()); | |
123 } else { | 115 } else { |
124 if (alignment == SHELF_ALIGNMENT_BOTTOM) { | 116 bounds = gfx::Rect( |
125 bounds = gfx::Rect( | 117 bounds.x() + (bounds.width() - background->width()) / 2, |
126 bounds.x() + ((bounds.width() - kButtonHoverSize) / 2) - 1, | 118 bounds.y() + ShelfLayoutManager::kShelfItemInset, |
127 bounds.y() + kBackgroundOffset - 1, | 119 background->width(), background->height()); |
128 kButtonHoverSize, kButtonHoverSize); | |
129 } else { | |
130 bounds = gfx::Rect( | |
131 bounds.x() + kBackgroundOffset -1, | |
132 bounds.y() + ((bounds.height() - kButtonHoverSize) / 2) -1, | |
133 kButtonHoverSize, kButtonHoverSize); | |
134 } | |
135 if (hover_animation_->is_animating()) { | |
136 PaintBackground( | |
137 canvas, | |
138 kButtonHoverAlpha * hover_animation_->GetCurrentValue()); | |
139 } else if (state() == STATE_HOVERED || state() == STATE_PRESSED) { | |
140 PaintBackground(canvas, kButtonHoverAlpha); | |
141 } | |
142 } | 120 } |
| 121 canvas->DrawImageInt(*background, bounds.x(), bounds.y()); |
143 | 122 |
144 if (height() < kButtonHoverSize) | 123 if (height() < kButtonHoverSize) |
145 return; | 124 return; |
146 | 125 |
147 const gfx::ImageSkia* image = NULL; | 126 const gfx::ImageSkia* image = NULL; |
148 | 127 |
149 switch(alignment) { | 128 switch(alignment) { |
150 case SHELF_ALIGNMENT_LEFT: | 129 case SHELF_ALIGNMENT_LEFT: |
151 if (left_image_.isNull()) { | 130 if (left_image_.isNull()) { |
152 left_image_ = gfx::ImageSkiaOperations::CreateRotatedImage( | 131 left_image_ = gfx::ImageSkiaOperations::CreateRotatedImage( |
(...skipping 13 matching lines...) Expand all Loading... |
166 break; | 145 break; |
167 } | 146 } |
168 | 147 |
169 canvas->DrawImageInt(*image, | 148 canvas->DrawImageInt(*image, |
170 bounds.x() + ((bounds.width() - image->width()) / 2), | 149 bounds.x() + ((bounds.width() - image->width()) / 2), |
171 bounds.y() + ((bounds.height() - image->height()) / 2)); | 150 bounds.y() + ((bounds.height() - image->height()) / 2)); |
172 } | 151 } |
173 | 152 |
174 } // namespace internal | 153 } // namespace internal |
175 } // namespace ash | 154 } // namespace ash |
OLD | NEW |