Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/desktop_capture/desktop_media_picker_views.h" | 5 #include "chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "chrome/browser/media/desktop_media_list.h" | 9 #include "chrome/browser/media/desktop_media_list.h" |
| 10 #include "chrome/browser/ui/views/desktop_capture/desktop_media_list_view.h" | 10 #include "chrome/browser/ui/views/desktop_capture/desktop_media_list_view.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 views::BoxLayout::kVertical, views::kButtonHEdgeMarginNew, | 68 views::BoxLayout::kVertical, views::kButtonHEdgeMarginNew, |
| 69 views::kPanelVertMargin, views::kLabelToControlVerticalSpacing)); | 69 views::kPanelVertMargin, views::kLabelToControlVerticalSpacing)); |
| 70 | 70 |
| 71 description_label_->SetMultiLine(true); | 71 description_label_->SetMultiLine(true); |
| 72 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 72 description_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 73 AddChildView(description_label_); | 73 AddChildView(description_label_); |
| 74 | 74 |
| 75 if (screen_list) { | 75 if (screen_list) { |
| 76 source_types_.push_back(DesktopMediaID::TYPE_SCREEN); | 76 source_types_.push_back(DesktopMediaID::TYPE_SCREEN); |
| 77 | 77 |
| 78 const DesktopMediaSourceViewStyle kSingleScreenStyle( | |
|
msw
2016/05/20 23:26:36
Hard-coding all these values is a fairly strange a
qiangchen
2016/05/24 00:03:37
My understanding of the different styles is:
For
| |
| 79 1, // columns | |
| 80 gfx::Size(360, 280), // item_size | |
| 81 gfx::Rect(20, 220, 320, 40), // label_position | |
|
msw
2016/05/20 23:26:37
Does this work well enough for internationalizatio
qiangchen
2016/05/24 00:03:37
It should work, as I use the same height, and not
| |
| 82 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment | |
| 83 gfx::Rect(20, 20, 320, 200), // image_position | |
| 84 2, // selection_border_thickness | |
| 85 5, // paint_inset_horizontal | |
| 86 5); // paint_inset_vertical | |
| 87 | |
| 88 const DesktopMediaSourceViewStyle kGenericScreenStyle( | |
| 89 2, // columns | |
| 90 gfx::Size(270, 220), // item_size | |
| 91 gfx::Rect(15, 165, 240, 40), // label_position | |
| 92 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment | |
| 93 gfx::Rect(15, 15, 240, 150), // image_position | |
| 94 2, // selection_border_thickness | |
| 95 5, // paint_inset_horizontal | |
| 96 5); // paint_inset_vertical | |
| 97 | |
| 78 views::ScrollView* screen_scroll_view = | 98 views::ScrollView* screen_scroll_view = |
| 79 views::ScrollView::CreateScrollViewWithBorder(); | 99 views::ScrollView::CreateScrollViewWithBorder(); |
| 80 list_views_.push_back( | 100 list_views_.push_back(new DesktopMediaListView( |
| 81 new DesktopMediaListView(this, std::move(screen_list))); | 101 this, std::move(screen_list), kSingleScreenStyle, kGenericScreenStyle)); |
| 82 | 102 |
| 83 screen_scroll_view->SetContents(list_views_.back()); | 103 screen_scroll_view->SetContents(list_views_.back()); |
| 84 screen_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 104 screen_scroll_view->ClipHeightTo( |
| 105 kGenericScreenStyle.item_size.height(), | |
| 106 kGenericScreenStyle.item_size.height() * 2); | |
| 107 screen_scroll_view->set_hide_horizontal_scrollbar(true); | |
|
msw
2016/05/20 23:26:36
Does this mean that we're overflowing the availabl
qiangchen
2016/05/24 00:03:37
Actually the sizes are guaranteed not to overflow.
msw
2016/05/24 18:54:25
I mentioned that calling SetSize in Layout seems w
qiangchen
2016/05/25 16:24:08
Without set_hide_horizontal_scrollbar here and Set
| |
| 85 pane_->AddTab( | 108 pane_->AddTab( |
| 86 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_SCREEN), | 109 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_SCREEN), |
| 87 screen_scroll_view); | 110 screen_scroll_view); |
| 88 pane_->set_listener(this); | 111 pane_->set_listener(this); |
| 89 } | 112 } |
| 90 | 113 |
| 91 if (window_list) { | 114 if (window_list) { |
| 92 source_types_.push_back(DesktopMediaID::TYPE_WINDOW); | 115 source_types_.push_back(DesktopMediaID::TYPE_WINDOW); |
| 116 | |
| 117 const DesktopMediaSourceViewStyle kWindowStyle( | |
| 118 3, // columns | |
| 119 gfx::Size(180, 160), // item_size | |
| 120 gfx::Rect(10, 110, 160, 40), // label_position | |
| 121 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment | |
| 122 gfx::Rect(8, 8, 164, 104), // image_position | |
| 123 2, // selection_border_thickness | |
| 124 5, // paint_inset_horizontal | |
| 125 5); // paint_inset_vertical | |
| 126 | |
| 93 views::ScrollView* window_scroll_view = | 127 views::ScrollView* window_scroll_view = |
| 94 views::ScrollView::CreateScrollViewWithBorder(); | 128 views::ScrollView::CreateScrollViewWithBorder(); |
| 95 list_views_.push_back( | 129 list_views_.push_back(new DesktopMediaListView(this, std::move(window_list), |
| 96 new DesktopMediaListView(this, std::move(window_list))); | 130 kWindowStyle, kWindowStyle)); |
| 97 | 131 |
| 98 window_scroll_view->SetContents(list_views_.back()); | 132 window_scroll_view->SetContents(list_views_.back()); |
| 99 window_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 133 window_scroll_view->ClipHeightTo(kWindowStyle.item_size.height(), |
| 134 kWindowStyle.item_size.height() * 2); | |
| 135 window_scroll_view->set_hide_horizontal_scrollbar(true); | |
| 100 | 136 |
| 101 pane_->AddTab( | 137 pane_->AddTab( |
| 102 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_WINDOW), | 138 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_WINDOW), |
| 103 window_scroll_view); | 139 window_scroll_view); |
| 104 pane_->set_listener(this); | 140 pane_->set_listener(this); |
| 105 } | 141 } |
| 106 | 142 |
| 107 if (tab_list) { | 143 if (tab_list) { |
| 108 source_types_.push_back(DesktopMediaID::TYPE_WEB_CONTENTS); | 144 source_types_.push_back(DesktopMediaID::TYPE_WEB_CONTENTS); |
| 145 | |
| 146 const DesktopMediaSourceViewStyle kTabStyle( | |
| 147 1, // columns | |
| 148 gfx::Size(600, 30), // item_size | |
| 149 gfx::Rect(46, 0, 490, 30), // label_position | |
| 150 gfx::HorizontalAlignment::ALIGN_LEFT, // text_alignment | |
| 151 gfx::Rect(10, 2, 26, 26), // image_position | |
| 152 1, // selection_border_thickness | |
| 153 0, // paint_inset_horizontal | |
| 154 0); // paint_inset_vertical | |
| 155 | |
| 109 views::ScrollView* tab_scroll_view = | 156 views::ScrollView* tab_scroll_view = |
| 110 views::ScrollView::CreateScrollViewWithBorder(); | 157 views::ScrollView::CreateScrollViewWithBorder(); |
| 111 list_views_.push_back(new DesktopMediaListView(this, std::move(tab_list))); | 158 list_views_.push_back(new DesktopMediaListView(this, std::move(tab_list), |
| 159 kTabStyle, kTabStyle)); | |
| 112 | 160 |
| 113 tab_scroll_view->SetContents(list_views_.back()); | 161 tab_scroll_view->SetContents(list_views_.back()); |
| 114 tab_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 162 tab_scroll_view->ClipHeightTo(kTabStyle.item_size.height(), |
| 163 kTabStyle.item_size.height() * 2); | |
| 164 tab_scroll_view->set_hide_horizontal_scrollbar(true); | |
| 115 | 165 |
| 116 pane_->AddTab( | 166 pane_->AddTab( |
| 117 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_TAB), | 167 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_TAB), |
| 118 tab_scroll_view); | 168 tab_scroll_view); |
| 119 pane_->set_listener(this); | 169 pane_->set_listener(this); |
| 120 } | 170 } |
| 121 | 171 |
| 122 if (app_name == target_name) { | 172 if (app_name == target_name) { |
| 123 description_label_->SetText( | 173 description_label_->SetText( |
| 124 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); | 174 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 | 425 |
| 376 // static | 426 // static |
| 377 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 427 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
| 378 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 428 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 379 extensions::switches::kDisableDesktopCapturePickerOldUI)) { | 429 extensions::switches::kDisableDesktopCapturePickerOldUI)) { |
| 380 return std::unique_ptr<DesktopMediaPicker>( | 430 return std::unique_ptr<DesktopMediaPicker>( |
| 381 new deprecated::DesktopMediaPickerViews()); | 431 new deprecated::DesktopMediaPickerViews()); |
| 382 } | 432 } |
| 383 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 433 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
| 384 } | 434 } |
| OLD | NEW |