Status area improvements:
- text is now 70% alpha - font is 1 size larger - 6 pixels between status icons - icon and text are lined up better - when clock changes text, bounds are reset properly TEST=none BUG=none Review URL: http://codereview.chromium.org/1589021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44128 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
@ -7502,10 +7502,10 @@ Keep your key file in a safe place. You will need it to create new versions of y
|
||||
Open date and time options...
|
||||
</message>
|
||||
<message name="IDS_STATUSBAR_CLOCK_SHORT_TIME_AM" desc="In the clock menu button, this shows the AM time in a short format.">
|
||||
<ph name="HOUR">$1<ex>2</ex></ph>:<ph name="MIUTE">$2<ex>30</ex></ph>a
|
||||
<ph name="HOUR">$1<ex>2</ex></ph>:<ph name="MIUTE">$2<ex>30</ex></ph> AM
|
||||
</message>
|
||||
<message name="IDS_STATUSBAR_CLOCK_SHORT_TIME_PM" desc="In the clock menu button, this shows the PM time in a short format.">
|
||||
<ph name="HOUR">$1<ex>2</ex></ph>:<ph name="MIUTE">$2<ex>30</ex></ph>p
|
||||
<ph name="HOUR">$1<ex>2</ex></ph>:<ph name="MIUTE">$2<ex>30</ex></ph> PM
|
||||
</message>
|
||||
<message name="IDS_STATUSBAR_BATTERY_PERCENTAGE" desc="In the power menu button, this shows what percentage of battery is left.">
|
||||
Battery: <ph name="PRECENTAGE">$1<ex>100</ex></ph>%
|
||||
|
@ -433,6 +433,11 @@ BaseTabStrip* BrowserView::CreateTabStrip(
|
||||
return new ChromeosTabStrip(tab_strip_model, this);
|
||||
}
|
||||
|
||||
void BrowserView::ChildPreferredSizeChanged(View* child) {
|
||||
Layout();
|
||||
SchedulePaint();
|
||||
}
|
||||
|
||||
// views::ButtonListener overrides.
|
||||
void BrowserView::ButtonPressed(views::Button* sender,
|
||||
const views::Event& event) {
|
||||
|
@ -65,6 +65,7 @@ class BrowserView : public ::BrowserView,
|
||||
virtual void ToggleCompactNavigationBar();
|
||||
virtual views::LayoutManager* CreateLayoutManager() const;
|
||||
virtual BaseTabStrip* CreateTabStrip(TabStripModel* tab_strip_model);
|
||||
virtual void ChildPreferredSizeChanged(View* child);
|
||||
|
||||
// views::ButtonListener overrides.
|
||||
virtual void ButtonPressed(views::Button* sender, const views::Event& event);
|
||||
|
@ -91,6 +91,11 @@ void BackgroundView::Layout() {
|
||||
status_area_size.height());
|
||||
}
|
||||
|
||||
void BackgroundView::ChildPreferredSizeChanged(View* child) {
|
||||
Layout();
|
||||
SchedulePaint();
|
||||
}
|
||||
|
||||
gfx::NativeWindow BackgroundView::GetNativeWindow() const {
|
||||
return
|
||||
GTK_WINDOW(static_cast<WidgetGtk*>(GetWidget())->GetNativeView());
|
||||
|
@ -38,6 +38,7 @@ class BackgroundView : public views::View, public StatusAreaHost {
|
||||
// Overridden from views::View:
|
||||
virtual void Paint(gfx::Canvas* canvas);
|
||||
virtual void Layout();
|
||||
virtual void ChildPreferredSizeChanged(View* child);
|
||||
|
||||
// Overridden from StatusAreaHost:
|
||||
virtual Profile* GetProfile() const { return NULL; }
|
||||
|
@ -28,13 +28,24 @@ ClockMenuButton::ClockMenuButton(StatusAreaHost* host)
|
||||
host_(host) {
|
||||
set_border(NULL);
|
||||
SetFont(ResourceBundle::GetSharedInstance().GetFont(
|
||||
ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD));
|
||||
SetEnabledColor(SK_ColorWHITE);
|
||||
ResourceBundle::BaseFont).DeriveFont(1, gfx::Font::BOLD));
|
||||
SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha
|
||||
SetShowHighlighted(false);
|
||||
// Set initial text to make sure that the text button wide enough.
|
||||
std::wstring zero = ASCIIToWide("00");
|
||||
SetText(l10n_util::GetStringF(IDS_STATUSBAR_CLOCK_SHORT_TIME_AM, zero, zero));
|
||||
SetText(l10n_util::GetStringF(IDS_STATUSBAR_CLOCK_SHORT_TIME_PM, zero, zero));
|
||||
// Fill text with 0s to figure out max width of text size.
|
||||
ClearMaxTextSize();
|
||||
std::wstring zero = ASCIIToWide("0");
|
||||
std::wstring zerozero = ASCIIToWide("00");
|
||||
SetText(l10n_util::GetStringF(IDS_STATUSBAR_CLOCK_SHORT_TIME_AM,
|
||||
zero, zerozero));
|
||||
SetText(l10n_util::GetStringF(IDS_STATUSBAR_CLOCK_SHORT_TIME_PM,
|
||||
zero, zerozero));
|
||||
max_width_one_digit = GetPreferredSize().width();
|
||||
ClearMaxTextSize();
|
||||
SetText(l10n_util::GetStringF(IDS_STATUSBAR_CLOCK_SHORT_TIME_AM,
|
||||
zerozero, zerozero));
|
||||
SetText(l10n_util::GetStringF(IDS_STATUSBAR_CLOCK_SHORT_TIME_PM,
|
||||
zerozero, zerozero));
|
||||
max_width_two_digit = GetPreferredSize().width();
|
||||
set_alignment(TextButton::ALIGN_RIGHT);
|
||||
UpdateTextAndSetNextTimer();
|
||||
// Init member prefs so we can update the clock if prefs change.
|
||||
@ -91,7 +102,16 @@ void ClockMenuButton::UpdateText() {
|
||||
|
||||
std::wstring time_string = l10n_util::GetStringF(msg, hour_str, min_str);
|
||||
|
||||
// See if the preferred size changed. If so, relayout the StatusAreaView.
|
||||
int cur_width = GetPreferredSize().width();
|
||||
int new_width = hour < 10 ? max_width_one_digit : max_width_two_digit;
|
||||
SetText(time_string);
|
||||
set_max_width(new_width);
|
||||
|
||||
// If width has changed, we want to relayout the StatusAreaView.
|
||||
if (new_width != cur_width)
|
||||
PreferredSizeChanged();
|
||||
|
||||
SchedulePaint();
|
||||
}
|
||||
|
||||
|
@ -75,6 +75,11 @@ class ClockMenuButton : public views::MenuButton,
|
||||
|
||||
StatusAreaHost* host_;
|
||||
|
||||
// Variables to keep track of the max width of this view when there is 1 or 2
|
||||
// digits in the hour time.
|
||||
int max_width_one_digit;
|
||||
int max_width_two_digit;
|
||||
|
||||
// Preferences for this section:
|
||||
StringPrefMember timezone_;
|
||||
|
||||
|
@ -132,6 +132,11 @@ LanguageMenuButton::LanguageMenuButton(StatusAreaHost* host)
|
||||
host_(host) {
|
||||
DCHECK(input_method_descriptors_.get() &&
|
||||
!input_method_descriptors_->empty());
|
||||
set_border(NULL);
|
||||
SetFont(ResourceBundle::GetSharedInstance().GetFont(
|
||||
ResourceBundle::BaseFont).DeriveFont(1, gfx::Font::BOLD));
|
||||
SetEnabledColor(0xB3FFFFFF); // White with 70% Alpha
|
||||
SetShowHighlighted(false);
|
||||
// Update the model
|
||||
RebuildModel();
|
||||
// Grab the real estate.
|
||||
@ -363,11 +368,6 @@ void LanguageMenuButton::ImePropertiesChanged(LanguageLibrary* obj) {
|
||||
}
|
||||
|
||||
void LanguageMenuButton::UpdateIcon(const std::wstring& name) {
|
||||
set_border(NULL);
|
||||
SetFont(ResourceBundle::GetSharedInstance().GetFont(
|
||||
ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD));
|
||||
SetEnabledColor(SK_ColorWHITE);
|
||||
SetShowHighlighted(false);
|
||||
SetText(name);
|
||||
set_alignment(TextButton::ALIGN_RIGHT);
|
||||
SchedulePaint();
|
||||
|
@ -375,10 +375,9 @@ SkBitmap NetworkMenuButton::IconForDisplay(SkBitmap icon, SkBitmap badge) {
|
||||
// Icons are 24x24.
|
||||
static const int kIconWidth = 24;
|
||||
static const int kIconHeight = 24;
|
||||
// Draw the network icon 4 pixels down to center it.
|
||||
// Because the status icon is 24x24 but the images are 24x16.
|
||||
// Draw the network icon 3 pixels down to center it.
|
||||
static const int kIconX = 0;
|
||||
static const int kIconY = 4;
|
||||
static const int kIconY = 3;
|
||||
// Draw badge at (14,14).
|
||||
static const int kBadgeX = 14;
|
||||
static const int kBadgeY = 14;
|
||||
|
@ -115,10 +115,8 @@ void PowerMenuButton::DrawIcon(gfx::Canvas* canvas) {
|
||||
}
|
||||
|
||||
void PowerMenuButton::DrawPowerIcon(gfx::Canvas* canvas, SkBitmap icon) {
|
||||
// Draw the battery icon 6 pixels down to center it.
|
||||
// Because the status icon is 24x24 but the images are 24x16.
|
||||
// But since the images are shifted up by 4 pixels, we draw at 6 pixels down.
|
||||
static const int kIconVerticalPadding = 6;
|
||||
// Draw the battery icon 5 pixels down to center it.
|
||||
static const int kIconVerticalPadding = 5;
|
||||
canvas->DrawBitmapInt(icon, 0, kIconVerticalPadding);
|
||||
}
|
||||
|
||||
|
@ -15,13 +15,8 @@
|
||||
|
||||
namespace chromeos {
|
||||
|
||||
// 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 separate the language selector from the next item
|
||||
// on the right.
|
||||
const int kLanguageSeparation = 4;
|
||||
// Number of pixels to separate each icon.
|
||||
const int kSeparation = 6;
|
||||
|
||||
// BrowserWindowGtk tiles its image with this offset
|
||||
const int kCustomFrameBackgroundVerticalOffset = 15;
|
||||
@ -64,15 +59,14 @@ void StatusAreaView::Update() {
|
||||
}
|
||||
|
||||
gfx::Size StatusAreaView::GetPreferredSize() {
|
||||
// Start with padding.
|
||||
int result_w = kLeftBorder + kClockSeparation + kLanguageSeparation;
|
||||
int result_w = kSeparation;
|
||||
int result_h = 0;
|
||||
for (int i = 0; i < GetChildViewCount(); i++) {
|
||||
views::View* cur = GetChildViewAt(i);
|
||||
if (cur->IsVisible()) {
|
||||
gfx::Size cur_size = cur->GetPreferredSize();
|
||||
// Add each width.
|
||||
result_w += cur_size.width();
|
||||
result_w += cur_size.width() + kSeparation;
|
||||
// Use max height.
|
||||
result_h = std::max(result_h, cur_size.height());
|
||||
}
|
||||
@ -81,7 +75,7 @@ gfx::Size StatusAreaView::GetPreferredSize() {
|
||||
}
|
||||
|
||||
void StatusAreaView::Layout() {
|
||||
int cur_x = kLeftBorder;
|
||||
int cur_x = kSeparation;
|
||||
for (int i = 0; i < GetChildViewCount(); i++) {
|
||||
views::View* cur = GetChildViewAt(i);
|
||||
if (cur->IsVisible()) {
|
||||
@ -94,17 +88,19 @@ void StatusAreaView::Layout() {
|
||||
// Put next in row horizontally, and center vertically.
|
||||
cur->SetBounds(cur_x, cur_y, cur_size.width(), cur_size.height());
|
||||
|
||||
cur_x += cur_size.width();
|
||||
|
||||
// Buttons have built in padding, but clock and language status don't.
|
||||
if (cur == clock_view_)
|
||||
cur_x += kClockSeparation;
|
||||
else if (cur == language_view_)
|
||||
cur_x += kLanguageSeparation;
|
||||
cur_x += cur_size.width() + kSeparation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StatusAreaView::ChildPreferredSizeChanged(View* child) {
|
||||
// When something like the clock menu button's size changes, we need to
|
||||
// relayout. Also mark that this view's size has changed. This will let
|
||||
// BrowserView know to relayout, which will reset the bounds of this view.
|
||||
Layout();
|
||||
PreferredSizeChanged();
|
||||
}
|
||||
|
||||
// static
|
||||
StatusAreaView::OpenTabsMode StatusAreaView::GetOpenTabsMode() {
|
||||
return open_tabs_mode_;
|
||||
|
@ -38,6 +38,7 @@ class StatusAreaView : public views::View {
|
||||
// views::View* overrides.
|
||||
virtual gfx::Size GetPreferredSize();
|
||||
virtual void Layout();
|
||||
virtual void ChildPreferredSizeChanged(View* child);
|
||||
|
||||
static OpenTabsMode GetOpenTabsMode();
|
||||
static void SetOpenTabsMode(OpenTabsMode mode);
|
||||
|
@ -218,10 +218,11 @@ void Canvas::DrawStringInt(const std::wstring& text,
|
||||
pango_layout_set_height(layout, h * PANGO_SCALE);
|
||||
|
||||
cairo_save(cr);
|
||||
cairo_set_source_rgb(cr,
|
||||
SkColorGetR(color) / 255.0,
|
||||
SkColorGetG(color) / 255.0,
|
||||
SkColorGetB(color) / 255.0);
|
||||
cairo_set_source_rgba(cr,
|
||||
SkColorGetR(color) / 255.0,
|
||||
SkColorGetG(color) / 255.0,
|
||||
SkColorGetB(color) / 255.0,
|
||||
SkColorGetA(color) / 255.0);
|
||||
|
||||
int width, height;
|
||||
pango_layout_get_pixel_size(layout, &width, &height);
|
||||
|
@ -44,7 +44,7 @@ void Canvas::DrawStringInt(const std::wstring& text, const gfx::Font& font,
|
||||
NSColor* ns_color = [NSColor colorWithDeviceRed:SkColorGetR(color) / 255.0
|
||||
green:SkColorGetG(color) / 255.0
|
||||
blue:SkColorGetB(color) / 255.0
|
||||
alpha:1.0];
|
||||
alpha:SkColorGetA(color) / 255.0];
|
||||
NSMutableParagraphStyle *ns_style =
|
||||
[[[NSParagraphStyle alloc] init] autorelease];
|
||||
if (flags & TEXT_ALIGN_CENTER)
|
||||
|
Reference in New Issue
Block a user