summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-20 16:48:29 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-20 16:48:29 +0000
commitb3e3a7c25563c04221141be853d91af264c8c440 (patch)
tree3fad894326a1e5514fcff26710a0541253a49ebd /chrome/browser
parent42179c2ecb844952a49c44c7598400b7f69270db (diff)
downloadchromium_src-b3e3a7c25563c04221141be853d91af264c8c440.zip
chromium_src-b3e3a7c25563c04221141be853d91af264c8c440.tar.gz
chromium_src-b3e3a7c25563c04221141be853d91af264c8c440.tar.bz2
Roll our own grow box since the OS one wants to indent by 3px due to the textured window style.
Review URL: http://codereview.chromium.org/21544 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10099 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_window_cocoa.mm9
-rw-r--r--chrome/browser/browser_window_controller.h3
-rw-r--r--chrome/browser/browser_window_controller.mm4
-rw-r--r--chrome/browser/cocoa/grow_box_view.h22
-rw-r--r--chrome/browser/cocoa/grow_box_view.m34
-rw-r--r--chrome/browser/cocoa/tab_contents_controller.h5
-rw-r--r--chrome/browser/cocoa/tab_contents_controller.mm15
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.h3
-rw-r--r--chrome/browser/cocoa/tab_strip_controller.mm5
9 files changed, 74 insertions, 26 deletions
diff --git a/chrome/browser/browser_window_cocoa.mm b/chrome/browser/browser_window_cocoa.mm
index e61bea443..10d56db 100644
--- a/chrome/browser/browser_window_cocoa.mm
+++ b/chrome/browser/browser_window_cocoa.mm
@@ -99,15 +99,8 @@ bool BrowserWindowCocoa::IsFullscreen() const {
return false;
}
-@interface NSWindow(OSInternals)
-- (NSRect)_growBoxRect;
-@end
-
gfx::Rect BrowserWindowCocoa::GetRootWindowResizerRect() const {
- NSRect windowRect = [window_ _growBoxRect];
- // convert from window coordinates to the coordinates of the currently
- // selected tab. |tabRect| will already be flipped into WebKit coordinates.
- NSRect tabRect = [controller_ selectedTabGrowBoxFromWindowGrowBox:windowRect];
+ NSRect tabRect = [controller_ selectedTabGrowBoxRect];
return gfx::Rect(NSRectToCGRect(tabRect));
}
diff --git a/chrome/browser/browser_window_controller.h b/chrome/browser/browser_window_controller.h
index 9428cd3..db91e5a 100644
--- a/chrome/browser/browser_window_controller.h
+++ b/chrome/browser/browser_window_controller.h
@@ -57,8 +57,7 @@ class BrowserWindow;
// Return the rect, in WebKit coordinates (flipped), of the window's grow box
// in the coordinate system of the content area of the currently selected tab.
-// |windowGrowBox| needs to be in the window's coordinate system.
-- (NSRect)selectedTabGrowBoxFromWindowGrowBox:(NSRect)windowGrowBox;
+- (NSRect)selectedTabGrowBoxRect;
@end
diff --git a/chrome/browser/browser_window_controller.mm b/chrome/browser/browser_window_controller.mm
index eade6e2..63e0b91 100644
--- a/chrome/browser/browser_window_controller.mm
+++ b/chrome/browser/browser_window_controller.mm
@@ -148,9 +148,9 @@
// Return the rect, in WebKit coordinates (flipped), of the window's grow box
// in the coordinate system of the content area of the currently selected tab.
// |windowGrowBox| needs to be in the window's coordinate system.
-- (NSRect)selectedTabGrowBoxFromWindowGrowBox:(NSRect)windowGrowBox {
+- (NSRect)selectedTabGrowBoxRect {
return [tabStripController_
- selectedTabGrowBoxFromWindowGrowBox:windowGrowBox];
+ selectedTabGrowBoxRect];
}
@end
diff --git a/chrome/browser/cocoa/grow_box_view.h b/chrome/browser/cocoa/grow_box_view.h
new file mode 100644
index 0000000..60c51f0
--- /dev/null
+++ b/chrome/browser/cocoa/grow_box_view.h
@@ -0,0 +1,22 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COCOA_GROW_BOX_VIEW_H_
+#define CHROME_BROWSER_COCOA_GROW_BOX_VIEW_H_
+
+#import <Cocoa/Cocoa.h>
+
+// A class that handles drawing and mouse tracking to replace the standard
+// window "grow box" grippy in cases where the OS one won't do. Relies on
+// an image named "grow_box" be included in the application's resources. The
+// box should be 15x15 in size, but that's not a requirement.
+
+@interface GrowBoxView : NSView {
+ @private
+ NSImage* image_; // grow box image
+}
+
+@end
+
+#endif // CHROME_BROWSER_COCOA_GROW_BOX_VIEW_H_
diff --git a/chrome/browser/cocoa/grow_box_view.m b/chrome/browser/cocoa/grow_box_view.m
new file mode 100644
index 0000000..79f3ca0
--- /dev/null
+++ b/chrome/browser/cocoa/grow_box_view.m
@@ -0,0 +1,34 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/cocoa/grow_box_view.h"
+
+@implementation GrowBoxView
+
+- (void)awakeFromNib {
+ image_ = [[NSImage imageNamed:@"grow_box"] retain];
+}
+
+- (void)dealloc {
+ [image_ release];
+ [super dealloc];
+}
+
+// Draws the "grow_box" image in our bounds.
+- (void)drawRect:(NSRect)dirtyRect {
+ [image_ drawInRect:[self bounds] fromRect:NSZeroRect
+ operation:NSCompositeSourceOver fraction:1.0];
+}
+
+// Called when the user clicks and drags within the bounds. Resize the window's
+// frame based on the delta of the drag.
+- (void)mouseDragged:(NSEvent*)event {
+ NSRect frame = [[self window] frame];
+ frame.size.width += [event deltaX];
+ frame.origin.y -= [event deltaY];
+ frame.size.height += [event deltaY];
+ [[self window] setFrame:frame display:YES];
+}
+
+@end
diff --git a/chrome/browser/cocoa/tab_contents_controller.h b/chrome/browser/cocoa/tab_contents_controller.h
index 20d9a38..9f2eddd 100644
--- a/chrome/browser/cocoa/tab_contents_controller.h
+++ b/chrome/browser/cocoa/tab_contents_controller.h
@@ -8,6 +8,7 @@
#include <Cocoa/Cocoa.h>
class CommandUpdater;
+@class GrowBoxView;
class LocationBar;
class TabContents;
class TabContentsCommandObserver;
@@ -36,6 +37,7 @@ class TabStripModel;
IBOutlet NSButton* starButton_;
IBOutlet NSTextField* locationBar_;
IBOutlet NSBox* contentsBox_;
+ IBOutlet GrowBoxView* growBox_;
}
// Create the contents of a tab represented by |contents| and loaded from the
@@ -70,8 +72,7 @@ class TabStripModel;
// Return the rect, in WebKit coordinates (flipped), of the window's grow box
// in the coordinate system of the content area of this tab.
-// |windowGrowBox| needs to be in the window's coordinate system.
-- (NSRect)growBoxFromWindowGrowBox:(NSRect)windowGrowBox;
+- (NSRect)growBoxRect;
@end
diff --git a/chrome/browser/cocoa/tab_contents_controller.mm b/chrome/browser/cocoa/tab_contents_controller.mm
index 5d62716..8924a87 100644
--- a/chrome/browser/cocoa/tab_contents_controller.mm
+++ b/chrome/browser/cocoa/tab_contents_controller.mm
@@ -204,18 +204,21 @@ class LocationBarBridge : public LocationBar {
// Return the rect, in WebKit coordinates (flipped), of the window's grow box
// in the coordinate system of the content area of this tab.
-// |windowGrowBox| needs to be in the window's coordinate system.
-- (NSRect)growBoxFromWindowGrowBox:(NSRect)windowGrowBox {
+- (NSRect)growBoxRect {
NSRect localGrowBox = NSMakeRect(0, 0, 0, 0);
NSView* contentView = contents_->GetNativeView();
if (contentView) {
- localGrowBox = windowGrowBox;
+ // For the rect, we start with the grow box view which is a sibling of
+ // the content view's containing box. It's in the coordinate system of
+ // the controller view.
+ localGrowBox = [growBox_ frame];
// The scrollbar assumes that the resizer goes all the way down to the
// bottom corner, so we ignore any y offset to the rect itself and use the
// entire bottom corner.
localGrowBox.origin.y = 0;
- // Convert to view coordinates from window coordinates.
- localGrowBox = [contentView convertRect:localGrowBox fromView:nil];
+ // Convert to the content view's coordinates.
+ localGrowBox = [contentView convertRect:localGrowBox
+ fromView:[self view]];
// Flip the rect in view coordinates
localGrowBox.origin.y =
[contentView frame].size.height - localGrowBox.origin.y -
@@ -264,5 +267,3 @@ std::wstring LocationBarBridge::GetInputString() const {
void LocationBarBridge::FocusLocation() {
[controller_ focusLocationBar];
}
-
-
diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h
index 6062d70..5a03525 100644
--- a/chrome/browser/cocoa/tab_strip_controller.h
+++ b/chrome/browser/cocoa/tab_strip_controller.h
@@ -59,8 +59,7 @@ class TabContents;
// Return the rect, in WebKit coordinates (flipped), of the window's grow box
// in the coordinate system of the content area of the currently selected tab.
-// |windowGrowBox| needs to be in the window's coordinate system.
-- (NSRect)selectedTabGrowBoxFromWindowGrowBox:(NSRect)windowGrowBox;
+- (NSRect)selectedTabGrowBoxRect;
@end
diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm
index 65ad9b0..2f821e5 100644
--- a/chrome/browser/cocoa/tab_strip_controller.mm
+++ b/chrome/browser/cocoa/tab_strip_controller.mm
@@ -336,8 +336,7 @@ class TabStripBridge : public TabStripModelObserver {
// Return the rect, in WebKit coordinates (flipped), of the window's grow box
// in the coordinate system of the content area of the currently selected tab.
-// |windowGrowBox| needs to be in the window's coordinate system.
-- (NSRect)selectedTabGrowBoxFromWindowGrowBox:(NSRect)windowGrowBox {
+- (NSRect)selectedTabGrowBoxRect {
TabContents* selectedContents = model_->GetSelectedTabContents();
if (!selectedContents) {
// When the window is initially being constructed, there may be no currently
@@ -349,7 +348,7 @@ class TabStripBridge : public TabStripModelObserver {
}
TabContentsController* selectedController =
[self controllerWithContents:selectedContents];
- return [selectedController growBoxFromWindowGrowBox:windowGrowBox];
+ return [selectedController growBoxRect];
}
@end