Additional undo/redo changes

This commit is contained in:
Damiano Galassi committed 2026-09-29 19:55:05 +02:00
1 parent 616cd9733b
commit cf35350ad3
6 files changed
+162 -15

No files matched your search

+23
View File
@@ -216,25 +216,48 @@ MP42_OBJC_DIRECT_MEMBERS
- (void)setVolume:(float)newVolume - (void)setVolume:(float)newVolume
{ {
if (_volume != newVolume) {
[[self.undo prepareWithInvocationTarget:self] setVolume:_volume];
}
_volume = newVolume; _volume = newVolume;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
self.updatedProperty[@"volume"] = @YES; self.updatedProperty[@"volume"] = @YES;
}
} }
- (void)setFallbackTrack:(MP42Track *)newFallbackTrack - (void)setFallbackTrack:(MP42Track *)newFallbackTrack
{ {
MP42Track *_fallbackTrackStrongRef = _fallbackTrack;
if (_fallbackTrackStrongRef != newFallbackTrack) {
[[self.undo prepareWithInvocationTarget:self] setFallbackTrack:_fallbackTrackStrongRef];
}
_fallbackTrack = newFallbackTrack; _fallbackTrack = newFallbackTrack;
_fallbackTrackId = 0; _fallbackTrackId = 0;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
self.updatedProperty[@"fallback"] = @YES; self.updatedProperty[@"fallback"] = @YES;
}
} }
- (void)setFollowsTrack:(MP42Track *)newFollowsTrack - (void)setFollowsTrack:(MP42Track *)newFollowsTrack
{ {
MP42Track *_followsTrackStrongRef = _followsTrack;
if (_followsTrackStrongRef != newFollowsTrack) {
[[self.undo prepareWithInvocationTarget:self] setFollowsTrack:_followsTrackStrongRef];
}
_followsTrack = newFollowsTrack; _followsTrack = newFollowsTrack;
_followsTrackId = 0; _followsTrackId = 0;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
self.updatedProperty[@"follows"] = @YES; self.updatedProperty[@"follows"] = @YES;
}
} }
- (NSString *)formatSummary - (NSString *)formatSummary
+2
View File
@@ -200,6 +200,8 @@ typedef void (^MP42FileProgressHandler)(double progress);
*/ */
- (void)cancel; - (void)cancel;
@property (nonatomic, readwrite, nullable) NSUndoManager *undo;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
+8
View File
@@ -1409,4 +1409,12 @@ MP42_OBJC_DIRECT_MEMBERS
[self.URL stopAccessingSecurityScopedResource]; [self.URL stopAccessingSecurityScopedResource];
} }
- (void)setUndo:(NSUndoManager *)undo {
_undo = undo;
for (MP42Track *track in self.tracks) {
track.undo = undo;
}
}
@end @end
+14 -3
View File
@@ -121,18 +121,29 @@ MP42_OBJC_DIRECT_MEMBERS
- (void)setSomeSamplesAreForced:(BOOL)value - (void)setSomeSamplesAreForced:(BOOL)value
{ {
_someSamplesAreForced = value; if (_someSamplesAreForced != value) {
self.edited = YES; [[self.undo prepareWithInvocationTarget:self] setSomeSamplesAreForced:_someSamplesAreForced];
}
_someSamplesAreForced = value;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES;
self.updatedProperty[@"forcedSubtitles"] = @YES; self.updatedProperty[@"forcedSubtitles"] = @YES;
}
} }
- (void)setAllSamplesAreForced:(BOOL)value - (void)setAllSamplesAreForced:(BOOL)value
{ {
if (_allSamplesAreForced != value) {
[[self.undo prepareWithInvocationTarget:self] setAllSamplesAreForced:_allSamplesAreForced];
}
_allSamplesAreForced = value; _allSamplesAreForced = value;
self.edited = YES;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES;
self.updatedProperty[@"forcedSubtitles"] = @YES; self.updatedProperty[@"forcedSubtitles"] = @YES;
}
} }
- (BOOL)canExport - (BOOL)canExport
+24 -6
View File
@@ -260,6 +260,15 @@ typedef struct muxer_helper {
return StringFromTime(_duration, 1000); return StringFromTime(_duration, 1000);
} }
- (void)setEdited:(BOOL)edited
{
if (_edited != edited) {
[[self.undo prepareWithInvocationTarget:self] setEdited:_edited];
}
_edited = edited;
}
@synthesize name = _name; @synthesize name = _name;
- (NSString *)name { - (NSString *)name {
@@ -275,6 +284,10 @@ typedef struct muxer_helper {
- (void)setName:(NSString *)newName - (void)setName:(NSString *)newName
{ {
if ([newName isEqualToString:_name] == NO) {
[(MP42Track *)[self.undo prepareWithInvocationTarget:self] setName:_name];
}
if (newName.length) { if (newName.length) {
_name = [newName copy]; _name = [newName copy];
} }
@@ -290,10 +303,11 @@ typedef struct muxer_helper {
- (void)setLanguage:(NSString *)language - (void)setLanguage:(NSString *)language
{ {
if (![_language isEqualToString:language]) { if (![_language isEqualToString:language]) {
[[self.undo prepareWithInvocationTarget:self] setMediaCharacteristicTags:_mediaCharacteristicTags]; [(MP42Track *)[self.undo prepareWithInvocationTarget:self] setLanguage:_language];
_language = [language copy];
} }
_language = [language copy];
if (!(self.undo.isUndoing || self.undo.isRedoing)) { if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
_updatedProperty[@"language"] = @YES; _updatedProperty[@"language"] = @YES;
@@ -304,9 +318,10 @@ typedef struct muxer_helper {
{ {
if (![_mediaCharacteristicTags isEqualToSet:mediaCharacteristicTags]) { if (![_mediaCharacteristicTags isEqualToSet:mediaCharacteristicTags]) {
[[self.undo prepareWithInvocationTarget:self] setMediaCharacteristicTags:_mediaCharacteristicTags]; [[self.undo prepareWithInvocationTarget:self] setMediaCharacteristicTags:_mediaCharacteristicTags];
_mediaCharacteristicTags = [mediaCharacteristicTags copy];
} }
_mediaCharacteristicTags = [mediaCharacteristicTags copy];
if (!(self.undo.isUndoing || self.undo.isRedoing)) { if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
_updatedProperty[@"mediaCharacteristicTags"] = @YES; _updatedProperty[@"mediaCharacteristicTags"] = @YES;
@@ -317,9 +332,10 @@ typedef struct muxer_helper {
{ {
if (_enabled != enabled) { if (_enabled != enabled) {
[[self.undo prepareWithInvocationTarget:self] setEnabled:_enabled]; [[self.undo prepareWithInvocationTarget:self] setEnabled:_enabled];
_enabled = enabled;
} }
_enabled = enabled;
if (!(self.undo.isUndoing || self.undo.isRedoing)) { if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
_updatedProperty[@"enabled"] = @YES; _updatedProperty[@"enabled"] = @YES;
@@ -330,9 +346,10 @@ typedef struct muxer_helper {
{ {
if (_alternateGroup != alternateGroup) { if (_alternateGroup != alternateGroup) {
[[self.undo prepareWithInvocationTarget:self] setAlternateGroup:_alternateGroup]; [[self.undo prepareWithInvocationTarget:self] setAlternateGroup:_alternateGroup];
_alternateGroup = alternateGroup;
} }
_alternateGroup = alternateGroup;
if (!(self.undo.isUndoing || self.undo.isRedoing)) { if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
_updatedProperty[@"alternate_group"] = @YES; _updatedProperty[@"alternate_group"] = @YES;
@@ -343,9 +360,10 @@ typedef struct muxer_helper {
{ {
if (_startOffset != startOffset) { if (_startOffset != startOffset) {
[[self.undo prepareWithInvocationTarget:self] setStartOffset:_startOffset]; [[self.undo prepareWithInvocationTarget:self] setStartOffset:_startOffset];
_startOffset = startOffset;
} }
_startOffset = startOffset;
if (!(self.undo.isUndoing || self.undo.isRedoing)) { if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
_updatedProperty[@"start_offset"] = @YES; _updatedProperty[@"start_offset"] = @YES;
+91 -6
View File
@@ -428,82 +428,160 @@ static uint32_t convertToFixedPoint(CGFloat value) {
- (void)setTrackWidth:(float)trackWidth - (void)setTrackWidth:(float)trackWidth
{ {
if (_trackWidth != trackWidth) {
[[self.undo prepareWithInvocationTarget:self] setTrackWidth:_trackWidth];
}
_trackWidth = trackWidth; _trackWidth = trackWidth;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
}
} }
- (void)setTrackHeight:(float)trackHeight - (void)setTrackHeight:(float)trackHeight
{ {
if (_trackHeight != trackHeight) {
[[self.undo prepareWithInvocationTarget:self] setTrackHeight:_trackHeight];
}
_trackHeight = trackHeight; _trackHeight = trackHeight;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
}
} }
- (void)setTransform:(CGAffineTransform)transform - (void)setTransform:(CGAffineTransform)transform
{ {
if (CGAffineTransformEqualToTransform(_transform, transform) == false) {
[(MP42VideoTrack *)[self.undo prepareWithInvocationTarget:self] setTransform:_transform];
}
_transform = transform; _transform = transform;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
}
} }
- (void)setColorPrimaries:(uint16_t)colorPrimaries - (void)setColorPrimaries:(uint16_t)colorPrimaries
{ {
self.updatedProperty[@"colr"] = @YES; if (_colorPrimaries != colorPrimaries) {
[[self.undo prepareWithInvocationTarget:self] setColorPrimaries:_colorPrimaries];
}
_colorPrimaries = colorPrimaries; _colorPrimaries = colorPrimaries;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.updatedProperty[@"colr"] = @YES;
self.edited = YES; self.edited = YES;
}
} }
- (void)setTransferCharacteristics:(uint16_t)transferCharacteristics - (void)setTransferCharacteristics:(uint16_t)transferCharacteristics
{ {
self.updatedProperty[@"colr"] = @YES; if (_transferCharacteristics != transferCharacteristics) {
[[self.undo prepareWithInvocationTarget:self] setTransferCharacteristics:_transferCharacteristics];
}
_transferCharacteristics = transferCharacteristics; _transferCharacteristics = transferCharacteristics;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.updatedProperty[@"colr"] = @YES;
self.edited = YES; self.edited = YES;
}
} }
- (void)setMatrixCoefficients:(uint16_t)matrixCoefficients - (void)setMatrixCoefficients:(uint16_t)matrixCoefficients
{ {
self.updatedProperty[@"colr"] = @YES; if (_matrixCoefficients != matrixCoefficients) {
[[self.undo prepareWithInvocationTarget:self] setMatrixCoefficients:_matrixCoefficients];
}
_matrixCoefficients = matrixCoefficients; _matrixCoefficients = matrixCoefficients;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.updatedProperty[@"colr"] = @YES;
self.edited = YES; self.edited = YES;
}
} }
- (void)setColorRange:(uint16_t)colorRange - (void)setColorRange:(uint16_t)colorRange
{ {
self.updatedProperty[@"colr"] = @YES; if (_colorRange != colorRange) {
[[self.undo prepareWithInvocationTarget:self] setColorRange:_colorRange];
}
_colorRange = colorRange; _colorRange = colorRange;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.updatedProperty[@"colr"] = @YES;
self.edited = YES; self.edited = YES;
}
} }
- (void)setMastering:(MP42MasteringDisplayMetadata)mastering - (void)setMastering:(MP42MasteringDisplayMetadata)mastering
{ {
self.updatedProperty[@"mdcv"] = @YES; [[self.undo prepareWithInvocationTarget:self] setMastering:_mastering];
_mastering = mastering; _mastering = mastering;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.updatedProperty[@"mdcv"] = @YES;
self.edited = YES; self.edited = YES;
}
} }
- (void)setColl:(MP42ContentLightMetadata)coll - (void)setColl:(MP42ContentLightMetadata)coll
{ {
self.updatedProperty[@"coll"] = @YES; [[self.undo prepareWithInvocationTarget:self] setColl:_coll];
_coll = coll; _coll = coll;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.updatedProperty[@"coll"] = @YES;
self.edited = YES; self.edited = YES;
}
} }
- (void)setHSpacing:(uint64_t)newHSpacing - (void)setHSpacing:(uint64_t)newHSpacing
{ {
if (_hSpacing != newHSpacing) {
[[self.undo prepareWithInvocationTarget:self] setHSpacing:_hSpacing];
}
_hSpacing = newHSpacing; _hSpacing = newHSpacing;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
self.updatedProperty[@"hSpacing"] = @YES; self.updatedProperty[@"hSpacing"] = @YES;
}
} }
- (void)setVSpacing:(uint64_t)newVSpacing - (void)setVSpacing:(uint64_t)newVSpacing
{ {
if (_vSpacing != newVSpacing) {
[[self.undo prepareWithInvocationTarget:self] setVSpacing:_vSpacing];
}
_vSpacing = newVSpacing; _vSpacing = newVSpacing;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
self.updatedProperty[@"vSpacing"] = @YES; self.updatedProperty[@"vSpacing"] = @YES;
}
} }
- (void)setNewProfile:(uint8_t)newProfile - (void)setNewProfile:(uint8_t)newProfile
{ {
if (_newProfile != newProfile) {
[[self.undo prepareWithInvocationTarget:self] setNewProfile:_newProfile];
}
_newProfile = newProfile; _newProfile = newProfile;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
}
if (_newProfile == _origProfile) { if (_newProfile == _origProfile) {
self.updatedProperty[@"profile"] = @NO; self.updatedProperty[@"profile"] = @NO;
@@ -515,8 +593,15 @@ static uint32_t convertToFixedPoint(CGFloat value) {
- (void)setNewLevel:(uint8_t)newLevel - (void)setNewLevel:(uint8_t)newLevel
{ {
if (_newLevel != newLevel) {
[[self.undo prepareWithInvocationTarget:self] setNewLevel:_newLevel];
}
_newLevel = newLevel; _newLevel = newLevel;
if (!(self.undo.isUndoing || self.undo.isRedoing)) {
self.edited = YES; self.edited = YES;
}
if (_newLevel == _origLevel) { if (_newLevel == _origLevel) {
self.updatedProperty[@"level"] = @NO; self.updatedProperty[@"level"] = @NO;