mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-03 19:44:22 +00:00
Tests/Manual/People: Add Reduce motion setting
Add a Reduce motion checkbox to the Settings window that updates the workspace's application-level reduced-motion setting, persists in user defaults across launches, and resets via File > Reset Application…. Retain browser reduced-motion behavior when the checkbox is unchecked. Rename `applySavedAppearance` and `resetAppearance` to `applySavedSettings` and `resetSettings` to reflect both settings, and document the option in the README checklist.
This commit is contained in:
1 parent
5b4192e597
commit
2b54a289e9
4 files changed
+58
-21
No files matched your search
@@ -22,7 +22,7 @@
|
||||
*
|
||||
* Data (people, groups, smart folders) is persisted in CPUserDefaults.
|
||||
* Use File ▸ Reset Application… to return to the deterministic sample data and the
|
||||
* default toolbar, layout and appearance.
|
||||
* default toolbar, layout, appearance and Reduce motion setting.
|
||||
*
|
||||
* The application catches no exception. It tests the frameworks, so a
|
||||
* framework failure must show and must not fall back to a default. If the
|
||||
@@ -48,7 +48,7 @@
|
||||
{
|
||||
_library = [[Library alloc] init];
|
||||
|
||||
[SettingsWindowController applySavedAppearance];
|
||||
[SettingsWindowController applySavedSettings];
|
||||
|
||||
[self _buildMainMenu];
|
||||
[MainWindowController applySavedMenuBarVisibility];
|
||||
|
||||
@@ -3,8 +3,13 @@
|
||||
* People
|
||||
*
|
||||
* Settings window with the application's appearance: Light, Dark or Auto, which follows
|
||||
* the system. The choice is kept in the user defaults and applied at launch.
|
||||
* Exercises CPSegmentedControl, CPPanel and CPApplication's appearance.
|
||||
* the system, and a Reduce motion switch. The choices are kept in the user defaults and
|
||||
* applied at launch.
|
||||
* Exercises CPSegmentedControl, CPCheckBox, CPPanel, CPApplication's appearance and
|
||||
* CPWorkspace's reduced motion.
|
||||
*
|
||||
* Reduce motion sets the application's own value. It can turn reduced motion on, but it
|
||||
* cannot turn off the system setting: the workspace reduces motion when either one is on.
|
||||
*/
|
||||
|
||||
@import <AppKit/AppKit.j>
|
||||
@@ -12,33 +17,43 @@
|
||||
var SettingsAppearanceKey = @"PeopleAppearance",
|
||||
SettingsAppearanceNames = [CPAppearanceNameAqua, CPAppearanceNameDarkAqua, nil],
|
||||
SettingsAutoSegment = 2,
|
||||
SettingsAppearanceDidResetNotification = @"SettingsAppearanceDidResetNotification";
|
||||
SettingsReduceMotionKey = @"PeopleReduceMotion",
|
||||
SettingsDidResetNotification = @"SettingsDidResetNotification";
|
||||
|
||||
@implementation SettingsWindowController : CPWindowController
|
||||
{
|
||||
CPSegmentedControl _appearanceControl;
|
||||
CPCheckBox _reduceMotionCheckBox;
|
||||
}
|
||||
|
||||
/*
|
||||
Applies the appearance kept in the user defaults. Without one, the application follows
|
||||
the system appearance.
|
||||
Applies the settings kept in the user defaults. Without an appearance, the application
|
||||
follows the system appearance. Without a Reduce motion value, it follows the system
|
||||
setting only.
|
||||
*/
|
||||
+ (void)applySavedAppearance
|
||||
+ (void)applySavedSettings
|
||||
{
|
||||
var segment = [[CPUserDefaults standardUserDefaults] objectForKey:SettingsAppearanceKey];
|
||||
var defaults = [CPUserDefaults standardUserDefaults],
|
||||
segment = [defaults objectForKey:SettingsAppearanceKey];
|
||||
|
||||
[self _applyAppearanceOfSegment:segment == nil ? SettingsAutoSegment : segment];
|
||||
[[CPWorkspace sharedWorkspace] setApplicationShouldReduceMotion:[defaults boolForKey:SettingsReduceMotionKey]];
|
||||
}
|
||||
|
||||
/*
|
||||
Removes the kept appearance, so the application follows the system appearance again. An
|
||||
open Settings window shows Auto.
|
||||
Removes the kept settings, so the application follows the system appearance and the system
|
||||
reduced motion setting again. An open Settings window shows Auto and an unchecked Reduce
|
||||
motion.
|
||||
*/
|
||||
+ (void)resetAppearance
|
||||
+ (void)resetSettings
|
||||
{
|
||||
[[CPUserDefaults standardUserDefaults] removeObjectForKey:SettingsAppearanceKey];
|
||||
var defaults = [CPUserDefaults standardUserDefaults];
|
||||
|
||||
[defaults removeObjectForKey:SettingsAppearanceKey];
|
||||
[defaults removeObjectForKey:SettingsReduceMotionKey];
|
||||
[self _applyAppearanceOfSegment:SettingsAutoSegment];
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:SettingsAppearanceDidResetNotification object:self];
|
||||
[[CPWorkspace sharedWorkspace] setApplicationShouldReduceMotion:NO];
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:SettingsDidResetNotification object:self];
|
||||
}
|
||||
|
||||
+ (void)_applyAppearanceOfSegment:(int)aSegment
|
||||
@@ -50,7 +65,7 @@ var SettingsAppearanceKey = @"PeopleAppearance",
|
||||
|
||||
- (id)init
|
||||
{
|
||||
var panel = [[CPPanel alloc] initWithContentRect:CGRectMake(0, 0, 320, 90) styleMask:CPTitledWindowMask | CPClosableWindowMask];
|
||||
var panel = [[CPPanel alloc] initWithContentRect:CGRectMake(0, 0, 320, 120) styleMask:CPTitledWindowMask | CPClosableWindowMask];
|
||||
|
||||
if (self = [super initWithWindow:panel])
|
||||
{
|
||||
@@ -60,10 +75,10 @@ var SettingsAppearanceKey = @"PeopleAppearance",
|
||||
label = [CPTextField labelWithTitle:@"Appearance:"];
|
||||
|
||||
[label sizeToFit];
|
||||
[label setFrameOrigin:CGPointMake(20, 34)];
|
||||
[label setFrameOrigin:CGPointMake(20, 24)];
|
||||
[contentView addSubview:label];
|
||||
|
||||
_appearanceControl = [[CPSegmentedControl alloc] initWithFrame:CGRectMake(110, 30, 180, 24)];
|
||||
_appearanceControl = [[CPSegmentedControl alloc] initWithFrame:CGRectMake(110, 20, 180, 24)];
|
||||
[_appearanceControl setSegmentCount:3];
|
||||
[_appearanceControl setLabel:@"Light" forSegment:0];
|
||||
[_appearanceControl setLabel:@"Dark" forSegment:1];
|
||||
@@ -78,7 +93,15 @@ var SettingsAppearanceKey = @"PeopleAppearance",
|
||||
var segment = [[CPUserDefaults standardUserDefaults] objectForKey:SettingsAppearanceKey];
|
||||
[_appearanceControl setSelectedSegment:segment == nil ? SettingsAutoSegment : segment];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(appearanceDidReset:) name:SettingsAppearanceDidResetNotification object:nil];
|
||||
_reduceMotionCheckBox = [CPCheckBox checkBoxWithTitle:@"Reduce motion"];
|
||||
[_reduceMotionCheckBox sizeToFit];
|
||||
[_reduceMotionCheckBox setFrameOrigin:CGPointMake(110, 64)];
|
||||
[_reduceMotionCheckBox setState:[[CPUserDefaults standardUserDefaults] boolForKey:SettingsReduceMotionKey] ? CPOnState : CPOffState];
|
||||
[_reduceMotionCheckBox setTarget:self];
|
||||
[_reduceMotionCheckBox setAction:@selector(reduceMotionDidChange:)];
|
||||
[contentView addSubview:_reduceMotionCheckBox];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(settingsDidReset:) name:SettingsDidResetNotification object:nil];
|
||||
|
||||
[panel center];
|
||||
}
|
||||
@@ -86,9 +109,10 @@ var SettingsAppearanceKey = @"PeopleAppearance",
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)appearanceDidReset:(CPNotification)aNotification
|
||||
- (void)settingsDidReset:(CPNotification)aNotification
|
||||
{
|
||||
[_appearanceControl setSelectedSegment:SettingsAutoSegment];
|
||||
[_reduceMotionCheckBox setState:CPOffState];
|
||||
}
|
||||
|
||||
- (void)appearanceDidChange:(id)aSender
|
||||
@@ -99,4 +123,12 @@ var SettingsAppearanceKey = @"PeopleAppearance",
|
||||
[[self class] _applyAppearanceOfSegment:segment];
|
||||
}
|
||||
|
||||
- (void)reduceMotionDidChange:(id)aSender
|
||||
{
|
||||
var shouldReduceMotion = [aSender state] === CPOnState;
|
||||
|
||||
[[CPUserDefaults standardUserDefaults] setBool:shouldReduceMotion forKey:SettingsReduceMotionKey];
|
||||
[[CPWorkspace sharedWorkspace] setApplicationShouldReduceMotion:shouldReduceMotion];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -610,7 +610,7 @@ var ToolbarSidebarIdentifier = @"SidebarItem",
|
||||
[[CPUserDefaults standardUserDefaults] removeObjectForKey:MenuBarHiddenKey];
|
||||
[CPMenu setMenuBarVisible:YES];
|
||||
|
||||
[SettingsWindowController resetAppearance];
|
||||
[SettingsWindowController resetSettings];
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- Validation
|
||||
|
||||
@@ -66,7 +66,12 @@ spaces, because the legacy toolchain does not accept them.
|
||||
toolbar stays (autosave). While the sheet is open, the toolbar items do not act.
|
||||
The standard Colors item opens the colour panel. In both appearances its labels, the boxes
|
||||
around the preview and the swatches, and the opacity slider's track and knob show.
|
||||
13. File ▸ Reset Application…: alert sheet, then sample data, the menu bar shown, default toolbar (items, Icon and Text, regular size), default table columns (order and widths, Notes first), sidebar width, detail pane, empty recent searches and Auto appearance restored at once, without a reload. Cancel changes nothing.
|
||||
13. File ▸ Reset Application…: alert sheet, then sample data, the menu bar shown, default toolbar (items, Icon and Text, regular size), default table columns (order and widths, Notes first), sidebar width, detail pane, empty recent searches, Auto appearance and Reduce motion off restored at once, without a reload. Cancel changes nothing.
|
||||
14. People ▸ Settings… (⌘,): Appearance Light, Dark or Auto changes the application at once.
|
||||
Check Reduce motion: a sidebar disclosure triangle and the left and right arrow keys expand
|
||||
and collapse at once, without animation. Uncheck it: they animate again. Reload: both
|
||||
choices are restored. With Reduce motion unchecked, the system setting (System Settings ▸
|
||||
Accessibility ▸ Display ▸ Reduce motion) still stops the animation.
|
||||
|
||||
## Items to exercise
|
||||
|
||||
|
||||
Reference in new issue
Block a user