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

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/29 23:17:54 panel_manager has not removed this closing panel y
+ StopMouseWatcher();
}
void PanelBrowserView::SetBounds(const gfx::Rect& bounds) {
@@ -156,27 +163,35 @@
SetBounds(bounds);
}
-void PanelBrowserView::MinimizePanel() {
- if (minimized_)
- return;
+void PanelBrowserView::SetPanelExpansionState(
jennb 2011/06/29 23:17:54 This seems like it should really be OnExpansionSta
jianli 2011/06/30 01:28:33 Done. Changed to OnPanelExpansionStateChanged sinc
+ Panel::ExpansionState expansion_state) {
+ 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();
jennb 2011/06/29 23:17:54 NOTREACHED() is only defined for debug mode, right
jianli 2011/06/30 01:28:33 Yes. Normally we should not reach this. But just t
+ 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();
jennb 2011/06/29 23:17:54 I'm assuming some logic makes sure mouse_y isn't w
jianli 2011/06/30 01:28:33 Do we care? I think the mouse coordinates are prov
jennb 2011/06/30 17:33:31 I meant it's not clear from looking at this code t
}
void PanelBrowserView::ClosePanel() {
@@ -251,7 +266,10 @@
if (mouse_dragging_)
return EndDragging(false);
- MinimizeOrRestore();
+ Panel::ExpansionState new_expansion_state =
+ (panel_->expansion_state() != Panel::EXPANDED) ? Panel::EXPANDED
+ : Panel::MINIMIZED;
+ panel_->SetExpansionState(new_expansion_state);
return true;
}
@@ -271,10 +289,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