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

Unified Diff: chrome/browser/chromeos/compact_navigation_bar.cc

Issue 329009: CompactNavigationBar for toolkit views build, with some design change per Cole's request. (Closed)
Patch Set: updates per review Created 11 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/compact_navigation_bar.h ('k') | chrome/browser/chromeos/status_area_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/compact_navigation_bar.cc
diff --git a/chrome/browser/chromeos/compact_navigation_bar.cc b/chrome/browser/chromeos/compact_navigation_bar.cc
index d8859ee6eaced37a8b5bfde81ee558fb494c2d10..b316095630bedbacf865494d1dddd1c41d505396 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 {
« no previous file with comments | « chrome/browser/chromeos/compact_navigation_bar.h ('k') | chrome/browser/chromeos/status_area_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698