summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-01-06 22:30:35 +0000
committerCarl Hetherington <cth@carlh.net>2014-01-06 22:30:35 +0000
commit8236e321a4f437af9eaa6098f11930b233a9dfe8 (patch)
treebd4a2dcd9e846ba720bf332c3eb9b04a1bc80773 /src
parent34b40f12d7eec52862999da9e4417fc8f6e0f9af (diff)
Tooltips for audio matrix.
Diffstat (limited to 'src')
-rw-r--r--src/wx/audio_mapping_view.cc63
-rw-r--r--src/wx/audio_mapping_view.h5
2 files changed, 58 insertions, 10 deletions
diff --git a/src/wx/audio_mapping_view.cc b/src/wx/audio_mapping_view.cc
index 54749845d..9fa57a1b1 100644
--- a/src/wx/audio_mapping_view.cc
+++ b/src/wx/audio_mapping_view.cc
@@ -104,6 +104,8 @@ AudioMappingView::AudioMappingView (wxWindow* parent)
: wxPanel (parent, wxID_ANY)
, _menu_row (0)
, _menu_column (1)
+ , _last_tooltip_row (0)
+ , _last_tooltip_column (0)
{
_grid = new wxGrid (this, wxID_ANY);
@@ -123,6 +125,7 @@ AudioMappingView::AudioMappingView (wxWindow* parent)
Bind (wxEVT_GRID_CELL_LEFT_CLICK, boost::bind (&AudioMappingView::left_click, this, _1));
Bind (wxEVT_GRID_CELL_RIGHT_CLICK, boost::bind (&AudioMappingView::right_click, this, _1));
+ _grid->GetGridWindow()->Bind (wxEVT_MOTION, boost::bind (&AudioMappingView::mouse_moved, this, _1));
_menu = new wxMenu;
_menu->Append (ID_off, _("Off"));
@@ -137,6 +140,14 @@ AudioMappingView::AudioMappingView (wxWindow* parent)
}
void
+AudioMappingView::map_changed ()
+{
+ update_cells ();
+ Changed (_map);
+ _last_tooltip_column = -1;
+}
+
+void
AudioMappingView::left_click (wxGridEvent& ev)
{
if (ev.GetCol() == 0) {
@@ -151,8 +162,7 @@ AudioMappingView::left_click (wxGridEvent& ev)
_map.set (ev.GetRow(), d, 1);
}
- update_cells ();
- Changed (_map);
+ map_changed ();
}
void
@@ -171,24 +181,21 @@ void
AudioMappingView::off ()
{
_map.set (_menu_row, static_cast<libdcp::Channel> (_menu_column - 1), 0);
- update_cells ();
- Changed (_map);
+ map_changed ();
}
void
AudioMappingView::full ()
{
_map.set (_menu_row, static_cast<libdcp::Channel> (_menu_column - 1), 1);
- update_cells ();
- Changed (_map);
+ map_changed ();
}
void
AudioMappingView::minus3dB ()
{
_map.set (_menu_row, static_cast<libdcp::Channel> (_menu_column - 1), 1 / sqrt (2));
- update_cells ();
- Changed (_map);
+ map_changed ();
}
void
@@ -199,8 +206,7 @@ AudioMappingView::edit ()
AudioGainDialog* dialog = new AudioGainDialog (this, _menu_row, _menu_column - 1, _map.get (_menu_row, d));
if (dialog->ShowModal () == wxID_OK) {
_map.set (_menu_row, d, dialog->value ());
- update_cells ();
- Changed (_map);
+ map_changed ();
}
dialog->Destroy ();
@@ -288,3 +294,40 @@ AudioMappingView::set_column_labels ()
_grid->AutoSize ();
}
+
+void
+AudioMappingView::mouse_moved (wxMouseEvent& ev)
+{
+ int xx;
+ int yy;
+ _grid->CalcUnscrolledPosition (ev.GetX(), ev.GetY(), &xx, &yy);
+
+ int const row = _grid->YToRow (yy);
+ int const column = _grid->XToCol (xx);
+
+ if (row < 0 || column < 1) {
+ _grid->GetGridWindow()->SetToolTip ("");
+ _last_tooltip_row = row;
+ _last_tooltip_column = column;
+ }
+
+ if (row != _last_tooltip_row || column != _last_tooltip_column) {
+
+ wxString s;
+ float const gain = _map.get (row, static_cast<libdcp::Channel> (column - 1));
+ if (gain == 0) {
+ s = wxString::Format (_("No audio will be passed from content channel %d to DCP channel %d."), row + 1, column);
+ } else if (gain == 1) {
+ s = wxString::Format (_("Audio will be passed from content channel %d to DCP channel %d unaltered."), row + 1, column);
+ } else {
+ float const dB = 20 * log10 (gain);
+ s = wxString::Format (_("Audio will be passed from content channel %d to DCP channel %d with gain %.1fdB."), row + 1, column, dB);
+ }
+
+ _grid->GetGridWindow()->SetToolTip (s + " " + _("Right click to change gain."));
+ _last_tooltip_row = row;
+ _last_tooltip_column = column;
+ }
+
+ ev.Skip ();
+}
diff --git a/src/wx/audio_mapping_view.h b/src/wx/audio_mapping_view.h
index 31b6e6e3c..26f1746e0 100644
--- a/src/wx/audio_mapping_view.h
+++ b/src/wx/audio_mapping_view.h
@@ -35,8 +35,10 @@ public:
private:
void left_click (wxGridEvent &);
void right_click (wxGridEvent &);
+ void mouse_moved (wxMouseEvent &);
void set_column_labels ();
void update_cells ();
+ void map_changed ();
void off ();
void full ();
@@ -50,4 +52,7 @@ private:
wxMenu* _menu;
int _menu_row;
int _menu_column;
+
+ int _last_tooltip_row;
+ int _last_tooltip_column;
};