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

Side by Side Diff: chrome/browser/ui/views/download/download_item_view.cc

Issue 23731010: Move text_elider to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update3 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 "chrome/browser/ui/views/download/download_item_view.h" 5 #include "chrome/browser/ui/views/download/download_item_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 18 matching lines...) Expand all
29 #include "chrome/browser/ui/views/download/download_shelf_view.h" 29 #include "chrome/browser/ui/views/download/download_shelf_view.h"
30 #include "content/public/browser/download_danger_type.h" 30 #include "content/public/browser/download_danger_type.h"
31 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
32 #include "grit/theme_resources.h" 32 #include "grit/theme_resources.h"
33 #include "third_party/icu/source/common/unicode/uchar.h" 33 #include "third_party/icu/source/common/unicode/uchar.h"
34 #include "ui/base/accessibility/accessible_view_state.h" 34 #include "ui/base/accessibility/accessible_view_state.h"
35 #include "ui/base/animation/slide_animation.h" 35 #include "ui/base/animation/slide_animation.h"
36 #include "ui/base/events/event.h" 36 #include "ui/base/events/event.h"
37 #include "ui/base/l10n/l10n_util.h" 37 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/resource/resource_bundle.h" 38 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/base/text/text_elider.h"
40 #include "ui/base/theme_provider.h" 39 #include "ui/base/theme_provider.h"
41 #include "ui/gfx/canvas.h" 40 #include "ui/gfx/canvas.h"
42 #include "ui/gfx/color_utils.h" 41 #include "ui/gfx/color_utils.h"
43 #include "ui/gfx/image/image.h" 42 #include "ui/gfx/image/image.h"
43 #include "ui/gfx/text_elider.h"
44 #include "ui/views/controls/button/label_button.h" 44 #include "ui/views/controls/button/label_button.h"
45 #include "ui/views/controls/label.h" 45 #include "ui/views/controls/label.h"
46 #include "ui/views/widget/root_view.h" 46 #include "ui/views/widget/root_view.h"
47 #include "ui/views/widget/widget.h" 47 #include "ui/views/widget/widget.h"
48 48
49 // TODO(paulg): These may need to be adjusted when download progress 49 // TODO(paulg): These may need to be adjusted when download progress
50 // animation is added, and also possibly to take into account 50 // animation is added, and also possibly to take into account
51 // different screen resolutions. 51 // different screen resolutions.
52 static const int kTextWidth = 140; // Pixels 52 static const int kTextWidth = 140; // Pixels
53 static const int kDangerousTextWidth = 200; // Pixels 53 static const int kDangerousTextWidth = 200; // Pixels
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 // Consequently, the x-axis of following canvas->DrawXXX() method should be 741 // Consequently, the x-axis of following canvas->DrawXXX() method should be
742 // mirrored so the text and images are down in the right positions. 742 // mirrored so the text and images are down in the right positions.
743 canvas->Restore(); 743 canvas->Restore();
744 744
745 // Print the text, left aligned and always print the file extension. 745 // Print the text, left aligned and always print the file extension.
746 // Last value of x was the end of the right image, just before the button. 746 // Last value of x was the end of the right image, just before the button.
747 // Note that in dangerous mode we use a label (as the text is multi-line). 747 // Note that in dangerous mode we use a label (as the text is multi-line).
748 if (!IsShowingWarningDialog()) { 748 if (!IsShowingWarningDialog()) {
749 string16 filename; 749 string16 filename;
750 if (!disabled_while_opening_) { 750 if (!disabled_while_opening_) {
751 filename = ui::ElideFilename(download()->GetFileNameToReportUser(), 751 filename = gfx::ElideFilename(download()->GetFileNameToReportUser(),
752 font_list_, kTextWidth); 752 font_list_, kTextWidth);
753 } else { 753 } else {
754 // First, Calculate the download status opening string width. 754 // First, Calculate the download status opening string width.
755 string16 status_string = 755 string16 status_string =
756 l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, string16()); 756 l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, string16());
757 int status_string_width = font_list_.GetStringWidth(status_string); 757 int status_string_width = font_list_.GetStringWidth(status_string);
758 // Then, elide the file name. 758 // Then, elide the file name.
759 string16 filename_string = 759 string16 filename_string =
760 ui::ElideFilename(download()->GetFileNameToReportUser(), font_list_, 760 gfx::ElideFilename(download()->GetFileNameToReportUser(), font_list_,
761 kTextWidth - status_string_width); 761 kTextWidth - status_string_width);
762 // Last, concat the whole string. 762 // Last, concat the whole string.
763 filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING, 763 filename = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPENING,
764 filename_string); 764 filename_string);
765 } 765 }
766 766
767 int mirrored_x = GetMirroredXWithWidthInView( 767 int mirrored_x = GetMirroredXWithWidthInView(
768 DownloadShelf::kSmallProgressIconSize, kTextWidth); 768 DownloadShelf::kSmallProgressIconSize, kTextWidth);
769 SkColor file_name_color = GetThemeProvider()->GetColor( 769 SkColor file_name_color = GetThemeProvider()->GetColor(
770 ThemeProperties::COLOR_BOOKMARK_TEXT); 770 ThemeProperties::COLOR_BOOKMARK_TEXT);
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 void DownloadItemView::AnimateStateTransition(State from, State to, 1266 void DownloadItemView::AnimateStateTransition(State from, State to,
1267 ui::SlideAnimation* animation) { 1267 ui::SlideAnimation* animation) {
1268 if (from == NORMAL && to == HOT) { 1268 if (from == NORMAL && to == HOT) {
1269 animation->Show(); 1269 animation->Show();
1270 } else if (from == HOT && to == NORMAL) { 1270 } else if (from == HOT && to == NORMAL) {
1271 animation->Hide(); 1271 animation->Hide();
1272 } else if (from != to) { 1272 } else if (from != to) {
1273 animation->Reset((to == HOT) ? 1.0 : 0.0); 1273 animation->Reset((to == HOT) ? 1.0 : 0.0);
1274 } 1274 }
1275 } 1275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698