diff options
| author | Martin Lambers <marlam@marlam.de> | 2012-02-01 07:58:03 +0100 |
|---|---|---|
| committer | Martin Lambers <marlam@marlam.de> | 2012-02-01 07:58:03 +0100 |
| commit | fe5a518eec90427f1eff916c6361422062081c50 (patch) | |
| tree | ba761f7ffae4fee409b4439ffbb4ac87b0b2036b | |
| parent | 27095573fee12acc90bc5b181ba7516f06b83779 (diff) | |
| download | bino-fe5a518eec90427f1eff916c6361422062081c50.tar.gz | |
Improve zoom, and put it into its own GUI dialog.
| -rw-r--r-- | doc/bino.1 | 4 | ||||
| -rw-r--r-- | doc/bino.texi | 4 | ||||
| -rw-r--r-- | src/main.cpp | 2 | ||||
| -rw-r--r-- | src/player.cpp | 4 | ||||
| -rw-r--r-- | src/player_qt.cpp | 170 | ||||
| -rw-r--r-- | src/player_qt.h | 26 |
6 files changed, 139 insertions, 71 deletions
@@ -202,8 +202,8 @@ Flip right view vertically when in fullscreen mode. .IP "\-\-fullscreen\-flop\-right" Flop right view horizontally when in fullscreen mode. .IP "\-z|\-\-zoom=\fIZ\fP" -Set zoom for videos that are wider than the screen, from 0 (off; show full -video width) to 1 (full; use full screen height). The default is 0. +Set zoom for videos that are wider than the screen, from 0 to 2. +Z=0: show full video width, Z=1: use full screen height. The default is 0. .IP "\-c|\-\-center" Center window on screen. .IP "\-\-subtitle\-encoding=\fIENC\fP" diff --git a/doc/bino.texi b/doc/bino.texi index 5db3874..deb8ed6 100644 --- a/doc/bino.texi +++ b/doc/bino.texi @@ -170,8 +170,8 @@ Flip right view vertically when in fullscreen mode. Flop right view horizontally when in fullscreen mode. @item -z @itemx --zoom=@var{Z} -Set zoom for videos that are wider than the screen, from 0 (off; show full -video width) to 1 (full; use full screen height). The default is 0. +Set zoom for videos that are wider than the screen, from 0 to 2. +@var{Z}=0: show full video width, @var{Z}=1: use full screen height. @item -c @itemx --center Center window on screen. diff --git a/src/main.cpp b/src/main.cpp index a1f1a6f..2c1e15e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -297,7 +297,7 @@ int main(int argc, char *argv[]) options.push_back(&fullscreen_flip_right); opt::flag fullscreen_flop_right("fullscreen-flop-right", '\0', opt::optional); options.push_back(&fullscreen_flop_right); - opt::val<float> zoom("zoom", 'z', opt::optional, 0.0f, 1.0f, parameters().zoom); + opt::val<float> zoom("zoom", 'z', opt::optional, 0.0f, 2.0f, parameters().zoom); options.push_back(&zoom); opt::flag center("center", 'c', opt::optional); options.push_back(¢er); diff --git a/src/player.cpp b/src/player.cpp index a5675f9..125994e 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -1147,14 +1147,14 @@ void player::receive_cmd(const command &cmd) case command::adjust_zoom: s11n::load(p, param); oldval = _params.zoom; - _params.zoom = std::max(std::min(_params.zoom + param, 1.0f), 0.0f); + _params.zoom = std::max(std::min(_params.zoom + param, 2.0f), 0.0f); parameters_changed = true; controller::notify_all(notification::zoom, oldval, _params.zoom); break; case command::set_zoom: s11n::load(p, param); oldval = _params.zoom; - _params.zoom = std::max(std::min(param, 1.0f), 0.0f); + _params.zoom = std::max(std::min(param, 2.0f), 0.0f); parameters_changed = true; controller::notify_all(notification::zoom, oldval, _params.zoom); break; diff --git a/src/player_qt.cpp b/src/player_qt.cpp index e41b834..4b06a08 100644 --- a/src/player_qt.cpp +++ b/src/player_qt.cpp @@ -1422,6 +1422,90 @@ void crosstalk_dialog::receive_notification(const notification ¬e) } +zoom_dialog::zoom_dialog(parameters *params, QWidget *parent) : QDialog(parent), + _params(params), _lock(false) +{ + setModal(false); + setWindowTitle(_("Zoom for wide videos")); + + QLabel *info_label = new QLabel(_( + "<p>Set zoom level for videos that<br>" + "are wider than the screen:<br>" + "0: Show full video width.<br>" + "1: Use full screen height.<br>" + "> 1: Zoom even more.</p>")); + QLabel *z_label = new QLabel(_("Zoom:")); + z_label->setToolTip(_("<p>Set the zoom level for videos that are wider than the screen</p>")); + _z_slider = new QSlider(Qt::Horizontal); + _z_slider->setRange(0, 2000); + _z_slider->setValue(params->zoom * 1000.0f); + _z_slider->setToolTip(z_label->toolTip()); + connect(_z_slider, SIGNAL(valueChanged(int)), this, SLOT(z_slider_changed(int))); + _z_spinbox = new QDoubleSpinBox(); + _z_spinbox->setRange(0.0, +2.0); + _z_spinbox->setValue(params->zoom); + _z_spinbox->setDecimals(2); + _z_spinbox->setSingleStep(0.01); + _z_spinbox->setToolTip(z_label->toolTip()); + connect(_z_spinbox, SIGNAL(valueChanged(double)), this, SLOT(z_spinbox_changed(double))); + + QPushButton *ok_button = new QPushButton(_("OK")); + connect(ok_button, SIGNAL(pressed()), this, SLOT(close())); + + QGridLayout *layout = new QGridLayout; + layout->addWidget(info_label, 0, 0, 1, 3); + layout->addWidget(z_label, 1, 0); + layout->addWidget(_z_slider, 1, 1); + layout->addWidget(_z_spinbox, 1, 2); + layout->addWidget(ok_button, 2, 0, 1, 3); + setLayout(layout); +} + +void zoom_dialog::z_slider_changed(int val) +{ + if (!_lock) + { + _params->zoom = val / 1000.0f; + _lock = true; + _z_spinbox->setValue(val / 1000.0f); + _lock = false; + send_cmd(command::set_zoom, val / 1000.0f); + } +} + +void zoom_dialog::z_spinbox_changed(double val) +{ + if (!_lock) + { + _params->zoom = val; + _lock = true; + _z_slider->setValue(val * 1000.0); + _lock = false; + send_cmd(command::set_zoom, static_cast<float>(val)); + } +} + +void zoom_dialog::receive_notification(const notification ¬e) +{ + std::istringstream current(note.current); + float value; + + switch (note.type) + { + case notification::zoom: + s11n::load(current, value); + _lock = true; + _z_slider->setValue(value * 1000.0f); + _z_spinbox->setValue(value); + _lock = false; + break; + default: + /* not handled */ + break; + } +} + + audio_dialog::audio_dialog(player_init_data *init_data, parameters *params, QWidget *parent) : QDialog(parent), _init_data(init_data), _params(params), _lock(false) { @@ -1807,22 +1891,6 @@ video_dialog::video_dialog(parameters *params, QWidget *parent) : QDialog(parent setModal(false); setWindowTitle(_("Video Settings")); - QLabel *z_label = new QLabel(_("Zoom:")); - z_label->setToolTip(_("<p>Set the zoom level for videos that are wider than the screen, " - "from 0 (off; show full video width) to 1 (full; use full screen height).</p>")); - _z_slider = new QSlider(Qt::Horizontal); - _z_slider->setRange(0, 1000); - _z_slider->setValue(params->zoom * 1000.0f); - _z_slider->setToolTip(z_label->toolTip()); - connect(_z_slider, SIGNAL(valueChanged(int)), this, SLOT(z_slider_changed(int))); - _z_spinbox = new QDoubleSpinBox(); - _z_spinbox->setRange(0.0, +1.0); - _z_spinbox->setValue(params->zoom); - _z_spinbox->setDecimals(2); - _z_spinbox->setSingleStep(0.01); - _z_spinbox->setToolTip(z_label->toolTip()); - connect(_z_spinbox, SIGNAL(valueChanged(double)), this, SLOT(z_spinbox_changed(double))); - QLabel *p_label = new QLabel(_("Parallax:")); p_label->setToolTip(_("<p>Adjust parallax, from -1 to +1. This changes the separation of left and right view, " "and thus the perceived distance of the scene.</p>")); @@ -1876,46 +1944,19 @@ video_dialog::video_dialog(parameters *params, QWidget *parent) : QDialog(parent connect(ok_button, SIGNAL(pressed()), this, SLOT(close())); QGridLayout *layout = new QGridLayout; - layout->addWidget(z_label, 0, 0); - layout->addWidget(_z_slider, 0, 1); - layout->addWidget(_z_spinbox, 0, 2); - layout->addWidget(p_label, 1, 0); - layout->addWidget(_p_slider, 1, 1); - layout->addWidget(_p_spinbox, 1, 2); - layout->addWidget(sp_label, 2, 0); - layout->addWidget(_sp_slider, 2, 1); - layout->addWidget(_sp_spinbox, 2, 2); - layout->addWidget(g_label, 3, 0); - layout->addWidget(_g_slider, 3, 1); - layout->addWidget(_g_spinbox, 3, 2); - layout->addWidget(ok_button, 4, 0, 1, 3); + layout->addWidget(p_label, 0, 0); + layout->addWidget(_p_slider, 0, 1); + layout->addWidget(_p_spinbox, 0, 2); + layout->addWidget(sp_label, 1, 0); + layout->addWidget(_sp_slider, 1, 1); + layout->addWidget(_sp_spinbox, 1, 2); + layout->addWidget(g_label, 2, 0); + layout->addWidget(_g_slider, 2, 1); + layout->addWidget(_g_spinbox, 2, 2); + layout->addWidget(ok_button, 3, 0, 1, 3); setLayout(layout); } -void video_dialog::z_slider_changed(int val) -{ - if (!_lock) - { - _params->zoom = val / 1000.0f; - _lock = true; - _z_spinbox->setValue(val / 1000.0f); - _lock = false; - send_cmd(command::set_zoom, val / 1000.0f); - } -} - -void video_dialog::z_spinbox_changed(double val) -{ - if (!_lock) - { - _params->zoom = val; - _lock = true; - _z_slider->setValue(val * 1000.0); - _lock = false; - send_cmd(command::set_zoom, static_cast<float>(val)); - } -} - void video_dialog::p_slider_changed(int val) { if (!_lock) @@ -1995,13 +2036,6 @@ void video_dialog::receive_notification(const notification ¬e) switch (note.type) { - case notification::zoom: - s11n::load(current, value); - _lock = true; - _z_slider->setValue(value * 1000.0f); - _z_spinbox->setValue(value); - _lock = false; - break; case notification::parallax: s11n::load(current, value); _lock = true; @@ -2154,6 +2188,7 @@ main_window::main_window(QSettings *settings, const player_init_data &init_data) _settings(settings), _color_dialog(NULL), _crosstalk_dialog(NULL), + _zoom_dialog(NULL), _audio_dialog(NULL), _subtitle_dialog(NULL), _video_dialog(NULL), @@ -2325,6 +2360,10 @@ main_window::main_window(QSettings *settings, const player_init_data &init_data) connect(preferences_crosstalk_act, SIGNAL(triggered()), this, SLOT(preferences_crosstalk())); preferences_menu->addAction(preferences_crosstalk_act); preferences_menu->addSeparator(); + QAction *preferences_zoom_act = new QAction(_("&Zoom for wide videos..."), this); + connect(preferences_zoom_act, SIGNAL(triggered()), this, SLOT(preferences_zoom())); + preferences_menu->addAction(preferences_zoom_act); + preferences_menu->addSeparator(); QAction *preferences_audio_act = new QAction(_("&Audio Settings..."), this); connect(preferences_audio_act, SIGNAL(triggered()), this, SLOT(preferences_audio())); preferences_menu->addAction(preferences_audio_act); @@ -3211,6 +3250,17 @@ void main_window::preferences_crosstalk() _crosstalk_dialog->activateWindow(); } +void main_window::preferences_zoom() +{ + if (!_zoom_dialog) + { + _zoom_dialog = new zoom_dialog(&_init_data.params, this); + } + _zoom_dialog->show(); + _zoom_dialog->raise(); + _zoom_dialog->activateWindow(); +} + void main_window::preferences_audio() { if (!_audio_dialog) diff --git a/src/player_qt.h b/src/player_qt.h index 41ca351..e58e348 100644 --- a/src/player_qt.h +++ b/src/player_qt.h @@ -218,6 +218,26 @@ public: virtual void receive_notification(const notification ¬e); }; +class zoom_dialog : public QDialog, public controller +{ + Q_OBJECT + +private: + parameters *_params; + bool _lock; + QDoubleSpinBox *_z_spinbox; + QSlider *_z_slider; + +private slots: + void z_slider_changed(int val); + void z_spinbox_changed(double val); + +public: + zoom_dialog(parameters *params, QWidget *parent); + + virtual void receive_notification(const notification ¬e); +}; + class audio_dialog : public QDialog, public controller { Q_OBJECT @@ -282,8 +302,6 @@ class video_dialog : public QDialog, public controller private: parameters *_params; bool _lock; - QDoubleSpinBox *_z_spinbox; - QSlider *_z_slider; QDoubleSpinBox *_p_spinbox; QSlider *_p_slider; QDoubleSpinBox *_sp_spinbox; @@ -292,8 +310,6 @@ private: QSlider *_g_slider; private slots: - void z_slider_changed(int val); - void z_spinbox_changed(double val); void p_slider_changed(int val); void p_spinbox_changed(double val); void sp_slider_changed(int val); @@ -346,6 +362,7 @@ private: controls_widget *_controls_widget; color_dialog *_color_dialog; crosstalk_dialog *_crosstalk_dialog; + zoom_dialog *_zoom_dialog; audio_dialog *_audio_dialog; subtitle_dialog *_subtitle_dialog; video_dialog *_video_dialog; @@ -376,6 +393,7 @@ private slots: void preferences_fullscreen(); void preferences_colors(); void preferences_crosstalk(); + void preferences_zoom(); void preferences_audio(); void preferences_subtitle(); void preferences_video(); |
