diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-06-16 23:52:50 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-12-12 22:08:01 +0100 |
| commit | 8c20648865135610f7db8c453c91df06bcd3309f (patch) | |
| tree | a356531ae5424f927012987c56564ef3667c281a | |
| parent | 444677ce626b99b241b714655e5e42007d3e8d32 (diff) | |
Horizontally-centre player image with the simple view.
| -rw-r--r-- | src/wx/simple_video_view.cc | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/wx/simple_video_view.cc b/src/wx/simple_video_view.cc index a1572dfc9..d6a828a45 100644 --- a/src/wx/simple_video_view.cc +++ b/src/wx/simple_video_view.cc @@ -79,6 +79,9 @@ SimpleVideoView::paint () auto const pad = pad_colour(); dcp::Size out_size; + int x_position = 0; + int y_position = 0; + if (!_image) { wxBrush b (pad); dc.SetBackground (b); @@ -86,9 +89,11 @@ SimpleVideoView::paint () } else { DCPOMATIC_ASSERT (_image->alignment() == Image::Alignment::COMPACT); out_size = _image->size(); + x_position = max(0, (panel_size.width - out_size.width) / 2); + y_position = max(0, (panel_size.height - out_size.height) / 2); wxImage frame (out_size.width, out_size.height, _image->data()[0], true); wxBitmap frame_bitmap (frame); - dc.DrawBitmap(frame_bitmap, 0, max(0, (panel_size.height - out_size.height) / 2)); + dc.DrawBitmap(frame_bitmap, x_position, y_position); } if (out_size.width < panel_size.width) { @@ -96,7 +101,9 @@ SimpleVideoView::paint () wxBrush b (pad); dc.SetPen (p); dc.SetBrush (b); - dc.DrawRectangle(out_size.width, 0, panel_size.width - out_size.width, panel_size.height); + auto const gap = (panel_size.width - out_size.width) / 2; + dc.DrawRectangle(0, 0, gap, panel_size.height); + dc.DrawRectangle(gap + out_size.width, 0, gap + 1, panel_size.height); } if (out_size.height < panel_size.height) { @@ -113,7 +120,12 @@ SimpleVideoView::paint () wxPen p (outline_content_colour(), 2); dc.SetPen (p); dc.SetBrush (*wxTRANSPARENT_BRUSH); - dc.DrawRectangle(_inter_position.x, _inter_position.y + (panel_size.height - out_size.height) / 2, _inter_size.width, _inter_size.height); + dc.DrawRectangle( + x_position + _inter_position.x, + y_position + _inter_position.y + (panel_size.height - out_size.height) / 2, + _inter_size.width, + _inter_size.height + ); } auto subs = _viewer->outline_subtitles(); @@ -121,7 +133,12 @@ SimpleVideoView::paint () wxPen p (outline_subtitles_colour(), 2); dc.SetPen (p); dc.SetBrush (*wxTRANSPARENT_BRUSH); - dc.DrawRectangle (subs->x * out_size.width, subs->y * out_size.height, subs->width * out_size.width, subs->height * out_size.height); + dc.DrawRectangle( + x_position + subs->x * out_size.width, + y_position + subs->y * out_size.height, + subs->width * out_size.width, + subs->height * out_size.height + ); } if (_viewer->crop_guess()) { @@ -130,8 +147,8 @@ SimpleVideoView::paint () dc.SetBrush (*wxTRANSPARENT_BRUSH); auto const crop_guess = _viewer->crop_guess().get(); dc.DrawRectangle ( - _inter_position.x + _inter_size.width * crop_guess.x, - _inter_position.y + _inter_size.height * crop_guess.y, + x_position + _inter_position.x + _inter_size.width * crop_guess.x, + y_position + _inter_position.y + _inter_size.height * crop_guess.y, _inter_size.width * crop_guess.width, _inter_size.height * crop_guess.height ); |
