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
+185 -38

No files matched your search

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