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

Unified Diff: chrome/browser/ui/panels/panel_browser_view.cc

Issue 7242017: Support minimizing the panel into 3-pixel line on Windows. Also support bringing up/down the titl... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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
Index: chrome/browser/ui/panels/panel_browser_view.cc
===================================================================
--- chrome/browser/ui/panels/panel_browser_view.cc (revision 90982)
+++ chrome/browser/ui/panels/panel_browser_view.cc (working copy)
@@ -8,6 +8,7 @@
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_browser_frame_view.h"
#include "chrome/browser/ui/panels/panel_manager.h"
+#include "chrome/browser/ui/panels/panel_mouse_watcher_win.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
#include "grit/chromium_strings.h"
#include "ui/base/animation/slide_animation.h"
@@ -17,6 +18,9 @@
namespace {
// This value is experimental and subjective.
const int kSetBoundsAnimationMs = 200;
+
+// The panel can be fully minimized to 3-pixel lines.
+const int kFullyMinimizedHeight = 3;
}
NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel,
@@ -32,7 +36,6 @@
panel_(panel),
bounds_(bounds),
original_height_(bounds.height()),
- minimized_(false),
closed_(false),
focused_(false),
mouse_pressed_(false),
@@ -58,6 +61,10 @@
bounds_animator_.reset();
::BrowserView::Close();
+
+ // Stop the global mouse watcher only if we do not have any panels up.
+ if (panel_->manager()->active_count())
jennb 2011/06/30 17:33:31 Should check for active count is 1? There must not
jianli 2011/06/30 18:22:36 Done. Also added test coverage.
+ StopMouseWatcher();
}
void PanelBrowserView::SetBounds(const gfx::Rect& bounds) {
@@ -156,27 +163,36 @@
SetBounds(bounds);
}
-void PanelBrowserView::MinimizePanel() {
- if (minimized_)
- return;
+void PanelBrowserView::OnPanelExpansionStateChanged(
+ Panel::ExpansionState expansion_state) {
jennb 2011/06/30 17:33:31 Variable was named 'state' in .h. Should match nam
jianli 2011/06/30 18:22:36 Done.
+ int height;
+ switch (expansion_state) {
+ case Panel::EXPANDED:
+ height = original_height_;
+ break;
+ case Panel::TITLE_ONLY:
+ height = GetFrameView()->NonClientTopBorderHeight();
+ break;
+ case Panel::MINIMIZED:
+ height = kFullyMinimizedHeight;
+ EnsureMouseWatcherStarted();
+ break;
+ default:
+ NOTREACHED();
+ height = original_height_;
+ break;
+ }
- minimized_ = true;
- gfx::Rect bounds = GetPanelBounds();
- original_height_ = bounds.height();
- bounds.set_height(GetFrameView()->NonClientTopBorderHeight());
- bounds.set_y(bounds.y() + original_height_ - bounds.height());
- SetPanelBounds(bounds);
+ gfx::Rect bounds = bounds_;
+ bounds.set_y(bounds.y() + bounds.height() - height);
+ bounds.set_height(height);
+ SetBounds(bounds);
}
-void PanelBrowserView::RestorePanel() {
- if (!minimized_)
- return;
-
- minimized_ = false;
- gfx::Rect bounds = GetPanelBounds();
- bounds.set_y(bounds.y() - original_height_ + bounds.height());
- bounds.set_height(original_height_);
- SetPanelBounds(bounds);
+bool PanelBrowserView::ShouldBringUpPanelTitleBar(int mouse_x,
+ int mouse_y) const {
+ return bounds_.x() <= mouse_x && mouse_x <= bounds_.right() &&
+ mouse_y >= bounds_.y();
}
void PanelBrowserView::ClosePanel() {
@@ -251,7 +267,10 @@
if (mouse_dragging_)
return EndDragging(false);
- MinimizeOrRestore();
+ Panel::ExpansionState new_expansion_state =
+ (panel_->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED
jennb 2011/06/30 17:33:31 What if user clicks on the title bar in title-bar-
jianli 2011/06/30 18:22:36 The panel will be fully expanded.
+ : Panel::MINIMIZED;
+ panel_->SetExpansionState(new_expansion_state);
return true;
}
@@ -271,10 +290,3 @@
panel_->manager()->EndDragging(cancelled);
return true;
}
-
-void PanelBrowserView::MinimizeOrRestore() {
- if (minimized_)
- panel_->Restore();
- else
- panel_->Minimize();
-}

Powered by Google App Engine
This is Rietveld 408576698