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

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

Issue 2143893002: Purge the App Launcher code from Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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_item_view.h" 5 #include "ui/app_list/views/app_list_item_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 namespace { 42 namespace {
43 43
44 const int kTopPadding = 18; 44 const int kTopPadding = 18;
45 const int kIconTitleSpacing = 6; 45 const int kIconTitleSpacing = 6;
46 46
47 // Radius of the folder dropping preview circle. 47 // Radius of the folder dropping preview circle.
48 const int kFolderPreviewRadius = 40; 48 const int kFolderPreviewRadius = 40;
49 49
50 const int kLeftRightPaddingChars = 1; 50 const int kLeftRightPaddingChars = 1;
51 51
52 #if !defined(OS_WIN)
53 // Scale to transform the icon when a drag starts.
54 const float kDraggingIconScale = 1.5f;
55 #endif
56
57 // Delay in milliseconds of when the dragging UI should be shown for mouse drag. 52 // Delay in milliseconds of when the dragging UI should be shown for mouse drag.
58 const int kMouseDragUIDelayInMs = 200; 53 const int kMouseDragUIDelayInMs = 200;
59 54
60 gfx::FontList GetFontList() { 55 gfx::FontList GetFontList() {
61 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 56 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
62 const gfx::FontList& font_list = rb.GetFontList(kItemTextFontStyle); 57 const gfx::FontList& font_list = rb.GetFontList(kItemTextFontStyle);
63 // The font is different on each platform. The font size is adjusted on some 58 // The font is different on each platform. The font size is adjusted on some
64 // platforms to keep a consistent look. 59 // platforms to keep a consistent look.
65 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 60 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
66 // Reducing the font size by 2 makes it the same as the Windows font size. 61 // Reducing the font size by 2 makes it the same as the Windows font size.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 title_->SetVisible(!is_installing_); 149 title_->SetVisible(!is_installing_);
155 progress_bar_->SetVisible(is_installing_); 150 progress_bar_->SetVisible(is_installing_);
156 break; 151 break;
157 case UI_STATE_DRAGGING: 152 case UI_STATE_DRAGGING:
158 title_->SetVisible(false); 153 title_->SetVisible(false);
159 progress_bar_->SetVisible(false); 154 progress_bar_->SetVisible(false);
160 break; 155 break;
161 case UI_STATE_DROPPING_IN_FOLDER: 156 case UI_STATE_DROPPING_IN_FOLDER:
162 break; 157 break;
163 } 158 }
164 #if !defined(OS_WIN)
165 ui::ScopedLayerAnimationSettings settings(layer()->GetAnimator());
166 switch (ui_state_) {
167 case UI_STATE_NORMAL:
168 layer()->SetTransform(gfx::Transform());
169 break;
170 case UI_STATE_DRAGGING: {
171 const gfx::Rect bounds(layer()->bounds().size());
172 layer()->SetTransform(gfx::GetScaleTransform(
173 bounds.CenterPoint(),
174 kDraggingIconScale));
175 break;
176 }
177 case UI_STATE_DROPPING_IN_FOLDER:
178 break;
179 }
180 #endif // !OS_WIN
181 159
182 SetTitleSubpixelAA(); 160 SetTitleSubpixelAA();
183 SchedulePaint(); 161 SchedulePaint();
184 } 162 }
185 163
186 void AppListItemView::SetTouchDragging(bool touch_dragging) { 164 void AppListItemView::SetTouchDragging(bool touch_dragging) {
187 if (touch_dragging_ == touch_dragging) 165 if (touch_dragging_ == touch_dragging)
188 return; 166 return;
189 167
190 touch_dragging_ = touch_dragging; 168 touch_dragging_ = touch_dragging;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 return false; 380 return false;
403 381
404 return CustomButton::OnKeyPressed(event); 382 return CustomButton::OnKeyPressed(event);
405 } 383 }
406 384
407 void AppListItemView::OnMouseReleased(const ui::MouseEvent& event) { 385 void AppListItemView::OnMouseReleased(const ui::MouseEvent& event) {
408 CustomButton::OnMouseReleased(event); 386 CustomButton::OnMouseReleased(event);
409 apps_grid_view_->EndDrag(false); 387 apps_grid_view_->EndDrag(false);
410 } 388 }
411 389
412 void AppListItemView::OnMouseCaptureLost() {
413 // We don't cancel the dag on mouse capture lost for windows as entering a
414 // synchronous drag causes mouse capture to be lost and pressing escape
415 // dismisses the app list anyway.
416 #if !defined(OS_WIN)
417 CustomButton::OnMouseCaptureLost();
418 apps_grid_view_->EndDrag(true);
419 #endif
420 }
421
422 bool AppListItemView::OnMouseDragged(const ui::MouseEvent& event) { 390 bool AppListItemView::OnMouseDragged(const ui::MouseEvent& event) {
423 CustomButton::OnMouseDragged(event); 391 CustomButton::OnMouseDragged(event);
424 if (apps_grid_view_->IsDraggedView(this)) { 392 if (apps_grid_view_->IsDraggedView(this)) {
425 // If the drag is no longer happening, it could be because this item 393 // If the drag is no longer happening, it could be because this item
426 // got removed, in which case this item has been destroyed. So, bail out 394 // got removed, in which case this item has been destroyed. So, bail out
427 // now as there will be nothing else to do anyway as 395 // now as there will be nothing else to do anyway as
428 // apps_grid_view_->dragging() will be false. 396 // apps_grid_view_->dragging() will be false.
429 if (!apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, event)) 397 if (!apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, event))
430 return true; 398 return true;
431 } 399 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 SetItemPercentDownloaded(item_weak_->percent_downloaded()); 540 SetItemPercentDownloaded(item_weak_->percent_downloaded());
573 } 541 }
574 542
575 void AppListItemView::ItemBeingDestroyed() { 543 void AppListItemView::ItemBeingDestroyed() {
576 DCHECK(item_weak_); 544 DCHECK(item_weak_);
577 item_weak_->RemoveObserver(this); 545 item_weak_->RemoveObserver(this);
578 item_weak_ = NULL; 546 item_weak_ = NULL;
579 } 547 }
580 548
581 } // namespace app_list 549 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698