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

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: 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 screenBrowser_.reset([[self
283 createImageBrowserWithSize:NSMakeSize(kSingleScreenWidth, 285 createImageBrowserWithSize:NSMakeSize(kSingleScreenWidth,
tapted 2017/05/22 04:54:47 Can you pass the correct size here by inspecting |
qiangchen 2017/05/22 16:35:37 Done.
284 kSingleScreenHeight)] retain]); 286 kSingleScreenHeight)] retain]);
285 } 287 }
286 288
287 if (windowList_) { 289 if (windowList_) {
288 windowBrowser_.reset([ 290 windowBrowser_.reset([
289 [self createImageBrowserWithSize:NSMakeSize(kThumbnailWidth, 291 [self createImageBrowserWithSize:NSMakeSize(kThumbnailWidth,
290 kThumbnailHeight)] retain]); 292 kThumbnailHeight)] retain]);
291 } 293 }
292 294
293 if (tabList_) { 295 if (tabList_) {
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 596 }
595 597
596 - (id)imageBrowser:(IKImageBrowserView*)browser itemAtIndex:(NSUInteger)index { 598 - (id)imageBrowser:(IKImageBrowserView*)browser itemAtIndex:(NSUInteger)index {
597 DesktopMediaID::Type sourceType = [self sourceTypeForBrowser:browser]; 599 DesktopMediaID::Type sourceType = [self sourceTypeForBrowser:browser];
598 NSMutableArray* items = [self itemSetForType:sourceType]; 600 NSMutableArray* items = [self itemSetForType:sourceType];
599 DesktopMediaPickerItem* item = [items objectAtIndex:index]; 601 DesktopMediaPickerItem* item = [items objectAtIndex:index];
600 602
601 // For screen source, if there is only one source, we can omit the label 603 // 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 604 // "Entire Screen", because it is redundant with tab label "Your Entire
603 // Screen". 605 // Screen".
604 [item setTitleHidden:browser == screenBrowser_ && [items count] == 1]; 606 if (browser == screenBrowser_) {
607 if ([items count] > 1) {
608 [item setTitleHidden:NO];
609 [screenBrowser_
610 setCellSize:NSMakeSize(kMultipleScreenWidth, kMultipleScreenHeight)];
611 } else {
612 [item setTitleHidden:YES];
613 [screenBrowser_
614 setCellSize:NSMakeSize(kSingleScreenWidth, kSingleScreenHeight)];
615 }
616 }
tapted 2017/05/22 04:54:47 what if bowser != screenBrowser_? The old code wou
qiangchen 2017/05/22 16:35:37 For those cases, we never setTitleHidden to YES at
605 617
606 return item; 618 return item;
607 } 619 }
608 620
609 #pragma mark IKImageBrowserDelegate 621 #pragma mark IKImageBrowserDelegate
610 622
611 - (void)imageBrowser:(IKImageBrowserView*)browser 623 - (void)imageBrowser:(IKImageBrowserView*)browser
612 cellWasDoubleClickedAtIndex:(NSUInteger)index { 624 cellWasDoubleClickedAtIndex:(NSUInteger)index {
613 DesktopMediaPickerItem* item; 625 DesktopMediaPickerItem* item;
614 if (browser == screenBrowser_) 626 if (browser == screenBrowser_)
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 796
785 DesktopMediaPickerItem* item = [items objectAtIndex:index]; 797 DesktopMediaPickerItem* item = [items objectAtIndex:index];
786 [item setImageRepresentation:image]; 798 [item setImageRepresentation:image];
787 [browser reloadData]; 799 [browser reloadData];
788 800
789 if (sourceType == DesktopMediaID::TYPE_WEB_CONTENTS) 801 if (sourceType == DesktopMediaID::TYPE_WEB_CONTENTS)
790 [self setTabBrowserIndex:selectedIndex]; 802 [self setTabBrowserIndex:selectedIndex];
791 } 803 }
792 804
793 @end // @interface DesktopMediaPickerController 805 @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