summaryrefslogtreecommitdiff
path: root/src/wx/film_viewer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/wx/film_viewer.cc')
-rw-r--r--src/wx/film_viewer.cc53
1 files changed, 25 insertions, 28 deletions
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index bf082adc2..c42ffaeeb 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -58,21 +58,18 @@ public:
if (_frame_rebuild_needed) {
_image.reset (new wxImage (std_to_wx (_film->thumb_file (_index))));
- _subtitles.clear ();
- list<pair<Position, string> > s = _film->thumb_subtitles (_index);
- for (list<pair<Position, string> >::iterator i = s.begin(); i != s.end(); ++i) {
- _subtitles.push_back (SubtitleView (i->first, std_to_wx (i->second)));
+ _subtitle.reset ();
+ pair<Position, string> s = _film->thumb_subtitle (_index);
+ if (!s.second.empty ()) {
+ _subtitle.reset (new SubtitleView (s.first, std_to_wx (s.second)));
}
_frame_rebuild_needed = false;
-
compose ();
- _composition_needed = false;
}
if (_composition_needed) {
compose ();
- _composition_needed = false;
}
wxPaintDC dc (this);
@@ -80,10 +77,8 @@ public:
dc.DrawBitmap (*_bitmap, 0, 0, false);
}
- if (_film->with_subtitles ()) {
- for (list<SubtitleView>::iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
- dc.DrawBitmap (*i->bitmap, i->transformed_area.x, i->transformed_area.y, true);
- }
+ if (_film->with_subtitles() && _subtitle) {
+ dc.DrawBitmap (*_subtitle->bitmap, _subtitle->transformed_area.x, _subtitle->transformed_area.y, true);
}
}
@@ -123,7 +118,7 @@ public:
{
_bitmap.reset ();
_image.reset ();
- _subtitles.clear ();
+ _subtitle.reset ();
}
void recompose ()
@@ -138,6 +133,8 @@ private:
void compose ()
{
+ _composition_needed = false;
+
if (!_film || !_image) {
return;
}
@@ -157,7 +154,7 @@ private:
/* Target ratio */
float const target = _film->format() ? _film->format()->ratio_as_float (_film) : 1.78;
- _transformed_image = _image->GetSubImage (wxRect (cropped_area.x, cropped_area.y, cropped_area.w, cropped_area.h));
+ _transformed_image = _image->GetSubImage (wxRect (cropped_area.x, cropped_area.y, cropped_area.width, cropped_area.height));
float x_scale = 1;
float y_scale = 1;
@@ -165,28 +162,28 @@ private:
if ((float (vw) / vh) > target) {
/* view is longer (horizontally) than the ratio; fit height */
_transformed_image.Rescale (vh * target, vh, wxIMAGE_QUALITY_HIGH);
- x_scale = vh * target / cropped_area.w;
- y_scale = float (vh) / cropped_area.h;
+ x_scale = vh * target / cropped_area.width;
+ y_scale = float (vh) / cropped_area.height;
} else {
/* view is shorter (horizontally) than the ratio; fit width */
_transformed_image.Rescale (vw, vw / target, wxIMAGE_QUALITY_HIGH);
- x_scale = float (vw) / cropped_area.w;
- y_scale = (vw / target) / cropped_area.h;
+ x_scale = float (vw) / cropped_area.width;
+ y_scale = (vw / target) / cropped_area.height;
}
_bitmap.reset (new wxBitmap (_transformed_image));
- for (list<SubtitleView>::iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) {
+ if (_subtitle) {
- i->transformed_area = transformed_subtitle_area (
- x_scale, y_scale, i->base_area, _film->subtitle_offset(), _film->subtitle_scale()
+ _subtitle->transformed_area = subtitle_transformed_area (
+ x_scale, y_scale, _subtitle->base_area, _film->subtitle_offset(), _film->subtitle_scale()
);
- i->transformed_image = i->base_image;
- i->transformed_image.Rescale (i->transformed_area.w, i->transformed_area.h, wxIMAGE_QUALITY_HIGH);
- i->transformed_area.x -= _film->crop().left;
- i->transformed_area.y -= _film->crop().top;
- i->bitmap.reset (new wxBitmap (i->transformed_image));
+ _subtitle->transformed_image = _subtitle->base_image;
+ _subtitle->transformed_image.Rescale (_subtitle->transformed_area.width, _subtitle->transformed_area.height, wxIMAGE_QUALITY_HIGH);
+ _subtitle->transformed_area.x -= _film->crop().left;
+ _subtitle->transformed_area.y -= _film->crop().top;
+ _subtitle->bitmap.reset (new wxBitmap (_subtitle->transformed_image));
}
}
@@ -206,8 +203,8 @@ private:
{
base_area.x = p.x;
base_area.y = p.y;
- base_area.w = base_image.GetWidth ();
- base_area.h = base_image.GetHeight ();
+ base_area.width = base_image.GetWidth ();
+ base_area.height = base_image.GetHeight ();
}
Rectangle base_area;
@@ -217,7 +214,7 @@ private:
shared_ptr<wxBitmap> bitmap;
};
- list<SubtitleView> _subtitles;
+ shared_ptr<SubtitleView> _subtitle;
};
BEGIN_EVENT_TABLE (ThumbPanel, wxPanel)