summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-04 01:18:53 +0000
committermrossetti@chromium.org <mrossetti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-04 01:18:53 +0000
commit8d050d9a9ddcc090f338c774afa676fa2483fcfc (patch)
tree889edca63ebe4d749ade13106037546b31215d08 /chrome
parent7432c02d66ed3e0dfa94519e5e01d07a95c32555 (diff)
downloadchromium_src-8d050d9a9ddcc090f338c774afa676fa2483fcfc.zip
chromium_src-8d050d9a9ddcc090f338c774afa676fa2483fcfc.tar.gz
chromium_src-8d050d9a9ddcc090f338c774afa676fa2483fcfc.tar.bz2
Keep all parent folders highlighted in an active bookmark menu folder structure.
BUG=40284 TEST=Click on a folder in the bookmark bar which itself has subfolders. Move the mouse to hover over a subfolder. Verify that the folder in the bookmark bar remains highlighted. Move the mouse into the subfolder being hovered. Verify that the subfolder button remains highlighted. Move the mouse onto a different bookmark within the main parent folder. Verify that the originally highlighted subfolder is no longer highlighted. Review URL: http://codereview.chromium.org/1784012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/cocoa/bookmark_bar_folder_controller.mm47
1 files changed, 38 insertions, 9 deletions
diff --git a/chrome/browser/cocoa/bookmark_bar_folder_controller.mm b/chrome/browser/cocoa/bookmark_bar_folder_controller.mm
index 39797d6..9227a4f 100644
--- a/chrome/browser/cocoa/bookmark_bar_folder_controller.mm
+++ b/chrome/browser/cocoa/bookmark_bar_folder_controller.mm
@@ -67,6 +67,34 @@ const CGFloat kScrollWindowVerticalMargin = 0.0;
@end
+@interface BookmarkButton (BookmarkBarFolderMenuHighlighting)
+
+// Make the button's border frame always appear when |forceOn| is YES,
+// otherwise only border the button when the mouse is inside the button.
+- (void)forceButtonBorderToStayOnAlways:(BOOL)forceOn;
+
+// On 10.6 event dispatch for an NSButtonCell's
+// showsBorderOnlyWhileMouseInside seems broken if scrolling the
+// view that contains the button. It appears that a mouseExited:
+// gets lost, so the button stays highlit forever. We accomodate
+// here.
+- (void)toggleButtonBorderingWhileMouseInside;
+@end
+
+@implementation BookmarkButton (BookmarkBarFolderMenuHighlighting)
+
+- (void)forceButtonBorderToStayOnAlways:(BOOL)forceOn {
+ [self setShowsBorderOnlyWhileMouseInside:!forceOn];
+}
+
+- (void)toggleButtonBorderingWhileMouseInside {
+ BOOL toggle = [self showsBorderOnlyWhileMouseInside];
+ [self setShowsBorderOnlyWhileMouseInside:!toggle];
+ [self setShowsBorderOnlyWhileMouseInside:toggle];
+}
+
+@end
+
@implementation BookmarkBarFolderController
- (id)initWithParentButton:(BookmarkButton*)button
@@ -77,6 +105,10 @@ const CGFloat kScrollWindowVerticalMargin = 0.0;
ofType:@"nib"];
if ((self = [super initWithWindowNibPath:nibPath owner:self])) {
parentButton_.reset([button retain]);
+
+ // We want the button to remain bordered as part of the menu path.
+ [button forceButtonBorderToStayOnAlways:YES];
+
parentController_.reset([parentController retain]);
barController_ = barController; // WEAK
buttons_.reset([[NSMutableArray alloc] init]);
@@ -93,6 +125,10 @@ const CGFloat kScrollWindowVerticalMargin = 0.0;
}
- (void)dealloc {
+ // The button is no longer part of the menu path.
+ [parentButton_ forceButtonBorderToStayOnAlways:NO];
+ [parentButton_ setNeedsDisplay];
+
[self removeScrollTracking];
[self endScroll];
[hoverState_ draggingExited];
@@ -622,15 +658,8 @@ const CGFloat kScrollWindowVerticalMargin = 0.0;
scrollPosition.y -= delta;
[[scrollView_ documentView] scrollPoint:scrollPosition];
- // On 10.6 event dispatch for an NSButtonCell's
- // showsBorderOnlyWhileMouseInside seems broken if scrolling the
- // view that contains the button. It appears that a mouseExited:
- // gets lost, so the button stays highlit forever. We accomodate
- // here.
- if (buttonThatMouseIsIn_) {
- [[buttonThatMouseIsIn_ cell] setShowsBorderOnlyWhileMouseInside:NO];
- [[buttonThatMouseIsIn_ cell] setShowsBorderOnlyWhileMouseInside:YES];
- }
+ if (buttonThatMouseIsIn_)
+ [buttonThatMouseIsIn_ toggleButtonBorderingWhileMouseInside];
// We update the window size after shifting the scroll to avoid a race.
CGFloat screenHeightMinusMargin = (NSHeight(screenFrame) -