summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-07-27 22:30:35 +0100
committerCarl Hetherington <cth@carlh.net>2012-07-27 22:30:35 +0100
commit6427e9dcb2cd239dcd5a392aac847df47f9875d9 (patch)
treeeb69053b6b103db808bfeaf1d07fc9c729fa533f /src/wx
parent423928e4a0c9294f7e7da30030f00e3fc09cdf14 (diff)
Use a Crop struct and use it to speed up cropping a bit.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/film_editor.cc29
-rw-r--r--src/wx/film_viewer.cc42
2 files changed, 32 insertions, 39 deletions
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index ce2b02211..f0fc4f68f 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -224,7 +224,7 @@ FilmEditor::left_crop_changed (wxCommandEvent &)
return;
}
- _ignore_changes = Film::LEFT_CROP;
+ _ignore_changes = Film::CROP;
_film->set_left_crop (_left_crop->GetValue ());
_ignore_changes = Film::NONE;
}
@@ -237,7 +237,7 @@ FilmEditor::right_crop_changed (wxCommandEvent &)
return;
}
- _ignore_changes = Film::RIGHT_CROP;
+ _ignore_changes = Film::CROP;
_film->set_right_crop (_right_crop->GetValue ());
_ignore_changes = Film::NONE;
}
@@ -250,7 +250,7 @@ FilmEditor::top_crop_changed (wxCommandEvent &)
return;
}
- _ignore_changes = Film::TOP_CROP;
+ _ignore_changes = Film::CROP;
_film->set_top_crop (_top_crop->GetValue ());
_ignore_changes = Film::NONE;
}
@@ -263,7 +263,7 @@ FilmEditor::bottom_crop_changed (wxCommandEvent &)
return;
}
- _ignore_changes = Film::BOTTOM_CROP;
+ _ignore_changes = Film::CROP;
_film->set_bottom_crop (_bottom_crop->GetValue ());
_ignore_changes = Film::NONE;
}
@@ -341,17 +341,11 @@ FilmEditor::film_changed (Film::Property p)
case Film::FORMAT:
_format->SetSelection (Format::as_index (_film->format ()));
break;
- case Film::LEFT_CROP:
- _left_crop->SetValue (_film->left_crop ());
- break;
- case Film::RIGHT_CROP:
- _right_crop->SetValue (_film->right_crop ());
- break;
- case Film::TOP_CROP:
- _top_crop->SetValue (_film->top_crop ());
- break;
- case Film::BOTTOM_CROP:
- _bottom_crop->SetValue (_film->bottom_crop ());
+ case Film::CROP:
+ _left_crop->SetValue (_film->crop().left);
+ _right_crop->SetValue (_film->crop().right);
+ _top_crop->SetValue (_film->crop().top);
+ _bottom_crop->SetValue (_film->crop().bottom);
break;
case Film::FILTERS:
{
@@ -489,10 +483,7 @@ FilmEditor::set_film (Film* f)
film_changed (Film::CONTENT);
film_changed (Film::DCP_CONTENT_TYPE);
film_changed (Film::FORMAT);
- film_changed (Film::LEFT_CROP);
- film_changed (Film::RIGHT_CROP);
- film_changed (Film::TOP_CROP);
- film_changed (Film::BOTTOM_CROP);
+ film_changed (Film::CROP);
film_changed (Film::FILTERS);
film_changed (Film::DCP_FRAMES);
film_changed (Film::DCP_TRIM_ACTION);
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index be2b93f79..f75efd728 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -44,10 +44,6 @@ public:
, _film (film)
, _image (0)
, _bitmap (0)
- , _left_crop (0)
- , _right_crop (0)
- , _top_crop (0)
- , _bottom_crop (0)
{
}
@@ -59,7 +55,12 @@ public:
_current_image = _pending_image;
setup ();
}
-
+
+ if (_current_crop != _pending_crop) {
+ _current_crop = _pending_crop;
+ setup ();
+ }
+
wxPaintDC dc (this);
if (_bitmap) {
dc.DrawBitmap (*_bitmap, 0, 0, false);
@@ -73,6 +74,7 @@ public:
}
setup ();
+ Refresh ();
}
void set (string f)
@@ -81,13 +83,10 @@ public:
Refresh ();
}
- void set_crop (int l, int r, int t, int b)
+ void set_crop (Crop c)
{
- _left_crop = l;
- _right_crop = r;
- _top_crop = t;
- _bottom_crop = b;
- setup ();
+ _pending_crop = c;
+ Refresh ();
}
void set_film (Film* f)
@@ -95,8 +94,10 @@ public:
_film = f;
if (!_film) {
clear ();
+ Refresh ();
} else {
setup ();
+ Refresh ();
}
}
@@ -124,7 +125,12 @@ private:
float const target = _film->format() ? _film->format()->ratio_as_float () : 1.78;
_cropped_image = _image->GetSubImage (
- wxRect (_left_crop, _top_crop, _image->GetWidth() - (_left_crop + _right_crop), _image->GetHeight() - (_top_crop + _bottom_crop))
+ wxRect (
+ _current_crop.left,
+ _current_crop.top,
+ _image->GetWidth() - (_current_crop.left + _current_crop.right),
+ _image->GetHeight() - (_current_crop.top + _current_crop.bottom)
+ )
);
if ((float (vw) / vh) > target) {
@@ -137,8 +143,6 @@ private:
delete _bitmap;
_bitmap = new wxBitmap (_cropped_image);
-
- Refresh ();
}
Film* _film;
@@ -147,10 +151,8 @@ private:
std::string _pending_image;
wxImage _cropped_image;
wxBitmap* _bitmap;
- int _left_crop;
- int _right_crop;
- int _top_crop;
- int _bottom_crop;
+ Crop _current_crop;
+ Crop _pending_crop;
};
BEGIN_EVENT_TABLE (ThumbPanel, wxPanel)
@@ -203,8 +205,8 @@ FilmViewer::slider_changed (wxCommandEvent &)
void
FilmViewer::film_changed (Film::Property p)
{
- if (p == Film::LEFT_CROP || p == Film::RIGHT_CROP || p == Film::TOP_CROP || p == Film::BOTTOM_CROP) {
- _thumb_panel->set_crop (_film->left_crop(), _film->right_crop(), _film->top_crop(), _film->bottom_crop ());
+ if (p == Film::CROP) {
+ _thumb_panel->set_crop (_film->crop ());
} else if (p == Film::THUMBS) {
if (_film && _film->num_thumbs() > 1) {
_slider->SetRange (0, _film->num_thumbs () - 1);