projects
/
dcpomatic.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use wx_ptr more.
[dcpomatic.git]
/
src
/
wx
/
audio_mapping_view.cc
diff --git
a/src/wx/audio_mapping_view.cc
b/src/wx/audio_mapping_view.cc
index 67ece1f7b1ef0ec4961f8157c080c5c3e11326dd..9c14f61e78f421bc54f867247daf62a2fd6ee27f 100644
(file)
--- a/
src/wx/audio_mapping_view.cc
+++ b/
src/wx/audio_mapping_view.cc
@@
-18,41
+18,44
@@
*/
*/
+
/** @file src/wx/audio_mapping_view.cc
* @brief AudioMappingView class and helpers.
*/
/** @file src/wx/audio_mapping_view.cc
* @brief AudioMappingView class and helpers.
*/
+
+#include "audio_gain_dialog.h"
#include "audio_mapping_view.h"
#include "audio_mapping_view.h"
+#include "wx_ptr.h"
#include "wx_util.h"
#include "wx_util.h"
-#include "audio_gain_dialog.h"
#include "lib/audio_mapping.h"
#include "lib/audio_mapping.h"
-#include "lib/util.h"
-#include "lib/warnings.h"
+#include "lib/maths_util.h"
#include <dcp/locale_convert.h>
#include <dcp/types.h>
#include <dcp/locale_convert.h>
#include <dcp/types.h>
-DCPOMATIC_DISABLE_WARNINGS
-#include <wx/wx.h>
-#include <wx/renderer.h>
-#include <wx/grid.h>
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
#include <wx/graphics.h>
#include <wx/graphics.h>
-DCPOMATIC_ENABLE_WARNINGS
-#include <iostream>
+#include <wx/grid.h>
+#include <wx/renderer.h>
+#include <wx/wx.h>
+LIBDCP_ENABLE_WARNINGS
+
-using std::cout;
using std::list;
using std::list;
-using std::string;
-using std::min;
+using std::make_pair;
using std::max;
using std::max;
-using std::
vector
;
+using std::
min
;
using std::pair;
using std::pair;
-using std::make_pair;
using std::shared_ptr;
using std::shared_ptr;
+using std::string;
+using std::vector;
using boost::optional;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
using dcp::locale_convert;
using boost::optional;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
using dcp::locale_convert;
+
static constexpr auto INDICATOR_SIZE = 20;
static constexpr auto ROW_HEIGHT = 32;
static constexpr auto MINIMUM_COLUMN_WIDTH = 32;
static constexpr auto INDICATOR_SIZE = 20;
static constexpr auto ROW_HEIGHT = 32;
static constexpr auto MINIMUM_COLUMN_WIDTH = 32;
@@
-61,6
+64,7
@@
static constexpr auto TOP_HEIGHT = ROW_HEIGHT * 2;
static constexpr auto COLUMN_PADDING = 16;
static constexpr auto HORIZONTAL_PAGE_SIZE = 32;
static constexpr auto COLUMN_PADDING = 16;
static constexpr auto HORIZONTAL_PAGE_SIZE = 32;
+
enum {
ID_off = 1,
ID_minus6dB = 2,
enum {
ID_off = 1,
ID_minus6dB = 2,
@@
-69,6
+73,7
@@
enum {
ID_edit = 5
};
ID_edit = 5
};
+
AudioMappingView::AudioMappingView (wxWindow* parent, wxString left_label, wxString from, wxString top_label, wxString to)
: wxPanel (parent, wxID_ANY)
, _menu_input (0)
AudioMappingView::AudioMappingView (wxWindow* parent, wxString left_label, wxString from, wxString top_label, wxString to)
: wxPanel (parent, wxID_ANY)
, _menu_input (0)
@@
-122,6
+127,7
@@
AudioMappingView::AudioMappingView (wxWindow* parent, wxString left_label, wxStr
_horizontal_scroll->Bind (wxEVT_SCROLL_THUMBRELEASE, boost::bind(&AudioMappingView::scroll, this));
}
_horizontal_scroll->Bind (wxEVT_SCROLL_THUMBRELEASE, boost::bind(&AudioMappingView::scroll, this));
}
+
void
AudioMappingView::size (wxSizeEvent& ev)
{
void
AudioMappingView::size (wxSizeEvent& ev)
{
@@
-129,6
+135,7
@@
AudioMappingView::size (wxSizeEvent& ev)
ev.Skip ();
}
ev.Skip ();
}
+
void
AudioMappingView::setup ()
{
void
AudioMappingView::setup ()
{
@@
-176,12
+183,14
@@
AudioMappingView::setup ()
true);
}
true);
}
+
void
AudioMappingView::scroll ()
{
Refresh ();
}
void
AudioMappingView::scroll ()
{
Refresh ();
}
+
void
AudioMappingView::paint_static (wxDC& dc)
{
void
AudioMappingView::paint_static (wxDC& dc)
{
@@
-203,6
+212,7
@@
AudioMappingView::paint_static (wxDC& dc)
dc.SetFont (*wxSWISS_FONT);
}
dc.SetFont (*wxSWISS_FONT);
}
+
void
AudioMappingView::paint_column_labels (wxDC& dc)
{
void
AudioMappingView::paint_column_labels (wxDC& dc)
{
@@
-220,6
+230,7
@@
AudioMappingView::paint_column_labels (wxDC& dc)
dc.DrawLine(wxPoint(LEFT_WIDTH, ROW_HEIGHT * 2), wxPoint(LEFT_WIDTH + _column_widths_total, ROW_HEIGHT * 2));
}
dc.DrawLine(wxPoint(LEFT_WIDTH, ROW_HEIGHT * 2), wxPoint(LEFT_WIDTH + _column_widths_total, ROW_HEIGHT * 2));
}
+
void
AudioMappingView::paint_column_lines (wxDC& dc)
{
void
AudioMappingView::paint_column_lines (wxDC& dc)
{
@@
-238,6
+249,7
@@
AudioMappingView::paint_column_lines (wxDC& dc)
);
}
);
}
+
void
AudioMappingView::paint_row_labels (wxDC& dc)
{
void
AudioMappingView::paint_row_labels (wxDC& dc)
{
@@
-298,6
+310,7
@@
AudioMappingView::paint_row_labels (wxDC& dc)
}
}
}
}
+
void
AudioMappingView::paint_row_lines (wxDC& dc)
{
void
AudioMappingView::paint_row_lines (wxDC& dc)
{
@@
-313,6
+326,7
@@
AudioMappingView::paint_row_lines (wxDC& dc)
);
}
);
}
+
void
AudioMappingView::paint_indicators (wxDC& dc)
{
void
AudioMappingView::paint_indicators (wxDC& dc)
{
@@
-354,17
+368,6
@@
AudioMappingView::paint_indicators (wxDC& dc)
}
}
}
}
-static
-void clip (wxDC& dc, int x, int y, int w, int h)
-{
- dc.SetClippingRegion (x, y, w, h);
-}
-
-static
-void translate (wxDC& dc, int x, int y)
-{
- dc.SetLogicalOrigin (x, y);
-}
static
void restore (wxDC& dc)
static
void restore (wxDC& dc)
@@
-373,6
+376,7
@@
void restore (wxDC& dc)
dc.DestroyClippingRegion ();
}
dc.DestroyClippingRegion ();
}
+
void
AudioMappingView::paint ()
{
void
AudioMappingView::paint ()
{
@@
-383,62
+387,58
@@
AudioMappingView::paint ()
paint_static (dc);
paint_static (dc);
- clip (
- dc,
+ dc.SetClippingRegion (
LEFT_WIDTH,
0,
_column_widths_total,
ROW_HEIGHT * (2 + _input_channels.size())
LEFT_WIDTH,
0,
_column_widths_total,
ROW_HEIGHT * (2 + _input_channels.size())
- );
-
translate (dc,
hs, 0);
+
);
+
dc.SetLogicalOrigin (
hs, 0);
paint_column_labels (dc);
restore (dc);
paint_column_labels (dc);
restore (dc);
- clip (
- dc,
+ dc.SetClippingRegion(
0,
TOP_HEIGHT,
LEFT_WIDTH,
0,
TOP_HEIGHT,
LEFT_WIDTH,
- min(int(ROW_HEIGHT * _input_channels.size()), GetSize().GetHeight() - TOP_HEIGHT)
+ min(int(ROW_HEIGHT * _input_channels.size()), GetSize().GetHeight() - TOP_HEIGHT)
+ 1
);
);
-
translate (dc,
0, vs);
+
dc.SetLogicalOrigin (
0, vs);
paint_row_labels (dc);
restore (dc);
paint_row_labels (dc);
restore (dc);
- clip (
- dc,
+ dc.SetClippingRegion(
MINIMUM_COLUMN_WIDTH * 2,
TOP_HEIGHT,
MINIMUM_COLUMN_WIDTH + _column_widths_total,
min(int(ROW_HEIGHT * (2 + _input_channels.size())), GetSize().GetHeight() - TOP_HEIGHT)
);
MINIMUM_COLUMN_WIDTH * 2,
TOP_HEIGHT,
MINIMUM_COLUMN_WIDTH + _column_widths_total,
min(int(ROW_HEIGHT * (2 + _input_channels.size())), GetSize().GetHeight() - TOP_HEIGHT)
);
-
translate (dc,
hs, vs);
+
dc.SetLogicalOrigin (
hs, vs);
paint_row_lines (dc);
restore (dc);
paint_row_lines (dc);
restore (dc);
- clip (
- dc,
+ dc.SetClippingRegion(
LEFT_WIDTH,
MINIMUM_COLUMN_WIDTH,
MINIMUM_COLUMN_WIDTH + _column_widths_total,
min(int(ROW_HEIGHT * (1 + _input_channels.size())), GetSize().GetHeight() - ROW_HEIGHT)
);
LEFT_WIDTH,
MINIMUM_COLUMN_WIDTH,
MINIMUM_COLUMN_WIDTH + _column_widths_total,
min(int(ROW_HEIGHT * (1 + _input_channels.size())), GetSize().GetHeight() - ROW_HEIGHT)
);
-
translate (dc,
hs, vs);
+
dc.SetLogicalOrigin(
hs, vs);
paint_column_lines (dc);
restore (dc);
paint_column_lines (dc);
restore (dc);
- clip (
- dc,
+ dc.SetClippingRegion (
LEFT_WIDTH,
TOP_HEIGHT,
_column_widths_total,
min(int(ROW_HEIGHT * _input_channels.size()), GetSize().GetHeight() - TOP_HEIGHT)
);
LEFT_WIDTH,
TOP_HEIGHT,
_column_widths_total,
min(int(ROW_HEIGHT * _input_channels.size()), GetSize().GetHeight() - TOP_HEIGHT)
);
-
translate (dc,
hs, vs);
+
dc.SetLogicalOrigin(
hs, vs);
paint_indicators (dc);
restore (dc);
}
paint_indicators (dc);
restore (dc);
}
+
optional<pair<NamedChannel, NamedChannel>>
AudioMappingView::mouse_event_to_channels (wxMouseEvent& ev) const
{
optional<pair<NamedChannel, NamedChannel>>
AudioMappingView::mouse_event_to_channels (wxMouseEvent& ev) const
{
@@
-551,13
+551,11
@@
AudioMappingView::set_gain_from_menu (double linear)
void
AudioMappingView::edit ()
{
void
AudioMappingView::edit ()
{
- auto dialog =
new AudioGainDialog
(this, _menu_input, _menu_output, _map.get(_menu_input, _menu_output));
+ auto dialog =
make_wx<AudioGainDialog>
(this, _menu_input, _menu_output, _map.get(_menu_input, _menu_output));
if (dialog->ShowModal() == wxID_OK) {
_map.set (_menu_input, _menu_output, dialog->value ());
map_values_changed ();
}
if (dialog->ShowModal() == wxID_OK) {
_map.set (_menu_input, _menu_output, dialog->value ());
map_values_changed ();
}
-
- dialog->Destroy ();
}
void
}
void