Commit 86f13782 authored by henrika@chromium.org's avatar henrika@chromium.org

Revert 221651 "Switch to doing user-resizing via system for pane..."

> Switch to doing user-resizing via system for panels on Mac
> 
> We used to track and handle user-resizing by ourselves. This brings up a few problems and makes the user-resizing hard to use on Mac. For example, the user-resizing could not be triggered outside or on the edge. Switching to doing it via system solve all these problems.
> 
> Also removed EnableResizeByMouse which is not really used in our code.
> 
> BUG=282652,282657
> TEST=manual test by user-resizing panels
> 
> Review URL: https://chromiumcodereview.appspot.com/23918002

TBR=jianli@chromium.org

Review URL: https://codereview.chromium.org/23922003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221674 0039d316-1c4b-4281-b951-d872f2087c98
parent c878e50e
......@@ -46,6 +46,7 @@ class PanelCocoa : public NativePanel {
virtual void FullScreenModeChanged(bool is_full_screen) OVERRIDE;
virtual bool IsPanelAlwaysOnTop() const OVERRIDE;
virtual void SetPanelAlwaysOnTop(bool on_top) OVERRIDE;
virtual void EnableResizeByMouse(bool enable) OVERRIDE;
virtual void UpdatePanelMinimizeRestoreButtonVisibility() OVERRIDE;
virtual void SetWindowCornerStyle(panel::CornerStyle corner_style) OVERRIDE;
virtual void PanelExpansionStateChanging(
......
......@@ -261,6 +261,10 @@ void PanelCocoa::SetPanelAlwaysOnTop(bool on_top) {
[controller_ updateWindowCollectionBehavior];
}
void PanelCocoa::EnableResizeByMouse(bool enable) {
[controller_ enableResizeByMouse:enable];
}
void PanelCocoa::UpdatePanelMinimizeRestoreButtonVisibility() {
[controller_ updateTitleBarMinimizeRestoreButtonVisibility];
}
......
......@@ -12,23 +12,18 @@
namespace cocoa_utils {
// TODO(dcheng): Move elsewhere so BrowserWindowCocoa can use them too.
// Converts a rect from the platform-independent screen coordinates (with the
// Converts a rect from the platfrom-independent screen coordinates (with the
// (0,0) in the top-left corner of the primary screen) to the Cocoa screen
// coordinates (with (0,0) in the low-left corner).
NSRect ConvertRectToCocoaCoordinates(const gfx::Rect& bounds);
// Converts a rect from the Cocoa screen oordinates (with (0,0) in the low-left
// corner) to the platform-independent screen coordinates (with the (0,0) in
// the top-left corner of the primary screen).
gfx::Rect ConvertRectFromCocoaCoordinates(NSRect bounds);
// Converts a point from the platform-independent screen coordinates (with the
// Converts a point from the platfrom-independent screen coordinates (with the
// (0,0) in the top-left corner of the primary screen) to the Cocoa screen
// coordinates (with (0,0) in the low-left corner).
NSPoint ConvertPointToCocoaCoordinates(const gfx::Point& point);
// Converts a point from the Cocoa screen coordinates (with (0,0) in the
// low-left corner of the primary screen) to the platform-independent screen
// low-left corner of the primary screen) to the platfrom-independent screen
// coordinates (with the (0,0) in the top-left corner).
gfx::Point ConvertPointFromCocoaCoordinates(NSPoint point);
......
......@@ -15,15 +15,6 @@ NSRect ConvertRectToCocoaCoordinates(const gfx::Rect& bounds) {
bounds.width(), bounds.height());
}
gfx::Rect ConvertRectFromCocoaCoordinates(NSRect bounds) {
// Flip coordinates based on the primary screen.
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
return gfx::Rect(
NSMinX(bounds), NSHeight([screen frame]) - NSMaxY(bounds),
NSWidth(bounds), NSHeight(bounds));
}
NSPoint ConvertPointToCocoaCoordinates(const gfx::Point& point) {
// Flip coordinates based on the primary screen.
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
......
......@@ -15,7 +15,6 @@
#include "base/memory/scoped_ptr.h"
#import "chrome/browser/ui/cocoa/chrome_browser_window.h"
#include "chrome/browser/ui/panels/panel.h"
#import "ui/base/cocoa/tracking_area.h"
class PanelCocoa;
@class PanelTitlebarViewCocoa;
......@@ -43,17 +42,12 @@ class PanelCocoa;
// window over other application windows due to panels having a higher
// priority NSWindowLevel, so we distinguish between the two scenarios.
BOOL activationRequestedByPanel_;
// Is user resizing in progress?
BOOL userResizing_;
// Tracks the whole window in order to receive NSMouseMoved event.
ui::ScopedCrTrackingArea trackingArea_;
base::scoped_nsobject<NSView> overlayView_;
}
// Load the window nib and do any Cocoa-specific initialization.
- (id)initWithPanel:(PanelCocoa*)window;
- (Panel*)panel;
- (void)webContentsInserted:(content::WebContents*)contents;
- (void)webContentsDetached:(content::WebContents*)contents;
......@@ -143,9 +137,8 @@ class PanelCocoa;
// Adjusts NSWindowCollectionBehavior based on whether panel is always on top.
- (void)updateWindowCollectionBehavior;
// Updates the tracking area per the window size change. This is needed in
// order to receive the NSMouseMoved notification.
- (void)updateTrackingArea;
// Turns on user-resizable corners/sides indications and enables live resize.
- (void)enableResizeByMouse:(BOOL)enable;
// Turns on/off shadow effect around the window shape.
- (void)showShadow:(BOOL)show;
......@@ -155,10 +148,6 @@ class PanelCocoa;
// Returns true if the window is minimized to the dock.
- (BOOL)isMiniaturized;
// Returns true if the user-resizing is allowed for the edge/corner close to
// current mouse location.
- (BOOL)canResizeByMouseAtCurrentLocation;
- (NSRect)frameRectForContentRect:(NSRect)contentRect;
- (NSRect)contentRectForFrameRect:(NSRect)frameRect;
......
......@@ -1068,6 +1068,9 @@ void PanelGtk::SetPanelAlwaysOnTop(bool on_top) {
gtk_window_unstick(window_);
}
void PanelGtk::EnableResizeByMouse(bool enable) {
}
void PanelGtk::UpdatePanelMinimizeRestoreButtonVisibility() {
titlebar_->UpdateMinimizeRestoreButtonVisibility();
}
......
......@@ -78,6 +78,7 @@ class PanelGtk : public NativePanel,
virtual int TitleOnlyHeight() const OVERRIDE;
virtual bool IsPanelAlwaysOnTop() const OVERRIDE;
virtual void SetPanelAlwaysOnTop(bool on_top) OVERRIDE;
virtual void EnableResizeByMouse(bool enable) OVERRIDE;
virtual void UpdatePanelMinimizeRestoreButtonVisibility() OVERRIDE;
virtual void SetWindowCornerStyle(panel::CornerStyle corner_style) OVERRIDE;
virtual void MinimizePanelBySystem() OVERRIDE;
......
......@@ -239,6 +239,7 @@ void DetachedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) {
static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION |
Panel::USE_SYSTEM_ATTENTION));
panel->ShowShadow(true);
panel->EnableResizeByMouse(true);
panel->UpdateMinimizeRestoreButtonVisibility();
panel->SetWindowCornerStyle(panel::ALL_ROUNDED);
}
......
......@@ -765,6 +765,7 @@ void DockedPanelCollection::CloseAll() {
void DockedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) {
panel->set_attention_mode(Panel::USE_PANEL_ATTENTION);
panel->ShowShadow(true);
panel->EnableResizeByMouse(true);
panel->UpdateMinimizeRestoreButtonVisibility();
panel->SetWindowCornerStyle(panel::TOP_ROUNDED);
}
......
......@@ -72,6 +72,9 @@ class NativePanel {
virtual bool IsPanelAlwaysOnTop() const = 0;
virtual void SetPanelAlwaysOnTop(bool on_top) = 0;
// Enables resizing by dragging edges/corners.
virtual void EnableResizeByMouse(bool enable) = 0;
// Updates the visibility of the minimize and restore buttons.
virtual void UpdatePanelMinimizeRestoreButtonVisibility() = 0;
......
......@@ -667,6 +667,11 @@ void Panel::SetPreviewMode(bool in_preview) {
in_preview_mode_ = in_preview;
}
void Panel::EnableResizeByMouse(bool enable) {
DCHECK(native_panel_);
native_panel_->EnableResizeByMouse(enable);
}
void Panel::UpdateMinimizeRestoreButtonVisibility() {
native_panel_->UpdatePanelMinimizeRestoreButtonVisibility();
}
......
......@@ -252,6 +252,10 @@ class Panel : public ui::BaseWindow,
// being dragged, it is in preview mode.
void SetPreviewMode(bool in_preview_mode);
// Sets up the panel for being resizable by the user - for example,
// enables the resize mouse cursors when mouse is hovering over the edges.
void EnableResizeByMouse(bool enable);
// Sets whether the minimize or restore button, if any, are visible.
void UpdateMinimizeRestoreButtonVisibility();
......
......@@ -626,6 +626,7 @@ void StackedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) {
static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION |
Panel::USE_SYSTEM_ATTENTION));
panel->ShowShadow(false);
panel->EnableResizeByMouse(true);
panel->UpdateMinimizeRestoreButtonVisibility();
UpdatePanelCornerStyle(panel);
}
......
......@@ -599,6 +599,10 @@ void PanelView::SetPanelAlwaysOnTop(bool on_top) {
window_->client_view()->Layout();
}
void PanelView::EnableResizeByMouse(bool enable) {
// Nothing to do since we use system resizing.
}
void PanelView::UpdatePanelMinimizeRestoreButtonVisibility() {
GetFrameView()->UpdateTitlebarMinimizeRestoreButtonVisibility();
}
......
......@@ -63,6 +63,7 @@ class PanelView : public NativePanel,
virtual void FullScreenModeChanged(bool is_full_screen) OVERRIDE;
virtual bool IsPanelAlwaysOnTop() const OVERRIDE;
virtual void SetPanelAlwaysOnTop(bool on_top) OVERRIDE;
virtual void EnableResizeByMouse(bool enable) OVERRIDE;
virtual void UpdatePanelMinimizeRestoreButtonVisibility() OVERRIDE;
virtual void SetWindowCornerStyle(panel::CornerStyle corner_style) OVERRIDE;
virtual void PanelExpansionStateChanging(
......
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