Attempt to rationalise menu IDs and avoid duplicates.
authorCarl Hetherington <cth@carlh.net>
Thu, 11 Jan 2024 21:50:29 +0000 (22:50 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 11 Jan 2024 21:50:29 +0000 (22:50 +0100)
src/tools/dcpomatic.cc
src/tools/dcpomatic_batch.cc
src/tools/dcpomatic_disk.cc
src/tools/dcpomatic_editor.cc
src/tools/dcpomatic_kdm.cc
src/tools/dcpomatic_player.cc
src/tools/dcpomatic_server.cc
src/wx/audio_mapping_view.cc
src/wx/content_menu.cc
src/wx/id.h [new file with mode: 0644]
src/wx/markers_panel.cc

index 8faaf5bcdc6e2ab3f071b05e92b3ab820ad743aa..6635cdb82abcd364fe96d8e5cace00f154f48258 100644 (file)
@@ -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<wxMenuItem*, int> 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,
index 3114768aca497c5f03bd8ebc4845b239ffb6b2b9..6a0e46cf8b462cdeb781766fab41d079c5369068 100644 (file)
@@ -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<boost::filesystem::path> films_to_load;
 
 
 enum {
-       ID_file_add_film = 1,
+       ID_file_add_film = DCPOMATIC_MAIN_MENU,
        ID_tools_encoding_servers,
        ID_help_about
 };
index 5941d6d7038d8d508cc15d92cdb3e454cd77a921..c1b26235199b2ae868c4e81149e4551a876bbddc 100644 (file)
@@ -69,7 +69,7 @@ using namespace boost::placeholders;
 
 #ifdef DCPOMATIC_OSX
 enum {
-       ID_tools_uninstall = 1,
+       ID_tools_uninstall = DCPOMATIC_MAIN_MENU,
 };
 #endif
 
index eb968b1e8d5cd251a65e690fec45a584f14f2a0c..14ff6da7f04129f8188cb70d9d7e01ee337966a3 100644 (file)
@@ -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,
 };
 
index 372a711a07ede74444ea2a583e169bdfb97dda30..8e5e75da06d8bb08e39b9aa63ec108c4e519c2cd 100644 (file)
@@ -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,
 };
 
 
index 301e893ff66005be50ceca0963e153112d2cb906..feac2a9150ea1f3203e3f5b974c79339deb40bcb 100644 (file)
@@ -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,
index d93dec853dbff8e5f915933686389c8c6099344c..9bdc688c8f0e4bda214e48b7f61c37703cd41815 100644 (file)
@@ -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
 };
index 6f4a39b1edac3af60e6f6df6d1b642192077570c..188bf57cf53823bfc8e08db102b8929ef19ddd92 100644 (file)
@@ -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
 };
 
 
index c0479ac8355c53f51489849a94d22958bbd9f204..b096ecae6c1551e0aabff7d6f8735ac0ae18ef0a 100644 (file)
@@ -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> 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 (file)
index 0000000..99aa258
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+    Copyright (C) 2024 Carl Hetherington <cth@carlh.net>
+
+    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 <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#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)
+
index 463f06758f1aae7575f82f9a54eb88767012e90a..42a3ce8aeda357550b886cbeb60648d7f41d7a44 100644 (file)
@@ -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