summaryrefslogtreecommitdiffstats
path: root/ash/system/tray
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-11 17:42:48 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-11 17:42:48 +0000
commit6f2679a2a9bb0693be012a67882aa49016aa50cf (patch)
treedf5ccd14b5ef20a4ed135add33e9801dfaff6fa4 /ash/system/tray
parent4710bbf4b8cfa525d2019faab4a7a4ccc61e5e1d (diff)
downloadchromium_src-6f2679a2a9bb0693be012a67882aa49016aa50cf.zip
chromium_src-6f2679a2a9bb0693be012a67882aa49016aa50cf.tar.gz
chromium_src-6f2679a2a9bb0693be012a67882aa49016aa50cf.tar.bz2
Move the header entries in the sub-dialogs at the bottom of the dialogs.
BUG=127430 TEST=none Review URL: https://chromiumcodereview.appspot.com/10388079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136605 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/system/tray')
-rw-r--r--ash/system/tray/system_tray.cc2
-rw-r--r--ash/system/tray/system_tray_bubble.cc37
-rw-r--r--ash/system/tray/tray_constants.cc6
-rw-r--r--ash/system/tray/tray_constants.h4
-rw-r--r--ash/system/tray/tray_views.cc88
-rw-r--r--ash/system/tray/tray_views.h26
6 files changed, 110 insertions, 53 deletions
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 5342f9c..e0362d5 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -23,7 +23,6 @@
#include "ash/system/tray/system_tray_item.h"
#include "ash/system/tray/system_tray_widget_delegate.h"
#include "ash/system/tray/tray_constants.h"
-#include "ash/system/tray/tray_empty.h"
#include "ash/system/tray_accessibility.h"
#include "ash/system/tray_caps_lock.h"
#include "ash/system/tray_update.h"
@@ -195,7 +194,6 @@ void SystemTray::CreateItems() {
user_observer_ = tray_user;
AddTrayItem(tray_user);
- AddTrayItem(new internal::TrayEmpty());
AddTrayItem(tray_power);
AddTrayItem(tray_network);
AddTrayItem(tray_bluetooth);
diff --git a/ash/system/tray/system_tray_bubble.cc b/ash/system/tray/system_tray_bubble.cc
index 8a7810f..4dce878 100644
--- a/ash/system/tray/system_tray_bubble.cc
+++ b/ash/system/tray/system_tray_bubble.cc
@@ -148,18 +148,18 @@ class SystemTrayBubbleBackground : public views::Background {
gfx::Point(v->x() + v->width(), v->y() - 1),
!last_view || last_view->border() ? kBorderDarkColor :
kBorderLightColor);
- canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1),
- gfx::Point(v->x() - 1, v->y() + v->height() + 1),
- kBorderDarkColor);
- canvas->DrawLine(gfx::Point(v->x() + v->width(), v->y() - 1),
- gfx::Point(v->x() + v->width(), v->y() + v->height() + 1),
- kBorderDarkColor);
} else if (last_view && !last_view->border()) {
canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1),
gfx::Point(v->x() + v->width() + 1, v->y() - 1),
kBorderDarkColor);
}
+ canvas->DrawLine(gfx::Point(v->x() - 1, v->y() - 1),
+ gfx::Point(v->x() - 1, v->y() + v->height() + 1),
+ kBorderDarkColor);
+ canvas->DrawLine(gfx::Point(v->x() + v->width(), v->y() - 1),
+ gfx::Point(v->x() + v->width(), v->y() + v->height() + 1),
+ kBorderDarkColor);
last_view = v;
}
}
@@ -190,29 +190,10 @@ class SystemTrayBubbleBorder : public views::BubbleBorder {
// Overridden from views::Border.
virtual void Paint(const views::View& view,
gfx::Canvas* canvas) const OVERRIDE {
- views::View* first = NULL, *last = NULL;
gfx::Insets inset;
GetInsets(&inset);
- for (int i = 0; i < owner_->child_count(); i++) {
- views::View* v = owner_->child_at(i);
- if (v->border()) {
- if (first) {
- DrawBlurredShadowAroundView(canvas, first->y(),
- last->y() + last->height(), owner_->width(), inset);
- first = NULL;
- last = NULL;
- }
- continue;
- }
-
- if (!first)
- first = v;
- last = v;
- }
- if (first) {
- DrawBlurredShadowAroundView(canvas, first->y(),
- last->y() + last->height(), owner_->width(), inset);
- }
+ DrawBlurredShadowAroundView(canvas, 0, owner_->height(), owner_->width(),
+ inset);
// Draw the bottom line.
int y = owner_->height() + 1;
@@ -238,7 +219,7 @@ class SystemTrayBubbleBorder : public views::BubbleBorder {
SkPaint paint;
paint.setStyle(SkPaint::kFill_Style);
- paint.setColor(kBackgroundColor);
+ paint.setColor(kHeaderBackgroundColorDark);
canvas->DrawPath(path, paint);
// Now draw the arrow border.
diff --git a/ash/system/tray/tray_constants.cc b/ash/system/tray/tray_constants.cc
index d4427e9..4799a31 100644
--- a/ash/system/tray/tray_constants.cc
+++ b/ash/system/tray/tray_constants.cc
@@ -24,10 +24,10 @@ const int kTrayRoundedBorderRadius = 2;
const SkColor kBackgroundColor = SkColorSetRGB(0xfe, 0xfe, 0xfe);
const SkColor kHoverBackgroundColor = SkColorSetRGB(0xf5, 0xf5, 0xf5);
-const SkColor kHeaderBackgroundColor = SkColorSetRGB(0xf1, 0xf1, 0xf1);
-const SkColor kHeaderHoverBackgroundColor = SkColorSetRGB(0xe1, 0xe1, 0xe1);
+const SkColor kHeaderBackgroundColorLight = SkColorSetRGB(0xf1, 0xf1, 0xf1);
+const SkColor kHeaderBackgroundColorDark = SkColorSetRGB(0xe7, 0xe7, 0xe7);
-const SkColor kBorderDarkColor = SkColorSetARGB(51, 0, 0, 0);
+const SkColor kBorderDarkColor = SkColorSetRGB(0xbb, 0xbb, 0xbb);
const SkColor kBorderLightColor = SkColorSetRGB(0xeb, 0xeb, 0xeb);
const SkColor kButtonStrokeColor = SkColorSetRGB(0xdd, 0xdd, 0xdd);
diff --git a/ash/system/tray/tray_constants.h b/ash/system/tray/tray_constants.h
index 7db11d6..852db20 100644
--- a/ash/system/tray/tray_constants.h
+++ b/ash/system/tray/tray_constants.h
@@ -26,8 +26,8 @@ extern const int kTrayRoundedBorderRadius;
extern const SkColor kBackgroundColor;
extern const SkColor kHoverBackgroundColor;
-extern const SkColor kHeaderBackgroundColor;
-extern const SkColor kHeaderHoverBackgroundColor;
+extern const SkColor kHeaderBackgroundColorLight;
+extern const SkColor kHeaderBackgroundColorDark;
extern const SkColor kBorderDarkColor;
extern const SkColor kBorderLightColor;
diff --git a/ash/system/tray/tray_views.cc b/ash/system/tray/tray_views.cc
index d4b675a..573f5cc 100644
--- a/ash/system/tray/tray_views.cc
+++ b/ash/system/tray/tray_views.cc
@@ -16,6 +16,7 @@
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
+#include "ui/views/painter.h"
namespace ash {
namespace internal {
@@ -23,6 +24,15 @@ namespace internal {
namespace {
const int kIconPaddingLeft = 5;
const int kPaddingAroundButtons = 5;
+
+views::View* CreatePopupHeaderButtonsContainer() {
+ views::View* view = new views::View;
+ view->SetLayoutManager(new
+ views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, -1));
+ view->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 5));
+ return view;
+}
+
}
////////////////////////////////////////////////////////////////////////////////
@@ -291,7 +301,7 @@ void TrayPopupTextButtonContainer::AddTextButton(TrayPopupTextButton* button) {
}
////////////////////////////////////////////////////////////////////////////////
-// TrayPopupTextButtonContainer
+// TrayPopupHeaderButton
TrayPopupHeaderButton::TrayPopupHeaderButton(views::ButtonListener* listener,
int enabled_resource_id,
@@ -304,8 +314,6 @@ TrayPopupHeaderButton::TrayPopupHeaderButton(views::ButtonListener* listener,
bundle.GetImageNamed(disabled_resource_id).ToSkBitmap());
SetImageAlignment(views::ImageButton::ALIGN_CENTER,
views::ImageButton::ALIGN_MIDDLE);
- set_background(views::Background::CreateSolidBackground(
- ash::kHeaderBackgroundColor));
set_focusable(true);
}
@@ -316,8 +324,11 @@ gfx::Size TrayPopupHeaderButton::GetPreferredSize() {
}
void TrayPopupHeaderButton::OnPaintBorder(gfx::Canvas* canvas) {
- // Left border.
- canvas->FillRect(gfx::Rect(0, 0, 1, height()), ash::kBorderDarkColor);
+ // Just the left border.
+ const int kBorderHeight = 25;
+ int padding = (height() - kBorderHeight) / 2;
+ canvas->FillRect(gfx::Rect(0, padding, 1, height() - padding * 2),
+ ash::kBorderDarkColor);
}
void TrayPopupHeaderButton::OnPaintFocusBorder(gfx::Canvas* canvas) {
@@ -328,13 +339,26 @@ void TrayPopupHeaderButton::OnPaintFocusBorder(gfx::Canvas* canvas) {
}
void TrayPopupHeaderButton::StateChanged() {
- set_background(views::Background::CreateSolidBackground(
- IsHotTracked() ? ash::kHeaderHoverBackgroundColor :
- ash::kHeaderBackgroundColor));
+ SchedulePaint();
}
-views::View* CreateDetailedHeaderEntry(int string_id,
- ViewClickListener* listener) {
+SpecialPopupRow::SpecialPopupRow()
+ : content_(NULL),
+ button_container_(NULL) {
+ set_background(views::Background::CreateBackgroundPainter(true,
+ views::Painter::CreateVerticalGradient(
+ kHeaderBackgroundColorLight,
+ kHeaderBackgroundColorDark)));
+ set_border(views::Border::CreateSolidSidedBorder(2, 0, 0, 0,
+ ash::kBorderDarkColor));
+ SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
+}
+
+SpecialPopupRow::~SpecialPopupRow() {
+}
+
+void SpecialPopupRow::SetTextLabel(int string_id, ViewClickListener* listener) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
HoverHighlightView* container = new HoverHighlightView(listener);
container->set_fixed_height(kTrayPopupItemHeight);
@@ -347,13 +371,49 @@ views::View* CreateDetailedHeaderEntry(int string_id,
container->AddChildView(back);
views::Label* header = new views::Label(rb.GetLocalizedString(string_id));
header->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- header->SetFont(header->font().DeriveFont(4));
+ header->SetFont(header->font().DeriveFont(0, gfx::Font::BOLD));
container->AddChildView(header);
container->SetAccessibleName(
rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_PREVIOUS_MENU));
- container->set_highlight_color(kHeaderHoverBackgroundColor);
- container->set_default_color(kHeaderBackgroundColor);
- return container;
+ container->set_highlight_color(SkColorSetARGB(0, 0, 0, 0));
+ container->set_default_color(SkColorSetARGB(0, 0, 0, 0));
+ SetContent(container);
+}
+
+void SpecialPopupRow::SetContent(views::View* view) {
+ CHECK(!content_);
+ content_ = view;
+ AddChildViewAt(content_, 0);
+}
+
+void SpecialPopupRow::AddButton(TrayPopupHeaderButton* button) {
+ if (!button_container_) {
+ button_container_ = CreatePopupHeaderButtonsContainer();
+ AddChildView(button_container_);
+ }
+
+ button_container_->AddChildView(button);
+}
+
+void SpecialPopupRow::Layout() {
+ views::View::Layout();
+ gfx::Rect content_bounds = GetContentsBounds();
+ if (content_bounds.IsEmpty())
+ return;
+ if (!button_container_) {
+ content_->SetBoundsRect(GetContentsBounds());
+ return;
+ }
+
+ gfx::Rect bounds(button_container_->GetPreferredSize());
+ bounds.set_height(content_bounds.height());
+ bounds = content_bounds.Center(bounds.size());
+ bounds.set_x(content_bounds.width() - bounds.width());
+ button_container_->SetBoundsRect(bounds);
+
+ bounds = content_->bounds();
+ bounds.set_width(button_container_->x());
+ content_->SetBoundsRect(bounds);
}
void SetupLabelForTray(views::Label* label) {
diff --git a/ash/system/tray/tray_views.h b/ash/system/tray/tray_views.h
index c91bdf4..54b2846 100644
--- a/ash/system/tray/tray_views.h
+++ b/ash/system/tray/tray_views.h
@@ -207,10 +207,28 @@ class TrayPopupHeaderButton : public views::ToggleImageButton {
DISALLOW_COPY_AND_ASSIGN(TrayPopupHeaderButton);
};
-// Creates a container for the various detailed popups. Clicking on the view
-// triggers the callback in ViewClickListener.
-views::View* CreateDetailedHeaderEntry(int string_id,
- ViewClickListener* listener);
+// The 'special' looking row in the uber-tray popups. This is usually the bottom
+// row in the popups.
+class SpecialPopupRow : public views::View {
+ public:
+ SpecialPopupRow();
+ virtual ~SpecialPopupRow();
+
+ void SetTextLabel(int string_id, ViewClickListener* listener);
+ void SetContent(views::View* view);
+
+ void AddButton(TrayPopupHeaderButton* button);
+
+ views::View* content() const { return content_; }
+
+ private:
+ // Overridden from views::View.
+ virtual void Layout() OVERRIDE;
+
+ views::View* content_;
+ views::View* button_container_;
+ DISALLOW_COPY_AND_ASSIGN(SpecialPopupRow);
+};
// Sets up a Label properly for the tray (sets color, font etc.).
void SetupLabelForTray(views::Label* label);