Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc

Issue 13800017: Move the Apps shortcut to the left of the bookmarks bar, and use new icon. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Without the bitmaps. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 1371 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 } 1382 }
1383 } 1383 }
1384 1384
1385 views::TextButton* BookmarkBarView::CreateAppsPageShortcutButton() { 1385 views::TextButton* BookmarkBarView::CreateAppsPageShortcutButton() {
1386 views::TextButton* button = new ShortcutButton( 1386 views::TextButton* button = new ShortcutButton(
1387 this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_APPS_SHORTCUT_NAME)); 1387 this, l10n_util::GetStringUTF16(IDS_BOOKMARK_BAR_APPS_SHORTCUT_NAME));
1388 button->SetTooltipText(l10n_util::GetStringUTF16( 1388 button->SetTooltipText(l10n_util::GetStringUTF16(
1389 IDS_BOOKMARK_BAR_APPS_SHORTCUT_TOOLTIP)); 1389 IDS_BOOKMARK_BAR_APPS_SHORTCUT_TOOLTIP));
1390 button->set_id(VIEW_ID_BOOKMARK_BAR_ELEMENT); 1390 button->set_id(VIEW_ID_BOOKMARK_BAR_ELEMENT);
1391 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 1391 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
1392 button->SetIcon(*rb.GetImageSkiaNamed(IDR_WEBSTORE_ICON_16)); 1392 button->SetIcon(*rb.GetImageSkiaNamed(IDR_BOOKMARK_BAR_APPS_SHORTCUT));
1393 button->set_context_menu_controller(this); 1393 button->set_context_menu_controller(this);
1394 button->set_tag(kAppsShortcutButtonTag); 1394 button->set_tag(kAppsShortcutButtonTag);
1395 return button; 1395 return button;
1396 } 1396 }
1397 1397
1398 void BookmarkBarView::ConfigureButton(const BookmarkNode* node, 1398 void BookmarkBarView::ConfigureButton(const BookmarkNode* node,
1399 views::TextButton* button) { 1399 views::TextButton* button) {
1400 button->SetText(node->GetTitle()); 1400 button->SetText(node->GetTitle());
1401 button->SetAccessibleName(node->GetTitle()); 1401 button->SetAccessibleName(node->GetTitle());
1402 button->set_id(VIEW_ID_BOOKMARK_BAR_ELEMENT); 1402 button->set_id(VIEW_ID_BOOKMARK_BAR_ELEMENT);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 UpdateBookmarksSeparatorVisibility(); 1713 UpdateBookmarksSeparatorVisibility();
1714 Layout(); 1714 Layout();
1715 SchedulePaint(); 1715 SchedulePaint();
1716 } 1716 }
1717 1717
1718 void BookmarkBarView::UpdateBookmarksSeparatorVisibility() { 1718 void BookmarkBarView::UpdateBookmarksSeparatorVisibility() {
1719 // Ash does not paint the bookmarks separator line because it looks odd on 1719 // Ash does not paint the bookmarks separator line because it looks odd on
1720 // the flat background. We keep it present for layout, but don't draw it. 1720 // the flat background. We keep it present for layout, but don't draw it.
1721 bookmarks_separator_view_->SetVisible( 1721 bookmarks_separator_view_->SetVisible(
1722 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH && 1722 browser_->host_desktop_type() != chrome::HOST_DESKTOP_TYPE_ASH &&
1723 (other_bookmarked_button_->visible() || 1723 other_bookmarked_button_->visible());
1724 apps_page_shortcut_->visible()));
1725 } 1724 }
1726 1725
1727 gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) { 1726 gfx::Size BookmarkBarView::LayoutItems(bool compute_bounds_only) {
1728 gfx::Size prefsize; 1727 gfx::Size prefsize;
1729 if (!parent() && !compute_bounds_only) 1728 if (!parent() && !compute_bounds_only)
1730 return prefsize; 1729 return prefsize;
1731 1730
1732 int x = kLeftMargin; 1731 int x = kLeftMargin;
1733 int top_margin = IsDetached() ? kDetachedTopMargin : 0; 1732 int top_margin = IsDetached() ? kDetachedTopMargin : 0;
1734 int y = top_margin; 1733 int y = top_margin;
(...skipping 24 matching lines...) Expand all
1759 1758
1760 int max_x = width - overflow_pref.width() - kButtonPadding - 1759 int max_x = width - overflow_pref.width() - kButtonPadding -
1761 bookmarks_separator_pref.width(); 1760 bookmarks_separator_pref.width();
1762 if (other_bookmarked_button_->visible()) 1761 if (other_bookmarked_button_->visible())
1763 max_x -= other_bookmarked_pref.width() + kButtonPadding; 1762 max_x -= other_bookmarked_pref.width() + kButtonPadding;
1764 if (apps_page_shortcut_->visible()) 1763 if (apps_page_shortcut_->visible())
1765 max_x -= apps_page_shortcut_pref.width() + kButtonPadding; 1764 max_x -= apps_page_shortcut_pref.width() + kButtonPadding;
1766 1765
1767 // Next, layout out the buttons. Any buttons that are placed beyond the 1766 // Next, layout out the buttons. Any buttons that are placed beyond the
1768 // visible region and made invisible. 1767 // visible region and made invisible.
1768
1769 // Start with the apps page shortcut button.
1770 if (apps_page_shortcut_->visible()) {
1771 if (!compute_bounds_only) {
1772 apps_page_shortcut_->SetBounds(x, y, apps_page_shortcut_pref.width(),
1773 height);
1774 }
1775 x += apps_page_shortcut_pref.width() + kButtonPadding;
1776 }
1777
1778 // Then go through the bookmark buttons.
1769 if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded()) { 1779 if (GetBookmarkButtonCount() == 0 && model_ && model_->IsLoaded()) {
1770 gfx::Size pref = instructions_->GetPreferredSize(); 1780 gfx::Size pref = instructions_->GetPreferredSize();
1771 if (!compute_bounds_only) { 1781 if (!compute_bounds_only) {
1772 instructions_->SetBounds( 1782 instructions_->SetBounds(
1773 x + kInstructionsPadding, y, 1783 x + kInstructionsPadding, y,
1774 std::min(static_cast<int>(pref.width()), 1784 std::min(static_cast<int>(pref.width()),
1775 max_x - x), 1785 max_x - x),
1776 height); 1786 height);
1777 instructions_->SetVisible(true); 1787 instructions_->SetVisible(true);
1778 } 1788 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1824 1834
1825 // The other bookmarks button. 1835 // The other bookmarks button.
1826 if (other_bookmarked_button_->visible()) { 1836 if (other_bookmarked_button_->visible()) {
1827 if (!compute_bounds_only) { 1837 if (!compute_bounds_only) {
1828 other_bookmarked_button_->SetBounds(x, y, other_bookmarked_pref.width(), 1838 other_bookmarked_button_->SetBounds(x, y, other_bookmarked_pref.width(),
1829 height); 1839 height);
1830 } 1840 }
1831 x += other_bookmarked_pref.width() + kButtonPadding; 1841 x += other_bookmarked_pref.width() + kButtonPadding;
1832 } 1842 }
1833 1843
1834 // The app page shortcut button.
1835 if (apps_page_shortcut_->visible()) {
1836 if (!compute_bounds_only) {
1837 apps_page_shortcut_->SetBounds(x, y, apps_page_shortcut_pref.width(),
1838 height);
1839 }
1840 x += apps_page_shortcut_pref.width() + kButtonPadding;
1841 }
1842
1843 // Set the preferred size computed so far. 1844 // Set the preferred size computed so far.
1844 if (compute_bounds_only) { 1845 if (compute_bounds_only) {
1845 x += kRightMargin; 1846 x += kRightMargin;
1846 prefsize.set_width(x); 1847 prefsize.set_width(x);
1847 if (IsDetached()) { 1848 if (IsDetached()) {
1848 x += static_cast<int>(GetNewtabHorizontalPadding() * 1849 x += static_cast<int>(GetNewtabHorizontalPadding() *
1849 (1 - size_animation_->GetCurrentValue())); 1850 (1 - size_animation_->GetCurrentValue()));
1850 int ntp_bookmark_bar_height = 1851 int ntp_bookmark_bar_height =
1851 chrome::IsInstantExtendedAPIEnabled() 1852 chrome::IsInstantExtendedAPIEnabled()
1852 ? kSearchNewTabBookmarkBarHeight : chrome::kNTPBookmarkBarHeight; 1853 ? kSearchNewTabBookmarkBarHeight : chrome::kNTPBookmarkBarHeight;
(...skipping 22 matching lines...) Expand all
1875 return; 1876 return;
1876 apps_page_shortcut_->SetVisible(visible); 1877 apps_page_shortcut_->SetVisible(visible);
1877 UpdateBookmarksSeparatorVisibility(); 1878 UpdateBookmarksSeparatorVisibility();
1878 Layout(); 1879 Layout();
1879 } 1880 }
1880 1881
1881 void BookmarkBarView::OnAppLauncherEnabledCompleted(bool app_launcher_enabled) { 1882 void BookmarkBarView::OnAppLauncherEnabledCompleted(bool app_launcher_enabled) {
1882 // Disregard |app_launcher_enabled|, use apps::WasAppLauncherEnable instead. 1883 // Disregard |app_launcher_enabled|, use apps::WasAppLauncherEnable instead.
1883 OnAppsPageShortcutVisibilityPrefChanged(); 1884 OnAppsPageShortcutVisibilityPrefChanged();
1884 } 1885 }
OLDNEW
« no previous file with comments | « chrome/app/theme/theme_resources.grd ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698