summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/clock_menu_button.cc1
-rw-r--r--chrome/browser/chromeos/cros_power_library.cc7
-rw-r--r--chrome/browser/chromeos/cros_power_library.h3
-rw-r--r--chrome/browser/chromeos/network_menu_button.cc6
-rw-r--r--chrome/browser/chromeos/network_menu_button.h4
-rw-r--r--chrome/browser/chromeos/power_menu_button.cc9
-rw-r--r--chrome/browser/chromeos/power_menu_button.h5
-rw-r--r--chrome/browser/chromeos/status_area_button.cc43
-rw-r--r--chrome/browser/chromeos/status_area_button.h20
-rw-r--r--chrome/browser/chromeos/status_area_view.cc60
-rw-r--r--chrome/browser/chromeos/status_area_view.h7
11 files changed, 119 insertions, 46 deletions
diff --git a/chrome/browser/chromeos/clock_menu_button.cc b/chrome/browser/chromeos/clock_menu_button.cc
index 247b5fe..d89d474 100644
--- a/chrome/browser/chromeos/clock_menu_button.cc
+++ b/chrome/browser/chromeos/clock_menu_button.cc
@@ -26,6 +26,7 @@ ClockMenuButton::ClockMenuButton(Browser* browser)
: MenuButton(NULL, std::wstring(), this, false),
clock_menu_(this),
browser_(browser) {
+ set_border(NULL);
SetFont(ResourceBundle::GetSharedInstance().GetFont(
ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD));
SetEnabledColor(SK_ColorWHITE);
diff --git a/chrome/browser/chromeos/cros_power_library.cc b/chrome/browser/chromeos/cros_power_library.cc
index f3d8abf..ae3092b 100644
--- a/chrome/browser/chromeos/cros_power_library.cc
+++ b/chrome/browser/chromeos/cros_power_library.cc
@@ -56,9 +56,12 @@ bool CrosPowerLibrary::line_power_on() const {
return status_.line_power_on;
}
+bool CrosPowerLibrary::battery_is_present() const {
+ return status_.battery_is_present;
+}
+
bool CrosPowerLibrary::battery_fully_charged() const {
- return status_.line_power_on &&
- status_.battery_state == chromeos::BATTERY_STATE_FULLY_CHARGED;
+ return status_.battery_state == chromeos::BATTERY_STATE_FULLY_CHARGED;
}
double CrosPowerLibrary::battery_percentage() const {
diff --git a/chrome/browser/chromeos/cros_power_library.h b/chrome/browser/chromeos/cros_power_library.h
index 3184627..e01e76d 100644
--- a/chrome/browser/chromeos/cros_power_library.h
+++ b/chrome/browser/chromeos/cros_power_library.h
@@ -38,6 +38,9 @@ class CrosPowerLibrary {
// The percentage (0-100) of remaining battery.
double battery_percentage() const;
+ // Whether there is a battery present.
+ bool battery_is_present() const;
+
// The amount of time until battery is empty.
base::TimeDelta battery_time_to_empty() const;
diff --git a/chrome/browser/chromeos/network_menu_button.cc b/chrome/browser/chromeos/network_menu_button.cc
index 03746e4..93aefb5 100644
--- a/chrome/browser/chromeos/network_menu_button.cc
+++ b/chrome/browser/chromeos/network_menu_button.cc
@@ -22,12 +22,10 @@ const int NetworkMenuButton::kNumWifiImages = 8;
const int NetworkMenuButton::kThrobDuration = 1000;
NetworkMenuButton::NetworkMenuButton(gfx::NativeWindow browser_window)
- : MenuButton(NULL, std::wstring(), this, false),
- refreshing_menu_(false),
+ : StatusAreaButton(this),
ALLOW_THIS_IN_INITIALIZER_LIST(network_menu_(this)),
browser_window_(browser_window),
ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)) {
- SetShowHighlighted(false);
animation_.SetThrobDuration(kThrobDuration);
animation_.SetTweenType(SlideAnimation::NONE);
UpdateIcon();
@@ -142,7 +140,7 @@ void NetworkMenuButton::NetworkChanged(CrosNetworkLibrary* obj) {
void NetworkMenuButton::UpdateIcon() {
CrosNetworkLibrary* cros = CrosNetworkLibrary::Get();
- int id = IDR_STATUSBAR_DISCONNECTED;
+ int id = IDR_STATUSBAR_NETWORK_DISCONNECTED;
if (cros->wifi_connecting()) {
// Start the connecting animation if not running.
if (!animation_.IsAnimating())
diff --git a/chrome/browser/chromeos/network_menu_button.h b/chrome/browser/chromeos/network_menu_button.h
index 8a97348..4d2c3d0 100644
--- a/chrome/browser/chromeos/network_menu_button.h
+++ b/chrome/browser/chromeos/network_menu_button.h
@@ -11,7 +11,7 @@
#include "base/timer.h"
#include "chrome/browser/chromeos/cros_network_library.h"
#include "chrome/browser/chromeos/password_dialog_view.h"
-#include "views/controls/button/menu_button.h"
+#include "chrome/browser/chromeos/status_area_button.h"
#include "views/controls/menu/menu_2.h"
#include "views/controls/menu/view_menu_delegate.h"
@@ -22,7 +22,7 @@ class SkBitmap;
// This class will handle getting the wifi networks and populating the menu.
// It will also handle the status icon changing and connecting to another
// wifi network.
-class NetworkMenuButton : public views::MenuButton,
+class NetworkMenuButton : public StatusAreaButton,
public views::ViewMenuDelegate,
public views::Menu2Model,
public PasswordDialogDelegate,
diff --git a/chrome/browser/chromeos/power_menu_button.cc b/chrome/browser/chromeos/power_menu_button.cc
index 192893b..1ded368 100644
--- a/chrome/browser/chromeos/power_menu_button.cc
+++ b/chrome/browser/chromeos/power_menu_button.cc
@@ -14,12 +14,11 @@
// PowerMenuButton
// static
-const int PowerMenuButton::kNumPowerImages = 8;
+const int PowerMenuButton::kNumPowerImages = 16;
PowerMenuButton::PowerMenuButton()
- : MenuButton(NULL, std::wstring(), this, false),
+ : StatusAreaButton(this),
ALLOW_THIS_IN_INITIALIZER_LIST(power_menu_(this)) {
- SetShowHighlighted(false);
UpdateIcon();
CrosPowerLibrary::Get()->AddObserver(this);
}
@@ -102,7 +101,9 @@ void PowerMenuButton::UpdateIcon() {
CrosPowerLibrary* cros = CrosPowerLibrary::Get();
int id = IDR_STATUSBAR_BATTERY_UNKNOWN;
if (CrosPowerLibrary::loaded()) {
- if (cros->battery_fully_charged()) {
+ if (!cros->battery_is_present()) {
+ id = IDR_STATUSBAR_BATTERY_MISSING;
+ } else if (cros->line_power_on() && cros->battery_fully_charged()) {
id = IDR_STATUSBAR_BATTERY_CHARGED;
} else {
// If fully charged, always show 100% even if percentage is a bit less.
diff --git a/chrome/browser/chromeos/power_menu_button.h b/chrome/browser/chromeos/power_menu_button.h
index 7abe100..a250b26 100644
--- a/chrome/browser/chromeos/power_menu_button.h
+++ b/chrome/browser/chromeos/power_menu_button.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_CHROMEOS_POWER_MENU_BUTTON_H_
#include "chrome/browser/chromeos/cros_power_library.h"
-#include "views/controls/button/menu_button.h"
+#include "chrome/browser/chromeos/status_area_button.h"
#include "views/controls/menu/menu_2.h"
#include "views/controls/menu/view_menu_delegate.h"
@@ -15,8 +15,7 @@ class SkBitmap;
// The power menu button in the status area.
// This class will handle getting the power status and populating the menu.
-// It handles the status icon changing and connecting to another wifi power.
-class PowerMenuButton : public views::MenuButton,
+class PowerMenuButton : public StatusAreaButton,
public views::ViewMenuDelegate,
public views::Menu2Model,
public CrosPowerLibrary::Observer {
diff --git a/chrome/browser/chromeos/status_area_button.cc b/chrome/browser/chromeos/status_area_button.cc
new file mode 100644
index 0000000..694fb03
--- /dev/null
+++ b/chrome/browser/chromeos/status_area_button.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/status_area_button.h"
+
+#include "app/gfx/canvas.h"
+#include "app/gfx/skbitmap_operations.h"
+#include "app/resource_bundle.h"
+#include "grit/theme_resources.h"
+#include "views/border.h"
+#include "views/view.h"
+
+////////////////////////////////////////////////////////////////////////////////
+// StatusAreaButton
+
+StatusAreaButton::StatusAreaButton(views::ViewMenuDelegate* menu_delegate)
+ : MenuButton(NULL, std::wstring(), menu_delegate, false) {
+ set_border(NULL);
+ SetShowHighlighted(true);
+}
+
+void StatusAreaButton::Paint(gfx::Canvas* canvas, bool for_drag) {
+ int bitmap_id;
+
+ switch(state()) {
+ case BS_NORMAL:
+ bitmap_id = IDR_STATUSBAR_CONTAINER;
+ break;
+ case BS_HOT:
+ bitmap_id = IDR_STATUSBAR_CONTAINER_HOVER;
+ break;
+ case BS_PUSHED:
+ bitmap_id = IDR_STATUSBAR_CONTAINER_PRESSED;
+ break;
+ default:
+ NOTREACHED();
+ }
+ SkBitmap* container =
+ ResourceBundle::GetSharedInstance().GetBitmapNamed(bitmap_id);
+ canvas->DrawBitmapInt(*container, 0, 0);
+ canvas->DrawBitmapInt(icon(), 0, 0);
+}
diff --git a/chrome/browser/chromeos/status_area_button.h b/chrome/browser/chromeos/status_area_button.h
new file mode 100644
index 0000000..b862215
--- /dev/null
+++ b/chrome/browser/chromeos/status_area_button.h
@@ -0,0 +1,20 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_STATUS_AREA_BUTTON_H_
+#define CHROME_BROWSER_CHROMEOS_STATUS_AREA_BUTTON_H_
+
+#include "views/controls/button/menu_button.h"
+#include "views/controls/menu/view_menu_delegate.h"
+
+// Button to be used to represent status and allow menus to be popped up.
+// Shows current button state by drawing a border around the current icon.
+class StatusAreaButton : public views::MenuButton {
+ public:
+ StatusAreaButton(views::ViewMenuDelegate* menu_delegate);
+ virtual ~StatusAreaButton() {}
+ virtual void Paint(gfx::Canvas* canvas, bool for_drag);
+};
+
+#endif // CHROME_BROWSER_CHROMEOS_STATUS_AREA_BUTTON_H_
diff --git a/chrome/browser/chromeos/status_area_view.cc b/chrome/browser/chromeos/status_area_view.cc
index 6bb377a5..59f4f9c 100644
--- a/chrome/browser/chromeos/status_area_view.cc
+++ b/chrome/browser/chromeos/status_area_view.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/clock_menu_button.h"
#include "chrome/browser/chromeos/network_menu_button.h"
#include "chrome/browser/chromeos/power_menu_button.h"
+#include "chrome/browser/chromeos/status_area_button.h"
#if !defined(TOOLKIT_VIEWS)
#include "chrome/browser/gtk/browser_window_gtk.h"
#endif
@@ -23,14 +24,17 @@
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
-#include "views/controls/button/menu_button.h"
#include "views/controls/menu/menu.h"
#include "views/controls/menu/simple_menu_model.h"
namespace {
-// Number of pixels to separate adjacent status items.
-const int kStatusItemSeparation = 1;
+// Number of pixels to pad on the left border.
+const int kLeftBorder = 1;
+// Number of pixels to separate the clock from the next item on the right.
+const int kClockSeparation = 4;
+// Number of pixels to adjust the y value of the clock.
+const int kClockYAdjustment = 2;
// BrowserWindowGtk tiles its image with this offset
const int kCustomFrameBackgroundVerticalOffset = 15;
@@ -131,52 +135,56 @@ void StatusAreaView::Init() {
clock_view_ = new ClockMenuButton(browser_);
AddChildView(clock_view_);
- // Network.
- network_view_ = new NetworkMenuButton(window_);
- AddChildView(network_view_);
-
// Battery.
battery_view_ = new PowerMenuButton();
AddChildView(battery_view_);
+ // Network.
+ network_view_ = new NetworkMenuButton(window_);
+ AddChildView(network_view_);
+
// Menu.
- menu_view_ = new views::MenuButton(NULL, std::wstring(), this, false);
- menu_view_->SetShowHighlighted(false);
+ menu_view_ = new StatusAreaButton(this);
menu_view_->SetIcon(*theme->GetBitmapNamed(IDR_STATUSBAR_MENU));
AddChildView(menu_view_);
}
gfx::Size StatusAreaView::GetPreferredSize() {
- int result_w = kStatusItemSeparation; // Left border.
+ // Start with padding.
+ int result_w = kLeftBorder + kClockSeparation;
int result_h = 0;
for (int i = 0; i < GetChildViewCount(); i++) {
gfx::Size cur_size = GetChildViewAt(i)->GetPreferredSize();
- result_w += cur_size.width() + kStatusItemSeparation;
+ // Add each width.
+ result_w += cur_size.width();
+ // Use max height.
result_h = std::max(result_h, cur_size.height());
}
- result_w -= kStatusItemSeparation; // Don't have space after the last one.
-
- // TODO(brettw) do we need to use result_h? This is currently hardcoded
- // becuase the menu button really wants to be larger, but we don't want
- // the status bar to force the whole tab strip to be larger. Making it
- // "smaller" just means that we'll expand to the height, which we want.
- // The height of 24 makes it just big enough to sit on top of the shadow
- // drawn by the browser window.
- return gfx::Size(result_w - kStatusItemSeparation, 24);
+ return gfx::Size(result_w, result_h);
}
void StatusAreaView::Layout() {
- int cur_x = 0;
+ int cur_x = kLeftBorder;
for (int i = 0; i < GetChildViewCount(); i++) {
views::View* cur = GetChildViewAt(i);
gfx::Size cur_size = cur->GetPreferredSize();
+ int cur_y = (height() - cur_size.height()) / 2;
+
+ // Handle odd number of pixels.
+ cur_y += (height() - cur_size.height()) % 2;
+
+ // Adjustment to make clock line up right.
+ if (cur == clock_view_)
+ cur_y += kClockYAdjustment;
// Put next in row horizontally, and center vertically.
- // Padding the y position by 1 balances the space above and
- // below the icons, but still allows the shadow to be drawn.
- cur->SetBounds(cur_x, (height() - cur_size.height()) / 2 + 1,
- cur_size.width(), cur_size.height());
- cur_x += cur_size.width() + kStatusItemSeparation;
+ cur->SetBounds(cur_x, cur_y, cur_size.width(), cur_size.height());
+
+ cur_x += cur_size.width();
+
+ // Buttons have built in padding, but clock doesn't.
+ if (cur == clock_view_)
+ cur_x += kClockSeparation;
}
}
diff --git a/chrome/browser/chromeos/status_area_view.h b/chrome/browser/chromeos/status_area_view.h
index 071b99b..9428697 100644
--- a/chrome/browser/chromeos/status_area_view.h
+++ b/chrome/browser/chromeos/status_area_view.h
@@ -15,10 +15,7 @@ class Browser;
class ClockMenuButton;
class NetworkMenuButton;
class PowerMenuButton;
-
-namespace views {
-class MenuButton;
-}
+class StatusAreaButton;
// This class is used to wrap the small informative widgets in the upper-right
// of the window title bar. It is used on ChromeOS only.
@@ -70,7 +67,7 @@ class StatusAreaView : public views::View,
ClockMenuButton* clock_view_;
NetworkMenuButton* network_view_;
PowerMenuButton* battery_view_;
- views::MenuButton* menu_view_;
+ StatusAreaButton* menu_view_;
scoped_ptr<views::SimpleMenuModel> app_menu_contents_;
scoped_ptr<views::SimpleMenuModel> options_menu_contents_;