summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-24 16:10:57 +0000
committerdavemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-24 16:10:57 +0000
commitb4b45aa8d146d13a9bb1c7278fa6fdf26ca08909 (patch)
treee607b83d1c543ba35680000aad1b035117569361
parent0398e99891af9f242d7403a642a4ce9ace49de1f (diff)
downloadchromium_src-b4b45aa8d146d13a9bb1c7278fa6fdf26ca08909.zip
chromium_src-b4b45aa8d146d13a9bb1c7278fa6fdf26ca08909.tar.gz
chromium_src-b4b45aa8d146d13a9bb1c7278fa6fdf26ca08909.tar.bz2
Fix app list and overflow icon drawing problems
BUG=150903,150902 TEST=Visual Review URL: https://codereview.chromium.org/10967065 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158287 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/launcher/app_list_button.cc2
-rw-r--r--ash/launcher/overflow_button.cc40
2 files changed, 32 insertions, 10 deletions
diff --git a/ash/launcher/app_list_button.cc b/ash/launcher/app_list_button.cc
index dcfaa3a..26ebb5b 100644
--- a/ash/launcher/app_list_button.cc
+++ b/ash/launcher/app_list_button.cc
@@ -25,7 +25,7 @@ namespace {
const int kAnimationDurationInMs = 600;
const float kAnimationOpacity[] = { 1.0f, 0.4f, 1.0f };
-const int kImageOffsetY = 8;
+const int kImageOffsetY = 7;
} // namespace
AppListButton::AppListButton(views::ButtonListener* listener,
diff --git a/ash/launcher/overflow_button.cc b/ash/launcher/overflow_button.cc
index c06d448..a0673a0 100644
--- a/ash/launcher/overflow_button.cc
+++ b/ash/launcher/overflow_button.cc
@@ -26,6 +26,8 @@ const int kButtonCornerRadius = 2;
const int kButtonHoverSize = 28;
+const int kBackgroundOffset = (48 - kButtonHoverSize) / 2;
+
void RotateCounterclockwise(ui::Transform* transform) {
transform->matrix().set3x3(0, -1, 0,
1, 0, 0,
@@ -65,8 +67,20 @@ void OverflowButton::SetShelfAlignment(ShelfAlignment alignment) {
}
void OverflowButton::PaintBackground(gfx::Canvas* canvas, int alpha) {
- gfx::Rect rect(GetContentsBounds());
- rect = rect.Center(gfx::Size(kButtonHoverSize, kButtonHoverSize));
+ gfx::Rect bounds(GetContentsBounds());
+ gfx::Rect rect(0, 0, kButtonHoverSize, kButtonHoverSize);
+
+ // Nudge the background a little to line up right.
+ if (alignment_ == SHELF_ALIGNMENT_BOTTOM) {
+ rect.set_origin(gfx::Point(
+ bounds.x() + ((bounds.width() - kButtonHoverSize) / 2) - 1,
+ bounds.y() + kBackgroundOffset - 1));
+
+ } else {
+ rect.set_origin(gfx::Point(
+ bounds.x() + kBackgroundOffset - 1,
+ bounds.y() + ((bounds.height() - kButtonHoverSize) / 2) - 1));
+ }
SkPaint paint;
paint.setAntiAlias(true);
@@ -90,20 +104,23 @@ void OverflowButton::OnPaint(gfx::Canvas* canvas) {
PaintBackground(canvas, kButtonHoverAlpha);
}
+ if (height() < kButtonHoverSize)
+ return;
+
ui::Transform transform;
switch (alignment_) {
case SHELF_ALIGNMENT_BOTTOM:
// Shift 1 pixel left to align with overflow bubble tip.
- transform.ConcatTranslate(-1, 0);
+ transform.ConcatTranslate(-1, kBackgroundOffset);
break;
case SHELF_ALIGNMENT_LEFT:
RotateClockwise(&transform);
- transform.ConcatTranslate(width(), -1);
+ transform.ConcatTranslate(kBackgroundOffset, -1);
break;
case SHELF_ALIGNMENT_RIGHT:
RotateCounterclockwise(&transform);
- transform.ConcatTranslate(0, height());
+ transform.ConcatTranslate(kBackgroundOffset, height());
break;
}
@@ -111,10 +128,15 @@ void OverflowButton::OnPaint(gfx::Canvas* canvas) {
canvas->Transform(transform);
gfx::Rect rect(GetContentsBounds());
- canvas->DrawImageInt(*image_,
- rect.x() + (rect.width() - image_->width()) / 2,
- rect.y() + (rect.height() - image_->height()) / 2);
-
+ if (alignment_ == SHELF_ALIGNMENT_BOTTOM) {
+ canvas->DrawImageInt(*image_,
+ rect.x() + (rect.width() - image_->width()) / 2,
+ kButtonHoverSize - image_->height());
+ } else {
+ canvas->DrawImageInt(*image_,
+ kButtonHoverSize - image_->width(),
+ rect.y() + (rect.height() - image_->height()) / 2);
+ }
canvas->Restore();
}