Commit 8bc0cd50 authored by dimich@chromium.org's avatar dimich@chromium.org

Mac Panels interaction with Dock modifications. (step 1)

1. Drop panels to the bottom edge of screen
2. Make then on top of the Dock

Also, change animation speed calc to make panels 'snappier'. That should make transition from 'minimized' to 'title-only' quite faster.
Add threshold for mouse drag that actually starts drag operation. This should remove spontaneous 'fail to minimize' effect.

BUG=104537,103095
TEST=Observe Panels on top of Dock, minimize them as needed.




Review URL: http://codereview.chromium.org/8574068

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110663 0039d316-1c4b-4281-b951-d872f2087c98
parent 8229b5e6
...@@ -42,9 +42,7 @@ const double kPanelMaxHeightFactor = 0.5; ...@@ -42,9 +42,7 @@ const double kPanelMaxHeightFactor = 0.5;
const int kMaxMillisecondsWaitForBottomBarVisibilityChange = 1000; const int kMaxMillisecondsWaitForBottomBarVisibilityChange = 1000;
// See usage below. // See usage below.
#if defined(OS_MACOSX) #if defined(TOOLKIT_GTK)
const int kMillisecondsBeforeCollapsingFromTitleOnlyState = 3000;
#elif defined(TOOLKIT_GTK)
const int kMillisecondsBeforeCollapsingFromTitleOnlyState = 2000; const int kMillisecondsBeforeCollapsingFromTitleOnlyState = 2000;
#else #else
const int kMillisecondsBeforeCollapsingFromTitleOnlyState = 0; const int kMillisecondsBeforeCollapsingFromTitleOnlyState = 0;
...@@ -81,7 +79,14 @@ PanelManager::~PanelManager() { ...@@ -81,7 +79,14 @@ PanelManager::~PanelManager() {
void PanelManager::OnDisplayChanged() { void PanelManager::OnDisplayChanged() {
scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider( scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider(
WindowSizer::CreateDefaultMonitorInfoProvider()); WindowSizer::CreateDefaultMonitorInfoProvider());
SetWorkArea(info_provider->GetPrimaryMonitorWorkArea()); #if defined(OS_MACOSX)
// On OSX, panels should be dropped all the way to the bottom edge of the
// screen (and overlap Dock).
gfx::Rect work_area = info_provider->GetPrimaryMonitorBounds();
#else
gfx::Rect work_area = info_provider->GetPrimaryMonitorWorkArea();
#endif
SetWorkArea(work_area);
} }
void PanelManager::SetWorkArea(const gfx::Rect& work_area) { void PanelManager::SetWorkArea(const gfx::Rect& work_area) {
...@@ -539,9 +544,9 @@ void PanelManager::AdjustWorkAreaForAutoHidingDesktopBars() { ...@@ -539,9 +544,9 @@ void PanelManager::AdjustWorkAreaForAutoHidingDesktopBars() {
int PanelManager::GetBottomPositionForExpansionState( int PanelManager::GetBottomPositionForExpansionState(
Panel::ExpansionState expansion_state) const { Panel::ExpansionState expansion_state) const {
int bottom = adjusted_work_area_.bottom();
// If there is an auto-hiding desktop bar aligned to the bottom edge, we need // If there is an auto-hiding desktop bar aligned to the bottom edge, we need
// to move the minimize panel down to the bottom edge. // to move the minimize panel down to the bottom edge.
int bottom = adjusted_work_area_.bottom();
if (expansion_state == Panel::MINIMIZED && if (expansion_state == Panel::MINIMIZED &&
auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_BOTTOM)) { auto_hiding_desktop_bar_->IsEnabled(AutoHidingDesktopBar::ALIGN_BOTTOM)) {
bottom += auto_hiding_desktop_bar_->GetThickness( bottom += auto_hiding_desktop_bar_->GetThickness(
......
...@@ -49,6 +49,7 @@ enum PanelDragState { ...@@ -49,6 +49,7 @@ enum PanelDragState {
ScopedCrTrackingArea closeButtonTrackingArea_; ScopedCrTrackingArea closeButtonTrackingArea_;
PanelDragState dragState_; PanelDragState dragState_;
BOOL isDrawingAttention_; BOOL isDrawingAttention_;
NSPoint dragStartLocation_;
} }
// Callback from Close button. // Callback from Close button.
......
...@@ -24,6 +24,11 @@ const int kRoundedCornerSize = 3; ...@@ -24,6 +24,11 @@ const int kRoundedCornerSize = 3;
const int kButtonPadding = 8; const int kButtonPadding = 8;
const int kIconAndTextPadding = 5; const int kIconAndTextPadding = 5;
// Distance that user needs to move the mouse in order to start the drag.
// Threshold is needed to differentiate drags from attempts to click the
// titlebar with a twitch of the mouse pointer.
const int kDragThreshold = 3;
// Used to implement TestingAPI // Used to implement TestingAPI
static NSEvent* MakeMouseEvent(NSEventType type, static NSEvent* MakeMouseEvent(NSEventType type,
NSPoint point, NSPoint point,
...@@ -317,6 +322,7 @@ static NSEvent* MakeMouseEvent(NSEventType type, ...@@ -317,6 +322,7 @@ static NSEvent* MakeMouseEvent(NSEventType type,
- (void)mouseDown:(NSEvent*)event { - (void)mouseDown:(NSEvent*)event {
dragState_ = PANEL_DRAG_CAN_START; dragState_ = PANEL_DRAG_CAN_START;
dragStartLocation_ = [event locationInWindow];
} }
- (void)mouseUp:(NSEvent*)event { - (void)mouseUp:(NSEvent*)event {
...@@ -326,6 +332,12 @@ static NSEvent* MakeMouseEvent(NSEventType type, ...@@ -326,6 +332,12 @@ static NSEvent* MakeMouseEvent(NSEventType type,
[controller_ onTitlebarMouseClicked]; [controller_ onTitlebarMouseClicked];
} }
- (BOOL)exceedsDragThreshold:(NSPoint)mouseLocation {
float deltaX = dragStartLocation_.x - mouseLocation.x;
float deltaY = dragStartLocation_.y - mouseLocation.y;
return deltaX > kDragThreshold || deltaY > kDragThreshold;
}
- (void)mouseDragged:(NSEvent*)event { - (void)mouseDragged:(NSEvent*)event {
// In addition to events needed to control the drag operation, fetch the right // In addition to events needed to control the drag operation, fetch the right
// mouse click events and key down events and ignore them, to prevent their // mouse click events and key down events and ignore them, to prevent their
...@@ -345,8 +357,11 @@ static NSEvent* MakeMouseEvent(NSEventType type, ...@@ -345,8 +357,11 @@ static NSEvent* MakeMouseEvent(NSEventType type,
switch ([event type]) { switch ([event type]) {
case NSLeftMouseDragged: case NSLeftMouseDragged:
if (dragState_ == PANEL_DRAG_CAN_START) if (dragState_ == PANEL_DRAG_CAN_START) {
if (![self exceedsDragThreshold:[event locationInWindow]])
return; // Don't start real drag yet.
[self startDrag]; [self startDrag];
}
[self dragWithDeltaX:[event deltaX]]; [self dragWithDeltaX:[event deltaX]];
break; break;
...@@ -358,7 +373,10 @@ static NSEvent* MakeMouseEvent(NSEventType type, ...@@ -358,7 +373,10 @@ static NSEvent* MakeMouseEvent(NSEventType type,
break; break;
case NSLeftMouseUp: case NSLeftMouseUp:
[self endDrag:NO]; if (dragState_ == PANEL_DRAG_CAN_START)
[self mouseUp:event]; // Drag didn't really start, minimize instead.
else
[self endDrag:NO];
keepGoing = NO; keepGoing = NO;
break; break;
......
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
#include "ui/gfx/mac/nsimage_cache.h" #include "ui/gfx/mac/nsimage_cache.h"
const int kMinimumWindowSize = 1; const int kMinimumWindowSize = 1;
const double kBoundsChangeAnimationDuration = 0.18; // Seconds. const double kBoundsAnimationSpeedPixelsPerSecond = 1000;
const double kBoundsAnimationMaxDurationSeconds = 0.18;
// Replicate specific 10.6 SDK declarations for building with prior SDKs. // Replicate specific 10.6 SDK declarations for building with prior SDKs.
#if !defined(MAC_OS_X_VERSION_10_6) || \ #if !defined(MAC_OS_X_VERSION_10_6) || \
...@@ -111,12 +112,7 @@ enum { ...@@ -111,12 +112,7 @@ enum {
DCHECK(titlebar_view_); DCHECK(titlebar_view_);
DCHECK_EQ(self, [window delegate]); DCHECK_EQ(self, [window delegate]);
// Using NSModalPanelWindowLevel (8) rather then NSStatusWindowLevel (25) [window setLevel:NSStatusWindowLevel];
// ensures notification balloons on top of regular windows, but below
// popup menus which are at NSPopUpMenuWindowLevel (101) and Spotlight
// drop-out, which is at NSStatusWindowLevel-2 (23) for OSX 10.6/7.
// See http://crbug.com/59878.
[window setLevel:NSModalPanelWindowLevel];
if (base::mac::IsOSSnowLeopardOrLater()) { if (base::mac::IsOSSnowLeopardOrLater()) {
[window setCollectionBehavior: [window setCollectionBehavior:
...@@ -443,7 +439,20 @@ enum { ...@@ -443,7 +439,20 @@ enum {
[boundsAnimation_ setDelegate:self]; [boundsAnimation_ setDelegate:self];
[boundsAnimation_ setAnimationBlockingMode: NSAnimationNonblocking]; [boundsAnimation_ setAnimationBlockingMode: NSAnimationNonblocking];
[boundsAnimation_ setDuration: kBoundsChangeAnimationDuration];
NSRect currentFrame = [[self window] frame];
// Compute duration. We use constant speed of animation, however if the change
// is too large, we clip the duration (effectively increasing speed) to
// limit total duration of animation. This makes 'small' transitions fast.
// 'distance' is the max travel between 4 potentially traveling corners.
double distanceX = std::max(abs(NSMinX(currentFrame) - NSMinX(frame)),
abs(NSMaxX(currentFrame) - NSMaxX(frame)));
double distanceY = std::max(abs(NSMinY(currentFrame) - NSMinY(frame)),
abs(NSMaxY(currentFrame) - NSMaxY(frame)));
double distance = std::max(distanceX, distanceY);
double duration = std::min(distance / kBoundsAnimationSpeedPixelsPerSecond,
kBoundsAnimationMaxDurationSeconds);
[boundsAnimation_ setDuration: duration];
[boundsAnimation_ startAnimation]; [boundsAnimation_ startAnimation];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment