summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-20 21:29:05 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-20 21:29:05 +0000
commit6825560e7645b6ae46da50a8a9f7f4a05c26f17f (patch)
treee78ce26ac2229f2a11c535d52694b403671fc046 /chrome
parent9d7be655058fdf5fec5bb69cbe3cf6bd5e35bf39 (diff)
downloadchromium_src-6825560e7645b6ae46da50a8a9f7f4a05c26f17f.zip
chromium_src-6825560e7645b6ae46da50a8a9f7f4a05c26f17f.tar.gz
chromium_src-6825560e7645b6ae46da50a8a9f7f4a05c26f17f.tar.bz2
Misc panel bug fixes on Windows.
1) SchedulePaint should be called for the frame view when the attention is changing. 2) Title-bar controls should be hidden when the panel is minimized. 3) The minimized panel should lose the focus. 4) The panel that pops up the title-bar for drawing attention should not be brought down when the mouse is over other minimized panel. BUG=none TEST=browser tests for 2-4. manual verification for 1. Review URL: http://codereview.chromium.org/7397022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93256 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/ui/panels/native_panel.h1
-rw-r--r--chrome/browser/ui/panels/panel.cc8
-rw-r--r--chrome/browser/ui/panels/panel.h2
-rw-r--r--chrome/browser/ui/panels/panel_browser_frame_view.cc17
-rw-r--r--chrome/browser/ui/panels/panel_browser_frame_view.h1
-rw-r--r--chrome/browser/ui/panels/panel_browser_view.cc17
-rw-r--r--chrome/browser/ui/panels/panel_browser_view.h2
-rw-r--r--chrome/browser/ui/panels/panel_browser_view_browsertest.cc46
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_cocoa.h1
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_cocoa.mm5
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_gtk.cc5
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_gtk.h1
-rw-r--r--chrome/browser/ui/panels/panel_manager.cc14
13 files changed, 97 insertions, 23 deletions
diff --git a/chrome/browser/ui/panels/native_panel.h b/chrome/browser/ui/panels/native_panel.h
index 7ae4166..a02e1a7 100644
--- a/chrome/browser/ui/panels/native_panel.h
+++ b/chrome/browser/ui/panels/native_panel.h
@@ -58,6 +58,7 @@ class NativePanel {
virtual void ShowTaskManagerForPanel() = 0;
virtual void NotifyPanelOnUserChangedTheme() = 0;
virtual void DrawAttention() = 0;
+ virtual bool IsDrawingAttention() const = 0;
virtual void DestroyPanelBrowser() = 0;
// Returns a pointer to the testing interface to the native panel.
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index cbc4e25..ec397e2 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -52,6 +52,10 @@ void Panel::SetExpansionState(ExpansionState new_expansion_state) {
expansion_state_ = new_expansion_state;
native_panel_->OnPanelExpansionStateChanged(expansion_state_);
+
+ // The minimized panel should not get the focus.
+ if (expansion_state_ == MINIMIZED)
+ Deactivate();
}
bool Panel::ShouldBringUpTitleBar(int mouse_x, int mouse_y) const {
@@ -63,6 +67,10 @@ bool Panel::ShouldBringUpTitleBar(int mouse_x, int mouse_y) const {
return native_panel_->ShouldBringUpPanelTitleBar(mouse_x, mouse_y);
}
+bool Panel::IsDrawingAttention() const {
+ return native_panel_->IsDrawingAttention();
+}
+
void Panel::Show() {
native_panel_->ShowPanel();
}
diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h
index 974a302..df5271d 100644
--- a/chrome/browser/ui/panels/panel.h
+++ b/chrome/browser/ui/panels/panel.h
@@ -44,6 +44,8 @@ class Panel : public BrowserWindow {
bool ShouldBringUpTitleBar(int mouse_x, int mouse_y) const;
+ bool IsDrawingAttention() const;
+
// BrowserWindow overrides.
virtual void Show() OVERRIDE;
virtual void ShowInactive() OVERRIDE;
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc
index 852ce82..af5dc83 100644
--- a/chrome/browser/ui/panels/panel_browser_frame_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc
@@ -207,6 +207,7 @@ PanelBrowserFrameView::PanelBrowserFrameView(BrowserFrame* frame,
browser_view_(browser_view),
paint_state_(NOT_PAINTED),
settings_button_(NULL),
+ is_settings_button_visible_(false),
close_button_(NULL),
title_icon_(NULL),
title_label_(NULL),
@@ -226,7 +227,7 @@ PanelBrowserFrameView::PanelBrowserFrameView(BrowserFrame* frame,
UTF16ToWide(l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_SETTINGS)));
settings_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_SETTINGS));
- settings_button_->SetVisible(false);
+ settings_button_->SetVisible(is_settings_button_visible_);
AddChildView(settings_button_);
close_button_ = new views::ImageButton(this);
@@ -330,7 +331,7 @@ void PanelBrowserFrameView::UpdateWindowIcon() {
void PanelBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
// The font and color need to be updated depending on the panel's state.
PaintState paint_state;
- if (browser_view_->is_drawing_attention())
+ if (browser_view_->panel()->IsDrawingAttention())
paint_state = PAINT_FOR_ATTENTION;
else if (browser_view_->focused())
paint_state = PAINT_AS_ACTIVE;
@@ -354,6 +355,15 @@ gfx::Size PanelBrowserFrameView::GetMinimumSize() {
}
void PanelBrowserFrameView::Layout() {
+ // If the panel height is smaller than the title-bar height, as in minimized
+ // case, we hide all controls.
+ bool is_control_visible = height() >= kTitleBarHeight;
+ close_button_->SetVisible(is_control_visible);
+ settings_button_->SetVisible(
+ is_control_visible && is_settings_button_visible_);
+ title_icon_->SetVisible(is_control_visible);
+ title_label_->SetVisible(is_control_visible);
+
// Layout the close button.
gfx::Size close_button_size = close_button_->GetPreferredSize();
close_button_->SetBounds(
@@ -714,7 +724,8 @@ void PanelBrowserFrameView::OnMouseEnterOrLeaveWindow(bool mouse_entered) {
void PanelBrowserFrameView::UpdateSettingsButtonVisibility(
bool focused, bool cursor_in_view) {
- settings_button_->SetVisible(focused || cursor_in_view);
+ is_settings_button_visible_ = focused || cursor_in_view;
+ settings_button_->SetVisible(is_settings_button_visible_);
}
const Extension* PanelBrowserFrameView::GetExtension() const {
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.h b/chrome/browser/ui/panels/panel_browser_frame_view.h
index 7a24304..d883caf 100644
--- a/chrome/browser/ui/panels/panel_browser_frame_view.h
+++ b/chrome/browser/ui/panels/panel_browser_frame_view.h
@@ -182,6 +182,7 @@ class PanelBrowserFrameView : public BrowserNonClientFrameView,
PaintState paint_state_;
views::MenuButton* settings_button_;
+ bool is_settings_button_visible_;
views::ImageButton* close_button_;
TabIconView* title_icon_;
views::Label* title_label_;
diff --git a/chrome/browser/ui/panels/panel_browser_view.cc b/chrome/browser/ui/panels/panel_browser_view.cc
index d79f1e9..e471032 100644
--- a/chrome/browser/ui/panels/panel_browser_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_view.cc
@@ -87,7 +87,7 @@ bool PanelBrowserView::CanMaximize() const {
void PanelBrowserView::SetBounds(const gfx::Rect& bounds) {
bounds_ = bounds;
- // No animation if the panel is being dragged.
+ //// No animation if the panel is being dragged.
if (mouse_dragging_) {
::BrowserView::SetBounds(bounds);
return;
@@ -197,6 +197,9 @@ void PanelBrowserView::OnPanelExpansionStateChanged(
break;
case Panel::MINIMIZED:
height = kFullyMinimizedHeight;
+
+ // Start the mouse watcher so that we can bring up the minimized panels.
+ // TODO(jianli): Need to support mouse watching in ChromeOS.
#if defined(OS_WIN)
EnsureMouseWatcherStarted();
#endif
@@ -266,7 +269,11 @@ void PanelBrowserView::DrawAttention() {
if (panel_->expansion_state() == Panel::MINIMIZED)
panel_->SetExpansionState(Panel::TITLE_ONLY);
- SchedulePaint();
+ GetFrameView()->SchedulePaint();
+}
+
+bool PanelBrowserView::IsDrawingAttention() const {
+ return is_drawing_attention_;
}
void PanelBrowserView::DestroyPanelBrowser() {
@@ -287,11 +294,11 @@ void PanelBrowserView::StopDrawingAttention() {
// user clicks on it to mean to clear the attention.
attention_cleared_time_ = base::TimeTicks::Now();
- // Bring down the title bar.
+ // Bring up the title bar.
if (panel_->expansion_state() == Panel::TITLE_ONLY)
- panel_->SetExpansionState(Panel::MINIMIZED);
+ panel_->SetExpansionState(Panel::EXPANDED);
- SchedulePaint();
+ GetFrameView()->SchedulePaint();
}
NativePanelTesting* PanelBrowserView::GetNativePanelTesting() {
diff --git a/chrome/browser/ui/panels/panel_browser_view.h b/chrome/browser/ui/panels/panel_browser_view.h
index 04fb5da..3c70bed 100644
--- a/chrome/browser/ui/panels/panel_browser_view.h
+++ b/chrome/browser/ui/panels/panel_browser_view.h
@@ -32,7 +32,6 @@ class PanelBrowserView : public BrowserView,
Panel* panel() const { return panel_.get(); }
bool closed() const { return closed_; }
bool focused() const { return focused_; }
- bool is_drawing_attention() const { return is_drawing_attention_; }
PanelBrowserFrameView* GetFrameView() const;
@@ -88,6 +87,7 @@ class PanelBrowserView : public BrowserView,
virtual void NotifyPanelOnUserChangedTheme() OVERRIDE;
virtual void DestroyPanelBrowser() OVERRIDE;
virtual void DrawAttention() OVERRIDE;
+ virtual bool IsDrawingAttention() const OVERRIDE;
virtual NativePanelTesting* GetNativePanelTesting() OVERRIDE;
// Overridden from AnimationDelegate:
diff --git a/chrome/browser/ui/panels/panel_browser_view_browsertest.cc b/chrome/browser/ui/panels/panel_browser_view_browsertest.cc
index e181d70..3b30bbd 100644
--- a/chrome/browser/ui/panels/panel_browser_view_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browser_view_browsertest.cc
@@ -87,6 +87,14 @@ class PanelBrowserViewTest : public InProcessBrowserTest {
return static_cast<PanelBrowserView*>(panel->native_panel());
}
+ void WaitTillBoundsAnimationFinished(PanelBrowserView* browser_view) {
+ // The timer for the animation will only kick in as async task.
+ while (browser_view->bounds_animator_->is_animating()) {
+ MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
+ MessageLoop::current()->RunAllPending();
+ }
+ }
+
void ValidateDragging(PanelBrowserView** browser_views,
size_t num_browser_views,
size_t index_to_drag,
@@ -284,6 +292,7 @@ class PanelBrowserViewTest : public InProcessBrowserTest {
PanelBrowserView* browser_view1 = CreatePanelBrowserView("PanelTest1",
SHOW_AS_ACTIVE);
Panel* panel1 = browser_view1->panel_.get();
+ PanelBrowserFrameView* frame_view1 = browser_view1->GetFrameView();
// Test minimizing/restoring an individual panel.
EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
@@ -296,14 +305,29 @@ class PanelBrowserViewTest : public InProcessBrowserTest {
EXPECT_LT(panel1->GetBounds().height(), titlebar_height);
EXPECT_GT(panel1->GetBounds().height(), 0);
EXPECT_TRUE(IsMouseWatcherStarted());
+ EXPECT_FALSE(panel1->IsActive());
+ WaitTillBoundsAnimationFinished(browser_view1);
+ // TODO(jianli): Enable the following checks after the patch to support
+ // minimizing window to 3-pixel line is landed.
+ //EXPECT_FALSE(frame_view1->close_button_->IsVisible());
+ //EXPECT_FALSE(frame_view1->title_icon_->IsVisible());
+ //EXPECT_FALSE(frame_view1->title_label_->IsVisible());
panel1->SetExpansionState(Panel::TITLE_ONLY);
EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
EXPECT_EQ(titlebar_height, panel1->GetBounds().height());
+ WaitTillBoundsAnimationFinished(browser_view1);
+ EXPECT_TRUE(frame_view1->close_button_->IsVisible());
+ EXPECT_TRUE(frame_view1->title_icon_->IsVisible());
+ EXPECT_TRUE(frame_view1->title_label_->IsVisible());
panel1->SetExpansionState(Panel::EXPANDED);
EXPECT_EQ(Panel::EXPANDED, panel1->expansion_state());
EXPECT_EQ(initial_height, panel1->GetBounds().height());
+ WaitTillBoundsAnimationFinished(browser_view1);
+ EXPECT_TRUE(frame_view1->close_button_->IsVisible());
+ EXPECT_TRUE(frame_view1->title_icon_->IsVisible());
+ EXPECT_TRUE(frame_view1->title_label_->IsVisible());
panel1->SetExpansionState(Panel::TITLE_ONLY);
EXPECT_EQ(Panel::TITLE_ONLY, panel1->expansion_state());
@@ -371,20 +395,20 @@ class PanelBrowserViewTest : public InProcessBrowserTest {
// Test that the attention should not be drawn if the expanded panel is in
// focus.
browser_view->DrawAttention();
- EXPECT_FALSE(browser_view->is_drawing_attention());
+ EXPECT_FALSE(browser_view->IsDrawingAttention());
MessageLoop::current()->RunAllPending();
EXPECT_NE(attention_color, frame_view->title_label_->GetColor());
// Test that the attention is drawn when the expanded panel is not in focus.
panel->Deactivate();
browser_view->DrawAttention();
- EXPECT_TRUE(browser_view->is_drawing_attention());
+ EXPECT_TRUE(browser_view->IsDrawingAttention());
MessageLoop::current()->RunAllPending();
EXPECT_EQ(attention_color, frame_view->title_label_->GetColor());
// Test that the attention is cleared.
browser_view->StopDrawingAttention();
- EXPECT_FALSE(browser_view->is_drawing_attention());
+ EXPECT_FALSE(browser_view->IsDrawingAttention());
MessageLoop::current()->RunAllPending();
EXPECT_NE(attention_color, frame_view->title_label_->GetColor());
@@ -394,7 +418,7 @@ class PanelBrowserViewTest : public InProcessBrowserTest {
panel->SetExpansionState(Panel::MINIMIZED);
EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state());
browser_view->DrawAttention();
- EXPECT_TRUE(browser_view->is_drawing_attention());
+ EXPECT_TRUE(browser_view->IsDrawingAttention());
EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state());
MessageLoop::current()->RunAllPending();
EXPECT_EQ(attention_color, frame_view->title_label_->GetColor());
@@ -405,10 +429,15 @@ class PanelBrowserViewTest : public InProcessBrowserTest {
ShouldBringUpTitleBarForAllMinimizedPanels(
panel->GetBounds().x(), panel->GetBounds().y()));
+ // Test that we cannot bring down the panel that is drawing the attention.
+ PanelManager::GetInstance()->BringUpOrDownTitleBarForAllMinimizedPanels(
+ false);
+ EXPECT_EQ(Panel::TITLE_ONLY, panel->expansion_state());
+
// Test that the attention is cleared.
browser_view->StopDrawingAttention();
- EXPECT_FALSE(browser_view->is_drawing_attention());
- EXPECT_EQ(Panel::MINIMIZED, panel->expansion_state());
+ EXPECT_FALSE(browser_view->IsDrawingAttention());
+ EXPECT_EQ(Panel::EXPANDED, panel->expansion_state());
MessageLoop::current()->RunAllPending();
EXPECT_NE(attention_color, frame_view->title_label_->GetColor());
@@ -691,10 +720,7 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserViewTest, SetBoundsAnimation) {
ASSERT_TRUE(browser_view->bounds_animator_.get());
EXPECT_TRUE(browser_view->bounds_animator_->is_animating());
EXPECT_NE(browser_view->GetBounds(), target_bounds);
- // The timer for the animation will only kick in as async task.
- while (browser_view->bounds_animator_->is_animating()) {
- MessageLoop::current()->RunAllPending();
- }
+ WaitTillBoundsAnimationFinished(browser_view);
EXPECT_EQ(browser_view->GetBounds(), target_bounds);
// Validates that no animation should be triggered for the panel currently
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa.h b/chrome/browser/ui/panels/panel_browser_window_cocoa.h
index a0f8a4f..3a19041 100644
--- a/chrome/browser/ui/panels/panel_browser_window_cocoa.h
+++ b/chrome/browser/ui/panels/panel_browser_window_cocoa.h
@@ -44,6 +44,7 @@ class PanelBrowserWindowCocoa : public NativePanel,
virtual void ShowTaskManagerForPanel() OVERRIDE;
virtual void NotifyPanelOnUserChangedTheme() OVERRIDE;
virtual void DrawAttention() OVERRIDE;
+ virtual bool IsDrawingAttention() const OVERRIDE;
virtual void DestroyPanelBrowser() OVERRIDE;
virtual NativePanelTesting* GetNativePanelTesting() OVERRIDE;
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
index 1f19c88..684e191 100644
--- a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
@@ -142,6 +142,11 @@ void PanelBrowserWindowCocoa::DrawAttention() {
NOTIMPLEMENTED();
}
+bool PanelBrowserWindowCocoa::IsDrawingAttention() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
void PanelBrowserWindowCocoa::DestroyPanelBrowser() {
[controller_ close];
controller_ = NULL;
diff --git a/chrome/browser/ui/panels/panel_browser_window_gtk.cc b/chrome/browser/ui/panels/panel_browser_window_gtk.cc
index 6eac071..0ac6377 100644
--- a/chrome/browser/ui/panels/panel_browser_window_gtk.cc
+++ b/chrome/browser/ui/panels/panel_browser_window_gtk.cc
@@ -138,6 +138,11 @@ void PanelBrowserWindowGtk::DrawAttention() {
NOTIMPLEMENTED();
}
+bool PanelBrowserWindowGtk::IsDrawingAttention() const {
+ NOTIMPLEMENTED();
+ return false;
+}
+
void PanelBrowserWindowGtk::DestroyPanelBrowser() {
DestroyBrowser();
}
diff --git a/chrome/browser/ui/panels/panel_browser_window_gtk.h b/chrome/browser/ui/panels/panel_browser_window_gtk.h
index 20e1fb1..45ee0c0 100644
--- a/chrome/browser/ui/panels/panel_browser_window_gtk.h
+++ b/chrome/browser/ui/panels/panel_browser_window_gtk.h
@@ -53,6 +53,7 @@ class PanelBrowserWindowGtk : public BrowserWindowGtk,
virtual void ShowTaskManagerForPanel() OVERRIDE;
virtual void NotifyPanelOnUserChangedTheme() OVERRIDE;
virtual void DrawAttention() OVERRIDE;
+ virtual bool IsDrawingAttention() const OVERRIDE;
virtual void DestroyPanelBrowser() OVERRIDE;
virtual NativePanelTesting* GetNativePanelTesting() OVERRIDE;
diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc
index 5f3add8..9aea49e 100644
--- a/chrome/browser/ui/panels/panel_manager.cc
+++ b/chrome/browser/ui/panels/panel_manager.cc
@@ -282,12 +282,18 @@ bool PanelManager::ShouldBringUpTitleBarForAllMinimizedPanels(
void PanelManager::BringUpOrDownTitleBarForAllMinimizedPanels(bool bring_up) {
for (ActivePanels::const_iterator iter = active_panels_.begin();
iter != active_panels_.end(); ++iter) {
+ Panel* panel = *iter;
+
+ // Skip any panel that is drawing the attention.
+ if (panel->IsDrawingAttention())
+ continue;
+
if (bring_up) {
- if ((*iter)->expansion_state() == Panel::MINIMIZED)
- (*iter)->SetExpansionState(Panel::TITLE_ONLY);
+ if (panel->expansion_state() == Panel::MINIMIZED)
+ panel->SetExpansionState(Panel::TITLE_ONLY);
} else {
- if ((*iter)->expansion_state() == Panel::TITLE_ONLY)
- (*iter)->SetExpansionState(Panel::MINIMIZED);
+ if (panel->expansion_state() == Panel::TITLE_ONLY)
+ panel->SetExpansionState(Panel::MINIMIZED);
}
}
}