| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/launcher/overflow_button.h" | 5 #include "ash/launcher/overflow_button.h" |
| 6 | 6 |
| 7 #include "grit/ash_resources.h" | 7 #include "grit/ash_resources.h" |
| 8 #include "grit/ash_strings.h" | 8 #include "grit/ash_strings.h" |
| 9 #include "third_party/skia/include/core/SkPaint.h" | 9 #include "third_party/skia/include/core/SkPaint.h" |
| 10 #include "third_party/skia/include/core/SkPath.h" | 10 #include "third_party/skia/include/core/SkPath.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 const int kButtonHoverAlpha = 150; | 23 const int kButtonHoverAlpha = 150; |
| 24 | 24 |
| 25 const int kButtonCornerRadius = 2; | 25 const int kButtonCornerRadius = 2; |
| 26 | 26 |
| 27 const int kButtonHoverSize = 28; | 27 const int kButtonHoverSize = 28; |
| 28 | 28 |
| 29 const int kBackgroundOffset = (48 - kButtonHoverSize) / 2; | 29 const int kBackgroundOffset = (48 - kButtonHoverSize) / 2; |
| 30 | 30 |
| 31 void RotateCounterclockwise(gfx::Transform* transform) { | 31 void RotateCounterclockwise(gfx::Transform* transform) { |
| 32 transform->matrix().set3x3(0, -1, 0, | 32 SkMatrix44 rotation; |
| 33 1, 0, 0, | 33 rotation.set3x3(0, -1, 0, |
| 34 0, 0, 1); | 34 1, 0, 0, |
| 35 0, 0, 1); |
| 36 transform->matrix().preConcat(rotation); |
| 35 } | 37 } |
| 36 | 38 |
| 37 void RotateClockwise(gfx::Transform* transform) { | 39 void RotateClockwise(gfx::Transform* transform) { |
| 38 transform->matrix().set3x3( 0, 1, 0, | 40 SkMatrix44 rotation; |
| 39 -1, 0, 0, | 41 rotation.set3x3( 0, 1, 0, |
| 40 0, 0, 1); | 42 -1, 0, 0, |
| 43 0, 0, 1); |
| 44 transform->matrix().preConcat(rotation); |
| 41 } | 45 } |
| 42 | 46 |
| 43 } // namesapce | 47 } // namesapce |
| 44 | 48 |
| 45 OverflowButton::OverflowButton(views::ButtonListener* listener) | 49 OverflowButton::OverflowButton(views::ButtonListener* listener) |
| 46 : CustomButton(listener), | 50 : CustomButton(listener), |
| 47 alignment_(SHELF_ALIGNMENT_BOTTOM), | 51 alignment_(SHELF_ALIGNMENT_BOTTOM), |
| 48 image_(NULL) { | 52 image_(NULL) { |
| 49 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 53 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 50 image_ = rb.GetImageNamed(IDR_AURA_LAUNCHER_OVERFLOW).ToImageSkia(); | 54 image_ = rb.GetImageNamed(IDR_AURA_LAUNCHER_OVERFLOW).ToImageSkia(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } | 109 } |
| 106 | 110 |
| 107 if (height() < kButtonHoverSize) | 111 if (height() < kButtonHoverSize) |
| 108 return; | 112 return; |
| 109 | 113 |
| 110 gfx::Transform transform; | 114 gfx::Transform transform; |
| 111 | 115 |
| 112 switch (alignment_) { | 116 switch (alignment_) { |
| 113 case SHELF_ALIGNMENT_BOTTOM: | 117 case SHELF_ALIGNMENT_BOTTOM: |
| 114 // Shift 1 pixel left to align with overflow bubble tip. | 118 // Shift 1 pixel left to align with overflow bubble tip. |
| 115 transform.ConcatTranslate(-1, kBackgroundOffset); | 119 transform.Translate(-1, kBackgroundOffset); |
| 116 break; | 120 break; |
| 117 case SHELF_ALIGNMENT_LEFT: | 121 case SHELF_ALIGNMENT_LEFT: |
| 122 transform.Translate(kBackgroundOffset, -1); |
| 118 RotateClockwise(&transform); | 123 RotateClockwise(&transform); |
| 119 transform.ConcatTranslate(kBackgroundOffset, -1); | |
| 120 break; | 124 break; |
| 121 case SHELF_ALIGNMENT_RIGHT: | 125 case SHELF_ALIGNMENT_RIGHT: |
| 126 transform.Translate(kBackgroundOffset, height()); |
| 122 RotateCounterclockwise(&transform); | 127 RotateCounterclockwise(&transform); |
| 123 transform.ConcatTranslate(kBackgroundOffset, height()); | |
| 124 break; | 128 break; |
| 125 } | 129 } |
| 126 | 130 |
| 127 canvas->Save(); | 131 canvas->Save(); |
| 128 canvas->Transform(transform); | 132 canvas->Transform(transform); |
| 129 | 133 |
| 130 gfx::Rect rect(GetContentsBounds()); | 134 gfx::Rect rect(GetContentsBounds()); |
| 131 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { | 135 if (alignment_ == SHELF_ALIGNMENT_BOTTOM) { |
| 132 canvas->DrawImageInt(*image_, | 136 canvas->DrawImageInt(*image_, |
| 133 rect.x() + (rect.width() - image_->width()) / 2, | 137 rect.x() + (rect.width() - image_->width()) / 2, |
| 134 kButtonHoverSize - image_->height()); | 138 kButtonHoverSize - image_->height()); |
| 135 } else { | 139 } else { |
| 136 canvas->DrawImageInt(*image_, | 140 canvas->DrawImageInt(*image_, |
| 137 kButtonHoverSize - image_->width(), | 141 kButtonHoverSize - image_->width(), |
| 138 rect.y() + (rect.height() - image_->height()) / 2); | 142 rect.y() + (rect.height() - image_->height()) / 2); |
| 139 } | 143 } |
| 140 canvas->Restore(); | 144 canvas->Restore(); |
| 141 } | 145 } |
| 142 | 146 |
| 143 } // namespace internal | 147 } // namespace internal |
| 144 } // namespace ash | 148 } // namespace ash |
| OLD | NEW |