diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 17:42:48 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-11 17:42:48 +0000 |
commit | 6f2679a2a9bb0693be012a67882aa49016aa50cf (patch) | |
tree | df5ccd14b5ef20a4ed135add33e9801dfaff6fa4 | |
parent | 4710bbf4b8cfa525d2019faab4a7a4ccc61e5e1d (diff) | |
download | chromium_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
-rw-r--r-- | ash/system/bluetooth/tray_bluetooth.cc | 35 | ||||
-rw-r--r-- | ash/system/date/tray_date.cc | 59 | ||||
-rw-r--r-- | ash/system/drive/tray_drive.cc | 10 | ||||
-rw-r--r-- | ash/system/ime/tray_ime.cc | 9 | ||||
-rw-r--r-- | ash/system/network/tray_network.cc | 54 | ||||
-rw-r--r-- | ash/system/tray/system_tray.cc | 2 | ||||
-rw-r--r-- | ash/system/tray/system_tray_bubble.cc | 37 | ||||
-rw-r--r-- | ash/system/tray/tray_constants.cc | 6 | ||||
-rw-r--r-- | ash/system/tray/tray_constants.h | 4 | ||||
-rw-r--r-- | ash/system/tray/tray_views.cc | 88 | ||||
-rw-r--r-- | ash/system/tray/tray_views.h | 26 |
11 files changed, 153 insertions, 177 deletions
diff --git a/ash/system/bluetooth/tray_bluetooth.cc b/ash/system/bluetooth/tray_bluetooth.cc index cd0a9d9..dcd561b 100644 --- a/ash/system/bluetooth/tray_bluetooth.cc +++ b/ash/system/bluetooth/tray_bluetooth.cc @@ -63,7 +63,6 @@ class BluetoothDetailedView : public views::View, explicit BluetoothDetailedView(user::LoginStatus login) : login_(login), header_(NULL), - header_text_(NULL), add_device_(NULL), toggle_bluetooth_(NULL) { SetLayoutManager(new views::BoxLayout( @@ -81,28 +80,22 @@ class BluetoothDetailedView : public views::View, RemoveAllChildViews(true); header_ = NULL; - header_text_ = NULL; add_device_ = NULL; toggle_bluetooth_ = NULL; - AppendHeaderEntry(); AppendDeviceList(list); AppendSettingsEntries(); + AppendHeaderEntry(); Layout(); } private: void AppendHeaderEntry() { - header_ = new views::View; - header_->SetLayoutManager(new - views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); + header_ = new SpecialPopupRow(); + header_->SetTextLabel(IDS_ASH_STATUS_TRAY_BLUETOOTH, this); AddChildView(header_); - header_text_ = CreateDetailedHeaderEntry(IDS_ASH_STATUS_TRAY_BLUETOOTH, - this); - header_->AddChildView(header_text_); - if (login_ == user::LOGGED_IN_LOCKED) return; @@ -113,7 +106,7 @@ class BluetoothDetailedView : public views::View, IDR_AURA_UBER_TRAY_BLUETOOTH_ENABLED, IDR_AURA_UBER_TRAY_BLUETOOTH_DISABLED); toggle_bluetooth_->SetToggled(!delegate->GetBluetoothEnabled()); - header_->AddChildView(toggle_bluetooth_); + header_->AddButton(toggle_bluetooth_); } void AppendDeviceList(const BluetoothDeviceList& list) { @@ -162,26 +155,11 @@ class BluetoothDetailedView : public views::View, add_device_ = container; } - // Overridden from views::View. - virtual void Layout() OVERRIDE { - views::View::Layout(); - if (toggle_bluetooth_) { - // Right-align the toggle-bluetooth button. - gfx::Rect header_bounds = header_->bounds(); - gfx::Size button_size = toggle_bluetooth_->size(); - - toggle_bluetooth_->SetBounds(header_->width() - button_size.width(), 0, - button_size.width(), header_->height()); - header_text_->SetBounds(0, 0, header_->width() - button_size.width(), - header_->height()); - } - } - // Overridden from ViewClickListener. virtual void ClickedOn(views::View* sender) OVERRIDE { ash::SystemTrayDelegate* delegate = ash::Shell::GetInstance()->tray_delegate(); - if (sender == header_text_) { + if (sender == header_->content()) { Shell::GetInstance()->tray()->ShowDefaultView(); } else if (sender == add_device_) { delegate->AddBluetoothDevice(); @@ -209,8 +187,7 @@ class BluetoothDetailedView : public views::View, user::LoginStatus login_; std::map<views::View*, std::string> device_map_; - views::View* header_; - views::View* header_text_; + SpecialPopupRow* header_; views::View* add_device_; TrayPopupHeaderButton* toggle_bluetooth_; views::View* settings_; diff --git a/ash/system/date/tray_date.cc b/ash/system/date/tray_date.cc index cf89036..5288947 100644 --- a/ash/system/date/tray_date.cc +++ b/ash/system/date/tray_date.cc @@ -27,6 +27,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" #include "ui/views/view.h" #include "ui/views/widget/widget.h" #include "unicode/datefmt.h" @@ -41,11 +42,10 @@ class DateDefaultView : public views::View, public views::ButtonListener { public: explicit DateDefaultView(ash::user::LoginStatus login) - : button_container_(NULL) { - SetLayoutManager(new views::BoxLayout( - views::BoxLayout::kHorizontal, 0, 0, 0)); - set_background(views::Background::CreateSolidBackground( - ash::kHeaderBackgroundColor)); + : help_(NULL), + shutdown_(NULL), + lock_(NULL) { + SetLayoutManager(new views::FillLayout); ash::internal::tray::DateView* date_view = new ash::internal::tray::DateView(); @@ -53,12 +53,9 @@ class DateDefaultView : public views::View, ash::kTrayPopupPaddingHorizontal, kPaddingVertical, ash::kTrayPopupPaddingHorizontal)); - ash::internal::HoverHighlightView* view = - new ash::internal::HoverHighlightView(NULL); - view->SetLayoutManager(new views::FillLayout); - view->set_focusable(false); - view->set_highlight_color(SkColorSetARGB(0, 0, 0, 0)); - view->AddChildView(date_view); + + ash::internal::SpecialPopupRow* view = new ash::internal::SpecialPopupRow(); + view->SetContent(date_view); AddChildView(view); if (login == ash::user::LOGGED_IN_LOCKED || @@ -66,57 +63,31 @@ class DateDefaultView : public views::View, return; date_view->SetActionable(true); - view->set_highlight_color(ash::kHeaderHoverBackgroundColor); - date_ = view; - - button_container_ = new views::View; - button_container_->SetLayoutManager(new - views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); help_ = new ash::internal::TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_HELP, IDR_AURA_UBER_TRAY_HELP); - button_container_->AddChildView(help_); - - shutdown_ = lock_ = NULL; + view->AddButton(help_); if (login != ash::user::LOGGED_IN_LOCKED && login != ash::user::LOGGED_IN_KIOSK) { shutdown_ = new ash::internal::TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_SHUTDOWN, IDR_AURA_UBER_TRAY_SHUTDOWN); - button_container_->AddChildView(shutdown_); + view->AddButton(shutdown_); if (login != ash::user::LOGGED_IN_GUEST) { lock_ = new ash::internal::TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_LOCKSCREEN, IDR_AURA_UBER_TRAY_LOCKSCREEN); - button_container_->AddChildView(lock_); + view->AddButton(lock_); } } - AddChildView(button_container_); } virtual ~DateDefaultView() {} private: - // Overridden from views::View. - virtual void Layout() OVERRIDE { - views::View::Layout(); - if (!button_container_) - return; - - gfx::Rect bounds(button_container_->GetPreferredSize()); - bounds.set_height(height()); - bounds = gfx::Rect(size()).Center(bounds.size()); - bounds.set_x(width() - bounds.width()); - button_container_->SetBoundsRect(bounds); - - bounds = date_->bounds(); - bounds.set_width(button_container_->x()); - date_->SetBoundsRect(bounds); - } - // Overridden from views::ButtonListener. virtual void ButtonPressed(views::Button* sender, const views::Event& event) OVERRIDE { @@ -131,11 +102,9 @@ class DateDefaultView : public views::View, NOTREACHED(); } - views::View* button_container_; - views::View* date_; - views::ToggleImageButton* help_; - views::ToggleImageButton* shutdown_; - views::ToggleImageButton* lock_; + ash::internal::TrayPopupHeaderButton* help_; + ash::internal::TrayPopupHeaderButton* shutdown_; + ash::internal::TrayPopupHeaderButton* lock_; DISALLOW_COPY_AND_ASSIGN(DateDefaultView); }; diff --git a/ash/system/drive/tray_drive.cc b/ash/system/drive/tray_drive.cc index 9da6397..3bdbd30 100644 --- a/ash/system/drive/tray_drive.cc +++ b/ash/system/drive/tray_drive.cc @@ -116,9 +116,10 @@ class DriveDetailedView : public views::View, } void Update(const DriveOperationStatusList* list) { - AppendHeaderEntry(list); AppendOperationList(list); AppendSettings(); + AppendHeaderEntry(list); + PreferredSizeChanged(); SchedulePaint(); } @@ -267,7 +268,8 @@ class DriveDetailedView : public views::View, void AppendHeaderEntry(const DriveOperationStatusList* list) { if (header_) return; - header_ = CreateDetailedHeaderEntry(IDS_ASH_STATUS_TRAY_DRIVE, this); + header_ = new SpecialPopupRow(); + header_->SetTextLabel(IDS_ASH_STATUS_TRAY_DRIVE, this); AddChildView(header_); } @@ -361,7 +363,7 @@ class DriveDetailedView : public views::View, // Overridden from ViewClickListener. virtual void ClickedOn(views::View* sender) OVERRIDE { SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); - if (sender == header_) { + if (sender == header_->content()) { Shell::GetInstance()->tray()->ShowDefaultView(); } else if (sender == settings_) { delegate->ShowDriveSettings(); @@ -370,7 +372,7 @@ class DriveDetailedView : public views::View, // Maps operation entries to their file paths. std::map<FilePath, RowView*> update_map_; - views::View* header_; + SpecialPopupRow* header_; views::View* operations_; views::View* settings_; SkBitmap* in_progress_img_; diff --git a/ash/system/ime/tray_ime.cc b/ash/system/ime/tray_ime.cc index 6d244af..e859372 100644 --- a/ash/system/ime/tray_ime.cc +++ b/ash/system/ime/tray_ime.cc @@ -79,12 +79,12 @@ class IMEDetailedView : public views::View, header_ = NULL; - AppendHeaderEntry(); AppendIMEList(list); if (!property_list.empty()) AppendIMEProperties(property_list); if (login_ != user::LOGGED_IN_NONE && login_ != user::LOGGED_IN_LOCKED) AppendSettings(); + AppendHeaderEntry(); Layout(); SchedulePaint(); @@ -92,7 +92,8 @@ class IMEDetailedView : public views::View, private: void AppendHeaderEntry() { - header_ = CreateDetailedHeaderEntry(IDS_ASH_STATUS_TRAY_IME, this); + header_ = new SpecialPopupRow(); + header_->SetTextLabel(IDS_ASH_STATUS_TRAY_IME, this); AddChildView(header_); } @@ -146,7 +147,7 @@ class IMEDetailedView : public views::View, // Overridden from ViewClickListener. virtual void ClickedOn(views::View* sender) OVERRIDE { SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); - if (sender == header_) { + if (sender == header_->content()) { Shell::GetInstance()->tray()->ShowDefaultView(); } else if (sender == settings_) { delegate->ShowIMESettings(); @@ -173,7 +174,7 @@ class IMEDetailedView : public views::View, std::map<views::View*, std::string> ime_map_; std::map<views::View*, std::string> property_map_; - views::View* header_; + SpecialPopupRow* header_; views::View* settings_; DISALLOW_COPY_AND_ASSIGN(IMEDetailedView); diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc index 2015dfb..4e7ae09 100644 --- a/ash/system/network/tray_network.cc +++ b/ash/system/network/tray_network.cc @@ -157,8 +157,6 @@ class NetworkDetailedView : public views::View, explicit NetworkDetailedView(user::LoginStatus login) : login_(login), header_(NULL), - header_text_(NULL), - header_buttons_(NULL), airplane_(NULL), info_icon_(NULL), button_wifi_(NULL), @@ -190,8 +188,6 @@ class NetworkDetailedView : public views::View, RemoveAllChildViews(true); header_ = NULL; - header_text_ = NULL; - header_buttons_ = NULL; airplane_ = NULL; info_icon_ = NULL; button_wifi_ = NULL; @@ -205,10 +201,10 @@ class NetworkDetailedView : public views::View, settings_ = NULL; proxy_settings_ = NULL; - AppendHeaderEntry(); - AppendHeaderButtons(); AppendNetworkEntries(); AppendNetworkExtra(); + AppendHeaderEntry(); + AppendHeaderButtons(); Update(); } @@ -223,35 +219,26 @@ class NetworkDetailedView : public views::View, private: void AppendHeaderEntry() { - header_ = new views::View; - header_->SetLayoutManager(new - views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); - header_text_ = CreateDetailedHeaderEntry(IDS_ASH_STATUS_TRAY_NETWORK, this); - header_->AddChildView(header_text_); + header_ = new SpecialPopupRow(); + header_->SetTextLabel(IDS_ASH_STATUS_TRAY_NETWORK, this); AddChildView(header_); } void AppendHeaderButtons() { - header_buttons_ = new views::View; - header_buttons_->SetLayoutManager(new - views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); - button_wifi_ = new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_WIFI_ENABLED, IDR_AURA_UBER_TRAY_WIFI_DISABLED); - header_buttons_->AddChildView(button_wifi_); + header_->AddButton(button_wifi_); button_cellular_ = new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_CELLULAR_ENABLED, IDR_AURA_UBER_TRAY_CELLULAR_DISABLED); - header_buttons_->AddChildView(button_cellular_); + header_->AddButton(button_cellular_); info_icon_ = new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_NETWORK_INFO, IDR_AURA_UBER_TRAY_NETWORK_INFO); - header_buttons_->AddChildView(info_icon_); - - header_->AddChildView(header_buttons_); + header_->AddButton(info_icon_); } void UpdateHeaderButtons() { @@ -461,21 +448,6 @@ class NetworkDetailedView : public views::View, return true; } - // Overridden from views::View. - virtual void Layout() OVERRIDE { - views::View::Layout(); - - // Align the network info view and icon. - gfx::Rect header_bounds = header_->bounds(); - gfx::Size buttons_size = header_buttons_->size(); - - header_buttons_->SetBounds( - header_->width() - buttons_size.width(), 0, - buttons_size.width(), header_->height()); - header_text_->SetBounds(0, 0, - header_->width() - buttons_size.width(), header_->height()); - } - // Overridden from ButtonListener. virtual void ButtonPressed(views::Button* sender, const views::Event& event) OVERRIDE { @@ -513,7 +485,7 @@ class NetworkDetailedView : public views::View, // on. ResetInfoBubble(); - if (sender == header_text_) + if (sender == header_->content()) Shell::GetInstance()->tray()->ShowDefaultView(); if (login_ == user::LOGGED_IN_LOCKED) @@ -541,13 +513,11 @@ class NetworkDetailedView : public views::View, user::LoginStatus login_; std::map<views::View*, std::string> network_map_; - views::View* header_; - views::View* header_text_; - views::View* header_buttons_; + SpecialPopupRow* header_; views::View* airplane_; - views::ImageButton* info_icon_; - views::ToggleImageButton* button_wifi_; - views::ToggleImageButton* button_cellular_; + TrayPopupHeaderButton* info_icon_; + TrayPopupHeaderButton* button_wifi_; + TrayPopupHeaderButton* button_cellular_; views::View* view_mobile_account_; views::View* setup_mobile_account_; views::View* networks_list_; 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); |