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

Side by Side Diff: chrome/browser/ui/views/extensions/media_gallery_checkbox_view.cc

Issue 2480813003: Reduce views::Border creation verbosity by promoting factory functions (Closed)
Patch Set: fix bad merge Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h" 5 #include "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h"
6 6
7 #include "chrome/browser/media_galleries/media_galleries_preferences.h" 7 #include "chrome/browser/media_galleries/media_galleries_preferences.h"
8 #include "third_party/skia/include/core/SkColor.h" 8 #include "third_party/skia/include/core/SkColor.h"
9 #include "ui/gfx/geometry/rect.h" 9 #include "ui/gfx/geometry/rect.h"
10 #include "ui/views/border.h" 10 #include "ui/views/border.h"
(...skipping 12 matching lines...) Expand all
23 } // namespace 23 } // namespace
24 24
25 MediaGalleryCheckboxView::MediaGalleryCheckboxView( 25 MediaGalleryCheckboxView::MediaGalleryCheckboxView(
26 const MediaGalleryPrefInfo& pref_info, 26 const MediaGalleryPrefInfo& pref_info,
27 int trailing_vertical_space, 27 int trailing_vertical_space,
28 views::ButtonListener* button_listener, 28 views::ButtonListener* button_listener,
29 views::ContextMenuController* menu_controller) { 29 views::ContextMenuController* menu_controller) {
30 DCHECK(button_listener != NULL); 30 DCHECK(button_listener != NULL);
31 SetLayoutManager( 31 SetLayoutManager(
32 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 32 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
33 SetBorder(views::Border::CreateEmptyBorder( 33 SetBorder(views::CreateEmptyBorder(0, views::kPanelHorizMargin,
34 0, views::kPanelHorizMargin, trailing_vertical_space, 34 trailing_vertical_space,
35 views::kPanelHorizMargin)); 35 views::kPanelHorizMargin));
36 if (menu_controller) 36 if (menu_controller)
37 set_context_menu_controller(menu_controller); 37 set_context_menu_controller(menu_controller);
38 38
39 checkbox_ = new views::Checkbox(pref_info.GetGalleryDisplayName()); 39 checkbox_ = new views::Checkbox(pref_info.GetGalleryDisplayName());
40 checkbox_->set_listener(button_listener); 40 checkbox_->set_listener(button_listener);
41 if (menu_controller) 41 if (menu_controller)
42 checkbox_->set_context_menu_controller(menu_controller); 42 checkbox_->set_context_menu_controller(menu_controller);
43 checkbox_->SetElideBehavior(gfx::ELIDE_MIDDLE); 43 checkbox_->SetElideBehavior(gfx::ELIDE_MIDDLE);
44 base::string16 tooltip_text = pref_info.GetGalleryTooltip(); 44 base::string16 tooltip_text = pref_info.GetGalleryTooltip();
45 checkbox_->SetTooltipText(tooltip_text); 45 checkbox_->SetTooltipText(tooltip_text);
46 46
47 base::string16 details = pref_info.GetGalleryAdditionalDetails(); 47 base::string16 details = pref_info.GetGalleryAdditionalDetails();
48 secondary_text_ = new views::Label(details); 48 secondary_text_ = new views::Label(details);
49 if (menu_controller) 49 if (menu_controller)
50 secondary_text_->set_context_menu_controller(menu_controller); 50 secondary_text_->set_context_menu_controller(menu_controller);
51 secondary_text_->SetVisible(details.length() > 0); 51 secondary_text_->SetVisible(details.length() > 0);
52 secondary_text_->SetEnabledColor(kDeemphasizedTextColor); 52 secondary_text_->SetEnabledColor(kDeemphasizedTextColor);
53 secondary_text_->SetElideBehavior(gfx::ELIDE_HEAD); 53 secondary_text_->SetElideBehavior(gfx::ELIDE_HEAD);
54 secondary_text_->SetTooltipText(tooltip_text); 54 secondary_text_->SetTooltipText(tooltip_text);
55 secondary_text_->SetBorder(views::Border::CreateEmptyBorder( 55 secondary_text_->SetBorder(views::CreateEmptyBorder(
56 0, views::kRelatedControlSmallHorizontalSpacing, 0, 0)); 56 0, views::kRelatedControlSmallHorizontalSpacing, 0, 0));
57 57
58 AddChildView(checkbox_); 58 AddChildView(checkbox_);
59 AddChildView(secondary_text_); 59 AddChildView(secondary_text_);
60 } 60 }
61 61
62 MediaGalleryCheckboxView::~MediaGalleryCheckboxView() {} 62 MediaGalleryCheckboxView::~MediaGalleryCheckboxView() {}
63 63
64 void MediaGalleryCheckboxView::Layout() { 64 void MediaGalleryCheckboxView::Layout() {
65 views::View::Layout(); 65 views::View::Layout();
(...skipping 15 matching lines...) Expand all
81 std::max(area.width() / 2, area.width() - checkbox_width); 81 std::max(area.width() / 2, area.width() - checkbox_width);
82 } 82 }
83 checkbox_width = area.width() - secondary_text_width; 83 checkbox_width = area.width() - secondary_text_width;
84 84
85 checkbox_->SetBounds(area.x(), area.y(), checkbox_width, area.height()); 85 checkbox_->SetBounds(area.x(), area.y(), checkbox_width, area.height());
86 if (secondary_text_->visible()) { 86 if (secondary_text_->visible()) {
87 secondary_text_->SetBounds(checkbox_->x() + checkbox_width, area.y(), 87 secondary_text_->SetBounds(checkbox_->x() + checkbox_width, area.y(),
88 secondary_text_width, area.height()); 88 secondary_text_width, area.height());
89 } 89 }
90 } 90 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc ('k') | chrome/browser/ui/views/find_bar_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698