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

Side by Side Diff: ui/views/controls/tree/tree_view_views.cc

Issue 9021046: Pass const gfx::Rect& as the first parameter to FillRect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: one more fix Created 8 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
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/tree/tree_view_views.h" 5 #include "ui/views/controls/tree/tree_view_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 canvas->DrawBitmapInt( 654 canvas->DrawBitmapInt(
655 icon, icon_x, 655 icon, icon_x,
656 bounds.y() + (bounds.height() - icon.height()) / 2); 656 bounds.y() + (bounds.height() - icon.height()) / 2);
657 657
658 if (!editor_ || node != selected_node_) { 658 if (!editor_ || node != selected_node_) {
659 gfx::Rect text_bounds(bounds.x() + text_offset_, bounds.y(), 659 gfx::Rect text_bounds(bounds.x() + text_offset_, bounds.y(),
660 bounds.width() - text_offset_, bounds.height()); 660 bounds.width() - text_offset_, bounds.height());
661 if (base::i18n::IsRTL()) 661 if (base::i18n::IsRTL())
662 text_bounds.set_x(bounds.x()); 662 text_bounds.set_x(bounds.x());
663 if (node == selected_node_) { 663 if (node == selected_node_) {
664 canvas->FillRect(kSelectedBackgroundColor, text_bounds); 664 canvas->FillRect(text_bounds, kSelectedBackgroundColor);
665 if (HasFocus()) 665 if (HasFocus())
666 canvas->DrawFocusRect(text_bounds); 666 canvas->DrawFocusRect(text_bounds);
667 } 667 }
668 canvas->DrawStringInt(node->model_node()->GetTitle(), font_, kTextColor, 668 canvas->DrawStringInt(node->model_node()->GetTitle(), font_, kTextColor,
669 text_bounds.x() + kTextHorizontalPadding, 669 text_bounds.x() + kTextHorizontalPadding,
670 text_bounds.y() + kTextVerticalPadding, 670 text_bounds.y() + kTextVerticalPadding,
671 text_bounds.width() - kTextHorizontalPadding * 2, 671 text_bounds.width() - kTextHorizontalPadding * 2,
672 text_bounds.height() - kTextVerticalPadding * 2); 672 text_bounds.height() - kTextVerticalPadding * 2);
673 } 673 }
674 } 674 }
675 675
676 void TreeView::PaintExpandControl(gfx::Canvas* canvas, 676 void TreeView::PaintExpandControl(gfx::Canvas* canvas,
677 const gfx::Rect& node_bounds, 677 const gfx::Rect& node_bounds,
678 bool expanded) { 678 bool expanded) {
679 int center_x; 679 int center_x;
680 if (base::i18n::IsRTL()) { 680 if (base::i18n::IsRTL()) {
681 center_x = node_bounds.right() - kArrowRegionSize + 681 center_x = node_bounds.right() - kArrowRegionSize +
682 (kArrowRegionSize - 4) / 2; 682 (kArrowRegionSize - 4) / 2;
683 } else { 683 } else {
684 center_x = node_bounds.x() + (kArrowRegionSize - 4) / 2; 684 center_x = node_bounds.x() + (kArrowRegionSize - 4) / 2;
685 } 685 }
686 int center_y = node_bounds.y() + node_bounds.height() / 2; 686 int center_y = node_bounds.y() + node_bounds.height() / 2;
687 // TODO: this should come from an image. 687 // TODO: this should come from an image.
688 if (!expanded) { 688 if (!expanded) {
689 int delta = base::i18n::IsRTL() ? 1 : -1; 689 int delta = base::i18n::IsRTL() ? 1 : -1;
690 for (int i = 0; i < 4; ++i) { 690 for (int i = 0; i < 4; ++i) {
691 canvas->FillRect(kArrowColor, 691 canvas->FillRect(gfx::Rect(center_x + delta * (2 - i),
692 gfx::Rect(center_x + delta * (2 - i), 692 center_y - (3 - i), 1, (3 - i) * 2 + 1),
693 center_y - (3 - i), 1, (3 - i) * 2 + 1)); 693 kArrowColor);
694 } 694 }
695 } else { 695 } else {
696 center_y -= 2; 696 center_y -= 2;
697 for (int i = 0; i < 4; ++i) { 697 for (int i = 0; i < 4; ++i) {
698 canvas->FillRect(kArrowColor, 698 canvas->FillRect(gfx::Rect(center_x - (3 - i), center_y + i,
699 gfx::Rect(center_x - (3 - i), center_y + i, 699 (3 - i) * 2 + 1, 1), kArrowColor);
700 (3 - i) * 2 + 1, 1));
701 } 700 }
702 } 701 }
703 } 702 }
704 703
705 TreeView::InternalNode* TreeView::GetInternalNodeForModelNode( 704 TreeView::InternalNode* TreeView::GetInternalNodeForModelNode(
706 ui::TreeModelNode* model_node, 705 ui::TreeModelNode* model_node,
707 GetInternalNodeCreateType create_type) { 706 GetInternalNodeCreateType create_type) {
708 if (model_node == root_.model_node()) 707 if (model_node == root_.model_node())
709 return &root_; 708 return &root_;
710 InternalNode* parent_internal_node = 709 InternalNode* parent_internal_node =
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 if (!is_expanded_) 899 if (!is_expanded_)
901 return max_width; 900 return max_width;
902 for (int i = 0; i < child_count(); ++i) { 901 for (int i = 0; i < child_count(); ++i) {
903 max_width = std::max(max_width, 902 max_width = std::max(max_width,
904 GetChild(i)->GetMaxWidth(indent, depth + 1)); 903 GetChild(i)->GetMaxWidth(indent, depth + 1));
905 } 904 }
906 return max_width; 905 return max_width;
907 } 906 }
908 907
909 } // namespace views 908 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/table/table_view_views.cc ('k') | ui/views/examples/native_theme_button_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698