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

Side by Side Diff: chrome/browser/ui/views/validation_message_bubble_delegate.cc

Issue 327273005: Revert of Use labels to display views tab titles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | « chrome/browser/ui/views/tabs/tab_unittest.cc ('k') | ui/gfx/text_constants.h » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/validation_message_bubble_delegate.h" 5 #include "chrome/browser/ui/views/validation_message_bubble_delegate.h"
6 6
7 #include "grit/theme_resources.h" 7 #include "grit/theme_resources.h"
8 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/views/controls/image_view.h" 9 #include "ui/views/controls/image_view.h"
10 #include "ui/views/controls/label.h" 10 #include "ui/views/controls/label.h"
(...skipping 20 matching lines...) Expand all
31 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 31 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
32 views::ImageView* icon = new views::ImageView(); 32 views::ImageView* icon = new views::ImageView();
33 icon->SetImage(*bundle.GetImageSkiaNamed(IDR_INPUT_ALERT)); 33 icon->SetImage(*bundle.GetImageSkiaNamed(IDR_INPUT_ALERT));
34 gfx::Size size = icon->GetPreferredSize(); 34 gfx::Size size = icon->GetPreferredSize();
35 icon->SetBounds(kPadding, kPadding, size.width(), size.height()); 35 icon->SetBounds(kPadding, kPadding, size.width(), size.height());
36 AddChildView(icon); 36 AddChildView(icon);
37 37
38 views::Label* label = new views::Label( 38 views::Label* label = new views::Label(
39 main_text, bundle.GetFontList(ui::ResourceBundle::MediumFont)); 39 main_text, bundle.GetFontList(ui::ResourceBundle::MediumFont));
40 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 40 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
41 label->set_directionality_mode(gfx::DIRECTIONALITY_FROM_TEXT); 41 label->set_directionality_mode(views::Label::AUTO_DETECT_DIRECTIONALITY);
42 int text_start_x = kPadding + size.width() + kIconTextMargin; 42 int text_start_x = kPadding + size.width() + kIconTextMargin;
43 int min_available = kWindowMinWidth - text_start_x - kPadding; 43 int min_available = kWindowMinWidth - text_start_x - kPadding;
44 int max_available = kWindowMaxWidth - text_start_x - kPadding; 44 int max_available = kWindowMaxWidth - text_start_x - kPadding;
45 int label_width = label->GetPreferredSize().width(); 45 int label_width = label->GetPreferredSize().width();
46 label->SetMultiLine(true); 46 label->SetMultiLine(true);
47 AddChildView(label); 47 AddChildView(label);
48 48
49 views::Label* sub_label = NULL; 49 views::Label* sub_label = NULL;
50 if (!sub_text.empty()) { 50 if (!sub_text.empty()) {
51 sub_label = new views::Label(sub_text); 51 sub_label = new views::Label(sub_text);
52 sub_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 52 sub_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
53 sub_label->set_directionality_mode(gfx::DIRECTIONALITY_FROM_TEXT); 53 sub_label->set_directionality_mode(
54 views::Label::AUTO_DETECT_DIRECTIONALITY);
54 label_width = std::max(label_width, sub_label->GetPreferredSize().width()); 55 label_width = std::max(label_width, sub_label->GetPreferredSize().width());
55 sub_label->SetMultiLine(true); 56 sub_label->SetMultiLine(true);
56 AddChildView(sub_label); 57 AddChildView(sub_label);
57 } 58 }
58 59
59 if (label_width < min_available) 60 if (label_width < min_available)
60 label_width = min_available; 61 label_width = min_available;
61 else if (label_width > max_available) 62 else if (label_width > max_available)
62 label_width = max_available; 63 label_width = max_available;
63 label->SetBounds(text_start_x, kPadding, 64 label->SetBounds(text_start_x, kPadding,
(...skipping 29 matching lines...) Expand all
93 } 94 }
94 95
95 void ValidationMessageBubbleDelegate::DeleteDelegate() { 96 void ValidationMessageBubbleDelegate::DeleteDelegate() {
96 delete this; 97 delete this;
97 } 98 }
98 99
99 void ValidationMessageBubbleDelegate::WindowClosing() { 100 void ValidationMessageBubbleDelegate::WindowClosing() {
100 if (observer_ != NULL) 101 if (observer_ != NULL)
101 observer_->WindowClosing(); 102 observer_->WindowClosing();
102 } 103 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_unittest.cc ('k') | ui/gfx/text_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698