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

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

Issue 2700083002: Views/Harmony: Use LayoutDelegate::GetMetric() for views::kPanelHorizMargin. (Closed)
Patch Set: Fix includes. Created 3 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
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 "chrome/browser/ui/views/harmony/layout_delegate.h"
8 #include "third_party/skia/include/core/SkColor.h" 9 #include "third_party/skia/include/core/SkColor.h"
9 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
10 #include "ui/views/border.h" 11 #include "ui/views/border.h"
11 #include "ui/views/context_menu_controller.h" 12 #include "ui/views/context_menu_controller.h"
12 #include "ui/views/controls/button/button.h" 13 #include "ui/views/controls/button/button.h"
13 #include "ui/views/controls/button/checkbox.h" 14 #include "ui/views/controls/button/checkbox.h"
14 #include "ui/views/controls/label.h" 15 #include "ui/views/controls/label.h"
15 #include "ui/views/layout/box_layout.h" 16 #include "ui/views/layout/box_layout.h"
16 #include "ui/views/layout/layout_constants.h" 17 #include "ui/views/layout/layout_constants.h"
17 18
18 namespace { 19 namespace {
19 20
20 // Equal to the #9F9F9F color used in spec (note WebUI color is #999). 21 // Equal to the #9F9F9F color used in spec (note WebUI color is #999).
21 const SkColor kDeemphasizedTextColor = SkColorSetRGB(159, 159, 159); 22 const SkColor kDeemphasizedTextColor = SkColorSetRGB(159, 159, 159);
22 23
23 } // namespace 24 } // namespace
24 25
25 MediaGalleryCheckboxView::MediaGalleryCheckboxView( 26 MediaGalleryCheckboxView::MediaGalleryCheckboxView(
26 const MediaGalleryPrefInfo& pref_info, 27 const MediaGalleryPrefInfo& pref_info,
27 int trailing_vertical_space, 28 int trailing_vertical_space,
28 views::ButtonListener* button_listener, 29 views::ButtonListener* button_listener,
29 views::ContextMenuController* menu_controller) { 30 views::ContextMenuController* menu_controller) {
30 DCHECK(button_listener != NULL); 31 DCHECK(button_listener != NULL);
31 SetLayoutManager( 32 SetLayoutManager(
32 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); 33 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
33 SetBorder(views::CreateEmptyBorder(0, views::kPanelHorizMargin, 34 const int kBorderHorizMargin = LayoutDelegate::Get()->GetMetric(
tapted 2017/02/20 04:42:00 nit: const int border_horiz_margin = .. (we only
Patti Lor 2017/02/20 06:34:39 Done, thanks!
34 trailing_vertical_space, 35 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN);
35 views::kPanelHorizMargin)); 36 SetBorder(views::CreateEmptyBorder(
37 0, kBorderHorizMargin, trailing_vertical_space, kBorderHorizMargin));
36 if (menu_controller) 38 if (menu_controller)
37 set_context_menu_controller(menu_controller); 39 set_context_menu_controller(menu_controller);
38 40
39 checkbox_ = new views::Checkbox(pref_info.GetGalleryDisplayName()); 41 checkbox_ = new views::Checkbox(pref_info.GetGalleryDisplayName());
40 checkbox_->set_listener(button_listener); 42 checkbox_->set_listener(button_listener);
41 if (menu_controller) 43 if (menu_controller)
42 checkbox_->set_context_menu_controller(menu_controller); 44 checkbox_->set_context_menu_controller(menu_controller);
43 checkbox_->SetElideBehavior(gfx::ELIDE_MIDDLE); 45 checkbox_->SetElideBehavior(gfx::ELIDE_MIDDLE);
44 base::string16 tooltip_text = pref_info.GetGalleryTooltip(); 46 base::string16 tooltip_text = pref_info.GetGalleryTooltip();
45 checkbox_->SetTooltipText(tooltip_text); 47 checkbox_->SetTooltipText(tooltip_text);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 std::max(area.width() / 2, area.width() - checkbox_width); 83 std::max(area.width() / 2, area.width() - checkbox_width);
82 } 84 }
83 checkbox_width = area.width() - secondary_text_width; 85 checkbox_width = area.width() - secondary_text_width;
84 86
85 checkbox_->SetBounds(area.x(), area.y(), checkbox_width, area.height()); 87 checkbox_->SetBounds(area.x(), area.y(), checkbox_width, area.height());
86 if (secondary_text_->visible()) { 88 if (secondary_text_->visible()) {
87 secondary_text_->SetBounds(checkbox_->x() + checkbox_width, area.y(), 89 secondary_text_->SetBounds(checkbox_->x() + checkbox_width, area.y(),
88 secondary_text_width, area.height()); 90 secondary_text_width, area.height());
89 } 91 }
90 } 92 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698