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

Side by Side Diff: ui/app_list/views/app_list_view.cc

Issue 23622020: Fixing the dynamic positioning (move with anchor) for the app launcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Created 7 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/app_list/views/app_list_view.h" 5 #include "ui/app_list/views/app_list_view.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "ui/app_list/app_list_constants.h" 10 #include "ui/app_list/app_list_constants.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 delegate_->SetModel(model_.get()); 57 delegate_->SetModel(model_.get());
58 model_->AddObserver(this); 58 model_->AddObserver(this);
59 } 59 }
60 60
61 AppListView::~AppListView() { 61 AppListView::~AppListView() {
62 model_->RemoveObserver(this); 62 model_->RemoveObserver(this);
63 // Models are going away, ensure their references are cleared. 63 // Models are going away, ensure their references are cleared.
64 RemoveAllChildViews(true); 64 RemoveAllChildViews(true);
65 } 65 }
66 66
67 void AppListView::InitAsBubble(gfx::NativeView parent, 67 void AppListView::InitAsBubbleAttachedToAnchor(
68 PaginationModel* pagination_model, 68 gfx::NativeView parent,
69 views::View* anchor, 69 PaginationModel* pagination_model,
70 const gfx::Point& anchor_point, 70 views::View* anchor,
71 views::BubbleBorder::Arrow arrow, 71 const gfx::Point& anchor_offset,
72 bool border_accepts_events) { 72 views::BubbleBorder::Arrow arrow,
73 app_list_main_view_ = new AppListMainView(delegate_.get(), 73 bool border_accepts_events) {
74 model_.get(), 74 set_anchor_view(anchor);
75 pagination_model, 75 set_anchor_offset(anchor_offset);
76 parent); 76 InitAsBubbleInternal(parent, pagination_model, arrow, border_accepts_events);
77 AddChildView(app_list_main_view_); 77 }
78 #if defined(USE_AURA)
79 app_list_main_view_->SetPaintToLayer(true);
80 app_list_main_view_->SetFillsBoundsOpaquely(false);
81 app_list_main_view_->layer()->SetMasksToBounds(true);
82 #endif
83 78
84 signin_view_ = new SigninView( 79 void AppListView::InitAsBubbleAtFixedLocation(
85 GetSigninDelegate(), 80 gfx::NativeView parent,
86 app_list_main_view_->GetPreferredSize().width()); 81 PaginationModel* pagination_model,
87 AddChildView(signin_view_); 82 const gfx::Point& anchor_point_in_screen,
88 83 views::BubbleBorder::Arrow arrow,
89 OnSigninStatusChanged(); 84 bool border_accepts_events) {
90 85 set_anchor_view(NULL);
91 set_anchor_view(anchor); 86 set_anchor_rect(gfx::Rect(anchor_point_in_screen, gfx::Size()));
92 set_anchor_rect(gfx::Rect(anchor_point, gfx::Size())); 87 InitAsBubbleInternal(parent, pagination_model, arrow, border_accepts_events);
93 set_color(kContentsBackgroundColor);
94 set_margins(gfx::Insets());
95 set_move_with_anchor(true);
96 set_parent_window(parent);
97 set_close_on_deactivate(false);
98 set_close_on_esc(false);
99 set_anchor_view_insets(gfx::Insets(kArrowOffset, kArrowOffset,
100 kArrowOffset, kArrowOffset));
101 set_border_accepts_events(border_accepts_events);
102 set_shadow(views::BubbleBorder::BIG_SHADOW);
103 #if defined(USE_AURA) && defined(OS_WIN)
104 if (!ui::win::IsAeroGlassEnabled() ||
105 CommandLine::ForCurrentProcess()->HasSwitch(
106 switches::kDisableDwmComposition)) {
107 set_shadow(views::BubbleBorder::NO_SHADOW_OPAQUE_BORDER);
108 }
109 #endif
110 views::BubbleDelegateView::CreateBubble(this);
111 SetBubbleArrow(arrow);
112
113 #if defined(USE_AURA)
114 GetWidget()->GetNativeWindow()->layer()->SetMasksToBounds(true);
115 GetBubbleFrameView()->set_background(new AppListBackground(
116 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(),
117 app_list_main_view_));
118 set_background(NULL);
119 #else
120 set_background(new AppListBackground(
121 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(),
122 app_list_main_view_));
123
124 // On non-aura the bubble has two widgets, and it's possible for the border
125 // to be shown independently in odd situations. Explicitly hide the bubble
126 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the
127 // window manager do not have the SWP_SHOWWINDOW flag set which would cause
128 // the border to be shown. See http://crbug.com/231687 .
129 GetWidget()->Hide();
130 #endif
131 } 88 }
132 89
133 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { 90 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) {
134 GetBubbleFrameView()->bubble_border()->set_arrow(arrow); 91 GetBubbleFrameView()->bubble_border()->set_arrow(arrow);
135 SizeToContents(); // Recalcuates with new border. 92 SizeToContents(); // Recalcuates with new border.
136 GetBubbleFrameView()->SchedulePaint(); 93 GetBubbleFrameView()->SchedulePaint();
137 } 94 }
138 95
139 void AppListView::SetAnchorPoint(const gfx::Point& anchor_point) { 96 void AppListView::SetAnchorPoint(const gfx::Point& anchor_point) {
140 set_anchor_rect(gfx::Rect(anchor_point, gfx::Size())); 97 set_anchor_rect(gfx::Rect(anchor_point, gfx::Size()));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 #if defined(USE_AURA) 163 #if defined(USE_AURA)
207 gfx::NativeWindow window = 164 gfx::NativeWindow window =
208 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); 165 GetWidget()->GetTopLevelWidget()->GetNativeWindow();
209 return window->GetRootWindow()->GetAcceleratedWidget(); 166 return window->GetRootWindow()->GetAcceleratedWidget();
210 #else 167 #else
211 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); 168 return GetWidget()->GetTopLevelWidget()->GetNativeWindow();
212 #endif 169 #endif
213 } 170 }
214 #endif 171 #endif
215 172
173 void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
174 PaginationModel* pagination_model,
175 views::BubbleBorder::Arrow arrow,
176 bool border_accepts_events) {
177 app_list_main_view_ = new AppListMainView(delegate_.get(),
178 model_.get(),
179 pagination_model,
180 parent);
181 AddChildView(app_list_main_view_);
182 #if defined(USE_AURA)
183 app_list_main_view_->SetPaintToLayer(true);
184 app_list_main_view_->SetFillsBoundsOpaquely(false);
185 app_list_main_view_->layer()->SetMasksToBounds(true);
186 #endif
187
188 signin_view_ = new SigninView(
189 GetSigninDelegate(),
190 app_list_main_view_->GetPreferredSize().width());
191 AddChildView(signin_view_);
192
193 OnSigninStatusChanged();
194 set_color(kContentsBackgroundColor);
195 set_margins(gfx::Insets());
196 set_move_with_anchor(true);
197 set_parent_window(parent);
198 set_close_on_deactivate(false);
199 set_close_on_esc(false);
200 set_anchor_view_insets(gfx::Insets(kArrowOffset, kArrowOffset,
201 kArrowOffset, kArrowOffset));
202 set_border_accepts_events(border_accepts_events);
203 set_shadow(views::BubbleBorder::BIG_SHADOW);
204 #if defined(USE_AURA) && defined(OS_WIN)
205 if (!ui::win::IsAeroGlassEnabled() ||
206 CommandLine::ForCurrentProcess()->HasSwitch(
207 switches::kDisableDwmComposition)) {
208 set_shadow(views::BubbleBorder::NO_SHADOW_OPAQUE_BORDER);
209 }
210 #endif
211 views::BubbleDelegateView::CreateBubble(this);
212 SetBubbleArrow(arrow);
213
214 #if defined(USE_AURA)
215 GetWidget()->GetNativeWindow()->layer()->SetMasksToBounds(true);
216 GetBubbleFrameView()->set_background(new AppListBackground(
217 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(),
218 app_list_main_view_));
219 set_background(NULL);
220 #else
221 set_background(new AppListBackground(
222 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(),
223 app_list_main_view_));
224
225 // On non-aura the bubble has two widgets, and it's possible for the border
226 // to be shown independently in odd situations. Explicitly hide the bubble
227 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the
228 // window manager do not have the SWP_SHOWWINDOW flag set which would cause
229 // the border to be shown. See http://crbug.com/231687 .
230 GetWidget()->Hide();
231 #endif
232 }
233
216 views::View* AppListView::GetInitiallyFocusedView() { 234 views::View* AppListView::GetInitiallyFocusedView() {
217 return app_list_main_view_->search_box_view()->search_box(); 235 return app_list_main_view_->search_box_view()->search_box();
218 } 236 }
219 237
220 gfx::ImageSkia AppListView::GetWindowIcon() { 238 gfx::ImageSkia AppListView::GetWindowIcon() {
221 if (delegate_) 239 if (delegate_)
222 return delegate_->GetWindowIcon(); 240 return delegate_->GetWindowIcon();
223 241
224 return gfx::ImageSkia(); 242 return gfx::ImageSkia();
225 } 243 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 311
294 void AppListView::OnAppListModelSigninStatusChanged() { 312 void AppListView::OnAppListModelSigninStatusChanged() {
295 OnSigninStatusChanged(); 313 OnSigninStatusChanged();
296 } 314 }
297 315
298 void AppListView::OnAppListModelCurrentUserChanged() { 316 void AppListView::OnAppListModelCurrentUserChanged() {
299 OnSigninStatusChanged(); 317 OnSigninStatusChanged();
300 } 318 }
301 319
302 } // namespace app_list 320 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698