Commit 359cd931 authored by stevenjb@google.com's avatar stevenjb@google.com

Fix Ash status area bubble borders

BUG=137293

Review URL: https://chromiumcodereview.appspot.com/10831159

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149920 0039d316-1c4b-4281-b951-d872f2087c98
parent 1d4ae424
......@@ -30,9 +30,14 @@ namespace {
// detailed view.
const int kDetailedBubbleMaxHeight = kTrayPopupItemHeight * 5;
// TODO(stevenjb/jennyz): Remove this when TrayBubbleBorder is integrated with
// BubbleBorder. See crbug.com/132772, crbug.com/139813.
class TrayPopupItemBorder : public views::Border {
public:
explicit TrayPopupItemBorder(views::View* owner) : owner_(owner) {}
explicit TrayPopupItemBorder(views::View* owner, ShelfAlignment alignment)
: owner_(owner),
alignment_(alignment) {
}
virtual ~TrayPopupItemBorder() {}
private:
......@@ -47,24 +52,36 @@ class TrayPopupItemBorder : public views::Border {
canvas->FillRect(gfx::Rect(0, 0, view.width(), 1), kBorderDarkColor);
// Bottom border.
if (index != parent->child_count() - 1) {
if ((index != parent->child_count() - 1) ||
(alignment_ != SHELF_ALIGNMENT_BOTTOM)) {
canvas->FillRect(gfx::Rect(0, view.height() - 1, view.width(), 1),
kBorderLightColor);
}
// Left and right borders.
canvas->FillRect(gfx::Rect(0, 0, 1, view.height()), kBorderDarkColor);
canvas->FillRect(gfx::Rect(view.width() - 1, 0, 1, view.height()),
kBorderDarkColor);
if (alignment_ != SHELF_ALIGNMENT_LEFT) {
canvas->FillRect(gfx::Rect(0, 0, 1, view.height()),
kBorderDarkColor);
}
if (alignment_ != SHELF_ALIGNMENT_RIGHT) {
canvas->FillRect(gfx::Rect(view.width() - 1, 0, 1, view.height()),
kBorderDarkColor);
}
}
virtual void GetInsets(gfx::Insets* insets) const OVERRIDE {
const views::View* parent = owner_->parent();
int index = parent->GetIndexOf(owner_);
insets->Set(index == 0, 1, index != parent->child_count() - 1, 1);
int left = (alignment_ == SHELF_ALIGNMENT_LEFT) ? 0 : 1;
int right = (alignment_ == SHELF_ALIGNMENT_RIGHT) ? 0 : 1;
insets->Set(index == 0 ? 1 : 0,
left,
(index != parent->child_count() - 1) ? 1 : 0,
right);
}
views::View* owner_;
ShelfAlignment alignment_;
DISALLOW_COPY_AND_ASSIGN(TrayPopupItemBorder);
};
......@@ -73,11 +90,13 @@ class TrayPopupItemBorder : public views::Border {
// - optionally changes background color on hover.
class TrayPopupItemContainer : public views::View {
public:
TrayPopupItemContainer(views::View* view, bool change_background)
TrayPopupItemContainer(views::View* view,
ShelfAlignment alignment,
bool change_background)
: hover_(false),
change_background_(change_background) {
set_notify_enter_exit_on_child(true);
set_border(new TrayPopupItemBorder(this));
set_border(new TrayPopupItemBorder(this, alignment));
views::BoxLayout* layout = new views::BoxLayout(
views::BoxLayout::kVertical, 0, 0, 0);
layout->set_spread_blank_space(true);
......@@ -385,7 +404,7 @@ void SystemTrayBubble::CreateItemViews(user::LoginStatus login_status) {
}
if (view) {
bubble_view_->AddChildView(new TrayPopupItemContainer(
view, bubble_type_ == BUBBLE_TYPE_DEFAULT));
view, tray_->shelf_alignment(), bubble_type_ == BUBBLE_TYPE_DEFAULT));
}
}
}
......
......@@ -482,12 +482,25 @@ class WebNotificationButtonView : public views::View,
class WebContentsView : public views::View {
public:
WebContentsView() {}
explicit WebContentsView(WebNotificationTray* tray)
: tray_(tray) {
// TODO(stevenjb): Remove this border when TrayBubbleBorder is integrated
// with BubbleBorder.
int left = (tray->shelf_alignment() == SHELF_ALIGNMENT_LEFT) ? 0 : 1;
int right = (tray->shelf_alignment() == SHELF_ALIGNMENT_RIGHT) ? 0 : 1;
int bottom = (tray->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) ? 0 : 1;
set_border(views::Border::CreateSolidSidedBorder(
1, left, bottom, right, ash::kBorderDarkColor));
set_notify_enter_exit_on_child(true);
}
virtual ~WebContentsView() {}
virtual void Update(
const WebNotificationList::Notifications& notifications) = 0;
protected:
WebNotificationTray* tray_;
private:
DISALLOW_COPY_AND_ASSIGN(WebContentsView);
};
......@@ -495,10 +508,7 @@ class WebContentsView : public views::View {
class MessageCenterContentsView : public WebContentsView {
public:
explicit MessageCenterContentsView(WebNotificationTray* tray)
: tray_(tray) {
set_border(views::Border::CreateSolidSidedBorder(
1, 1, 1, 1, ash::kBorderDarkColor));
: WebContentsView(tray) {
SetLayoutManager(
new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1));
set_background(views::Background::CreateSolidBackground(kBackgroundColor));
......@@ -542,7 +552,6 @@ class MessageCenterContentsView : public WebContentsView {
scroller_->SizeToPreferredSize();
}
WebNotificationTray* tray_;
internal::FixedSizedScrollView* scroller_;
views::View* scroll_content_;
internal::WebNotificationButtonView* button_view_;
......@@ -553,10 +562,7 @@ class MessageCenterContentsView : public WebContentsView {
class WebNotificationContentsView : public WebContentsView {
public:
explicit WebNotificationContentsView(WebNotificationTray* tray)
: tray_(tray) {
set_border(views::Border::CreateSolidSidedBorder(
1, 1, 1, 1, ash::kBorderDarkColor));
: WebContentsView(tray) {
SetLayoutManager(
new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1));
set_background(views::Background::CreateSolidBackground(kBackgroundColor));
......@@ -577,7 +583,6 @@ class WebNotificationContentsView : public WebContentsView {
}
private:
WebNotificationTray* tray_;
views::View* content_;
DISALLOW_COPY_AND_ASSIGN(WebNotificationContentsView);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment