]> git.sesse.net Git - casparcg/blob - core/producer/text/text_producer.h
Merge branch '2.1.0' of https://github.com/CasparCG/Server into 2.1.0
[casparcg] / core / producer / text / text_producer.h
1 /*
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
3 *
4 * This file is part of CasparCG (www.casparcg.com).
5 *
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: Niklas P Andersson, niklas.p.andersson@svt.se
20 */
21
22 #pragma once
23
24 #include "../frame_producer.h"
25
26 #include <common/memory.h>
27
28 #include <boost/property_tree/ptree_fwd.hpp>
29 #include <string>
30 #include <vector>
31
32 #include "utils/color.h"
33 #include "utils/string_metrics.h"
34
35 namespace caspar { namespace core {
36         namespace text 
37         {
38                 void init();
39
40                 struct text_info
41                 {
42                         std::wstring font;
43                         float size;
44                         color<float> color;
45                 };
46         }
47
48 class text_producer : public frame_producer_base
49 {
50 public:
51         text_producer(const spl::shared_ptr<frame_factory>& frame_factory, int x, int y, const std::wstring& str, const text::text_info& text_info, long parent_width, long parent_height, bool standalone);
52         static spl::shared_ptr<text_producer> create(const spl::shared_ptr<class frame_factory>& frame_factory, int x, int y, const std::wstring& str, const text::text_info& text_info, long parent_width, long parent_height, bool standalone = false);
53         
54         draw_frame receive_impl() override;
55         boost::unique_future<std::wstring> call(const std::vector<std::wstring>& param) override;
56
57         text::string_metrics measure_string(const std::wstring& str);
58
59         constraints& pixel_constraints() override;
60         std::wstring print() const override;
61         std::wstring name() const override;
62         boost::property_tree::wptree info() const override;
63         void subscribe(const monitor::observable::observer_ptr& o) override;
64         void unsubscribe(const monitor::observable::observer_ptr& o) override;
65
66         binding<std::wstring>& text();
67         const binding<int>& current_bearing_y() const;
68         const binding<int>& current_protrude_under_y() const;
69 private:
70         struct impl;
71         spl::unique_ptr<impl> impl_;
72 };
73
74 spl::shared_ptr<frame_producer> create_text_producer(const spl::shared_ptr<class frame_factory>& frame_factory, const video_format_desc& format_desc, const std::vector<std::wstring>& params);
75
76
77 }}