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

Unified Diff: ui/views/controls/label.h

Issue 323993002: Use labels to display views tab titles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments; update tests. 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/controls/button/label_button.cc ('k') | ui/views/controls/label.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/label.h
diff --git a/ui/views/controls/label.h b/ui/views/controls/label.h
index 9e2881dc69e93262bcc05df9703e7902d3887b19..60dfba9165aeb1246c0bf2781775f0d42234a83e 100644
--- a/ui/views/controls/label.h
+++ b/ui/views/controls/label.h
@@ -18,30 +18,9 @@
namespace views {
-/////////////////////////////////////////////////////////////////////////////
-//
-// Label class
-//
-// A label is a view subclass that can display a string.
-//
-/////////////////////////////////////////////////////////////////////////////
+// A view subclass that can display a string.
class VIEWS_EXPORT Label : public View {
public:
- // The following enum is used to indicate whether using the Chrome UI's
- // directionality as the label's directionality, or auto-detecting the label's
- // directionality.
- //
- // If the label text originates from the Chrome UI, we should use the Chrome
- // UI's directionality as the label's directionality.
- //
- // If the text originates from a web page, its directionality is determined
- // based on its first character with strong directionality, disregarding what
- // directionality the Chrome UI is.
- enum DirectionalityMode {
- USE_UI_DIRECTIONALITY = 0,
- AUTO_DETECT_DIRECTIONALITY
- };
-
// Internal class name.
static const char kViewClassName[];
@@ -94,28 +73,17 @@ class VIEWS_EXPORT Label : public View {
// Set the color of a halo on the painted text (use transparent for none).
void set_halo_color(SkColor halo_color) { halo_color_ = halo_color; }
- // Sets horizontal alignment. If the locale is RTL, and the directionality
- // mode is USE_UI_DIRECTIONALITY, the alignment is flipped around.
- //
- // Caveat: for labels originating from a web page, the directionality mode
- // should be reset to AUTO_DETECT_DIRECTIONALITY before the horizontal
- // alignment is set. Otherwise, the label's alignment specified as a parameter
- // will be flipped in RTL locales.
+ // Sets the horizontal alignment; the argument value is mirrored in RTL UI.
void SetHorizontalAlignment(gfx::HorizontalAlignment alignment);
+ gfx::HorizontalAlignment GetHorizontalAlignment() const;
- gfx::HorizontalAlignment horizontal_alignment() const {
- return horizontal_alignment_;
- }
-
- // Sets the directionality mode. The directionality mode is initialized to
- // USE_UI_DIRECTIONALITY when the label is constructed. USE_UI_DIRECTIONALITY
- // applies to every label that originates from the Chrome UI. However, if the
- // label originates from a web page, its directionality is auto-detected.
- void set_directionality_mode(DirectionalityMode mode) {
+ // Sets the directionality mode. The default value is DIRECTIONALITY_FROM_UI,
+ // which should be suitable for most text originating from UI string assets.
+ // Most text originating from web content should use DIRECTIONALITY_FROM_TEXT.
+ void set_directionality_mode(gfx::DirectionalityMode mode) {
directionality_mode_ = mode;
}
-
- DirectionalityMode directionality_mode() const {
+ gfx::DirectionalityMode directionality_mode() const {
return directionality_mode_;
}
@@ -212,9 +180,7 @@ class VIEWS_EXPORT Label : public View {
FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawMultiLineString);
FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawSingleLineStringInRTL);
FRIEND_TEST_ALL_PREFIXES(LabelTest, DrawMultiLineStringInRTL);
- FRIEND_TEST_ALL_PREFIXES(LabelTest, AutoDetectDirectionality);
-
- // Calls ComputeDrawStringFlags().
+ FRIEND_TEST_ALL_PREFIXES(LabelTest, DirectionalityFromText);
FRIEND_TEST_ALL_PREFIXES(LabelTest, DisableSubpixelRendering);
// Sets both |text_| and |layout_text_| to appropriate values, taking
@@ -272,10 +238,9 @@ class VIEWS_EXPORT Label : public View {
base::string16 tooltip_text_;
// Whether to collapse the label when it's not visible.
bool collapse_when_hidden_;
- // The following member variable is used to control whether the
- // directionality is auto-detected based on first strong directionality
- // character or is determined by chrome UI's locale.
- DirectionalityMode directionality_mode_;
+ // Controls whether the directionality is auto-detected based on first strong
+ // directionality character or is determined by the application UI's locale.
+ gfx::DirectionalityMode directionality_mode_;
// Colors for shadow.
SkColor enabled_shadow_color_;
« no previous file with comments | « ui/views/controls/button/label_button.cc ('k') | ui/views/controls/label.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698