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

Side by Side Diff: chrome/browser/cocoa/status_bubble_mac.mm

Issue 392007: gtk: Hide the status bubble when the mouse nears it. (Closed)
Patch Set: merge again Created 11 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/cocoa/status_bubble_mac.h ('k') | chrome/browser/gtk/download_shelf_gtk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/cocoa/status_bubble_mac.h" 5 #include "chrome/browser/cocoa/status_bubble_mac.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "app/gfx/text_elider.h" 9 #include "app/gfx/text_elider.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/gfx/point.h"
11 #include "base/message_loop.h" 12 #include "base/message_loop.h"
12 #include "base/string_util.h" 13 #include "base/string_util.h"
13 #include "base/sys_string_conversions.h" 14 #include "base/sys_string_conversions.h"
14 #import "chrome/browser/cocoa/bubble_view.h" 15 #import "chrome/browser/cocoa/bubble_view.h"
15 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
16 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" 17 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
17 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h" 18 #import "third_party/GTM/AppKit/GTMNSBezierPath+RoundRect.h"
18 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" 19 #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h"
19 #import "third_party/GTM/AppKit/GTMTheme.h" 20 #import "third_party/GTM/AppKit/GTMTheme.h"
20 21
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 [window_ setAlphaValue:0.0]; 200 [window_ setAlphaValue:0.0];
200 SetState(kBubbleHidden); 201 SetState(kBubbleHidden);
201 } 202 }
202 203
203 [status_text_ release]; 204 [status_text_ release];
204 status_text_ = nil; 205 status_text_ = nil;
205 [url_text_ release]; 206 [url_text_ release];
206 url_text_ = nil; 207 url_text_ = nil;
207 } 208 }
208 209
209 void StatusBubbleMac::MouseMoved() { 210 void StatusBubbleMac::MouseMoved(
211 const gfx::Point& location, bool left_content) {
212 if (left_content)
213 return;
214
210 if (!window_) 215 if (!window_)
211 return; 216 return;
212 217
218 // TODO(thakis): Use 'location' here instead of NSEvent.
213 NSPoint cursor_location = [NSEvent mouseLocation]; 219 NSPoint cursor_location = [NSEvent mouseLocation];
214 --cursor_location.y; // docs say the y coord starts at 1 not 0; don't ask why 220 --cursor_location.y; // docs say the y coord starts at 1 not 0; don't ask why
215 221
216 // Get the normal position of the frame. 222 // Get the normal position of the frame.
217 NSRect window_frame = [window_ frame]; 223 NSRect window_frame = [window_ frame];
218 window_frame.origin = [parent_ frame].origin; 224 window_frame.origin = [parent_ frame].origin;
219 225
220 bool isShelfVisible = false; 226 bool isShelfVisible = false;
221 227
222 // Adjust the position to sit on top of download and extension shelves. 228 // Adjust the position to sit on top of download and extension shelves.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 [animation_delegate autorelease]; 329 [animation_delegate autorelease];
324 [animation setDelegate:animation_delegate]; 330 [animation setDelegate:animation_delegate];
325 NSMutableDictionary* animation_dictionary = 331 NSMutableDictionary* animation_dictionary =
326 [NSMutableDictionary dictionaryWithDictionary:[window_ animations]]; 332 [NSMutableDictionary dictionaryWithDictionary:[window_ animations]];
327 [animation_dictionary setObject:animation forKey:kFadeAnimationKey]; 333 [animation_dictionary setObject:animation forKey:kFadeAnimationKey];
328 [window_ setAnimations:animation_dictionary]; 334 [window_ setAnimations:animation_dictionary];
329 335
330 Attach(); 336 Attach();
331 337
332 [view setCornerFlags:kRoundedTopRightCorner]; 338 [view setCornerFlags:kRoundedTopRightCorner];
333 MouseMoved(); 339 MouseMoved(gfx::Point(), false);
334 } 340 }
335 341
336 void StatusBubbleMac::Attach() { 342 void StatusBubbleMac::Attach() {
337 // If the parent window is offscreen when the child is added, the child will 343 // If the parent window is offscreen when the child is added, the child will
338 // never be displayed, even when the parent moves on-screen. This method 344 // never be displayed, even when the parent moves on-screen. This method
339 // may be called several times during the process of creating or showing a 345 // may be called several times during the process of creating or showing a
340 // status bubble to attach the bubble to its parent window. 346 // status bubble to attach the bubble to its parent window.
341 if (![window_ parentWindow] && [parent_ isVisible]) 347 if (![window_ parentWindow] && [parent_ isVisible])
342 [parent_ addChildWindow:window_ ordered:NSWindowAbove]; 348 [parent_ addChildWindow:window_ ordered:NSWindowAbove];
343 } 349 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 } 519 }
514 520
515 NSRect StatusBubbleMac::CalculateWindowFrame() { 521 NSRect StatusBubbleMac::CalculateWindowFrame() {
516 DCHECK(parent_); 522 DCHECK(parent_);
517 523
518 NSRect rect = [parent_ frame]; 524 NSRect rect = [parent_ frame];
519 rect.size.height = kWindowHeight; 525 rect.size.height = kWindowHeight;
520 rect.size.width = static_cast<int>(kWindowWidthPercent * rect.size.width); 526 rect.size.width = static_cast<int>(kWindowWidthPercent * rect.size.width);
521 return rect; 527 return rect;
522 } 528 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/status_bubble_mac.h ('k') | chrome/browser/gtk/download_shelf_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698