Commit 999fbf93 authored by sky@chromium.org's avatar sky@chromium.org

Nukes the nano tab style on gtk and brings back the toolbar for apps

on gtk. This is a revert of most of r52070and 51478. I've kept parts
of these changes we want in though: comments, nuking nano tab gap on
views, having app tabs use a bigger icon.

BUG=49013
TEST=none

Review URL: http://codereview.chromium.org/3011007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52830 0039d316-1c4b-4281-b951-d872f2087c98
parent 907ae6ad
......@@ -400,11 +400,6 @@ bool BookmarkBarGtk::OnNewTabPage() {
browser_->GetSelectedTabContents()->ShouldShowBookmarkBar());
}
bool BookmarkBarGtk::OnAppsPage() const {
return (browser_ && browser_->GetSelectedTabContents() &&
browser_->GetSelectedTabContents()->is_app());
}
void BookmarkBarGtk::Loaded(BookmarkModel* model) {
// If |instructions_| has been nulled, we are in the middle of browser
// shutdown. Do nothing.
......
......@@ -77,9 +77,6 @@ class BookmarkBarGtk : public AnimationDelegate,
// rendering).
bool OnNewTabPage();
// True if we're on an extension apps page.
bool OnAppsPage() const;
// Change the visibility of the bookmarks bar. (Starts out hidden, per GTK's
// default behaviour). There are three visiblity states:
//
......
......@@ -95,8 +95,7 @@ BrowserToolbarGtk::BrowserToolbarGtk(Browser* browser, BrowserWindowGtk* window)
profile_(NULL),
menu_bar_helper_(this),
upgrade_reminder_animation_(this),
upgrade_reminder_canceled_(false),
collapsed_(false) {
upgrade_reminder_canceled_(false) {
browser_->command_updater()->AddCommandObserver(IDC_BACK, this);
browser_->command_updater()->AddCommandObserver(IDC_FORWARD, this);
browser_->command_updater()->AddCommandObserver(IDC_HOME, this);
......@@ -293,14 +292,6 @@ LocationBar* BrowserToolbarGtk::GetLocationBar() const {
return location_bar_.get();
}
void BrowserToolbarGtk::set_collapsed(bool val) {
collapsed_ = val;
if (collapsed_)
Hide();
else
Show();
}
void BrowserToolbarGtk::UpdateForBookmarkBarVisibility(
bool show_bottom_padding) {
gtk_alignment_set_padding(GTK_ALIGNMENT(alignment_),
......
......@@ -83,9 +83,6 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
LocationBarViewGtk* GetLocationBarView() { return location_bar_.get(); }
bool collapsed() const { return collapsed_; }
void set_collapsed(bool val);
// We have to show padding on the bottom of the toolbar when the bookmark
// is in floating mode. Otherwise the bookmark bar will paint it for us.
void UpdateForBookmarkBarVisibility(bool show_bottom_padding);
......@@ -281,9 +278,6 @@ class BrowserToolbarGtk : public CommandUpdater::CommandObserver,
// We have already shown and dismissed the upgrade reminder animation.
bool upgrade_reminder_canceled_;
// When collapsed, the toolbar is just a tiny strip, no controls are visible.
bool collapsed_;
DISALLOW_COPY_AND_ASSIGN(BrowserToolbarGtk);
};
......
......@@ -863,7 +863,8 @@ void BrowserWindowGtk::RotatePaneFocus(bool forwards) {
}
bool BrowserWindowGtk::IsBookmarkBarVisible() const {
return IsBookmarkBarSupported() && bookmark_bar_.get() &&
return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR) &&
bookmark_bar_.get() &&
browser_->profile()->GetPrefs()->GetBoolean(prefs::kShowBookmarkBar);
}
......@@ -1113,10 +1114,6 @@ void BrowserWindowGtk::Paste() {
DoCutCopyPaste(this, &RenderViewHost::Paste, "paste-clipboard");
}
void BrowserWindowGtk::SetToolbarCollapsedMode(bool val) {
toolbar_->set_collapsed(val);
}
void BrowserWindowGtk::ConfirmBrowserCloseWithPendingDownloads() {
new DownloadInProgressDialogGtk(browser());
}
......@@ -1218,17 +1215,12 @@ void BrowserWindowGtk::ActiveWindowChanged(GdkWindow* active_window) {
void BrowserWindowGtk::MaybeShowBookmarkBar(TabContents* contents,
bool animate) {
if (!IsBookmarkBarSupported()) {
// Because the bookmark bar is never shown in app tab windows, we must
// explicitly hide to handle the case of switching tabs.
if (bookmark_bar_.get())
bookmark_bar_->Hide(false); // animate
if (!IsBookmarkBarSupported())
return;
}
bool show_bar = false;
if (contents) {
if (IsBookmarkBarSupported() && contents) {
bookmark_bar_->SetProfile(contents->profile());
bookmark_bar_->SetPageNavigator(contents);
show_bar = true;
......@@ -2040,16 +2032,11 @@ bool BrowserWindowGtk::IsTabStripSupported() const {
}
bool BrowserWindowGtk::IsToolbarSupported() const {
return !toolbar_->collapsed() &&
(browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR));
return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR);
}
bool BrowserWindowGtk::IsBookmarkBarSupported() const {
// We never show the bookmark bar on app tab pages.
if (bookmark_bar_.get() && bookmark_bar_->OnAppsPage())
return false;
return browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR);
}
......
......@@ -124,7 +124,7 @@ class BrowserWindowGtk : public BrowserWindow,
virtual void Copy();
virtual void Paste();
virtual void ToggleTabStripMode() {}
virtual void SetToolbarCollapsedMode(bool val);
virtual void SetToolbarCollapsedMode(bool val) {}
// Overridden from NotificationObserver:
virtual void Observe(NotificationType type,
......
......@@ -38,9 +38,7 @@ class TabGtk::ContextMenuController : public menus::SimpleMenuModel::Delegate {
public:
explicit ContextMenuController(TabGtk* tab)
: tab_(tab),
model_(this, tab->delegate()->IsTabPinned(tab),
tab->delegate()->IsAppTab(tab),
tab->delegate()->IsToolbarVisible(tab)) {
model_(this, tab->delegate()->IsTabPinned(tab), false, true) {
menu_.reset(new MenuGtk(NULL, &model_));
}
......
......@@ -32,15 +32,9 @@ class TabGtk : public TabRendererGtk,
// Returns true if the specified Tab is pinned.
virtual bool IsTabPinned(const TabGtk* tab) const = 0;
// Returns true if the specified Tab contains an app.
virtual bool IsAppTab(const TabGtk* tab) const = 0;
// Returns true if the specified Tab is detached.
virtual bool IsTabDetached(const TabGtk* tab) const = 0;
// Returns true if the toolbar is visible for |tab|.
virtual bool IsToolbarVisible(const TabGtk* tab) const = 0;
// Selects the specified Tab.
virtual void SelectTab(TabGtk* tab) = 0;
......
......@@ -128,11 +128,8 @@ TabRendererGtk::LoadingAnimation::Data::Data(
bool TabRendererGtk::initialized_ = false;
TabRendererGtk::TabImage TabRendererGtk::tab_active_ = {0};
TabRendererGtk::TabImage TabRendererGtk::tab_active_nano_ = {0};
TabRendererGtk::TabImage TabRendererGtk::tab_inactive_ = {0};
TabRendererGtk::TabImage TabRendererGtk::tab_inactive_nano_ = {0};
TabRendererGtk::TabImage TabRendererGtk::tab_alpha_ = {0};
TabRendererGtk::TabImage TabRendererGtk::tab_alpha_nano_ = {0};
gfx::Font* TabRendererGtk::title_font_ = NULL;
int TabRendererGtk::title_font_height_ = 0;
int TabRendererGtk::close_button_width_ = 0;
......@@ -391,18 +388,11 @@ void TabRendererGtk::PaintFavIconArea(GdkEventExpose* event) {
if (!theme_provider_->HasCustomImage(theme_id))
offset_y = background_offset_y_;
}
// If the tab is a nanotab, we must take care to only draw the background
// within the height of the nanotab.
int nanoTabOffset = data_.app ? 9 : 0;
SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(theme_id);
canvas.TileImageInt(*tab_bg,
x() + favicon_bounds_.x(),
offset_y + favicon_bounds_.y() + nanoTabOffset,
favicon_bounds_.x(),
favicon_bounds_.y() + nanoTabOffset,
favicon_bounds_.width(),
favicon_bounds_.height() - nanoTabOffset);
x() + favicon_bounds_.x(), offset_y + favicon_bounds_.y(),
favicon_bounds_.x(), favicon_bounds_.y(),
favicon_bounds_.width(), favicon_bounds_.height());
if (!IsSelected()) {
double throb_value = GetThrobValue();
......@@ -472,37 +462,18 @@ void TabRendererGtk::LoadTabImages() {
tab_alpha_.image_l = rb.GetBitmapNamed(IDR_TAB_ALPHA_LEFT);
tab_alpha_.image_r = rb.GetBitmapNamed(IDR_TAB_ALPHA_RIGHT);
tab_alpha_nano_.image_l = rb.GetBitmapNamed(IDR_TAB_ALPHA_NANO_LEFT);
tab_alpha_nano_.image_r = rb.GetBitmapNamed(IDR_TAB_ALPHA_NANO_RIGHT);
tab_active_.image_l = rb.GetBitmapNamed(IDR_TAB_ACTIVE_LEFT);
tab_active_.image_c = rb.GetBitmapNamed(IDR_TAB_ACTIVE_CENTER);
tab_active_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_RIGHT);
tab_active_.l_width = tab_active_.image_l->width();
tab_active_.r_width = tab_active_.image_r->width();
const int kNanoTabDiffHeight = 13;
tab_active_nano_.image_l = rb.GetBitmapNamed(IDR_TAB_ACTIVE_NANO_LEFT);
tab_active_nano_.image_c = rb.GetBitmapNamed(IDR_TAB_ACTIVE_NANO_CENTER);
tab_active_nano_.image_r = rb.GetBitmapNamed(IDR_TAB_ACTIVE_NANO_RIGHT);
tab_active_nano_.l_width = tab_active_nano_.image_l->width();
tab_active_nano_.r_width = tab_active_nano_.image_r->width();
tab_active_nano_.y_offset = kNanoTabDiffHeight;
tab_inactive_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_LEFT);
tab_inactive_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_CENTER);
tab_inactive_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_RIGHT);
tab_inactive_.l_width = tab_inactive_.image_l->width();
tab_inactive_.r_width = tab_inactive_.image_r->width();
tab_inactive_nano_.image_l = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_LEFT);
tab_inactive_nano_.image_c = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_CENTER);
tab_inactive_nano_.image_r = rb.GetBitmapNamed(IDR_TAB_INACTIVE_NANO_RIGHT);
tab_inactive_nano_.l_width = tab_inactive_.image_l->width();
tab_inactive_nano_.r_width = tab_inactive_.image_r->width();
tab_inactive_nano_.y_offset = kNanoTabDiffHeight;
close_button_width_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->width();
close_button_height_ = rb.GetBitmapNamed(IDR_TAB_CLOSE)->height();
}
......@@ -915,12 +886,6 @@ void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) {
SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(tab_id);
// App tabs are drawn slightly differently (as nano tabs).
TabImage* tab_image = data_.app ? &tab_active_nano_ : &tab_active_;
TabImage* tab_inactive_image = data_.app ? &tab_inactive_nano_ :
&tab_inactive_;
TabImage* alpha = data_.app ? &tab_alpha_nano_ : &tab_alpha_;
// If the theme is providing a custom background image, then its top edge
// should be at the top of the tab. Otherwise, we assume that the background
// image is a composited foreground + frame image.
......@@ -928,35 +893,27 @@ void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) {
0 : background_offset_y_;
// Draw left edge.
SkBitmap* theme_l = GetMaskedBitmap(alpha->image_l, tab_bg, offset_x,
SkBitmap* theme_l = GetMaskedBitmap(tab_alpha_.image_l, tab_bg, offset_x,
offset_y);
canvas->DrawBitmapInt(*theme_l, 0, 0);
// Draw right edge.
SkBitmap* theme_r = GetMaskedBitmap(alpha->image_r, tab_bg,
offset_x + width() - tab_image->r_width, offset_y);
SkBitmap* theme_r = GetMaskedBitmap(tab_alpha_.image_r, tab_bg,
offset_x + width() - tab_active_.r_width, offset_y);
canvas->DrawBitmapInt(*theme_r, width() - theme_r->width(), 0);
// Draw center.
canvas->TileImageInt(
*tab_bg,
offset_x + tab_image->l_width,
kDropShadowOffset + offset_y + tab_image->y_offset,
tab_image->l_width,
kDropShadowHeight + tab_image->y_offset,
width() - tab_image->l_width - tab_image->r_width,
height() - kDropShadowHeight - tab_image->y_offset);
canvas->DrawBitmapInt(*tab_inactive_image->image_l, 0, 0);
canvas->TileImageInt(
*tab_inactive_image->image_c,
tab_inactive_image->l_width,
0,
width() - tab_inactive_image->l_width - tab_inactive_image->r_width,
height());
canvas->DrawBitmapInt(*tab_inactive_image->image_r,
width() - tab_inactive_image->r_width, 0);
canvas->TileImageInt(*tab_bg,
offset_x + tab_active_.l_width, kDropShadowOffset + offset_y,
tab_active_.l_width, 2,
width() - tab_active_.l_width - tab_active_.r_width, height() - 2);
canvas->DrawBitmapInt(*tab_inactive_.image_l, 0, 0);
canvas->TileImageInt(*tab_inactive_.image_c, tab_inactive_.l_width, 0,
width() - tab_inactive_.l_width - tab_inactive_.r_width, height());
canvas->DrawBitmapInt(*tab_inactive_.image_r,
width() - tab_inactive_.r_width, 0);
}
void TabRendererGtk::PaintActiveTabBackground(gfx::Canvas* canvas) {
......@@ -964,32 +921,26 @@ void TabRendererGtk::PaintActiveTabBackground(gfx::Canvas* canvas) {
SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(IDR_THEME_TOOLBAR);
// App tabs are drawn slightly differently (as nano tabs).
TabImage* tab_image = data_.app ? &tab_active_nano_ : &tab_active_;
TabImage* alpha = data_.app ? &tab_alpha_nano_ : &tab_alpha_;
// Draw left edge.
SkBitmap* theme_l = GetMaskedBitmap(alpha->image_l, tab_bg, offset_x, 0);
SkBitmap* theme_l = GetMaskedBitmap(tab_alpha_.image_l, tab_bg, offset_x, 0);
canvas->DrawBitmapInt(*theme_l, 0, 0);
// Draw right edge.
SkBitmap* theme_r = GetMaskedBitmap(alpha->image_r, tab_bg,
offset_x + width() - tab_image->r_width, 0);
canvas->DrawBitmapInt(*theme_r, width() - tab_image->r_width, 0);
SkBitmap* theme_r = GetMaskedBitmap(tab_alpha_.image_r, tab_bg,
offset_x + width() - tab_active_.r_width, 0);
canvas->DrawBitmapInt(*theme_r, width() - tab_active_.r_width, 0);
// Draw center.
canvas->TileImageInt(*tab_bg,
offset_x + tab_image->l_width,
kDropShadowHeight + tab_image->y_offset,
tab_image->l_width,
kDropShadowHeight + tab_image->y_offset,
width() - tab_image->l_width - tab_image->r_width,
height() - kDropShadowHeight - tab_image->y_offset);
canvas->DrawBitmapInt(*tab_image->image_l, 0, 0);
canvas->TileImageInt(*tab_image->image_c, tab_image->l_width, 0,
width() - tab_image->l_width - tab_image->r_width, height());
canvas->DrawBitmapInt(*tab_image->image_r, width() - tab_image->r_width, 0);
offset_x + tab_active_.l_width, kDropShadowHeight,
tab_active_.l_width, kDropShadowHeight,
width() - tab_active_.l_width - tab_active_.r_width,
height() - kDropShadowHeight);
canvas->DrawBitmapInt(*tab_active_.image_l, 0, 0);
canvas->TileImageInt(*tab_active_.image_c, tab_active_.l_width, 0,
width() - tab_active_.l_width - tab_active_.r_width, height());
canvas->DrawBitmapInt(*tab_active_.image_r, width() - tab_active_.r_width, 0);
}
void TabRendererGtk::PaintLoadingAnimation(gfx::Canvas* canvas) {
......
......@@ -384,11 +384,8 @@ class TabRendererGtk : public AnimationDelegate,
TabData data_;
static TabImage tab_active_;
static TabImage tab_active_nano_;
static TabImage tab_inactive_;
static TabImage tab_inactive_nano_;
static TabImage tab_alpha_;
static TabImage tab_alpha_nano_;
static gfx::Font* title_font_;
static int title_font_height_;
......
......@@ -1084,10 +1084,6 @@ bool TabStripGtk::IsTabDetached(const TabGtk* tab) const {
return false;
}
bool TabStripGtk::IsToolbarVisible(const TabGtk* tab) const {
return model_->IsToolbarVisible(GetIndexOfTab(tab));
}
void TabStripGtk::GetCurrentTabWidths(double* unselected_width,
double* selected_width) const {
*unselected_width = current_unselected_width_;
......@@ -1101,13 +1097,6 @@ bool TabStripGtk::IsTabPinned(const TabGtk* tab) const {
return model_->IsTabPinned(GetIndexOfTab(tab));
}
bool TabStripGtk::IsAppTab(const TabGtk* tab) const {
if (tab->closing())
return false;
return model_->IsAppTab(GetIndexOfTab(tab));
}
void TabStripGtk::SelectTab(TabGtk* tab) {
int index = GetIndexOfTab(tab);
if (model_->ContainsIndex(index))
......
......@@ -121,9 +121,7 @@ class TabStripGtk : public TabStripModelObserver,
// TabGtk::TabDelegate implementation:
virtual bool IsTabSelected(const TabGtk* tab) const;
virtual bool IsTabPinned(const TabGtk* tab) const;
virtual bool IsAppTab(const TabGtk* tab) const;
virtual bool IsTabDetached(const TabGtk* tab) const;
virtual bool IsToolbarVisible(const TabGtk* tab) const;
virtual void SelectTab(TabGtk* tab);
virtual void CloseTab(TabGtk* tab);
virtual bool IsCommandEnabledForTab(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment