1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*
Copyright (C) 2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
#include "auto_crop_dialog.h"
#include "dcpomatic_spin_ctrl.h"
#include "wx_util.h"
#include "lib/config.h"
AutoCropDialog::AutoCropDialog(wxWindow* parent, Crop crop)
: TableDialog(parent, _("Auto crop"), 2, 1, true)
{
add(_("Left"), true);
_left = add(new SpinCtrl(this));
add(_("Right"), true);
_right = add(new SpinCtrl(this));
add(_("Top"), true);
_top = add(new SpinCtrl(this));
add(_("Bottom"), true);
_bottom = add(new SpinCtrl(this));
add(_("Threshold"), true);
_threshold = add(new SpinCtrl(this));
_left->SetRange(0, 4096);
_right->SetRange(0, 4096);
_top->SetRange(0, 4096);
_bottom->SetRange(0, 4096);
set(crop);
_threshold->SetValue(std::round(Config::instance()->auto_crop_threshold() * 100));
layout();
_left->Bind(wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); });
_right->Bind(wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); });
_top->Bind(wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); });
_bottom->Bind(wxEVT_SPINCTRL, [this](wxSpinEvent&) { Changed(get()); });
_threshold->Bind(wxEVT_SPINCTRL, [](wxSpinEvent& ev) { Config::instance()->set_auto_crop_threshold(ev.GetPosition() / 100.0); });
}
Crop
AutoCropDialog::get() const
{
return Crop(_left->GetValue(), _right->GetValue(), _top->GetValue(), _bottom->GetValue());
}
void
AutoCropDialog::set(Crop crop)
{
_left->SetValue(crop.left);
_right->SetValue(crop.right);
_top->SetValue(crop.top);
_bottom->SetValue(crop.bottom);
}
|