diff options
author | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 02:09:52 +0000 |
---|---|---|
committer | avayvod@chromium.org <avayvod@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-05 02:09:52 +0000 |
commit | 087e187238bafb30e6d28e2175e11fd56054e6d7 (patch) | |
tree | d90dcd0e4a6c875ace2ae93368f3a30dbc0a76e6 /chrome/browser/views/toolbar_star_toggle.cc | |
parent | 520b068ec2458f3441c84b6be13397d7a8daad4d (diff) | |
download | chromium_src-087e187238bafb30e6d28e2175e11fd56054e6d7.zip chromium_src-087e187238bafb30e6d28e2175e11fd56054e6d7.tar.gz chromium_src-087e187238bafb30e6d28e2175e11fd56054e6d7.tar.bz2 |
Added Star button to compact navigation mode.
BUG=32326
TEST=Switch Chrome to compact mode by pressing Ctrl-Shift-C. Test that Star
icon works.
Review URL: http://codereview.chromium.org/543215
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/toolbar_star_toggle.cc')
-rw-r--r-- | chrome/browser/views/toolbar_star_toggle.cc | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/chrome/browser/views/toolbar_star_toggle.cc b/chrome/browser/views/toolbar_star_toggle.cc index 9cd2e7b..6b93067 100644 --- a/chrome/browser/views/toolbar_star_toggle.cc +++ b/chrome/browser/views/toolbar_star_toggle.cc @@ -4,12 +4,18 @@ #include "chrome/browser/views/toolbar_star_toggle.h" +#include "app/l10n_util.h" #include "app/resource_bundle.h" +#include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser.h" +#include "chrome/browser/browser_theme_provider.h" +#include "chrome/browser/bubble_positioner.h" +#include "chrome/browser/profile.h" #include "chrome/browser/views/browser_dialogs.h" -#include "chrome/browser/views/toolbar_view.h" +#include "chrome/browser/view_ids.h" #include "googleurl/src/gurl.h" +#include "grit/generated_resources.h" #include "grit/theme_resources.h" using base::TimeTicks; @@ -27,15 +33,42 @@ using base::TimeTicks; // with the bubble because it has other native windows. static const int64 kDisallowClickMS = 40; -ToolbarStarToggle::ToolbarStarToggle(views::ButtonListener* listener, - ToolbarView* host) - : ToggleImageButton(listener), - host_(host), +ToolbarStarToggle::ToolbarStarToggle(views::ButtonListener* button_listener) + : ToggleImageButton(button_listener), + profile_(NULL), + host_view_(NULL), + bubble_positioner_(NULL), ignore_click_(false) { } +void ToolbarStarToggle::Init() { + ThemeProvider* tp = profile_->GetThemeProvider(); + + set_tag(IDC_BOOKMARK_PAGE); + SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_STAR)); + SetToggledTooltipText(l10n_util::GetString(IDS_TOOLTIP_STARRED)); + SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_STAR)); + SetID(VIEW_ID_STAR_BUTTON); + + // Load images. + SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND); + SkBitmap* background = tp->GetBitmapNamed(IDR_THEME_BUTTON_BACKGROUND); + + SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_STAR)); + SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_STAR_H)); + SetImage(views::CustomButton::BS_PUSHED, tp->GetBitmapNamed(IDR_STAR_P)); + SetImage(views::CustomButton::BS_DISABLED, tp->GetBitmapNamed(IDR_STAR_D)); + SetToggledImage(views::CustomButton::BS_NORMAL, + tp->GetBitmapNamed(IDR_STARRED)); + SetToggledImage(views::CustomButton::BS_HOT, + tp->GetBitmapNamed(IDR_STARRED_H)); + SetToggledImage(views::CustomButton::BS_PUSHED, + tp->GetBitmapNamed(IDR_STARRED_P)); + SetBackground(color, background, tp->GetBitmapNamed(IDR_STAR_MASK)); +} + void ToolbarStarToggle::ShowStarBubble(const GURL& url, bool newly_bookmarked) { - gfx::Rect bounds(host_->GetLocationStackBounds()); + gfx::Rect bounds(bubble_positioner_->GetLocationStackBounds()); gfx::Point star_location; views::View::ConvertPointToScreen(this, &star_location); // The visual center of the star is not centered within the bounds. The star @@ -49,12 +82,12 @@ void ToolbarStarToggle::ShowStarBubble(const GURL& url, bool newly_bookmarked) { // order to place the star's central pixel on the right side of the bounds' // center-line, so that the arrow's center will line up. // - // TODO: If the InfoBubble used mirroring transformations maybe this could - // become symmetric (-1 : 1). + // TODO(pkasting): If the InfoBubble used mirroring transformations maybe this + // could become symmetric (-1 : 1). bounds.set_x(star_location.x() + (UILayoutIsRightToLeft() ? -2 : 1)); bounds.set_width(width()); - browser::ShowBookmarkBubbleView(host_->GetWindow(), bounds, this, - host_->profile(), url, newly_bookmarked); + browser::ShowBookmarkBubbleView(host_view_->GetWindow(), bounds, this, + profile_, url, newly_bookmarked); } bool ToolbarStarToggle::OnMousePressed(const views::MouseEvent& e) { |