Logging improvements to allow prettier displays in the server GUI.
[dcpomatic.git] / src / lib / video_content_scale.h
1 /*
2     Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef DCPOMATIC_VIDEO_CONTENT_SCALE_H
21 #define DCPOMATIC_VIDEO_CONTENT_SCALE_H
22
23 #include <dcp/util.h>
24 #include <boost/shared_ptr.hpp>
25 #include <vector>
26
27 namespace cxml {
28         class Node;
29 }
30
31 namespace xmlpp {
32         class Node;
33 }
34
35 class Ratio;
36 class VideoContent;
37
38 class VideoContentScale
39 {
40 public:
41         VideoContentScale ();
42         VideoContentScale (Ratio const *);
43         VideoContentScale (bool);
44         VideoContentScale (boost::shared_ptr<cxml::Node>);
45
46         dcp::Size size (boost::shared_ptr<const VideoContent>, dcp::Size display_container, dcp::Size film_container) const;
47         std::string id () const;
48         std::string name () const;
49         void as_xml (xmlpp::Node *) const;
50
51         Ratio const * ratio () const {
52                 return _ratio;
53         }
54
55         bool scale () const {
56                 return _scale;
57         }
58
59         static void setup_scales ();
60         static std::vector<VideoContentScale> all () {
61                 return _scales;
62         }
63         static VideoContentScale from_id (std::string id);
64
65 private:
66         /** a ratio to stretch the content to, or 0 for no stretch */
67         Ratio const * _ratio;
68         /** true if we want to change the size of the content in any way */
69         bool _scale;
70
71         /* If _ratio is 0 and _scale is false there is no scale at all (i.e.
72            the content is used at its original size)
73         */
74
75         static std::vector<VideoContentScale> _scales;
76 };
77
78 bool operator== (VideoContentScale const & a, VideoContentScale const & b);
79 bool operator!= (VideoContentScale const & a, VideoContentScale const & b);
80
81 #endif