From 80c463b76284aa87f892fb331877c2caf5cc2771 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 11 Jan 2024 22:50:29 +0100 Subject: [PATCH] Attempt to rationalise menu IDs and avoid duplicates. --- src/tools/dcpomatic.cc | 5 +++-- src/tools/dcpomatic_batch.cc | 3 ++- src/tools/dcpomatic_disk.cc | 2 +- src/tools/dcpomatic_editor.cc | 3 ++- src/tools/dcpomatic_kdm.cc | 3 ++- src/tools/dcpomatic_player.cc | 7 ++++--- src/tools/dcpomatic_server.cc | 3 ++- src/wx/audio_mapping_view.cc | 11 ++++++----- src/wx/content_menu.cc | 7 +++---- src/wx/id.h | 27 +++++++++++++++++++++++++++ src/wx/markers_panel.cc | 3 ++- 11 files changed, 54 insertions(+), 20 deletions(-) create mode 100644 src/wx/id.h diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 8faaf5bcd..6635cdb82 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -37,6 +37,7 @@ #include "wx/hints_dialog.h" #include "wx/html_dialog.h" #include "wx/i18n_hook.h" +#include "wx/id.h" #include "wx/job_manager_view.h" #include "wx/kdm_dialog.h" #include "wx/nag_dialog.h" @@ -211,7 +212,7 @@ private: map menu_items; enum { - ID_file_new = 1, + ID_file_new = DCPOMATIC_MAIN_MENU, ID_file_open, ID_file_save, ID_file_save_as_template, @@ -219,7 +220,7 @@ enum { ID_file_duplicate_and_open, ID_file_history, /* Allow spare IDs after _history for the recent files list */ - ID_file_close = 100, + ID_file_close = DCPOMATIC_MAIN_MENU + 100, ID_edit_copy, ID_edit_paste, ID_edit_select_all, diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 3114768ac..6a0e46cf8 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -22,6 +22,7 @@ #include "wx/about_dialog.h" #include "wx/dcpomatic_button.h" #include "wx/full_config_dialog.h" +#include "wx/id.h" #include "wx/job_manager_view.h" #include "wx/servers_list_dialog.h" #include "wx/wx_ptr.h" @@ -71,7 +72,7 @@ static list films_to_load; enum { - ID_file_add_film = 1, + ID_file_add_film = DCPOMATIC_MAIN_MENU, ID_tools_encoding_servers, ID_help_about }; diff --git a/src/tools/dcpomatic_disk.cc b/src/tools/dcpomatic_disk.cc index 5941d6d70..c1b262351 100644 --- a/src/tools/dcpomatic_disk.cc +++ b/src/tools/dcpomatic_disk.cc @@ -69,7 +69,7 @@ using namespace boost::placeholders; #ifdef DCPOMATIC_OSX enum { - ID_tools_uninstall = 1, + ID_tools_uninstall = DCPOMATIC_MAIN_MENU, }; #endif diff --git a/src/tools/dcpomatic_editor.cc b/src/tools/dcpomatic_editor.cc index eb968b1e8..14ff6da7f 100644 --- a/src/tools/dcpomatic_editor.cc +++ b/src/tools/dcpomatic_editor.cc @@ -21,6 +21,7 @@ #include "wx/about_dialog.h" #include "wx/editable_list.h" +#include "wx/id.h" #include "wx/wx_signal_manager.h" #include "wx/wx_util.h" #include "lib/constants.h" @@ -59,7 +60,7 @@ using namespace boost::placeholders; enum { - ID_file_open = 1, + ID_file_open = DCPOMATIC_MAIN_MENU, ID_file_save, }; diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 372a711a0..8e5e75da0 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -22,6 +22,7 @@ #include "wx/about_dialog.h" #include "wx/dcpomatic_button.h" #include "wx/editable_list.h" +#include "wx/id.h" #include "wx/invalid_certificate_period_dialog.h" #include "wx/file_dialog.h" #include "wx/file_picker_ctrl.h" @@ -96,7 +97,7 @@ using namespace dcpomatic; enum { - ID_help_report_a_problem = 1, + ID_help_report_a_problem = DCPOMATIC_MAIN_MENU, }; diff --git a/src/tools/dcpomatic_player.cc b/src/tools/dcpomatic_player.cc index 301e893ff..feac2a915 100644 --- a/src/tools/dcpomatic_player.cc +++ b/src/tools/dcpomatic_player.cc @@ -21,6 +21,7 @@ #include "wx/about_dialog.h" #include "wx/file_dialog.h" #include "wx/film_viewer.h" +#include "wx/id.h" #include "wx/nag_dialog.h" #include "wx/player_config_dialog.h" #include "wx/player_information.h" @@ -119,16 +120,16 @@ using namespace dcpomatic; enum { - ID_file_open = 1, + ID_file_open = DCPOMATIC_MAIN_MENU, ID_file_add_ov, ID_file_add_kdm, ID_file_save_frame, ID_file_history, /* Allow spare IDs after _history for the recent files list */ - ID_file_close = 100, + ID_file_close = DCPOMATIC_MAIN_MENU + 100, ID_view_cpl, /* Allow spare IDs for CPLs */ - ID_view_full_screen = 200, + ID_view_full_screen = DCPOMATIC_MAIN_MENU + 200, ID_view_dual_screen, ID_view_closed_captions, ID_view_scale_appropriate, diff --git a/src/tools/dcpomatic_server.cc b/src/tools/dcpomatic_server.cc index d93dec853..9bdc688c8 100644 --- a/src/tools/dcpomatic_server.cc +++ b/src/tools/dcpomatic_server.cc @@ -18,6 +18,7 @@ */ +#include "wx/id.h" #include "wx/static_text.h" #include "wx/wx_signal_manager.h" #include "wx/wx_util.h" @@ -57,7 +58,7 @@ using namespace boost::placeholders; enum { - ID_status = 1, + ID_status = DCPOMATIC_MAIN_MENU, ID_quit, ID_timer }; diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc index 6f4a39b1e..188bf57cf 100644 --- a/src/wx/audio_mapping_view.cc +++ b/src/wx/audio_mapping_view.cc @@ -26,6 +26,7 @@ #include "audio_gain_dialog.h" #include "audio_mapping_view.h" +#include "id.h" #include "wx_util.h" #include "lib/audio_mapping.h" #include "lib/maths_util.h" @@ -63,11 +64,11 @@ static constexpr auto COLUMN_PADDING = 16; enum { - ID_off = 1, - ID_minus6dB = 2, - ID_0dB = 3, - ID_plus3dB = 4, - ID_edit = 5 + ID_off = DCPOMATIC_AUDIO_GAIN_MENU, + ID_minus6dB, + ID_0dB, + ID_plus3dB, + ID_edit }; diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index c0479ac83..b096ecae6 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -26,6 +26,7 @@ #include "dir_dialog.h" #include "file_dialog.h" #include "film_viewer.h" +#include "id.h" #include "repeat_dialog.h" #include "timeline_video_content_view.h" #include "timeline_audio_content_view.h" @@ -74,8 +75,7 @@ using namespace dcpomatic; enum { - /* Start at 256 so we can have IDs on _cpl_menu from 1 to 255 */ - ID_repeat = 256, + ID_repeat = DCPOMATIC_CONTENT_MENU, ID_join, ID_find_missing, ID_properties, @@ -168,8 +168,7 @@ ContentMenu::popup (weak_ptr film, ContentList c, TimelineContentViewList try { auto cpls = dcp::find_and_resolve_cpls (dcp->directories(), true); _choose_cpl->Enable (cpls.size() > 1); - /* We can't have 0 as a menu item ID on OS X */ - int id = 1; + int id = DCPOMATIC_CPL_MENU; for (auto i: cpls) { auto item = _cpl_menu->AppendRadioItem ( id++, diff --git a/src/wx/id.h b/src/wx/id.h new file mode 100644 index 000000000..99aa25855 --- /dev/null +++ b/src/wx/id.h @@ -0,0 +1,27 @@ +/* + Copyright (C) 2024 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#define DCPOMATIC_MARKERS_PANEL_MENU wxID_HIGHEST +#define DCPOMATIC_MAIN_MENU (wxID_HIGHEST + 500) +#define DCPOMATIC_CPL_MENU (wxID_HIGHEST + 1000) +#define DCPOMATIC_CONTENT_MENU (wxID_HIGHEST + 1500) +#define DCPOMATIC_AUDIO_GAIN_MENU (wxID_HIGHEST + 2000) + diff --git a/src/wx/markers_panel.cc b/src/wx/markers_panel.cc index 463f06758..42a3ce8ae 100644 --- a/src/wx/markers_panel.cc +++ b/src/wx/markers_panel.cc @@ -20,6 +20,7 @@ #include "film_viewer.h" +#include "id.h" #include "markers.h" #include "markers_panel.h" #include "wx_util.h" @@ -41,7 +42,7 @@ using namespace boost::placeholders; enum { - ID_move_marker_to_current_position, + ID_move_marker_to_current_position = DCPOMATIC_MARKERS_PANEL_MENU, ID_remove_marker, ID_add_marker, /* Leave some space after this one as we use an ID for each marker type -- 2.30.2