Add check/uncheck all buttons to screens panel.
authorCarl Hetherington <cth@carlh.net>
Sun, 20 Mar 2022 23:54:18 +0000 (00:54 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 20 Mar 2022 23:54:18 +0000 (00:54 +0100)
src/wx/screens_panel.cc
src/wx/screens_panel.h

index 69e7f1f4e12df11f76be546c0927c8277e3bb237..52d9fd88d2085682b1fb3fe70f3969e9a521463b 100644 (file)
@@ -67,6 +67,8 @@ ScreensPanel::ScreensPanel (wxWindow* parent)
 
        add_cinemas ();
 
+       auto side_buttons = new wxBoxSizer (wxVERTICAL);
+
        auto target_buttons = new wxBoxSizer (wxVERTICAL);
 
        _add_cinema = new Button (this, _("Add Cinema..."));
@@ -82,7 +84,18 @@ ScreensPanel::ScreensPanel (wxWindow* parent)
        _remove_screen = new Button (this, _("Remove Screen"));
        target_buttons->Add (_remove_screen, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
 
-       targets->Add (target_buttons, 0, 0);
+       side_buttons->Add (target_buttons, 0, 0);
+
+       auto check_buttons = new wxBoxSizer (wxVERTICAL);
+
+       _check_all = new Button (this, _("Check all"));
+       check_buttons->Add (_check_all, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
+       _uncheck_all = new Button (this, _("Uncheck all"));
+       check_buttons->Add (_uncheck_all, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
+
+       side_buttons->Add (check_buttons, 1, wxEXPAND | wxTOP, DCPOMATIC_BUTTON_STACK_GAP * 8);
+
+       targets->Add (side_buttons, 0, 0);
 
        sizer->Add (targets, 1, wxEXPAND);
 
@@ -98,6 +111,9 @@ ScreensPanel::ScreensPanel (wxWindow* parent)
        _edit_screen->Bind   (wxEVT_BUTTON, boost::bind (&ScreensPanel::edit_screen_clicked, this));
        _remove_screen->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::remove_screen_clicked, this));
 
+       _check_all->Bind     (wxEVT_BUTTON, boost::bind(&ScreensPanel::check_all, this));
+       _uncheck_all->Bind     (wxEVT_BUTTON, boost::bind(&ScreensPanel::uncheck_all, this));
+
        SetSizer (sizer);
 
        UErrorCode status = U_ZERO_ERROR;
@@ -121,6 +137,32 @@ ScreensPanel::~ScreensPanel ()
 }
 
 
+void
+ScreensPanel::check_all ()
+{
+       for (auto cinema = _targets->GetFirstChild(_targets->GetRootItem()); cinema.IsOk();  cinema = _targets->GetNextSibling(cinema)) {
+               _targets->CheckItem(cinema, wxCHK_CHECKED);
+               for (auto screen = _targets->GetFirstChild(cinema); screen.IsOk(); screen = _targets->GetNextSibling(screen)) {
+                       _targets->CheckItem(screen, wxCHK_CHECKED);
+                       set_screen_checked(screen, true);
+               }
+       }
+}
+
+
+void
+ScreensPanel::uncheck_all ()
+{
+       for (auto cinema = _targets->GetFirstChild(_targets->GetRootItem()); cinema.IsOk();  cinema = _targets->GetNextSibling(cinema)) {
+               _targets->CheckItem(cinema, wxCHK_UNCHECKED);
+               for (auto screen = _targets->GetFirstChild(cinema); screen.IsOk(); screen = _targets->GetNextSibling(screen)) {
+                       _targets->CheckItem(screen, wxCHK_UNCHECKED);
+                       set_screen_checked(screen, false);
+               }
+       }
+}
+
+
 void
 ScreensPanel::setup_sensitivity ()
 {
index e3c7023df844bd93fbeac760d383d6e07daad4d3..9c9811c1d0de7fa83d224896216b514410a7364c 100644 (file)
@@ -69,6 +69,8 @@ private:
        void set_screen_checked (wxTreeListItem item, bool checked);
        void setup_cinema_checked_state (wxTreeListItem screen);
        int compare (std::string const& utf8_a, std::string const& utf8_b);
+       void check_all ();
+       void uncheck_all ();
 
        std::shared_ptr<Cinema> item_to_cinema (wxTreeListItem item) const;
        std::shared_ptr<dcpomatic::Screen> item_to_screen (wxTreeListItem item) const;
@@ -83,6 +85,8 @@ private:
        wxButton* _add_screen;
        wxButton* _edit_screen;
        wxButton* _remove_screen;
+       wxButton* _check_all;
+       wxButton* _uncheck_all;
 
        /* We want to be able to search (and so remove selected things from the view)
         * but not deselect them, so we maintain lists of selected cinemas and screens.