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

Side by Side Diff: views/controls/button/text_button.cc

Issue 6334152: Clean up RTL methods.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 | « views/controls/button/menu_button.cc ('k') | views/controls/menu/menu_item_view.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/controls/button/text_button.h" 5 #include "views/controls/button/text_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (text_width > 0) { 336 if (text_width > 0) {
337 // Because the text button can (at times) draw multiple elements on the 337 // Because the text button can (at times) draw multiple elements on the
338 // canvas, we can not mirror the button by simply flipping the canvas as 338 // canvas, we can not mirror the button by simply flipping the canvas as
339 // doing this will mirror the text itself. Flipping the canvas will also 339 // doing this will mirror the text itself. Flipping the canvas will also
340 // make the icons look wrong because icons are almost always represented as 340 // make the icons look wrong because icons are almost always represented as
341 // direction insentisive bitmaps and such bitmaps should never be flipped 341 // direction insentisive bitmaps and such bitmaps should never be flipped
342 // horizontally. 342 // horizontally.
343 // 343 //
344 // Due to the above, we must perform the flipping manually for RTL UIs. 344 // Due to the above, we must perform the flipping manually for RTL UIs.
345 gfx::Rect text_bounds(text_x, text_y, text_width, text_size_.height()); 345 gfx::Rect text_bounds(text_x, text_y, text_width, text_size_.height());
346 text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); 346 text_bounds.set_x(GetMirroredXForRect(text_bounds));
347 347
348 SkColor text_color = (show_multiple_icon_states_ && 348 SkColor text_color = (show_multiple_icon_states_ &&
349 (state() == BS_HOT || state() == BS_PUSHED)) ? color_hover_ : color_; 349 (state() == BS_HOT || state() == BS_PUSHED)) ? color_hover_ : color_;
350 350
351 int draw_string_flags = gfx::CanvasSkia::DefaultCanvasTextAlignment() | 351 int draw_string_flags = gfx::CanvasSkia::DefaultCanvasTextAlignment() |
352 PrefixTypeToCanvasType(prefix_type_); 352 PrefixTypeToCanvasType(prefix_type_);
353 353
354 if (for_drag) { 354 if (for_drag) {
355 #if defined(OS_WIN) 355 #if defined(OS_WIN)
356 // TODO(erg): Either port DrawStringWithHalo to linux or find an 356 // TODO(erg): Either port DrawStringWithHalo to linux or find an
(...skipping 27 matching lines...) Expand all
384 text_bounds.height(), 384 text_bounds.height(),
385 draw_string_flags); 385 draw_string_flags);
386 } 386 }
387 } 387 }
388 388
389 if (icon.width() > 0) { 389 if (icon.width() > 0) {
390 int icon_y = (available_height - icon.height()) / 2 + insets.top(); 390 int icon_y = (available_height - icon.height()) / 2 + insets.top();
391 391
392 // Mirroring the icon position if necessary. 392 // Mirroring the icon position if necessary.
393 gfx::Rect icon_bounds(icon_x, icon_y, icon.width(), icon.height()); 393 gfx::Rect icon_bounds(icon_x, icon_y, icon.width(), icon.height());
394 icon_bounds.set_x(MirroredLeftPointForRect(icon_bounds)); 394 icon_bounds.set_x(GetMirroredXForRect(icon_bounds));
395 canvas->DrawBitmapInt(icon, icon_bounds.x(), icon_bounds.y()); 395 canvas->DrawBitmapInt(icon, icon_bounds.x(), icon_bounds.y());
396 } 396 }
397 } 397 }
398 398
399 void TextButton::UpdateColor() { 399 void TextButton::UpdateColor() {
400 color_ = IsEnabled() ? color_enabled_ : color_disabled_; 400 color_ = IsEnabled() ? color_enabled_ : color_disabled_;
401 } 401 }
402 402
403 void TextButton::UpdateTextSize() { 403 void TextButton::UpdateTextSize() {
404 int width = 0, height = 0; 404 int width = 0, height = 0;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 455
456 std::string TextButton::GetClassName() const { 456 std::string TextButton::GetClassName() const {
457 return kViewClassName; 457 return kViewClassName;
458 } 458 }
459 459
460 void TextButton::Paint(gfx::Canvas* canvas) { 460 void TextButton::Paint(gfx::Canvas* canvas) {
461 Paint(canvas, false); 461 Paint(canvas, false);
462 } 462 }
463 463
464 } // namespace views 464 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/button/menu_button.cc ('k') | views/controls/menu/menu_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698