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

Side by Side 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: Add Size Detection At Init 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h" 5 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 22 matching lines...) Expand all
33 33
34 namespace { 34 namespace {
35 35
36 const CGFloat kInitialContentWidth = 620; 36 const CGFloat kInitialContentWidth = 620;
37 const CGFloat kMinimumContentWidth = 500; 37 const CGFloat kMinimumContentWidth = 500;
38 const CGFloat kMinimumContentHeight = 390; 38 const CGFloat kMinimumContentHeight = 390;
39 const CGFloat kThumbnailWidth = 150; 39 const CGFloat kThumbnailWidth = 150;
40 const CGFloat kThumbnailHeight = 150; 40 const CGFloat kThumbnailHeight = 150;
41 const CGFloat kSingleScreenWidth = 300; 41 const CGFloat kSingleScreenWidth = 300;
42 const CGFloat kSingleScreenHeight = 300; 42 const CGFloat kSingleScreenHeight = 300;
43 const CGFloat kMultipleScreenWidth = 220;
44 const CGFloat kMultipleScreenHeight = 220;
43 const CGFloat kFramePadding = 20; 45 const CGFloat kFramePadding = 20;
44 const CGFloat kControlSpacing = 10; 46 const CGFloat kControlSpacing = 10;
45 const CGFloat kExcessButtonPadding = 6; 47 const CGFloat kExcessButtonPadding = 6;
46 const CGFloat kRowHeight = 20; 48 const CGFloat kRowHeight = 20;
47 const CGFloat kRowWidth = 500; 49 const CGFloat kRowWidth = 500;
48 const CGFloat kIconWidth = 20; 50 const CGFloat kIconWidth = 20;
49 const CGFloat kPaddedWidth = kInitialContentWidth - (kFramePadding * 2); 51 const CGFloat kPaddedWidth = kInitialContentWidth - (kFramePadding * 2);
50 const CGFloat kFontSize = 13; 52 const CGFloat kFontSize = 13;
51 53
52 NSString* const kIconId = @"icon"; 54 NSString* const kIconId = @"icon";
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 CGFloat controlWidth = NSWidth([sourceTypeControl_ frame]); 274 CGFloat controlWidth = NSWidth([sourceTypeControl_ frame]);
273 CGFloat controlHeight = NSHeight([sourceTypeControl_ frame]); 275 CGFloat controlHeight = NSHeight([sourceTypeControl_ frame]);
274 NSRect centerFrame = NSMakeRect((kInitialContentWidth - controlWidth) / 2, 276 NSRect centerFrame = NSMakeRect((kInitialContentWidth - controlWidth) / 2,
275 origin.y, controlWidth, controlHeight); 277 origin.y, controlWidth, controlHeight);
276 278
277 [sourceTypeControl_ setFrame:NSIntegralRect(centerFrame)]; 279 [sourceTypeControl_ setFrame:NSIntegralRect(centerFrame)];
278 } 280 }
279 281
280 - (void)createSourceViewsAtOrigin:(NSPoint)origin { 282 - (void)createSourceViewsAtOrigin:(NSPoint)origin {
281 if (screenList_) { 283 if (screenList_) {
282 screenBrowser_.reset([[self 284 const bool is_single = screenList_->GetSourceCount() <= 1;
283 createImageBrowserWithSize:NSMakeSize(kSingleScreenWidth, 285 const CGFloat width = is_single ? kSingleScreenWidth : kMultipleScreenWidth;
284 kSingleScreenHeight)] retain]); 286 const CGFloat height =
287 is_single ? kSingleScreenHeight : kMultipleScreenHeight;
288 screenBrowser_.reset(
289 [[self createImageBrowserWithSize:NSMakeSize(width, height)] retain]);
285 } 290 }
286 291
287 if (windowList_) { 292 if (windowList_) {
288 windowBrowser_.reset([ 293 windowBrowser_.reset([
289 [self createImageBrowserWithSize:NSMakeSize(kThumbnailWidth, 294 [self createImageBrowserWithSize:NSMakeSize(kThumbnailWidth,
290 kThumbnailHeight)] retain]); 295 kThumbnailHeight)] retain]);
291 } 296 }
292 297
293 if (tabList_) { 298 if (tabList_) {
294 tabBrowser_.reset([[NSTableView alloc] initWithFrame:NSZeroRect]); 299 tabBrowser_.reset([[NSTableView alloc] initWithFrame:NSZeroRect]);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 599 }
595 600
596 - (id)imageBrowser:(IKImageBrowserView*)browser itemAtIndex:(NSUInteger)index { 601 - (id)imageBrowser:(IKImageBrowserView*)browser itemAtIndex:(NSUInteger)index {
597 DesktopMediaID::Type sourceType = [self sourceTypeForBrowser:browser]; 602 DesktopMediaID::Type sourceType = [self sourceTypeForBrowser:browser];
598 NSMutableArray* items = [self itemSetForType:sourceType]; 603 NSMutableArray* items = [self itemSetForType:sourceType];
599 DesktopMediaPickerItem* item = [items objectAtIndex:index]; 604 DesktopMediaPickerItem* item = [items objectAtIndex:index];
600 605
601 // For screen source, if there is only one source, we can omit the label 606 // For screen source, if there is only one source, we can omit the label
602 // "Entire Screen", because it is redundant with tab label "Your Entire 607 // "Entire Screen", because it is redundant with tab label "Your Entire
603 // Screen". 608 // Screen".
604 [item setTitleHidden:browser == screenBrowser_ && [items count] == 1]; 609 if (browser == screenBrowser_) {
610 if ([items count] > 1) {
611 [item setTitleHidden:NO];
612 [screenBrowser_
613 setCellSize:NSMakeSize(kMultipleScreenWidth, kMultipleScreenHeight)];
tapted 2017/05/22 23:54:01 is this still needed? I don't think it should be h
qiangchen 2017/05/23 17:10:14 The list is dynamically updated in another thread,
614 } else {
615 [item setTitleHidden:YES];
616 [screenBrowser_
617 setCellSize:NSMakeSize(kSingleScreenWidth, kSingleScreenHeight)];
618 }
619 }
605 620
606 return item; 621 return item;
607 } 622 }
608 623
609 #pragma mark IKImageBrowserDelegate 624 #pragma mark IKImageBrowserDelegate
610 625
611 - (void)imageBrowser:(IKImageBrowserView*)browser 626 - (void)imageBrowser:(IKImageBrowserView*)browser
612 cellWasDoubleClickedAtIndex:(NSUInteger)index { 627 cellWasDoubleClickedAtIndex:(NSUInteger)index {
613 DesktopMediaPickerItem* item; 628 DesktopMediaPickerItem* item;
614 if (browser == screenBrowser_) 629 if (browser == screenBrowser_)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 799
785 DesktopMediaPickerItem* item = [items objectAtIndex:index]; 800 DesktopMediaPickerItem* item = [items objectAtIndex:index];
786 [item setImageRepresentation:image]; 801 [item setImageRepresentation:image];
787 [browser reloadData]; 802 [browser reloadData];
788 803
789 if (sourceType == DesktopMediaID::TYPE_WEB_CONTENTS) 804 if (sourceType == DesktopMediaID::TYPE_WEB_CONTENTS)
790 [self setTabBrowserIndex:selectedIndex]; 805 [self setTabBrowserIndex:selectedIndex];
791 } 806 }
792 807
793 @end // @interface DesktopMediaPickerController 808 @end // @interface DesktopMediaPickerController
OLDNEW
« 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