Skip to content

Commit ef1a6ae

Browse files
committed
NSTableColumn: keep the resizable flag and resizing mask consistent
isResizable and the resizing mask were independent: setResizingMask: did not affect isResizable, and setResizable: did not affect the mask. OS X derives one from the other. Make setResizable: set the mask (to the auto/user combination or to no resizing) and setResizingMask: update the resizable flag, so the two stay consistent.
1 parent a6390a8 commit ef1a6ae

4 files changed

Lines changed: 80 additions & 12 deletions

File tree

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2026-07-12 Todd White <todd.white@thalion.global>
2+
3+
* Source/NSTableColumn.m (-[NSTableColumn setResizable:], -[NSTableColumn
4+
setResizingMask:]): Keep the resizable flag and the resizing mask
5+
consistent, as OS X does. setResizable: now sets the mask to the
6+
auto/user resizing combination or to no resizing, and setResizingMask:
7+
updates the resizable flag from whether the mask allows any resizing.
8+
* Tests/gui/NSTableColumn/resizableMask.m:
9+
* Tests/gui/NSTableColumn/TestInfo:
10+
New test for the resizable/mask relationship.
11+
112
2026-07-12 Todd White <todd.white@thalion.global>
213

314
* Tests/gui/NSTableHeaderCell/headerCell.m:

Source/NSTableColumn.m

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,15 @@ - (CGFloat) maxWidth
296296
- (void) setResizable: (BOOL)flag
297297
{
298298
_is_resizable = flag;
299-
// TODO: To match Cocoa behavior, should be replaced by
300-
//if (flag)
301-
// {
302-
// [self setResizingMask: NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask)];
303-
// }
304-
//else
305-
// {
306-
// [self setResizingMask: NSTableColumnNoResizing];
307-
// }
299+
if (flag)
300+
{
301+
_resizing_mask = NSTableColumnAutoresizingMask
302+
| NSTableColumnUserResizingMask;
303+
}
304+
else
305+
{
306+
_resizing_mask = NSTableColumnNoResizing;
307+
}
308308
}
309309

310310
/**
@@ -313,16 +313,15 @@ - (void) setResizable: (BOOL)flag
313313
- (BOOL) isResizable
314314
{
315315
return _is_resizable;
316-
// TODO: To match Cocoa behavior, should be replaced by
317-
//return (BOOL)[self autoresizingMask];
318316
}
319317

320318
/**
321-
Return the resizing mask that describes whether the column is resizable and how
319+
Return the resizing mask that describes whether the column is resizable and how
322320
it resizes. */
323321
- (void) setResizingMask: (NSUInteger)resizingMask
324322
{
325323
_resizing_mask = resizingMask;
324+
_is_resizable = (resizingMask != NSTableColumnNoResizing);
326325
}
327326

328327
/**

Tests/gui/NSTableColumn/TestInfo

Whitespace-only changes.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/* An NSTableColumn's resizable flag and its resizing mask stay consistent,
2+
as on OS X: setResizingMask: with no resizing makes the column not
3+
resizable, and setResizable: sets the mask to the auto/user resizing
4+
combination or to no resizing. */
5+
#include "Testing.h"
6+
7+
#include <Foundation/NSAutoreleasePool.h>
8+
9+
#include <AppKit/NSApplication.h>
10+
#include <AppKit/NSTableColumn.h>
11+
12+
int
13+
main(int argc, char **argv)
14+
{
15+
CREATE_AUTORELEASE_POOL(arp);
16+
17+
START_SET("NSTableColumn resizable / mask")
18+
19+
NS_DURING
20+
{
21+
[NSApplication sharedApplication];
22+
}
23+
NS_HANDLER
24+
{
25+
if ([[localException name] isEqualToString: NSInternalInconsistencyException])
26+
SKIP("It looks like GNUstep backend is not yet installed")
27+
}
28+
NS_ENDHANDLER
29+
30+
/* The resizing mask drives isResizable. */
31+
{
32+
NSTableColumn *col = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"c"]);
33+
34+
[col setResizingMask: NSTableColumnNoResizing];
35+
pass([col isResizable] == NO, "a no-resizing mask makes the column not resizable");
36+
[col setResizingMask: NSTableColumnUserResizingMask];
37+
pass([col isResizable] == YES, "a user-resizing mask makes the column resizable");
38+
}
39+
40+
/* setResizable: drives the mask. */
41+
{
42+
NSTableColumn *col = AUTORELEASE([[NSTableColumn alloc] initWithIdentifier: @"c"]);
43+
44+
[col setResizable: NO];
45+
pass([col resizingMask] == NSTableColumnNoResizing
46+
&& [col isResizable] == NO,
47+
"setResizable: NO clears the resizing mask");
48+
[col setResizable: YES];
49+
pass([col resizingMask] == (NSTableColumnAutoresizingMask | NSTableColumnUserResizingMask)
50+
&& [col isResizable] == YES,
51+
"setResizable: YES sets the auto and user resizing mask");
52+
}
53+
54+
END_SET("NSTableColumn resizable / mask")
55+
56+
DESTROY(arp);
57+
return 0;
58+
}

0 commit comments

Comments
 (0)