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

Unified Diff: chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm

Issue 2890233003: Dynamically Adjust Screen Item Size According To Item Count (Closed)
Patch Set: Fix Unit test fail Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm
diff --git a/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm b/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm
index 5a660e5ae02eb48254335505ca4a96028680c17b..9fabd474e980467da3800f10b24494f935873bf4 100644
--- a/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm
+++ b/chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm
@@ -40,6 +40,8 @@ const CGFloat kThumbnailWidth = 150;
const CGFloat kThumbnailHeight = 150;
const CGFloat kSingleScreenWidth = 300;
const CGFloat kSingleScreenHeight = 300;
+const CGFloat kMultipleScreenWidth = 220;
+const CGFloat kMultipleScreenHeight = 220;
const CGFloat kFramePadding = 20;
const CGFloat kControlSpacing = 10;
const CGFloat kExcessButtonPadding = 6;
@@ -279,9 +281,12 @@ NSString* const kTitleId = @"title";
- (void)createSourceViewsAtOrigin:(NSPoint)origin {
if (screenList_) {
- screenBrowser_.reset([[self
- createImageBrowserWithSize:NSMakeSize(kSingleScreenWidth,
- kSingleScreenHeight)] retain]);
+ const bool is_single = screenList_->GetSourceCount() <= 1;
+ const CGFloat width = is_single ? kSingleScreenWidth : kMultipleScreenWidth;
+ const CGFloat height =
+ is_single ? kSingleScreenHeight : kMultipleScreenHeight;
+ screenBrowser_.reset(
+ [[self createImageBrowserWithSize:NSMakeSize(width, height)] retain]);
}
if (windowList_) {
@@ -602,7 +607,6 @@ NSString* const kTitleId = @"title";
// "Entire Screen", because it is redundant with tab label "Your Entire
// Screen".
[item setTitleHidden:browser == screenBrowser_ && [items count] == 1];
-
return item;
}
@@ -693,10 +697,16 @@ NSString* const kTitleId = @"title";
if (sourceType == DesktopMediaID::TYPE_WEB_CONTENTS) {
// Memorizing selection.
[self setTabBrowserIndex:selectedIndex];
- } else if (sourceType == DesktopMediaID::TYPE_SCREEN && [items count] == 1) {
- // Preselect the first screen source.
- [browser setSelectionIndexes:[NSIndexSet indexSetWithIndex:0]
- byExtendingSelection:NO];
+ } else if (sourceType == DesktopMediaID::TYPE_SCREEN) {
+ if ([items count] == 1) {
+ // Preselect the first screen source.
+ [browser setSelectionIndexes:[NSIndexSet indexSetWithIndex:0]
+ byExtendingSelection:NO];
+ } else if ([items count] == 2) {
+ // Switch to multiple sources mode.
+ [browser
+ setCellSize:NSMakeSize(kMultipleScreenWidth, kMultipleScreenHeight)];
+ }
}
NSString* autoselectSource = base::SysUTF8ToNSString(
@@ -731,6 +741,8 @@ NSString* const kTitleId = @"title";
[browser setSelectionIndexes:[NSIndexSet indexSet] byExtendingSelection:NO];
}
[items removeObjectAtIndex:index];
+ if (sourceType == DesktopMediaID::TYPE_SCREEN && [items count] == 1)
+ [browser setCellSize:NSMakeSize(kSingleScreenWidth, kSingleScreenHeight)];
[browser reloadData];
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698