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

Unified Diff: ui/views/examples/label_example.cc

Issue 312233003: Add fade eliding for Views Labels; related cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refine alignment check; minor additional cleanup. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/corewm/tooltip_aura_unittest.cc ('k') | ui/views/examples/text_example.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/examples/label_example.cc
diff --git a/ui/views/examples/label_example.cc b/ui/views/examples/label_example.cc
index 83dd9227ceb8d50848995e7c69909c9c1ca6110d..a4a91133f2fab1d081161c4df8269f18db48971b 100644
--- a/ui/views/examples/label_example.cc
+++ b/ui/views/examples/label_example.cc
@@ -21,26 +21,20 @@ namespace {
// A Label with a constrained preferred size to demonstrate eliding or wrapping.
class PreferredSizeLabel : public Label {
public:
- PreferredSizeLabel();
- virtual ~PreferredSizeLabel();
+ PreferredSizeLabel() : Label() {
+ SetBorder(Border::CreateSolidBorder(2, SK_ColorCYAN));
+ }
+ virtual ~PreferredSizeLabel() {}
// Label:
- virtual gfx::Size GetPreferredSize() const OVERRIDE;
+ virtual gfx::Size GetPreferredSize() const OVERRIDE {
+ return gfx::Size(100, 40);
+ }
private:
DISALLOW_COPY_AND_ASSIGN(PreferredSizeLabel);
};
-PreferredSizeLabel::PreferredSizeLabel() : Label() {
- SetBorder(Border::CreateSolidBorder(2, SK_ColorCYAN));
-}
-
-PreferredSizeLabel::~PreferredSizeLabel() {}
-
-gfx::Size PreferredSizeLabel::GetPreferredSize() const {
- return gfx::Size(100, 40);
-}
-
} // namespace
LabelExample::LabelExample() : ExampleBase("Label") {}
@@ -81,6 +75,12 @@ void LabelExample::CreateExampleView(View* container) {
container->AddChildView(label);
label = new PreferredSizeLabel();
+ label->SetElideBehavior(gfx::FADE_TAIL);
+ label->SetText(ASCIIToUTF16("Some long labels will fade, rather than elide, "
+ "if the text's width exceeds the label's available width."));
+ container->AddChildView(label);
+
+ label = new PreferredSizeLabel();
label->SetText(ASCIIToUTF16("A multi-line label will wrap onto subsequent "
"lines if the text's width exceeds the label's available width."));
label->SetMultiLine(true);
« no previous file with comments | « ui/views/corewm/tooltip_aura_unittest.cc ('k') | ui/views/examples/text_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698