summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/frame
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/chromeos/frame')
-rw-r--r--chrome/browser/chromeos/frame/browser_view.cc99
-rw-r--r--chrome/browser/chromeos/frame/browser_view.h18
-rw-r--r--chrome/browser/chromeos/frame/normal_browser_frame_view.cc14
3 files changed, 120 insertions, 11 deletions
diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc
index 528871b..b6fd133 100644
--- a/chrome/browser/chromeos/frame/browser_view.cc
+++ b/chrome/browser/chromeos/frame/browser_view.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/views/frame/browser_view_layout.h"
#include "chrome/browser/views/tabs/tab.h"
#include "chrome/browser/views/tabs/tab_strip.h"
+#include "chrome/browser/views/theme_background.h"
#include "chrome/browser/views/toolbar_view.h"
#include "gfx/canvas.h"
#include "grit/generated_resources.h"
@@ -59,6 +60,9 @@ const int kCompactNavbarSpaceHeight = 3;
// The padding of the app launcher to the left side of the border.
const int kAppLauncherLeftPadding = 5;
+// Amount to offset the toolbar by when vertical tabs are enabled.
+const int kVerticalTabStripToolbarOffset = 2;
+
// A space we insert between the tabstrip and the content in
// Compact mode.
class Spacer : public views::View {
@@ -165,8 +169,7 @@ class BrowserViewLayout : public ::BrowserViewLayout {
// layouts compact navigation buttons and status views in the title
// area. See Layout
virtual int LayoutTabStrip() {
- if (browser_view_->IsFullscreen() ||
- !browser_view_->IsTabStripVisible()) {
+ if (browser_view_->IsFullscreen() || !browser_view_->IsTabStripVisible()) {
compact_navigation_bar_->SetVisible(false);
status_area_->SetVisible(false);
otr_avatar_icon_->SetVisible(false);
@@ -180,10 +183,22 @@ class BrowserViewLayout : public ::BrowserViewLayout {
views::View::ConvertPointToView(browser_view_->GetParent(), browser_view_,
&tabstrip_origin);
layout_bounds.set_origin(tabstrip_origin);
+ if (browser_view_->UseVerticalTabs())
+ return LayoutTitlebarComponentsWithVerticalTabs(layout_bounds);
return LayoutTitlebarComponents(layout_bounds);
}
}
+ virtual int LayoutToolbar(int top) {
+ if (!browser_view_->IsFullscreen() && browser_view_->IsTabStripVisible() &&
+ browser_view_->UseVerticalTabs()) {
+ // For vertical tabs the toolbar is positioned in
+ // LayoutTitlebarComponentsWithVerticalTabs.
+ return top;
+ }
+ return ::BrowserViewLayout::LayoutToolbar(top);
+ }
+
virtual bool IsPositionInWindowCaption(const gfx::Point& point) {
return ::BrowserViewLayout::IsPositionInWindowCaption(point)
&& !IsPointInViewsInTitleArea(point);
@@ -223,6 +238,67 @@ class BrowserViewLayout : public ::BrowserViewLayout {
return false;
}
+ // Positions the titlebar, toolbar, tabstrip, tabstrip and otr icon. This is
+ // used when side tabs are enabled.
+ int LayoutTitlebarComponentsWithVerticalTabs(const gfx::Rect& bounds) {
+ if (bounds.IsEmpty())
+ return 0;
+
+ compact_navigation_bar_->SetVisible(false);
+ compact_navigation_bar_->SetBounds(0, 0, 0, 0);
+ spacer_->SetVisible(false);
+ tabstrip_->SetVisible(true);
+ otr_avatar_icon_->SetVisible(browser_view_->ShouldShowOffTheRecordAvatar());
+ status_area_->SetVisible(true);
+ status_area_->Update();
+
+ gfx::Size status_size = status_area_->GetPreferredSize();
+ int status_height = status_size.height();
+
+ // Layout the otr icon.
+ int status_x = bounds.x();
+ if (!otr_avatar_icon_->IsVisible()) {
+ otr_avatar_icon_->SetBounds(0, 0, 0, 0);
+ } else {
+ gfx::Size otr_size = otr_avatar_icon_->GetPreferredSize();
+
+ status_height = std::max(status_height, otr_size.height());
+ int y = bounds.bottom() - status_height;
+ otr_avatar_icon_->SetBounds(status_x, y, otr_size.width(), status_height);
+ status_x += otr_size.width();
+ }
+
+ // Layout the status area after the otr icon.
+ status_area_->SetBounds(status_x, bounds.bottom() - status_height,
+ status_size.width(), status_height);
+
+ // The tabstrip's width is the bigger of it's preferred width and the width
+ // the status area.
+ int tabstrip_w = std::max(status_x + status_size.width(),
+ tabstrip_->GetPreferredSize().width());
+ tabstrip_->SetBounds(bounds.x(), bounds.y(), tabstrip_w,
+ bounds.height() - status_height);
+
+ // The toolbar is promoted to the title for vertical tabs.
+ bool toolbar_visible = browser_view_->IsToolbarVisible();
+ toolbar_->SetVisible(toolbar_visible);
+ int toolbar_height = 0;
+ if (toolbar_visible)
+ toolbar_height = toolbar_->GetPreferredSize().height();
+ int tabstrip_max_x = tabstrip_->bounds().right();
+ toolbar_->SetBounds(tabstrip_max_x,
+ bounds.y() - kVerticalTabStripToolbarOffset,
+ browser_view_->width() - tabstrip_max_x,
+ toolbar_height);
+
+ // Adjust the available bounds for other components.
+ gfx::Rect available_bounds = vertical_layout_rect();
+ available_bounds.Inset(tabstrip_w, 0, 0, 0);
+ set_vertical_layout_rect(available_bounds);
+
+ return bounds.y() + toolbar_height;
+ }
+
// Layouts components in the title bar area (given by
// |bounds|). These include the main menu, the compact navigation
// buttons (in compact navbar mode), the otr avatar icon (in
@@ -412,7 +488,10 @@ void BrowserView::SetFocusToLocationBar(bool select_all) {
}
void BrowserView::ToggleCompactNavigationBar() {
- ui_style_ = static_cast<UIStyle>((ui_style_ + 1) % 2);
+ UIStyle new_style = static_cast<UIStyle>((ui_style_ + 1) % 2);
+ if (new_style != StandardStyle && UseVerticalTabs())
+ browser()->ExecuteCommand(IDC_TOGGLE_VERTICAL_TABS);
+ ui_style_ = new_style;
compact_location_bar_host_->SetEnabled(is_compact_style());
compact_location_bar_host_->Hide(false);
Layout();
@@ -422,6 +501,13 @@ views::LayoutManager* BrowserView::CreateLayoutManager() const {
return new BrowserViewLayout();
}
+void BrowserView::InitTabStrip(TabStripModel* tab_strip_model) {
+ if (UseVerticalTabs() && is_compact_style())
+ ToggleCompactNavigationBar();
+ ::BrowserView::InitTabStrip(tab_strip_model);
+ UpdateOTRBackground();
+}
+
void BrowserView::ChildPreferredSizeChanged(View* child) {
Layout();
SchedulePaint();
@@ -518,6 +604,13 @@ void BrowserView::InitSystemMenu() {
system_menu_menu_.reset(new views::Menu2(system_menu_contents_.get()));
}
+void BrowserView::UpdateOTRBackground() {
+ if (UseVerticalTabs())
+ otr_avatar_icon_->set_background(new ThemeBackground(this));
+ else
+ otr_avatar_icon_->set_background(NULL);
+}
+
} // namespace chromeos
// static
diff --git a/chrome/browser/chromeos/frame/browser_view.h b/chrome/browser/chromeos/frame/browser_view.h
index 8665859..2bdb029 100644
--- a/chrome/browser/chromeos/frame/browser_view.h
+++ b/chrome/browser/chromeos/frame/browser_view.h
@@ -40,16 +40,15 @@ class BrowserView : public ::BrowserView,
public views::ContextMenuController,
public StatusAreaHost {
public:
- // There are 3 ui styles, standard, compact and sidebar.
- // Standard uses the same layout as chromium/chrome browser.
- // Compact mode hides the omnibox/toolbar to save the vertical real estate,
- // and uses QSB (compact nav bar) to launch/switch url. In sidebar mode,
- // the tabstrip is moved to the side and the omnibox is moved on top of
- // the tabstrip.
+ // There are three distinct ui styles:
+ // . Standards uses the same layout as chrome. Within standard the user can
+ // turn on side tabs. Side tabs are still represented by the constant
+ // StandardStyle.
+ // . Compact mode hides the omnibox/toolbar to save the vertical real estate,
+ // and uses QSB (compact nav bar) to launch/switch url.
enum UIStyle {
StandardStyle = 0,
CompactStyle,
- SidebarStyle,
};
explicit BrowserView(Browser* browser);
@@ -62,6 +61,7 @@ class BrowserView : public ::BrowserView,
virtual void SetFocusToLocationBar(bool select_all);
virtual void ToggleCompactNavigationBar();
virtual views::LayoutManager* CreateLayoutManager() const;
+ virtual void InitTabStrip(TabStripModel* tab_strip_model);
virtual void ChildPreferredSizeChanged(View* child);
virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const;
@@ -97,6 +97,10 @@ class BrowserView : public ::BrowserView,
void InitSystemMenu();
+ // Updates the background of the otr icon. The background differs for vertical
+ // tabs.
+ void UpdateOTRBackground();
+
// Status Area view.
BrowserStatusAreaView* status_area_;
diff --git a/chrome/browser/chromeos/frame/normal_browser_frame_view.cc b/chrome/browser/chromeos/frame/normal_browser_frame_view.cc
index 7b80753..3aca16a 100644
--- a/chrome/browser/chromeos/frame/normal_browser_frame_view.cc
+++ b/chrome/browser/chromeos/frame/normal_browser_frame_view.cc
@@ -86,6 +86,13 @@ NormalBrowserFrameView::~NormalBrowserFrameView() {
gfx::Rect NormalBrowserFrameView::GetBoundsForTabStrip(
BaseTabStrip* tabstrip) const {
int border_thickness = FrameBorderThickness();
+ if (browser_view_->UseVerticalTabs()) {
+ // BrowserViewLayout adjusts the height/width based on the status area and
+ // otr icon.
+ gfx::Size ps = tabstrip->GetPreferredSize();
+ return gfx::Rect(border_thickness, NonClientTopBorderHeight(),
+ ps.width(), browser_view_->height());
+ }
return gfx::Rect(border_thickness, NonClientTopBorderHeight(),
std::max(0, width() - (2 * border_thickness)),
tabstrip->GetPreferredHeight());
@@ -185,8 +192,13 @@ bool NormalBrowserFrameView::HitTest(const gfx::Point& l) const {
return true;
// Otherwise claim it only if it's in a non-tab portion of the tabstrip.
- if (l.y() > browser_view_->tabstrip()->bounds().bottom())
+ bool vertical_tabs = browser_view_->UseVerticalTabs();
+ const gfx::Rect& tabstrip_bounds = browser_view_->tabstrip()->bounds();
+ if ((!vertical_tabs && l.y() > tabstrip_bounds.bottom()) ||
+ (vertical_tabs && (l.x() > tabstrip_bounds.right() ||
+ l.y() > tabstrip_bounds.bottom()))) {
return false;
+ }
// We convert from our parent's coordinates since we assume we fill its bounds
// completely. We need to do this since we're not a parent of the tabstrip,