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

Side by Side Diff: ui/views/cocoa/tooltip_manager_mac.mm

Issue 1137653005: MacViews: Implement Tooltips (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: @class ToolTip is not a thing Created 5 years, 7 months 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/views/cocoa/tooltip_manager_mac.h"
6
7 #include "ui/gfx/font_list.h"
8 #import "ui/gfx/mac/coordinate_conversion.h"
9 #import "ui/views/cocoa/bridged_content_view.h"
10 #import "ui/views/cocoa/bridged_native_widget.h"
11
12 // Max visual tooltip width in DIPs. Beyond this, Cocoa will wrap text.
13 const int kTooltipMaxWidthPixels = 250;
Andre 2015/05/13 19:33:13 Should be inside unnamed namespace.
tapted 2015/05/15 07:59:55 Done (`const` also imposes internal linkage, but I
14
15 namespace views {
16
17 TooltipManagerMac::TooltipManagerMac(BridgedNativeWidget* widget)
18 : widget_(widget) {
19 }
20
21 TooltipManagerMac::~TooltipManagerMac() {
22 }
23
24 int TooltipManagerMac::GetMaxWidth(const gfx::Point& location,
25 gfx::NativeView context) const {
26 return kTooltipMaxWidthPixels;
27 }
28
29 const gfx::FontList& TooltipManagerMac::GetFontList() const {
30 CR_DEFINE_STATIC_LOCAL(gfx::FontList, font_list,
31 (gfx::Font([NSFont toolTipsFontOfSize:0])));
32 return font_list;
33 }
34
35 void TooltipManagerMac::UpdateTooltip() {
36 NSWindow* window = widget_->ns_window();
37 BridgedContentView* view = widget_->ns_view();
38
39 NSPoint nspoint = [window convertScreenToBase:[NSEvent mouseLocation]];
Andre 2015/05/13 19:33:13 Why not [window mouseLocationOutsideOfEventStream]
tapted 2015/05/15 07:59:55 Hm, it wasn't a conscious decision. I tried it out
40 // Note: flip in the view's frame, which matches the window's contentRect.
41 gfx::Point point(nspoint.x, NSHeight([view frame]) - nspoint.y);
42 [view updateTooltipIfRequiredAt:point];
43 }
44
45 void TooltipManagerMac::TooltipTextChanged(View* view) {
46 // The intensive part is View::GetTooltipHandlerForPoint(), which will be done
47 // in [BridgedContentView updateTooltipIfRequiredAt:]. Don't do it here as
48 // well.
49 UpdateTooltip();
50 }
51
52 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698