diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-05-11 21:05:56 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-05-11 21:05:56 +0200 |
| commit | 72f6f3de6a098cc74394e047aaa3fa5f9f44aa83 (patch) | |
| tree | 0f83898e07b18f18694a09e2209e8418454bab19 | |
| parent | a98f6e4f84d02b87ba05cecfcc3005858f274afa (diff) | |
Use case for property checks now that it's possible.
This would have prevented the bug fixed in 6bbf7dee.
| -rw-r--r-- | src/lib/film.cc | 7 | ||||
| -rw-r--r-- | src/wx/audio_dialog.cc | 7 | ||||
| -rw-r--r-- | src/wx/audio_panel.cc | 27 | ||||
| -rw-r--r-- | src/wx/content_timeline.cc | 18 | ||||
| -rw-r--r-- | src/wx/dcp_panel.cc | 30 | ||||
| -rw-r--r-- | src/wx/film_viewer.cc | 27 | ||||
| -rw-r--r-- | src/wx/text_panel.cc | 43 | ||||
| -rw-r--r-- | src/wx/timing_panel.cc | 47 | ||||
| -rw-r--r-- | src/wx/video_panel.cc | 45 |
9 files changed, 155 insertions, 96 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index c969ff699..f26dcaed0 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1571,10 +1571,13 @@ Film::active_frame_rate_change(DCPTime t) const void Film::playlist_content_change(ChangeType type, weak_ptr<Content> c, int p, bool frequent) { - if (p == ContentProperty::VIDEO_FRAME_RATE) { + switch (p) { + case ContentProperty::VIDEO_FRAME_RATE: signal_change(type, FilmProperty::CONTENT); - } else if (p == AudioContentProperty::STREAMS) { + break; + case AudioContentProperty::STREAMS: signal_change(type, FilmProperty::NAME); + break; } if (type == ChangeType::DONE) { diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index f0bd80ca0..9f31107f4 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -344,9 +344,11 @@ AudioDialog::content_change (ChangeType type, int p) return; } - if (p == AudioContentProperty::STREAMS) { + switch (p) { + case AudioContentProperty::STREAMS: try_to_load_analysis (); - } else if (p == AudioContentProperty::GAIN) { + break; + case AudioContentProperty::GAIN: if (_playlist->content().size() == 1 && _analysis) { /* We can use a short-cut to render the effect of this change, rather than recalculating everything. @@ -356,6 +358,7 @@ AudioDialog::content_change (ChangeType type, int p) } else { try_to_load_analysis (); } + break; } } diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc index 1418f1ff9..41e073dd1 100644 --- a/src/wx/audio_panel.cc +++ b/src/wx/audio_panel.cc @@ -214,8 +214,9 @@ AudioPanel::film_changed (FilmProperty property) void AudioPanel::film_content_changed (int property) { - auto ac = _parent->selected_audio (); - if (property == AudioContentProperty::STREAMS) { + auto const ac = _parent->selected_audio(); + switch (property) { + case AudioContentProperty::STREAMS: if (ac.size() == 1) { _mapping->set (ac.front()->audio->mapping()); _mapping->set_input_channels (ac.front()->audio->channel_names ()); @@ -242,13 +243,17 @@ AudioPanel::film_content_changed (int property) setup_description (); setup_peak (); layout (); - } else if (property == AudioContentProperty::GAIN) { + break; + case AudioContentProperty::GAIN: /* This is a bit aggressive but probably not so bad */ _peak_cache.clear(); setup_peak (); - } else if (property == ContentProperty::VIDEO_FRAME_RATE) { + break; + case ContentProperty::VIDEO_FRAME_RATE: setup_description (); - } else if (property == AudioContentProperty::FADE_IN) { + break; + case AudioContentProperty::FADE_IN: + { set<Frame> check; for (auto i: ac) { check.insert (i->audio->fade_in().get()); @@ -262,7 +267,10 @@ AudioPanel::film_content_changed (int property) } else { _fade_in->clear (); } - } else if (property == AudioContentProperty::FADE_OUT) { + break; + } + case AudioContentProperty::FADE_OUT: + { set<Frame> check; for (auto i: ac) { check.insert (i->audio->fade_out().get()); @@ -276,7 +284,10 @@ AudioPanel::film_content_changed (int property) } else { _fade_out->clear (); } - } else if (property == AudioContentProperty::USE_SAME_FADES_AS_VIDEO) { + break; + } + case AudioContentProperty::USE_SAME_FADES_AS_VIDEO: + { set<bool> check; for (auto i: ac) { check.insert(i->audio->use_same_fades_as_video()); @@ -288,6 +299,8 @@ AudioPanel::film_content_changed (int property) _use_same_fades_as_video->set(false); } setup_sensitivity (); + break; + } } } diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc index 7200bf076..f4388b2be 100644 --- a/src/wx/content_timeline.cc +++ b/src/wx/content_timeline.cc @@ -335,13 +335,21 @@ ContentTimeline::film_content_change(ChangeType type, int property, bool frequen ensure_ui_thread (); - if (property == AudioContentProperty::STREAMS || property == VideoContentProperty::FRAME_TYPE) { + switch (property) { + case AudioContentProperty::STREAMS: + case VideoContentProperty::FRAME_TYPE: recreate_views (); - } else if (property == ContentProperty::POSITION || property == ContentProperty::LENGTH) { + break; + case ContentProperty::POSITION: + case ContentProperty::LENGTH: _reels_view->force_redraw (); - } else if (!frequent) { - setup_scrollbars (); - Refresh (); + break; + default: + if (!frequent) { + setup_scrollbars (); + Refresh (); + } + break; } } diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 2341bf043..b023cfe55 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -519,22 +519,24 @@ DCPPanel::film_changed(FilmProperty p) void DCPPanel::film_content_changed(int property) { - if (property == AudioContentProperty::STREAMS || - property == TextContentProperty::USE || - property == TextContentProperty::BURN || - property == TextContentProperty::LANGUAGE || - property == TextContentProperty::LANGUAGE_IS_ADDITIONAL || - property == TextContentProperty::TYPE || - property == TextContentProperty::DCP_TRACK || - property == VideoContentProperty::CUSTOM_RATIO || - property == VideoContentProperty::CUSTOM_SIZE || - property == VideoContentProperty::BURNT_SUBTITLE_LANGUAGE || - property == VideoContentProperty::CROP || - property == DCPContentProperty::REFERENCE_VIDEO || - property == DCPContentProperty::REFERENCE_AUDIO || - property == DCPContentProperty::REFERENCE_TEXT) { + switch (property) { + case AudioContentProperty::STREAMS: + case TextContentProperty::USE: + case TextContentProperty::BURN: + case TextContentProperty::LANGUAGE: + case TextContentProperty::LANGUAGE_IS_ADDITIONAL: + case TextContentProperty::TYPE: + case TextContentProperty::DCP_TRACK: + case VideoContentProperty::CUSTOM_RATIO: + case VideoContentProperty::CUSTOM_SIZE: + case VideoContentProperty::BURNT_SUBTITLE_LANGUAGE: + case VideoContentProperty::CROP: + case DCPContentProperty::REFERENCE_VIDEO: + case DCPContentProperty::REFERENCE_AUDIO: + case DCPContentProperty::REFERENCE_TEXT: setup_dcp_name(); setup_sensitivity(); + break; } } diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index b77ff987c..ba0651b14 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -457,21 +457,22 @@ FilmViewer::player_change(vector<int> properties) bool update_ccap_tracks = false; for (auto i: properties) { - if ( - i == VideoContentProperty::CROP || - i == VideoContentProperty::CUSTOM_RATIO || - i == VideoContentProperty::CUSTOM_SIZE || - i == VideoContentProperty::FADE_IN || - i == VideoContentProperty::FADE_OUT || - i == VideoContentProperty::COLOUR_CONVERSION || - i == PlayerProperty::VIDEO_CONTAINER_SIZE || - i == PlayerProperty::FILM_CONTAINER - ) { + switch (i) { + case VideoContentProperty::CROP: + case VideoContentProperty::CUSTOM_RATIO: + case VideoContentProperty::CUSTOM_SIZE: + case VideoContentProperty::FADE_IN: + case VideoContentProperty::FADE_OUT: + case VideoContentProperty::COLOUR_CONVERSION: + case PlayerProperty::VIDEO_CONTAINER_SIZE: + case PlayerProperty::FILM_CONTAINER: try_quick_refresh = true; - } - - if (i == TextContentProperty::USE || i == TextContentProperty::TYPE || i == TextContentProperty::DCP_TRACK) { + break; + case TextContentProperty::USE: + case TextContentProperty::TYPE: + case TextContentProperty::DCP_TRACK: update_ccap_tracks = true; + break; } } diff --git a/src/wx/text_panel.cc b/src/wx/text_panel.cc index 7e4ccf5d7..849e83294 100644 --- a/src/wx/text_panel.cc +++ b/src/wx/text_panel.cc @@ -412,7 +412,8 @@ TextPanel::film_content_changed (int property) text = scs->text_of_original_type(_original_type); } - if (property == FFmpegContentProperty::SUBTITLE_STREAMS) { + switch (property) { + case FFmpegContentProperty::SUBTITLE_STREAMS: _stream->Clear (); if (fcs) { for (auto i: fcs->subtitle_streams()) { @@ -427,11 +428,13 @@ TextPanel::film_content_changed (int property) } setup_sensitivity (); clear_outline_subtitles (); - } else if (property == TextContentProperty::USE) { + break; + case TextContentProperty::USE: checked_set (_use, text ? text->use() : false); setup_sensitivity (); clear_outline_subtitles (); - } else if (property == TextContentProperty::TYPE) { + break; + case TextContentProperty::TYPE: if (text) { _type->set_by_data(text_type_to_string(text->type())); } else { @@ -439,39 +442,49 @@ TextPanel::film_content_changed (int property) } setup_sensitivity (); setup_visibility (); - } else if (property == TextContentProperty::BURN) { + break; + case TextContentProperty::BURN: checked_set (_burn, text ? text->burn() : false); - } else if (property == TextContentProperty::X_OFFSET) { + break; + case TextContentProperty::X_OFFSET: checked_set (_x_offset, text ? lrint (text->x_offset() * 100) : 0); update_outline_subtitles_in_viewer (); - } else if (property == TextContentProperty::Y_OFFSET) { + break; + case TextContentProperty::Y_OFFSET: checked_set (_y_offset, text ? lrint (text->y_offset() * 100) : 0); update_outline_subtitles_in_viewer (); - } else if (property == TextContentProperty::X_SCALE) { + break; + case TextContentProperty::X_SCALE: checked_set (_x_scale, text ? lrint (text->x_scale() * 100) : 100); clear_outline_subtitles (); - } else if (property == TextContentProperty::Y_SCALE) { + break; + case TextContentProperty::Y_SCALE: checked_set (_y_scale, text ? lrint (text->y_scale() * 100) : 100); clear_outline_subtitles (); - } else if (property == TextContentProperty::LINE_SPACING) { + break; + case TextContentProperty::LINE_SPACING: checked_set (_line_spacing, text ? lrint (text->line_spacing() * 100) : 100); clear_outline_subtitles (); - } else if (property == TextContentProperty::DCP_TRACK) { + break; + case TextContentProperty::DCP_TRACK: if (_dcp_track) { update_dcp_track_selection (); } - } else if (property == TextContentProperty::LANGUAGE) { + break; + case TextContentProperty::LANGUAGE: if (_language) { _language->set (text ? text->language() : boost::none); } - } else if (property == TextContentProperty::LANGUAGE_IS_ADDITIONAL) { + break; + case TextContentProperty::LANGUAGE_IS_ADDITIONAL: if (_language_type) { _language_type->SetSelection (text ? (text->language_is_additional() ? 1 : 0) : 0); } - } else if (property == DCPContentProperty::TEXTS) { - setup_sensitivity (); - } else if (property == ContentProperty::TRIM_START) { + break; + case DCPContentProperty::TEXTS: + case ContentProperty::TRIM_START: setup_sensitivity (); + break; } } diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 482b1ce9c..8619b7e2f 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -224,8 +224,9 @@ TimingPanel::film_content_changed (int property) properties, and fill the controls with that value if so. */ - if (property == ContentProperty::POSITION) { - + switch (property) { + case ContentProperty::POSITION: + { set<DCPTime> check; for (auto i: _parent->selected()) { check.insert (i->position ()); @@ -236,17 +237,15 @@ TimingPanel::film_content_changed (int property) } else { _position->clear (); } - - } else if ( - property == ContentProperty::LENGTH || - property == ContentProperty::VIDEO_FRAME_RATE || - property == VideoContentProperty::FRAME_TYPE - ) { - + break; + } + case ContentProperty::LENGTH: + case ContentProperty::VIDEO_FRAME_RATE: + case VideoContentProperty::FRAME_TYPE: update_full_length (); - - } else if (property == ContentProperty::TRIM_START) { - + break; + case ContentProperty::TRIM_START: + { set<ContentTime> check; for (auto i: _parent->selected()) { check.insert (i->trim_start ()); @@ -257,9 +256,10 @@ TimingPanel::film_content_changed (int property) } else { _trim_start->clear (); } - - } else if (property == ContentProperty::TRIM_END) { - + break; + } + case ContentProperty::TRIM_END: + { set<ContentTime> check; for (auto i: _parent->selected()) { check.insert (i->trim_end ()); @@ -270,17 +270,18 @@ TimingPanel::film_content_changed (int property) } else { _trim_end->clear (); } + break; + } } - if ( - property == ContentProperty::LENGTH || - property == ContentProperty::TRIM_START || - property == ContentProperty::TRIM_END || - property == ContentProperty::VIDEO_FRAME_RATE || - property == VideoContentProperty::FRAME_TYPE - ) { - + switch (property) { + case ContentProperty::LENGTH: + case ContentProperty::TRIM_START: + case ContentProperty::TRIM_END: + case ContentProperty::VIDEO_FRAME_RATE: + case VideoContentProperty::FRAME_TYPE: update_play_length (); + break; } if (property == ContentProperty::VIDEO_FRAME_RATE) { diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index 75612a0ce..e58aa2678 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -379,11 +379,14 @@ VideoPanel::film_content_changed(int property) fcs = dynamic_pointer_cast<FFmpegContent>(vcs); } - if (property == ContentProperty::VIDEO_FRAME_RATE || - property == VideoContentProperty::FRAME_TYPE || - property == VideoContentProperty::CROP) { + switch (property) { + case ContentProperty::VIDEO_FRAME_RATE: + case VideoContentProperty::FRAME_TYPE: + case VideoContentProperty::CROP: setup_description(); - } else if (property == VideoContentProperty::COLOUR_CONVERSION) { + break; + case VideoContentProperty::COLOUR_CONVERSION: + { boost::unordered_set<optional<ColourConversion>> check; for (auto i: vc) { check.insert(i->video->colour_conversion()); @@ -417,10 +420,13 @@ VideoPanel::film_content_changed(int property) } setup_sensitivity(); - - } else if (property == VideoContentProperty::USE) { + break; + } + case VideoContentProperty::USE: setup_sensitivity(); - } else if (property == VideoContentProperty::FADE_IN) { + break; + case VideoContentProperty::FADE_IN: + { set<Frame> check; for (auto i: vc) { check.insert(i->video->fade_in()); @@ -434,7 +440,10 @@ VideoPanel::film_content_changed(int property) } else { _fade_in->clear(); } - } else if (property == VideoContentProperty::FADE_OUT) { + break; + } + case VideoContentProperty::FADE_OUT: + { set<Frame> check; for (auto i: vc) { check.insert(i->video->fade_out()); @@ -448,7 +457,9 @@ VideoPanel::film_content_changed(int property) } else { _fade_out->clear(); } - } else if (property == VideoContentProperty::RANGE) { + break; + } + case VideoContentProperty::RANGE: if (vcs) { checked_set(_range, vcs->video->range() == VideoRange::FULL ? 0 : 1); } else { @@ -456,7 +467,10 @@ VideoPanel::film_content_changed(int property) } setup_sensitivity(); - } else if (property == VideoContentProperty::CUSTOM_RATIO || property == VideoContentProperty::CUSTOM_SIZE) { + break; + case VideoContentProperty::CUSTOM_RATIO: + case VideoContentProperty::CUSTOM_SIZE: + { set<Frame> check; for (auto i: vc) { check.insert(i->video->custom_ratio() || i->video->custom_size()); @@ -471,12 +485,13 @@ VideoPanel::film_content_changed(int property) } setup_sensitivity(); setup_description(); - } else if ( - property == DCPContentProperty::REFERENCE_VIDEO || - property == DCPContentProperty::REFERENCE_AUDIO || - property == DCPContentProperty::REFERENCE_TEXT - ) { + break; + } + case DCPContentProperty::REFERENCE_VIDEO: + case DCPContentProperty::REFERENCE_AUDIO: + case DCPContentProperty::REFERENCE_TEXT: setup_sensitivity(); + break; } } |
