Remove GL context accessor and hence lock.
[dcpomatic.git] / src / wx / screens_panel.cc
index 3fabba46a567221f312e658c01350ca934e8df80..8db7a10355f14400e806baa134cf8acd18f17dde 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2015-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 */
 
-#include "lib/config.h"
-#include "lib/cinema.h"
-#include "lib/screen.h"
 #include "screens_panel.h"
 #include "wx_util.h"
 #include "cinema_dialog.h"
 #include "screen_dialog.h"
+#include "dcpomatic_button.h"
+#include "lib/config.h"
+#include "lib/cinema.h"
+#include "lib/screen.h"
 #include <boost/foreach.hpp>
 
 using std::list;
@@ -35,6 +36,7 @@ using std::string;
 using std::make_pair;
 using boost::shared_ptr;
 using boost::optional;
+using namespace dcpomatic;
 
 ScreensPanel::ScreensPanel (wxWindow* parent)
        : wxPanel (parent, wxID_ANY)
@@ -54,40 +56,40 @@ ScreensPanel::ScreensPanel (wxWindow* parent)
 
        wxBoxSizer* target_buttons = new wxBoxSizer (wxVERTICAL);
 
-       _add_cinema = new wxButton (this, wxID_ANY, _("Add Cinema..."));
+       _add_cinema = new Button (this, _("Add Cinema..."));
        target_buttons->Add (_add_cinema, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       _edit_cinema = new wxButton (this, wxID_ANY, _("Edit Cinema..."));
+       _edit_cinema = new Button (this, _("Edit Cinema..."));
        target_buttons->Add (_edit_cinema, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       _remove_cinema = new wxButton (this, wxID_ANY, _("Remove Cinema"));
+       _remove_cinema = new Button (this, _("Remove Cinema"));
        target_buttons->Add (_remove_cinema, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       _add_screen = new wxButton (this, wxID_ANY, _("Add Screen..."));
+       _add_screen = new Button (this, _("Add Screen..."));
        target_buttons->Add (_add_screen, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       _edit_screen = new wxButton (this, wxID_ANY, _("Edit Screen..."));
+       _edit_screen = new Button (this, _("Edit Screen..."));
        target_buttons->Add (_edit_screen, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP);
-       _remove_screen = new wxButton (this, wxID_ANY, _("Remove Screen"));
+       _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);
 
        sizer->Add (targets, 1, wxEXPAND);
 
-       _search->Bind        (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ScreensPanel::search_changed, this));
-       _targets->Bind       (wxEVT_COMMAND_TREE_SEL_CHANGED, &ScreensPanel::selection_changed_shim, this);
+       _search->Bind        (wxEVT_TEXT, boost::bind (&ScreensPanel::search_changed, this));
+       _targets->Bind       (wxEVT_TREE_SEL_CHANGED, &ScreensPanel::selection_changed_shim, this);
 
-       _add_cinema->Bind    (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::add_cinema_clicked, this));
-       _edit_cinema->Bind   (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::edit_cinema_clicked, this));
-       _remove_cinema->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::remove_cinema_clicked, this));
+       _add_cinema->Bind    (wxEVT_BUTTON, boost::bind (&ScreensPanel::add_cinema_clicked, this));
+       _edit_cinema->Bind   (wxEVT_BUTTON, boost::bind (&ScreensPanel::edit_cinema_clicked, this));
+       _remove_cinema->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::remove_cinema_clicked, this));
 
-       _add_screen->Bind    (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::add_screen_clicked, this));
-       _edit_screen->Bind   (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::edit_screen_clicked, this));
-       _remove_screen->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::remove_screen_clicked, this));
+       _add_screen->Bind    (wxEVT_BUTTON, boost::bind (&ScreensPanel::add_screen_clicked, this));
+       _edit_screen->Bind   (wxEVT_BUTTON, boost::bind (&ScreensPanel::edit_screen_clicked, this));
+       _remove_screen->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::remove_screen_clicked, this));
 
        SetSizer (sizer);
 }
 
 ScreensPanel::~ScreensPanel ()
 {
-       _targets->Unbind (wxEVT_COMMAND_TREE_SEL_CHANGED, &ScreensPanel::selection_changed_shim, this);
+       _targets->Unbind (wxEVT_TREE_SEL_CHANGED, &ScreensPanel::selection_changed_shim, this);
 }
 
 void
@@ -177,7 +179,7 @@ ScreensPanel::edit_cinema_clicked ()
                c.second->set_utc_offset_hour (d->utc_offset_hour ());
                c.second->set_utc_offset_minute (d->utc_offset_minute ());
                _targets->SetItemText (c.first, std_to_wx (d->name()));
-               Config::instance()->changed ();
+               Config::instance()->changed (Config::CINEMAS);
        }
 
        d->Destroy ();
@@ -222,14 +224,14 @@ ScreensPanel::add_screen_clicked ()
                }
        }
 
-       shared_ptr<Screen> s (new Screen (d->name(), d->recipient(), d->trusted_devices()));
+       shared_ptr<Screen> s (new Screen (d->name(), d->notes(), d->recipient(), d->trusted_devices()));
        c->add_screen (s);
        optional<wxTreeItemId> id = add_screen (c, s);
        if (id) {
                _targets->Expand (id.get ());
        }
 
-       Config::instance()->changed ();
+       Config::instance()->changed (Config::CINEMAS);
 
        d->Destroy ();
 }
@@ -268,7 +270,7 @@ ScreensPanel::edit_screen_clicked ()
        s.second->recipient = d->recipient ();
        s.second->trusted_devices = d->trusted_devices ();
        _targets->SetItemText (s.first, std_to_wx (d->name()));
-       Config::instance()->changed ();
+       Config::instance()->changed (Config::CINEMAS);
 
        d->Destroy ();
 }
@@ -295,7 +297,7 @@ ScreensPanel::remove_screen_clicked ()
                _targets->Delete (i->first);
        }
 
-       Config::instance()->changed ();
+       Config::instance()->changed (Config::CINEMAS);
 }
 
 list<shared_ptr<Screen> >