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

Side by Side Diff: ui/views/controls/label.cc

Issue 231643002: Added labels under the windows in OverviewMode displaying their current name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nits, added transparency Created 6 years, 8 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
« ui/views/controls/label.h ('K') | « ui/views/controls/label.h ('k') | no next file » | 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) 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/views/controls/label.h" 5 #include "ui/views/controls/label.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <vector> 10 #include <vector>
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 void Label::SetShadowColors(SkColor enabled_color, SkColor disabled_color) { 108 void Label::SetShadowColors(SkColor enabled_color, SkColor disabled_color) {
109 enabled_shadow_color_ = enabled_color; 109 enabled_shadow_color_ = enabled_color;
110 disabled_shadow_color_ = disabled_color; 110 disabled_shadow_color_ = disabled_color;
111 has_shadow_ = true; 111 has_shadow_ = true;
112 } 112 }
113 113
114 void Label::SetShadowOffset(int x, int y) { 114 void Label::SetShadowOffset(int x, int y) {
115 shadow_offset_.SetPoint(x, y); 115 shadow_offset_.SetPoint(x, y);
116 } 116 }
117 117
118 void Label::SetMirrorShadow(bool mirror_shadow) {
119 mirror_shadow_ = mirror_shadow;
120 }
121
122 void Label::SetShadowBlur(double shadow_blur) {
123 shadow_blur_ = shadow_blur;
124 }
125
118 void Label::ClearEmbellishing() { 126 void Label::ClearEmbellishing() {
119 has_shadow_ = false; 127 has_shadow_ = false;
120 } 128 }
121 129
122 void Label::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) { 130 void Label::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) {
123 // If the View's UI layout is right-to-left and directionality_mode_ is 131 // If the View's UI layout is right-to-left and directionality_mode_ is
124 // USE_UI_DIRECTIONALITY, we need to flip the alignment so that the alignment 132 // USE_UI_DIRECTIONALITY, we need to flip the alignment so that the alignment
125 // settings take into account the text directionality. 133 // settings take into account the text directionality.
126 if (base::i18n::IsRTL() && (directionality_mode_ == USE_UI_DIRECTIONALITY) && 134 if (base::i18n::IsRTL() && (directionality_mode_ == USE_UI_DIRECTIONALITY) &&
127 (alignment != gfx::ALIGN_CENTER)) { 135 (alignment != gfx::ALIGN_CENTER)) {
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 state->role = ui::AX_ROLE_STATIC_TEXT; 323 state->role = ui::AX_ROLE_STATIC_TEXT;
316 state->AddStateFlag(ui::AX_STATE_READ_ONLY); 324 state->AddStateFlag(ui::AX_STATE_READ_ONLY);
317 state->name = layout_text(); 325 state->name = layout_text();
318 } 326 }
319 327
320 void Label::PaintText(gfx::Canvas* canvas, 328 void Label::PaintText(gfx::Canvas* canvas,
321 const base::string16& text, 329 const base::string16& text,
322 const gfx::Rect& text_bounds, 330 const gfx::Rect& text_bounds,
323 int flags) { 331 int flags) {
324 gfx::ShadowValues shadows; 332 gfx::ShadowValues shadows;
325 if (has_shadow_) 333 if (has_shadow_) {
326 shadows.push_back(gfx::ShadowValue(shadow_offset_, 0, 334 shadows.push_back(gfx::ShadowValue(shadow_offset_, shadow_blur_,
327 enabled() ? enabled_shadow_color_ : disabled_shadow_color_)); 335 enabled() ? enabled_shadow_color_ : disabled_shadow_color_));
336 if (mirror_shadow_) {
337 gfx::Point shadow_point = shadow_offset_;
338 shadow_point.set_x(-shadow_point.x());
339 shadows.push_back(gfx::ShadowValue(shadow_point, shadow_blur_,
340 enabled() ? enabled_shadow_color_ : disabled_shadow_color_));
341 shadow_point.set_y(-shadow_point.y());
342 shadows.push_back(gfx::ShadowValue(shadow_point, shadow_blur_,
343 enabled() ? enabled_shadow_color_ : disabled_shadow_color_));
344 shadow_point.set_x(-shadow_point.x());
345 shadows.push_back(gfx::ShadowValue(shadow_point, shadow_blur_,
346 enabled() ? enabled_shadow_color_ : disabled_shadow_color_));
flackr 2014/04/14 20:31:18 I'm concerned that this effect may not be necessar
Nina 2014/04/15 15:15:03 Good point! Yes, it works that way, so I removed t
347 }
348 }
328 canvas->DrawStringRectWithShadows(text, font_list_, 349 canvas->DrawStringRectWithShadows(text, font_list_,
329 enabled() ? actual_enabled_color_ : actual_disabled_color_, 350 enabled() ? actual_enabled_color_ : actual_disabled_color_,
330 text_bounds, line_height_, flags, shadows); 351 text_bounds, line_height_, flags, shadows);
331 352
332 if (HasFocus()) { 353 if (HasFocus()) {
333 gfx::Rect focus_bounds = text_bounds; 354 gfx::Rect focus_bounds = text_bounds;
334 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding); 355 focus_bounds.Inset(-kFocusBorderPadding, -kFocusBorderPadding);
335 canvas->DrawFocusRect(focus_bounds); 356 canvas->DrawFocusRect(focus_bounds);
336 } 357 }
337 } 358 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 is_multi_line_ = false; 412 is_multi_line_ = false;
392 is_obscured_ = false; 413 is_obscured_ = false;
393 allow_character_break_ = false; 414 allow_character_break_ = false;
394 elide_behavior_ = ELIDE_AT_END; 415 elide_behavior_ = ELIDE_AT_END;
395 collapse_when_hidden_ = false; 416 collapse_when_hidden_ = false;
396 directionality_mode_ = USE_UI_DIRECTIONALITY; 417 directionality_mode_ = USE_UI_DIRECTIONALITY;
397 enabled_shadow_color_ = 0; 418 enabled_shadow_color_ = 0;
398 disabled_shadow_color_ = 0; 419 disabled_shadow_color_ = 0;
399 shadow_offset_.SetPoint(1, 1); 420 shadow_offset_.SetPoint(1, 1);
400 has_shadow_ = false; 421 has_shadow_ = false;
422 shadow_blur_ = 0;
423 mirror_shadow_ = false;
401 cached_heights_.resize(kCachedSizeLimit); 424 cached_heights_.resize(kCachedSizeLimit);
402 ResetCachedSize(); 425 ResetCachedSize();
403 426
404 SetText(text); 427 SetText(text);
405 } 428 }
406 429
407 void Label::RecalculateColors() { 430 void Label::RecalculateColors() {
408 actual_enabled_color_ = auto_color_readability_ ? 431 actual_enabled_color_ = auto_color_readability_ ?
409 color_utils::GetReadableColor(requested_enabled_color_, 432 color_utils::GetReadableColor(requested_enabled_color_,
410 background_color_) : 433 background_color_) :
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 cached_heights_[i] = gfx::Size(); 579 cached_heights_[i] = gfx::Size();
557 } 580 }
558 581
559 bool Label::ShouldShowDefaultTooltip() const { 582 bool Label::ShouldShowDefaultTooltip() const {
560 return !is_multi_line_ && !is_obscured_ && 583 return !is_multi_line_ && !is_obscured_ &&
561 gfx::GetStringWidth(layout_text(), font_list_) > 584 gfx::GetStringWidth(layout_text(), font_list_) >
562 GetAvailableRect().width(); 585 GetAvailableRect().width();
563 } 586 }
564 587
565 } // namespace views 588 } // namespace views
OLDNEW
« ui/views/controls/label.h ('K') | « ui/views/controls/label.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698