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

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
« no previous file with comments | « ui/app_list/views/app_list_view.h ('k') | no next file » | 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) 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::Vector2d& 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 InitAsBubbleInternal(
76 parent); 76 parent, pagination_model, arrow, border_accepts_events, anchor_offset);
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(
93 set_color(kContentsBackgroundColor); 88 parent, pagination_model, arrow, border_accepts_events, gfx::Vector2d());
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 } 89 }
132 90
133 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) { 91 void AppListView::SetBubbleArrow(views::BubbleBorder::Arrow arrow) {
134 GetBubbleFrameView()->bubble_border()->set_arrow(arrow); 92 GetBubbleFrameView()->bubble_border()->set_arrow(arrow);
135 SizeToContents(); // Recalcuates with new border. 93 SizeToContents(); // Recalcuates with new border.
136 GetBubbleFrameView()->SchedulePaint(); 94 GetBubbleFrameView()->SchedulePaint();
137 } 95 }
138 96
139 void AppListView::SetAnchorPoint(const gfx::Point& anchor_point) { 97 void AppListView::SetAnchorPoint(const gfx::Point& anchor_point) {
140 set_anchor_rect(gfx::Rect(anchor_point, gfx::Size())); 98 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) 164 #if defined(USE_AURA)
207 gfx::NativeWindow window = 165 gfx::NativeWindow window =
208 GetWidget()->GetTopLevelWidget()->GetNativeWindow(); 166 GetWidget()->GetTopLevelWidget()->GetNativeWindow();
209 return window->GetRootWindow()->GetAcceleratedWidget(); 167 return window->GetRootWindow()->GetAcceleratedWidget();
210 #else 168 #else
211 return GetWidget()->GetTopLevelWidget()->GetNativeWindow(); 169 return GetWidget()->GetTopLevelWidget()->GetNativeWindow();
212 #endif 170 #endif
213 } 171 }
214 #endif 172 #endif
215 173
174 void AppListView::InitAsBubbleInternal(gfx::NativeView parent,
175 PaginationModel* pagination_model,
176 views::BubbleBorder::Arrow arrow,
177 bool border_accepts_events,
178 const gfx::Vector2d& anchor_offset) {
179 app_list_main_view_ = new AppListMainView(delegate_.get(),
180 model_.get(),
181 pagination_model,
182 parent);
183 AddChildView(app_list_main_view_);
184 #if defined(USE_AURA)
185 app_list_main_view_->SetPaintToLayer(true);
186 app_list_main_view_->SetFillsBoundsOpaquely(false);
187 app_list_main_view_->layer()->SetMasksToBounds(true);
188 #endif
189
190 signin_view_ = new SigninView(
191 GetSigninDelegate(),
192 app_list_main_view_->GetPreferredSize().width());
193 AddChildView(signin_view_);
194
195 OnSigninStatusChanged();
196 set_color(kContentsBackgroundColor);
197 set_margins(gfx::Insets());
198 set_move_with_anchor(true);
199 set_parent_window(parent);
200 set_close_on_deactivate(false);
201 set_close_on_esc(false);
202 set_anchor_view_insets(gfx::Insets(kArrowOffset + anchor_offset.y(),
203 kArrowOffset + anchor_offset.x(),
204 kArrowOffset - anchor_offset.y(),
205 kArrowOffset - anchor_offset.x()));
206 set_border_accepts_events(border_accepts_events);
207 set_shadow(views::BubbleBorder::BIG_SHADOW);
208 #if defined(USE_AURA) && defined(OS_WIN)
209 if (!ui::win::IsAeroGlassEnabled() ||
210 CommandLine::ForCurrentProcess()->HasSwitch(
211 switches::kDisableDwmComposition)) {
212 set_shadow(views::BubbleBorder::NO_SHADOW_OPAQUE_BORDER);
213 }
214 #endif
215 views::BubbleDelegateView::CreateBubble(this);
216 SetBubbleArrow(arrow);
217
218 #if defined(USE_AURA)
219 GetWidget()->GetNativeWindow()->layer()->SetMasksToBounds(true);
220 GetBubbleFrameView()->set_background(new AppListBackground(
221 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(),
222 app_list_main_view_));
223 set_background(NULL);
224 #else
225 set_background(new AppListBackground(
226 GetBubbleFrameView()->bubble_border()->GetBorderCornerRadius(),
227 app_list_main_view_));
228
229 // On non-aura the bubble has two widgets, and it's possible for the border
230 // to be shown independently in odd situations. Explicitly hide the bubble
231 // widget to ensure that any WM_WINDOWPOSCHANGED messages triggered by the
232 // window manager do not have the SWP_SHOWWINDOW flag set which would cause
233 // the border to be shown. See http://crbug.com/231687 .
234 GetWidget()->Hide();
235 #endif
236 }
237
216 views::View* AppListView::GetInitiallyFocusedView() { 238 views::View* AppListView::GetInitiallyFocusedView() {
217 return app_list_main_view_->search_box_view()->search_box(); 239 return app_list_main_view_->search_box_view()->search_box();
218 } 240 }
219 241
220 gfx::ImageSkia AppListView::GetWindowIcon() { 242 gfx::ImageSkia AppListView::GetWindowIcon() {
221 if (delegate_) 243 if (delegate_)
222 return delegate_->GetWindowIcon(); 244 return delegate_->GetWindowIcon();
223 245
224 return gfx::ImageSkia(); 246 return gfx::ImageSkia();
225 } 247 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 315
294 void AppListView::OnAppListModelSigninStatusChanged() { 316 void AppListView::OnAppListModelSigninStatusChanged() {
295 OnSigninStatusChanged(); 317 OnSigninStatusChanged();
296 } 318 }
297 319
298 void AppListView::OnAppListModelCurrentUserChanged() { 320 void AppListView::OnAppListModelCurrentUserChanged() {
299 OnSigninStatusChanged(); 321 OnSigninStatusChanged();
300 } 322 }
301 323
302 } // namespace app_list 324 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698