summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-26 20:21:05 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-26 20:21:05 +0000
commit20d1724b21142632ccf78846284bcd6e5c1d527b (patch)
tree39c12f5d8e28750d52cde89bc1bbf6b3d5feb044 /chrome/browser/chromeos
parent42fb820ce022e072314b11aa4d5767d1caaa6b7d (diff)
downloadchromium_src-20d1724b21142632ccf78846284bcd6e5c1d527b.zip
chromium_src-20d1724b21142632ccf78846284bcd6e5c1d527b.tar.gz
chromium_src-20d1724b21142632ccf78846284bcd6e5c1d527b.tar.bz2
CompactNavigationBar for toolkit views build, with some design change per Cole's request.
* Swapped the positions of entry field and navigation buttons. * Hide navigation buttions when the entry field gains focus. - To implement this, I added OnKillFocus in AutocompleteEditController, and updated corresponding files. * Added accelerator (shift-ctrl-0) to toggle compact navigation bar Changes to BrowserExtender * Made all virtual methods in BrowserExtender pure virtual. * Added HideToolbar method to control visibility of toolbar from Extender. Review URL: http://codereview.chromium.org/329009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30082 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/chromeos_browser_extenders.cc70
-rw-r--r--chrome/browser/chromeos/compact_navigation_bar.cc67
-rw-r--r--chrome/browser/chromeos/compact_navigation_bar.h1
-rwxr-xr-xchrome/browser/chromeos/status_area_view.cc14
4 files changed, 116 insertions, 36 deletions
diff --git a/chrome/browser/chromeos/chromeos_browser_extenders.cc b/chrome/browser/chromeos/chromeos_browser_extenders.cc
index cf11585..fe63ec4 100644
--- a/chrome/browser/chromeos/chromeos_browser_extenders.cc
+++ b/chrome/browser/chromeos/chromeos_browser_extenders.cc
@@ -6,6 +6,7 @@
#include "app/theme_provider.h"
#include "chrome/app/chrome_dll_resource.h"
+#include "chrome/browser/chromeos/compact_navigation_bar.h"
#include "chrome/browser/chromeos/main_menu.h"
#include "chrome/browser/chromeos/status_area_view.h"
#include "chrome/browser/chromeos/panel_controller.h"
@@ -54,6 +55,14 @@ class NormalExtender : public BrowserExtender,
main_menu_->SetImage(views::CustomButton::BS_PUSHED, image);
browser_view()->AddChildView(main_menu_);
+ compact_navigation_bar_ =
+ new CompactNavigationBar(browser_view()->browser());
+ browser_view()->AddChildView(compact_navigation_bar_);
+ compact_navigation_bar_->Init();
+ // Disabled by default.
+ // TODO(oshima): Get this info from preference.
+ compact_navigation_bar_->SetVisible(false);
+
status_area_ = new StatusAreaView(
browser_view()->browser(),
browser_view()->GetWindow()->GetNativeWindow());
@@ -87,35 +96,64 @@ class NormalExtender : public BrowserExtender,
status_area_->SetBounds(bounds.x() + bounds.width() - status_size.width(),
bounds.y(), status_size.width(),
status_size.height());
+ int curx = bounds.x() + main_menu_size.width();
int width = bounds.width() - main_menu_size.width() - status_size.width();
- return gfx::Rect(bounds.x() + main_menu_size.width(),
- bounds.y(),
- std::max(0, width), // in case there is no space left.
- bounds.height());
+
+ if (compact_navigation_bar_->IsVisible()) {
+ gfx::Size cnb_bounds = compact_navigation_bar_->GetPreferredSize();
+ compact_navigation_bar_->SetBounds(curx, bounds.y(),
+ cnb_bounds.width(), bounds.height());
+ curx += cnb_bounds.width();
+ width -= cnb_bounds.width();
+ }
+ width = std::max(0, width); // In case there is no space left.
+ return gfx::Rect(curx, bounds.y(), width, bounds.height());
}
virtual bool NonClientHitTest(const gfx::Point& point) {
gfx::Point point_in_main_menu_coords(point);
views::View::ConvertPointToView(browser_view(), main_menu_,
&point_in_main_menu_coords);
+ if (main_menu_->HitTest(point_in_main_menu_coords))
+ return true;
gfx::Point point_in_status_area_coords(point);
views::View::ConvertPointToView(browser_view(), status_area_,
&point_in_status_area_coords);
-
- return main_menu_->HitTest(point_in_main_menu_coords) ||
- status_area_->HitTest(point_in_status_area_coords);
+ if (status_area_->HitTest(point_in_status_area_coords))
+ return true;
+
+ if (compact_navigation_bar_->IsVisible()) {
+ gfx::Point point_in_cnb_coords(point);
+ views::View::ConvertPointToView(browser_view(),
+ compact_navigation_bar_,
+ &point_in_cnb_coords);
+ return compact_navigation_bar_->HitTest(point_in_cnb_coords);
+ }
+ return false;
}
+ virtual void UpdateTitleBar() {}
+
virtual void Show() {
- // TODO(oshima): PanelController seems to be doing something similar.
- // Investigate if we need both.
TabOverviewTypes::instance()->SetWindowType(
GTK_WIDGET(GetBrowserWindow()->GetNativeWindow()),
TabOverviewTypes::WINDOW_TYPE_CHROME_TOPLEVEL,
NULL);
}
+ virtual void Close() {}
+
+ virtual void ActivationChanged() {}
+
+ virtual bool ShouldForceHideToolbar() {
+ return compact_navigation_bar_->IsVisible();
+ }
+
+ virtual void ToggleCompactNavigationBar() {
+ compact_navigation_bar_->SetVisible(!compact_navigation_bar_->IsVisible());
+ }
+
private:
// Creates system menu.
void InitSystemMenu() {
@@ -152,6 +190,9 @@ class NormalExtender : public BrowserExtender,
scoped_ptr<views::SimpleMenuModel> system_menu_contents_;
scoped_ptr<views::Menu2> system_menu_menu_;
+ // CompactNavigationBar view.
+ CompactNavigationBar* compact_navigation_bar_;
+
DISALLOW_COPY_AND_ASSIGN(NormalExtender);
};
@@ -183,6 +224,10 @@ class PopupExtender : public BrowserExtender {
gtk_window_resize(native_window, bounds.width(), bounds.height());
}
+ virtual gfx::Rect Layout(const gfx::Rect& bounds) {
+ return bounds;
+ }
+
virtual bool NonClientHitTest(const gfx::Point& point) {
return false;
}
@@ -210,6 +255,13 @@ class PopupExtender : public BrowserExtender {
}
}
+ virtual bool ShouldForceHideToolbar() {
+ // Always hide toolbar for popups.
+ return true;
+ }
+
+ virtual void ToggleCompactNavigationBar() {}
+
// Controls interactions with the window manager for popup panels.
scoped_ptr<PanelController> panel_controller_;
diff --git a/chrome/browser/chromeos/compact_navigation_bar.cc b/chrome/browser/chromeos/compact_navigation_bar.cc
index d8859ee..b316095 100644
--- a/chrome/browser/chromeos/compact_navigation_bar.cc
+++ b/chrome/browser/chromeos/compact_navigation_bar.cc
@@ -40,7 +40,8 @@ CompactNavigationBar::CompactNavigationBar(Browser* browser)
}
CompactNavigationBar::~CompactNavigationBar() {
- location_entry_view_->Detach();
+ if (location_entry_view_->native_view())
+ location_entry_view_->Detach();
}
void CompactNavigationBar::Init() {
@@ -100,27 +101,36 @@ void CompactNavigationBar::Layout() {
if (!initialized_)
return;
- int curx = 0;
-
- // "Back | Forward" section.
- gfx::Size button_size = back_button_->GetPreferredSize();
- button_size.set_width(button_size.width() + kInnerPadding * 2);
- back_button_->SetBounds(curx, 0, button_size.width(), height());
- curx += button_size.width() + kHorizPadding;
-
- button_size = bf_separator_->GetPreferredSize();
- bf_separator_->SetBounds(curx, 0, button_size.width(), height());
- curx += button_size.width() + kHorizPadding;
-
- button_size = forward_button_->GetPreferredSize();
- button_size.set_width(button_size.width() + kInnerPadding * 2);
- forward_button_->SetBounds(curx, 0, button_size.width(), height());
- curx += button_size.width() + kHorizPadding;
-
- // URL bar.
- location_entry_view_->SetBounds(curx + kURLPadding, 0,
- kURLWidth + kURLPadding * 2, height());
- curx += kURLWidth + kHorizPadding + kURLPadding * 2;
+ // We hide navigation buttons when the entry has focus. Navigation
+ // buttons' visibility is controlled in OnKillFocus/OnSetFocus methods.
+ if (!back_button_->IsVisible()) {
+ // Fill the view with the entry view while it has focus.
+ location_entry_view_->SetBounds(kURLPadding, 0,
+ width() - kHorizPadding, height());
+ } else {
+ // Layout forward/back buttons after entry views as follows:
+ // [Entry View] [Back]|[Forward]
+ int curx = 0;
+ // URL bar.
+ location_entry_view_->SetBounds(curx + kURLPadding, 0,
+ kURLWidth + kURLPadding * 2, height());
+ curx += kURLWidth + kHorizPadding + kURLPadding * 2;
+
+ // "Back | Forward" section.
+ gfx::Size button_size = back_button_->GetPreferredSize();
+ button_size.set_width(button_size.width() + kInnerPadding * 2);
+ back_button_->SetBounds(curx, 0, button_size.width(), height());
+ curx += button_size.width() + kHorizPadding;
+
+ button_size = bf_separator_->GetPreferredSize();
+ bf_separator_->SetBounds(curx, 0, button_size.width(), height());
+ curx += button_size.width() + kHorizPadding;
+
+ button_size = forward_button_->GetPreferredSize();
+ button_size.set_width(button_size.width() + kInnerPadding * 2);
+ forward_button_->SetBounds(curx, 0, button_size.width(), height());
+ curx += button_size.width() + kHorizPadding;
+ }
}
void CompactNavigationBar::Paint(gfx::Canvas* canvas) {
@@ -180,7 +190,20 @@ void CompactNavigationBar::OnChanged() {
void CompactNavigationBar::OnInputInProgress(bool in_progress) {
}
+void CompactNavigationBar::OnKillFocus() {
+ back_button_->SetVisible(true);
+ bf_separator_->SetVisible(true);
+ forward_button_->SetVisible(true);
+ Layout();
+ SchedulePaint();
+}
+
void CompactNavigationBar::OnSetFocus() {
+ back_button_->SetVisible(false);
+ bf_separator_->SetVisible(false);
+ forward_button_->SetVisible(false);
+ Layout();
+ SchedulePaint();
}
SkBitmap CompactNavigationBar::GetFavIcon() const {
diff --git a/chrome/browser/chromeos/compact_navigation_bar.h b/chrome/browser/chromeos/compact_navigation_bar.h
index d5e4961..dec7c1d 100644
--- a/chrome/browser/chromeos/compact_navigation_bar.h
+++ b/chrome/browser/chromeos/compact_navigation_bar.h
@@ -51,6 +51,7 @@ class CompactNavigationBar : public views::View,
const GURL& alternate_nav_url);
virtual void OnChanged();
virtual void OnInputInProgress(bool in_progress);
+ virtual void OnKillFocus();
virtual void OnSetFocus();
virtual SkBitmap GetFavIcon() const;
virtual std::wstring GetTitle() const;
diff --git a/chrome/browser/chromeos/status_area_view.cc b/chrome/browser/chromeos/status_area_view.cc
index 5b268dd..62bcd68 100755
--- a/chrome/browser/chromeos/status_area_view.cc
+++ b/chrome/browser/chromeos/status_area_view.cc
@@ -50,9 +50,12 @@ class OptionsMenuModel : public views::SimpleMenuModel,
views::SimpleMenuModel::Delegate* delegate)
: SimpleMenuModel(this),
browser_(browser) {
+#if defined(TOOLKIT_VIEWS)
+ AddItemWithStringId(IDC_COMPACT_NAVBAR, IDS_COMPACT_NAVBAR);
+#else
AddItem(static_cast<int>(CREATE_NEW_WINDOW),
ASCIIToUTF16("New window"));
-
+#endif
AddSeparator();
AddItem(static_cast<int>(StatusAreaView::OPEN_TABS_ON_LEFT),
@@ -79,11 +82,12 @@ class OptionsMenuModel : public views::SimpleMenuModel,
}
virtual void ExecuteCommand(int command_id) {
switch (command_id) {
- case CREATE_NEW_WINDOW:
#if defined(TOOLKIT_VIEWS)
- // TODO(oshima): Implement accelerator to enable/disable
- // compact nav bar.
+ case IDC_COMPACT_NAVBAR:
+ browser_->ExecuteCommand(command_id);
+ break;
#else
+ case CREATE_NEW_WINDOW:
// Reach into the GTK browser window and enable the flag to create the
// next window as a compact nav one.
// TODO(brettw) this is an evil hack, and is here so this can be tested.
@@ -91,8 +95,8 @@ class OptionsMenuModel : public views::SimpleMenuModel,
static_cast<BrowserWindowGtk*>(browser_->window())->
set_next_window_should_use_compact_nav();
browser_->ExecuteCommand(IDC_NEW_WINDOW);
-#endif
break;
+#endif
case StatusAreaView::OPEN_TABS_ON_LEFT:
case StatusAreaView::OPEN_TABS_CLOBBER:
case StatusAreaView::OPEN_TABS_ON_RIGHT: