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