From bb01b9612a0dfbfab832bec36d53c7a6856166ce Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Tue, 26 Jan 2010 17:56:59 +0000 Subject: Mac: Improve task manager column resizing, set min window size. xib changes: Set min window size to 300x200, change table view column resizing to "Uniform". Give task manager columns min max widths. BUG=33133,33134 TEST=See bugs. Review URL: http://codereview.chromium.org/551148 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37114 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/app/nibs/TaskManager.xib | 17 +++++---- chrome/browser/cocoa/task_manager_mac.mm | 59 ++++++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 11 deletions(-) (limited to 'chrome') diff --git a/chrome/app/nibs/TaskManager.xib b/chrome/app/nibs/TaskManager.xib index ceed983..3f72abc 100644 --- a/chrome/app/nibs/TaskManager.xib +++ b/chrome/app/nibs/TaskManager.xib @@ -43,6 +43,7 @@ NSWindow {3.40282e+38, 3.40282e+38} + {300, 200} 256 @@ -154,8 +155,8 @@ 1.600000e+01 - 1522532352 - 4 + 1522565120 + 1 15 0 YES @@ -286,6 +287,7 @@ {{0, 0}, {1680, 1028}} + {300, 222} {3.40282e+38, 3.40282e+38} @@ -549,6 +551,8 @@ 1.NSWindowTemplate.visibleAtLaunch 1.WindowOrigin 1.editorWindowContentRectSynchronizationRect + 1.windowTemplate.hasMinSize + 1.windowTemplate.minSize 11.IBPluginDependency 12.IBPluginDependency 13.IBPluginDependency @@ -576,6 +580,8 @@ {196, 240} {{357, 418}, {480, 270}} + + {300, 200} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -715,13 +721,6 @@ - NSWindow - - IBProjectSource - browser/cocoa/nswindow_local_state.h - - - TaskManagerWindowController NSWindowController diff --git a/chrome/browser/cocoa/task_manager_mac.mm b/chrome/browser/cocoa/task_manager_mac.mm index 593d9a1..caf5c59 100644 --- a/chrome/browser/cocoa/task_manager_mac.mm +++ b/chrome/browser/cocoa/task_manager_mac.mm @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,11 +15,45 @@ #include "chrome/common/pref_names.h" #include "grit/generated_resources.h" -// TODO(thakis): Better resizing behavior (and think about storing column sizes) // TODO(thakis): Column sort comparator // TODO(thakis): Clicking column header doesn't sort // TODO(thakis): Default sort column +// Width of "a" and most other letters/digits in "small" table views. +static const int kCharWidth = 6; + +// Some of the strings below have spaces at the end or are missing letters, to +// make the columns look nicer, and to take potentially longer localized strings +// into account. +static const struct ColumnWidth { + int columnId; + int minWidth; + int maxWidth; // If this is -1, 1.5*minColumWidth is used as max width. +} columnWidths[] = { + // Note that arraysize includes the trailing \0. That's intended. + { IDS_TASK_MANAGER_PAGE_COLUMN, 120, 600 }, + { IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN, + arraysize("800 MiB") * kCharWidth, -1 }, + { IDS_TASK_MANAGER_SHARED_MEM_COLUMN, + arraysize("800 MiB") * kCharWidth, -1 }, + { IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN, + arraysize("800 MiB") * kCharWidth, -1 }, + { IDS_TASK_MANAGER_CPU_COLUMN, + arraysize("99.9") * kCharWidth, -1 }, + { IDS_TASK_MANAGER_NET_COLUMN, + arraysize("150 kiB/s") * kCharWidth, -1 }, + { IDS_TASK_MANAGER_PROCESS_ID_COLUMN, + arraysize("73099 ") * kCharWidth, -1 }, + { IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN, + arraysize("2000.0K (2000.0 live)") * kCharWidth, -1 }, + { IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN, + arraysize("2000.0K (2000.0 live)") * kCharWidth, -1 }, + { IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN, + arraysize("2000.0K (2000.0 live)") * kCharWidth, -1 }, + { IDS_TASK_MANAGER_GOATS_TELEPORTED_COLUMN, + arraysize("15 ") * kCharWidth, -1 }, +}; + @interface TaskManagerWindowController (Private) - (NSTableColumn*)addColumnWithId:(int)columnId visible:(BOOL)isVisible; - (void)setUpTableColumns; @@ -106,6 +140,27 @@ [column.get() setHidden:!isVisible]; [column.get() setEditable:NO]; + + // Default values, only used in release builds if nobody notices the DCHECK + // during development when adding new columns. + int minWidth = 200, maxWidth = 400; + + size_t i; + for (i = 0; i < arraysize(columnWidths); ++i) { + if (columnWidths[i].columnId == columnId) { + minWidth = columnWidths[i].minWidth; + maxWidth = columnWidths[i].maxWidth; + if (maxWidth < 0) + maxWidth = 3 * minWidth / 2; // *1.5 for ints. + break; + } + } + DCHECK(i < arraysize(columnWidths)) << "Could not find " << columnId; + [column.get() setMinWidth:minWidth]; + [column.get() setMaxWidth:maxWidth]; + [column.get() setResizingMask:NSTableColumnAutoresizingMask | + NSTableColumnUserResizingMask]; + [tableView_ addTableColumn:column.get()]; return column.get(); // Now retained by |tableView_|. } -- cgit v1.1