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( | |
| 79 1, // columns | |
| 80 gfx::Size(360, 280), // item_size | |
| 81 gfx::Rect(0, 0, 0, 0), // label_rect | |
| 82 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment | |
| 83 gfx::Rect(20, 20, 320, 240), // image_rect | |
| 84 4, // selection_border_thickness | |
| 85 5); // focus_rectangle_inset | |
| 86 | |
| 87 const DesktopMediaSourceViewStyle kGenericScreenStyle( | |
| 88 2, // columns | |
| 89 gfx::Size(270, 220), // item_size | |
| 90 gfx::Rect(15, 165, 240, 40), // label_rect | |
| 91 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment | |
| 92 gfx::Rect(15, 15, 240, 150), // image_rect | |
| 93 2, // selection_border_thickness | |
| 94 5); // focus_rectangle_inset | |
| 95 | |
| 78 views::ScrollView* screen_scroll_view = | 96 views::ScrollView* screen_scroll_view = |
| 79 views::ScrollView::CreateScrollViewWithBorder(); | 97 views::ScrollView::CreateScrollViewWithBorder(); |
| 80 list_views_.push_back( | 98 list_views_.push_back(new DesktopMediaListView( |
| 81 new DesktopMediaListView(this, std::move(screen_list))); | 99 this, std::move(screen_list), kGenericScreenStyle, kSingleScreenStyle)); |
| 82 | 100 |
| 83 screen_scroll_view->SetContents(list_views_.back()); | 101 screen_scroll_view->SetContents(list_views_.back()); |
| 84 screen_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 102 screen_scroll_view->ClipHeightTo( |
| 103 kGenericScreenStyle.item_size.height(), | |
| 104 kGenericScreenStyle.item_size.height() * 2); | |
| 105 | |
| 85 pane_->AddTab( | 106 pane_->AddTab( |
| 86 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_SCREEN), | 107 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_SCREEN), |
| 87 screen_scroll_view); | 108 screen_scroll_view); |
| 88 pane_->set_listener(this); | 109 pane_->set_listener(this); |
| 89 } | 110 } |
| 90 | 111 |
| 91 if (window_list) { | 112 if (window_list) { |
| 92 source_types_.push_back(DesktopMediaID::TYPE_WINDOW); | 113 source_types_.push_back(DesktopMediaID::TYPE_WINDOW); |
| 114 | |
| 115 const DesktopMediaSourceViewStyle kWindowStyle( | |
| 116 3, // columns | |
| 117 gfx::Size(180, 160), // item_size | |
| 118 gfx::Rect(10, 110, 160, 40), // label_rect | |
| 119 gfx::HorizontalAlignment::ALIGN_CENTER, // text_alignment | |
| 120 gfx::Rect(8, 8, 164, 104), // image_rect | |
| 121 2, // selection_border_thickness | |
| 122 5); // focus_rectangle_inset | |
| 123 | |
| 93 views::ScrollView* window_scroll_view = | 124 views::ScrollView* window_scroll_view = |
| 94 views::ScrollView::CreateScrollViewWithBorder(); | 125 views::ScrollView::CreateScrollViewWithBorder(); |
| 95 list_views_.push_back( | 126 list_views_.push_back(new DesktopMediaListView(this, std::move(window_list), |
|
msw
2016/05/24 18:54:25
nit: format like lines 152/153?
qiangchen
2016/05/25 16:24:08
Done.
| |
| 96 new DesktopMediaListView(this, std::move(window_list))); | 127 kWindowStyle)); |
| 97 | |
| 98 window_scroll_view->SetContents(list_views_.back()); | 128 window_scroll_view->SetContents(list_views_.back()); |
| 99 window_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 129 window_scroll_view->ClipHeightTo(kWindowStyle.item_size.height(), |
| 130 kWindowStyle.item_size.height() * 2); | |
| 100 | 131 |
| 101 pane_->AddTab( | 132 pane_->AddTab( |
| 102 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_WINDOW), | 133 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_WINDOW), |
| 103 window_scroll_view); | 134 window_scroll_view); |
| 104 pane_->set_listener(this); | 135 pane_->set_listener(this); |
| 105 } | 136 } |
| 106 | 137 |
| 107 if (tab_list) { | 138 if (tab_list) { |
| 108 source_types_.push_back(DesktopMediaID::TYPE_WEB_CONTENTS); | 139 source_types_.push_back(DesktopMediaID::TYPE_WEB_CONTENTS); |
| 140 | |
| 141 const DesktopMediaSourceViewStyle kTabStyle( | |
| 142 1, // columns | |
| 143 gfx::Size(600, 30), // item_size | |
| 144 gfx::Rect(46, 0, 490, 30), // label_rect | |
| 145 gfx::HorizontalAlignment::ALIGN_LEFT, // text_alignment | |
| 146 gfx::Rect(10, 2, 26, 26), // image_rect | |
| 147 1, // selection_border_thickness | |
| 148 0); // focus_rectangle_inset | |
| 149 | |
| 109 views::ScrollView* tab_scroll_view = | 150 views::ScrollView* tab_scroll_view = |
| 110 views::ScrollView::CreateScrollViewWithBorder(); | 151 views::ScrollView::CreateScrollViewWithBorder(); |
| 111 list_views_.push_back(new DesktopMediaListView(this, std::move(tab_list))); | 152 list_views_.push_back( |
| 153 new DesktopMediaListView(this, std::move(tab_list), kTabStyle)); | |
| 112 | 154 |
| 113 tab_scroll_view->SetContents(list_views_.back()); | 155 tab_scroll_view->SetContents(list_views_.back()); |
| 114 tab_scroll_view->ClipHeightTo(kListItemHeight, kListItemHeight * 2); | 156 tab_scroll_view->ClipHeightTo(kTabStyle.item_size.height(), |
| 157 kTabStyle.item_size.height() * 2); | |
| 158 | |
| 159 // We want the hover shade to be the full row. | |
| 160 // Thus we make the DesktopMediaSourceView to horizontally overflow. | |
|
msw
2016/05/24 18:54:25
Can you avoid overflow by just setting the width o
qiangchen
2016/05/25 16:24:08
Dilemma:
The width will depend on whether we have
| |
| 161 // But on the other hand, we set the label size carefully not to overflow. | |
| 162 tab_scroll_view->set_hide_horizontal_scrollbar(true); | |
| 115 | 163 |
| 116 pane_->AddTab( | 164 pane_->AddTab( |
| 117 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_TAB), | 165 l10n_util::GetStringUTF16(IDS_DESKTOP_MEDIA_PICKER_SOURCE_TYPE_TAB), |
| 118 tab_scroll_view); | 166 tab_scroll_view); |
| 119 pane_->set_listener(this); | 167 pane_->set_listener(this); |
| 120 } | 168 } |
| 121 | 169 |
| 122 if (app_name == target_name) { | 170 if (app_name == target_name) { |
| 123 description_label_->SetText( | 171 description_label_->SetText( |
| 124 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); | 172 l10n_util::GetStringFUTF16(IDS_DESKTOP_MEDIA_PICKER_TEXT, app_name)); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 | 423 |
| 376 // static | 424 // static |
| 377 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 425 std::unique_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
| 378 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 426 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 379 extensions::switches::kDisableDesktopCapturePickerOldUI)) { | 427 extensions::switches::kDisableDesktopCapturePickerOldUI)) { |
| 380 return std::unique_ptr<DesktopMediaPicker>( | 428 return std::unique_ptr<DesktopMediaPicker>( |
| 381 new deprecated::DesktopMediaPickerViews()); | 429 new deprecated::DesktopMediaPickerViews()); |
| 382 } | 430 } |
| 383 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 431 return std::unique_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
| 384 } | 432 } |
| OLD | NEW |