New upstream version 24.0.1+dfsg1
This commit is contained in:
parent
b14f9eae6d
commit
5a730d6ec3
842 changed files with 42245 additions and 33385 deletions
|
|
@ -12,20 +12,23 @@
|
|||
using namespace std;
|
||||
using namespace Gdiplus;
|
||||
|
||||
#define warning(format, ...) blog(LOG_WARNING, "[%s] " format, \
|
||||
obs_source_get_name(source), ##__VA_ARGS__)
|
||||
#define warning(format, ...) \
|
||||
blog(LOG_WARNING, "[%s] " format, obs_source_get_name(source), \
|
||||
##__VA_ARGS__)
|
||||
|
||||
#define warn_stat(call) \
|
||||
do { \
|
||||
if (stat != Ok) \
|
||||
#define warn_stat(call) \
|
||||
do { \
|
||||
if (stat != Ok) \
|
||||
warning("%s: %s failed (%d)", __FUNCTION__, call, \
|
||||
(int)stat); \
|
||||
(int)stat); \
|
||||
} while (false)
|
||||
|
||||
#ifndef clamp
|
||||
#define clamp(val, min_val, max_val) \
|
||||
if (val < min_val) val = min_val; \
|
||||
else if (val > max_val) val = max_val;
|
||||
if (val < min_val) \
|
||||
val = min_val; \
|
||||
else if (val > max_val) \
|
||||
val = max_val;
|
||||
#endif
|
||||
|
||||
#define MIN_SIZE_CX 2
|
||||
|
|
@ -37,6 +40,8 @@ using namespace Gdiplus;
|
|||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
#define S_FONT "font"
|
||||
#define S_USE_FILE "read_from_file"
|
||||
#define S_FILE "file"
|
||||
|
|
@ -119,6 +124,8 @@ using namespace Gdiplus;
|
|||
#define T_TRANSFORM_UPPERCASE T_("Transform.Uppercase")
|
||||
#define T_TRANSFORM_LOWERCASE T_("Transform.Lowercase")
|
||||
|
||||
/* clang-format on */
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static inline DWORD get_alpha_val(uint32_t opacity)
|
||||
|
|
@ -155,7 +162,8 @@ template<typename T, typename T2, BOOL WINAPI deleter(T2)> class GDIObj {
|
|||
|
||||
inline GDIObj &Replace(T obj_)
|
||||
{
|
||||
if (obj) deleter(obj);
|
||||
if (obj)
|
||||
deleter(obj);
|
||||
obj = obj_;
|
||||
return *this;
|
||||
}
|
||||
|
|
@ -163,14 +171,18 @@ template<typename T, typename T2, BOOL WINAPI deleter(T2)> class GDIObj {
|
|||
public:
|
||||
inline GDIObj() {}
|
||||
inline GDIObj(T obj_) : obj(obj_) {}
|
||||
inline ~GDIObj() {deleter(obj);}
|
||||
inline ~GDIObj() { deleter(obj); }
|
||||
|
||||
inline T operator=(T obj_) {Replace(obj_); return obj;}
|
||||
inline T operator=(T obj_)
|
||||
{
|
||||
Replace(obj_);
|
||||
return obj;
|
||||
}
|
||||
|
||||
inline operator T() const {return obj;}
|
||||
inline operator T() const { return obj; }
|
||||
|
||||
inline bool operator==(T obj_) const {return obj == obj_;}
|
||||
inline bool operator!=(T obj_) const {return obj != obj_;}
|
||||
inline bool operator==(T obj_) const { return obj == obj_; }
|
||||
inline bool operator!=(T obj_) const { return obj != obj_; }
|
||||
};
|
||||
|
||||
using HDCObj = GDIObj<HDC, HDC, DeleteDC>;
|
||||
|
|
@ -182,13 +194,13 @@ using HBITMAPObj = GDIObj<HBITMAP, HGDIOBJ, DeleteObject>;
|
|||
enum class Align {
|
||||
Left,
|
||||
Center,
|
||||
Right
|
||||
Right,
|
||||
};
|
||||
|
||||
enum class VAlign {
|
||||
Top,
|
||||
Center,
|
||||
Bottom
|
||||
Bottom,
|
||||
};
|
||||
|
||||
struct TextSource {
|
||||
|
|
@ -246,10 +258,10 @@ struct TextSource {
|
|||
|
||||
/* --------------------------- */
|
||||
|
||||
inline TextSource(obs_source_t *source_, obs_data_t *settings) :
|
||||
source (source_),
|
||||
hdc (CreateCompatibleDC(nullptr)),
|
||||
graphics (hdc)
|
||||
inline TextSource(obs_source_t *source_, obs_data_t *settings)
|
||||
: source(source_),
|
||||
hdc(CreateCompatibleDC(nullptr)),
|
||||
graphics(hdc)
|
||||
{
|
||||
obs_source_update(source, settings);
|
||||
}
|
||||
|
|
@ -266,13 +278,13 @@ struct TextSource {
|
|||
void UpdateFont();
|
||||
void GetStringFormat(StringFormat &format);
|
||||
void RemoveNewlinePadding(const StringFormat &format, RectF &box);
|
||||
void CalculateTextSizes(const StringFormat &format,
|
||||
RectF &bounding_box, SIZE &text_size);
|
||||
void RenderOutlineText(Graphics &graphics,
|
||||
const GraphicsPath &path,
|
||||
const Brush &brush);
|
||||
void CalculateTextSizes(const StringFormat &format, RectF &bounding_box,
|
||||
SIZE &text_size);
|
||||
void RenderOutlineText(Graphics &graphics, const GraphicsPath &path,
|
||||
const Brush &brush);
|
||||
void RenderText();
|
||||
void LoadFileText();
|
||||
void TransformText();
|
||||
|
||||
const char *GetMainString(const char *str);
|
||||
|
||||
|
|
@ -320,11 +332,11 @@ void TextSource::UpdateFont()
|
|||
void TextSource::GetStringFormat(StringFormat &format)
|
||||
{
|
||||
UINT flags = StringFormatFlagsNoFitBlackBox |
|
||||
StringFormatFlagsMeasureTrailingSpaces;
|
||||
StringFormatFlagsMeasureTrailingSpaces;
|
||||
|
||||
if (vertical)
|
||||
flags |= StringFormatFlagsDirectionVertical |
|
||||
StringFormatFlagsDirectionRightToLeft;
|
||||
StringFormatFlagsDirectionRightToLeft;
|
||||
|
||||
format.SetFormatFlags(flags);
|
||||
format.SetTrimming(StringTrimmingWord);
|
||||
|
|
@ -381,11 +393,11 @@ void TextSource::RemoveNewlinePadding(const StringFormat &format, RectF &box)
|
|||
Status stat;
|
||||
|
||||
stat = graphics.MeasureString(L"W", 2, font.get(), PointF(0.0f, 0.0f),
|
||||
&format, &before);
|
||||
&format, &before);
|
||||
warn_stat("MeasureString (without newline)");
|
||||
|
||||
stat = graphics.MeasureString(L"W\n", 3, font.get(), PointF(0.0f, 0.0f),
|
||||
&format, &after);
|
||||
&format, &after);
|
||||
warn_stat("MeasureString (with newline)");
|
||||
|
||||
float offset_cx = after.Width - before.Width;
|
||||
|
|
@ -409,12 +421,12 @@ void TextSource::RemoveNewlinePadding(const StringFormat &format, RectF &box)
|
|||
box.X -= offset_cx;
|
||||
}
|
||||
|
||||
box.Width -= offset_cx;
|
||||
box.Width -= offset_cx;
|
||||
box.Height -= offset_cy;
|
||||
}
|
||||
|
||||
void TextSource::CalculateTextSizes(const StringFormat &format,
|
||||
RectF &bounding_box, SIZE &text_size)
|
||||
RectF &bounding_box, SIZE &text_size)
|
||||
{
|
||||
RectF layout_box;
|
||||
RectF temp_box;
|
||||
|
|
@ -423,26 +435,25 @@ void TextSource::CalculateTextSizes(const StringFormat &format,
|
|||
if (!text.empty()) {
|
||||
if (use_extents && wrap) {
|
||||
layout_box.X = layout_box.Y = 0;
|
||||
layout_box.Width = float(extents_cx);
|
||||
layout_box.Width = float(extents_cx);
|
||||
layout_box.Height = float(extents_cy);
|
||||
|
||||
if (use_outline) {
|
||||
layout_box.Width -= outline_size;
|
||||
layout_box.Width -= outline_size;
|
||||
layout_box.Height -= outline_size;
|
||||
}
|
||||
|
||||
stat = graphics.MeasureString(text.c_str(),
|
||||
(int)text.size() + 1, font.get(),
|
||||
layout_box, &format,
|
||||
&bounding_box);
|
||||
(int)text.size() + 1,
|
||||
font.get(), layout_box,
|
||||
&format, &bounding_box);
|
||||
warn_stat("MeasureString (wrapped)");
|
||||
|
||||
temp_box = bounding_box;
|
||||
} else {
|
||||
stat = graphics.MeasureString(text.c_str(),
|
||||
(int)text.size() + 1, font.get(),
|
||||
PointF(0.0f, 0.0f), &format,
|
||||
&bounding_box);
|
||||
stat = graphics.MeasureString(
|
||||
text.c_str(), (int)text.size() + 1, font.get(),
|
||||
PointF(0.0f, 0.0f), &format, &bounding_box);
|
||||
warn_stat("MeasureString (non-wrapped)");
|
||||
|
||||
temp_box = bounding_box;
|
||||
|
|
@ -453,7 +464,7 @@ void TextSource::CalculateTextSizes(const StringFormat &format,
|
|||
RemoveNewlinePadding(format, bounding_box);
|
||||
|
||||
if (use_outline) {
|
||||
bounding_box.Width += outline_size;
|
||||
bounding_box.Width += outline_size;
|
||||
bounding_box.Height += outline_size;
|
||||
}
|
||||
}
|
||||
|
|
@ -503,13 +514,12 @@ void TextSource::CalculateTextSizes(const StringFormat &format,
|
|||
|
||||
/* the internal text-rendering bounding box for is reset to
|
||||
* its internal value in case the texture gets cut off */
|
||||
bounding_box.Width = temp_box.Width;
|
||||
bounding_box.Width = temp_box.Width;
|
||||
bounding_box.Height = temp_box.Height;
|
||||
}
|
||||
|
||||
void TextSource::RenderOutlineText(Graphics &graphics,
|
||||
const GraphicsPath &path,
|
||||
const Brush &brush)
|
||||
void TextSource::RenderOutlineText(Graphics &graphics, const GraphicsPath &path,
|
||||
const Brush &brush)
|
||||
{
|
||||
DWORD outline_rgba = calc_color(outline_color, outline_opacity);
|
||||
Status stat;
|
||||
|
|
@ -536,15 +546,15 @@ void TextSource::RenderText()
|
|||
GetStringFormat(format);
|
||||
CalculateTextSizes(format, box, size);
|
||||
|
||||
unique_ptr<uint8_t> bits(new uint8_t[size.cx * size.cy * 4]);
|
||||
unique_ptr<uint8_t[]> bits(new uint8_t[size.cx * size.cy * 4]);
|
||||
Bitmap bitmap(size.cx, size.cy, 4 * size.cx, PixelFormat32bppARGB,
|
||||
bits.get());
|
||||
bits.get());
|
||||
|
||||
Graphics graphics_bitmap(&bitmap);
|
||||
LinearGradientBrush brush(RectF(0, 0, (float)size.cx, (float)size.cy),
|
||||
Color(calc_color(color, opacity)),
|
||||
Color(calc_color(color2, opacity2)),
|
||||
gradient_dir, 1);
|
||||
Color(calc_color(color, opacity)),
|
||||
Color(calc_color(color2, opacity2)),
|
||||
gradient_dir, 1);
|
||||
DWORD full_bk_color = bk_color & 0xFFFFFF;
|
||||
|
||||
if (!text.empty() || use_extents)
|
||||
|
|
@ -575,15 +585,16 @@ void TextSource::RenderText()
|
|||
|
||||
font->GetFamily(&family);
|
||||
stat = path.AddString(text.c_str(), (int)text.size(),
|
||||
&family, font->GetStyle(),
|
||||
font->GetSize(), box, &format);
|
||||
&family, font->GetStyle(),
|
||||
font->GetSize(), box, &format);
|
||||
warn_stat("path.AddString");
|
||||
|
||||
RenderOutlineText(graphics_bitmap, path, brush);
|
||||
} else {
|
||||
stat = graphics_bitmap.DrawString(text.c_str(),
|
||||
(int)text.size(), font.get(),
|
||||
box, &format, &brush);
|
||||
(int)text.size(),
|
||||
font.get(), box,
|
||||
&format, &brush);
|
||||
warn_stat("graphics_bitmap.DrawString");
|
||||
}
|
||||
}
|
||||
|
|
@ -593,9 +604,9 @@ void TextSource::RenderText()
|
|||
if (tex)
|
||||
gs_texture_destroy(tex);
|
||||
|
||||
const uint8_t *data = (uint8_t*)bits.get();
|
||||
const uint8_t *data = (uint8_t *)bits.get();
|
||||
tex = gs_texture_create(size.cx, size.cy, GS_BGRA, 1, &data,
|
||||
GS_DYNAMIC);
|
||||
GS_DYNAMIC);
|
||||
|
||||
obs_leave_graphics();
|
||||
|
||||
|
|
@ -623,7 +634,7 @@ const char *TextSource::GetMainString(const char *str)
|
|||
|
||||
const char *temp = str + len;
|
||||
|
||||
while(temp != str) {
|
||||
while (temp != str) {
|
||||
temp--;
|
||||
|
||||
if (temp[0] == '\n' && temp[1] != 0) {
|
||||
|
|
@ -644,55 +655,60 @@ void TextSource::LoadFileText()
|
|||
text.push_back('\n');
|
||||
}
|
||||
|
||||
#define obs_data_get_uint32 (uint32_t)obs_data_get_int
|
||||
void TextSource::TransformText()
|
||||
{
|
||||
if (text_transform == S_TRANSFORM_UPPERCASE)
|
||||
transform(text.begin(), text.end(), text.begin(), towupper);
|
||||
else if (text_transform == S_TRANSFORM_LOWERCASE)
|
||||
transform(text.begin(), text.end(), text.begin(), towlower);
|
||||
}
|
||||
|
||||
#define obs_data_get_uint32 (uint32_t) obs_data_get_int
|
||||
|
||||
inline void TextSource::Update(obs_data_t *s)
|
||||
{
|
||||
const char *new_text = obs_data_get_string(s, S_TEXT);
|
||||
obs_data_t *font_obj = obs_data_get_obj(s, S_FONT);
|
||||
const char *align_str = obs_data_get_string(s, S_ALIGN);
|
||||
const char *new_text = obs_data_get_string(s, S_TEXT);
|
||||
obs_data_t *font_obj = obs_data_get_obj(s, S_FONT);
|
||||
const char *align_str = obs_data_get_string(s, S_ALIGN);
|
||||
const char *valign_str = obs_data_get_string(s, S_VALIGN);
|
||||
uint32_t new_color = obs_data_get_uint32(s, S_COLOR);
|
||||
uint32_t new_opacity = obs_data_get_uint32(s, S_OPACITY);
|
||||
bool gradient = obs_data_get_bool(s, S_GRADIENT);
|
||||
uint32_t new_color2 = obs_data_get_uint32(s, S_GRADIENT_COLOR);
|
||||
uint32_t new_opacity2 = obs_data_get_uint32(s, S_GRADIENT_OPACITY);
|
||||
float new_grad_dir = (float)obs_data_get_double(s, S_GRADIENT_DIR);
|
||||
bool new_vertical = obs_data_get_bool(s, S_VERTICAL);
|
||||
bool new_outline = obs_data_get_bool(s, S_OUTLINE);
|
||||
uint32_t new_o_color = obs_data_get_uint32(s, S_OUTLINE_COLOR);
|
||||
uint32_t new_color = obs_data_get_uint32(s, S_COLOR);
|
||||
uint32_t new_opacity = obs_data_get_uint32(s, S_OPACITY);
|
||||
bool gradient = obs_data_get_bool(s, S_GRADIENT);
|
||||
uint32_t new_color2 = obs_data_get_uint32(s, S_GRADIENT_COLOR);
|
||||
uint32_t new_opacity2 = obs_data_get_uint32(s, S_GRADIENT_OPACITY);
|
||||
float new_grad_dir = (float)obs_data_get_double(s, S_GRADIENT_DIR);
|
||||
bool new_vertical = obs_data_get_bool(s, S_VERTICAL);
|
||||
bool new_outline = obs_data_get_bool(s, S_OUTLINE);
|
||||
uint32_t new_o_color = obs_data_get_uint32(s, S_OUTLINE_COLOR);
|
||||
uint32_t new_o_opacity = obs_data_get_uint32(s, S_OUTLINE_OPACITY);
|
||||
uint32_t new_o_size = obs_data_get_uint32(s, S_OUTLINE_SIZE);
|
||||
bool new_use_file = obs_data_get_bool(s, S_USE_FILE);
|
||||
const char *new_file = obs_data_get_string(s, S_FILE);
|
||||
bool new_chat_mode = obs_data_get_bool(s, S_CHATLOG_MODE);
|
||||
int new_chat_lines = (int)obs_data_get_int(s, S_CHATLOG_LINES);
|
||||
bool new_extents = obs_data_get_bool(s, S_EXTENTS);
|
||||
bool new_extents_wrap = obs_data_get_bool(s, S_EXTENTS_WRAP);
|
||||
uint32_t n_extents_cx = obs_data_get_uint32(s, S_EXTENTS_CX);
|
||||
uint32_t n_extents_cy = obs_data_get_uint32(s, S_EXTENTS_CY);
|
||||
uint32_t new_o_size = obs_data_get_uint32(s, S_OUTLINE_SIZE);
|
||||
bool new_use_file = obs_data_get_bool(s, S_USE_FILE);
|
||||
const char *new_file = obs_data_get_string(s, S_FILE);
|
||||
bool new_chat_mode = obs_data_get_bool(s, S_CHATLOG_MODE);
|
||||
int new_chat_lines = (int)obs_data_get_int(s, S_CHATLOG_LINES);
|
||||
bool new_extents = obs_data_get_bool(s, S_EXTENTS);
|
||||
bool new_extents_wrap = obs_data_get_bool(s, S_EXTENTS_WRAP);
|
||||
uint32_t n_extents_cx = obs_data_get_uint32(s, S_EXTENTS_CX);
|
||||
uint32_t n_extents_cy = obs_data_get_uint32(s, S_EXTENTS_CY);
|
||||
int new_text_transform = (int)obs_data_get_int(s, S_TRANSFORM);
|
||||
|
||||
const char *font_face = obs_data_get_string(font_obj, "face");
|
||||
int font_size = (int)obs_data_get_int(font_obj, "size");
|
||||
int64_t font_flags = obs_data_get_int(font_obj, "flags");
|
||||
bool new_bold = (font_flags & OBS_FONT_BOLD) != 0;
|
||||
bool new_italic = (font_flags & OBS_FONT_ITALIC) != 0;
|
||||
bool new_underline = (font_flags & OBS_FONT_UNDERLINE) != 0;
|
||||
bool new_strikeout = (font_flags & OBS_FONT_STRIKEOUT) != 0;
|
||||
const char *font_face = obs_data_get_string(font_obj, "face");
|
||||
int font_size = (int)obs_data_get_int(font_obj, "size");
|
||||
int64_t font_flags = obs_data_get_int(font_obj, "flags");
|
||||
bool new_bold = (font_flags & OBS_FONT_BOLD) != 0;
|
||||
bool new_italic = (font_flags & OBS_FONT_ITALIC) != 0;
|
||||
bool new_underline = (font_flags & OBS_FONT_UNDERLINE) != 0;
|
||||
bool new_strikeout = (font_flags & OBS_FONT_STRIKEOUT) != 0;
|
||||
|
||||
uint32_t new_bk_color = obs_data_get_uint32(s, S_BKCOLOR);
|
||||
uint32_t new_bk_color = obs_data_get_uint32(s, S_BKCOLOR);
|
||||
uint32_t new_bk_opacity = obs_data_get_uint32(s, S_BKOPACITY);
|
||||
|
||||
/* ----------------------------- */
|
||||
|
||||
wstring new_face = to_wide(font_face);
|
||||
|
||||
if (new_face != face ||
|
||||
face_size != font_size ||
|
||||
new_bold != bold ||
|
||||
new_italic != italic ||
|
||||
new_underline != underline ||
|
||||
if (new_face != face || face_size != font_size || new_bold != bold ||
|
||||
new_italic != italic || new_underline != underline ||
|
||||
new_strikeout != strikeout) {
|
||||
|
||||
face = new_face;
|
||||
|
|
@ -751,10 +767,7 @@ inline void TextSource::Update(obs_data_t *s)
|
|||
if (!text.empty())
|
||||
text.push_back('\n');
|
||||
}
|
||||
if(text_transform == S_TRANSFORM_UPPERCASE)
|
||||
transform(text.begin(), text.end(), text.begin(), towupper);
|
||||
else if(text_transform == S_TRANSFORM_LOWERCASE)
|
||||
transform(text.begin(), text.end(), text.begin(), towlower);
|
||||
TransformText();
|
||||
|
||||
use_outline = new_outline;
|
||||
outline_color = new_o_color;
|
||||
|
|
@ -796,6 +809,7 @@ inline void TextSource::Tick(float seconds)
|
|||
|
||||
if (update_file) {
|
||||
LoadFileText();
|
||||
TransformText();
|
||||
RenderText();
|
||||
update_file = false;
|
||||
}
|
||||
|
|
@ -813,12 +827,13 @@ inline void TextSource::Render()
|
|||
return;
|
||||
|
||||
gs_effect_t *effect = obs_get_base_effect(OBS_EFFECT_DEFAULT);
|
||||
gs_technique_t *tech = gs_effect_get_technique(effect, "Draw");
|
||||
gs_technique_t *tech = gs_effect_get_technique(effect, "Draw");
|
||||
|
||||
gs_technique_begin(tech);
|
||||
gs_technique_begin_pass(tech, 0);
|
||||
|
||||
gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"), tex);
|
||||
gs_effect_set_texture(gs_effect_get_param_by_name(effect, "image"),
|
||||
tex);
|
||||
gs_draw_sprite(tex, 0, cx, cy);
|
||||
|
||||
gs_technique_end_pass(tech);
|
||||
|
|
@ -836,14 +851,14 @@ MODULE_EXPORT const char *obs_module_description(void)
|
|||
return "Windows GDI+ text source";
|
||||
}
|
||||
|
||||
#define set_vis(var, val, show) \
|
||||
do { \
|
||||
p = obs_properties_get(props, val); \
|
||||
#define set_vis(var, val, show) \
|
||||
do { \
|
||||
p = obs_properties_get(props, val); \
|
||||
obs_property_set_visible(p, var == show); \
|
||||
} while (false)
|
||||
|
||||
static bool use_file_changed(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *s)
|
||||
obs_data_t *s)
|
||||
{
|
||||
bool use_file = obs_data_get_bool(s, S_USE_FILE);
|
||||
|
||||
|
|
@ -853,7 +868,7 @@ static bool use_file_changed(obs_properties_t *props, obs_property_t *p,
|
|||
}
|
||||
|
||||
static bool outline_changed(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *s)
|
||||
obs_data_t *s)
|
||||
{
|
||||
bool outline = obs_data_get_bool(s, S_OUTLINE);
|
||||
|
||||
|
|
@ -864,7 +879,7 @@ static bool outline_changed(obs_properties_t *props, obs_property_t *p,
|
|||
}
|
||||
|
||||
static bool chatlog_mode_changed(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *s)
|
||||
obs_data_t *s)
|
||||
{
|
||||
bool chatlog_mode = obs_data_get_bool(s, S_CHATLOG_MODE);
|
||||
|
||||
|
|
@ -873,7 +888,7 @@ static bool chatlog_mode_changed(obs_properties_t *props, obs_property_t *p,
|
|||
}
|
||||
|
||||
static bool gradient_changed(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *s)
|
||||
obs_data_t *s)
|
||||
{
|
||||
bool gradient = obs_data_get_bool(s, S_GRADIENT);
|
||||
|
||||
|
|
@ -884,7 +899,7 @@ static bool gradient_changed(obs_properties_t *props, obs_property_t *p,
|
|||
}
|
||||
|
||||
static bool extents_modified(obs_properties_t *props, obs_property_t *p,
|
||||
obs_data_t *s)
|
||||
obs_data_t *s)
|
||||
{
|
||||
bool use_extents = obs_data_get_bool(s, S_EXTENTS);
|
||||
|
||||
|
|
@ -898,7 +913,7 @@ static bool extents_modified(obs_properties_t *props, obs_property_t *p,
|
|||
|
||||
static obs_properties_t *get_properties(void *data)
|
||||
{
|
||||
TextSource *s = reinterpret_cast<TextSource*>(data);
|
||||
TextSource *s = reinterpret_cast<TextSource *>(data);
|
||||
string path;
|
||||
|
||||
obs_properties_t *props = obs_properties_create();
|
||||
|
|
@ -927,41 +942,48 @@ static obs_properties_t *get_properties(void *data)
|
|||
|
||||
obs_properties_add_text(props, S_TEXT, T_TEXT, OBS_TEXT_MULTILINE);
|
||||
obs_properties_add_path(props, S_FILE, T_FILE, OBS_PATH_FILE,
|
||||
filter.c_str(), path.c_str());
|
||||
filter.c_str(), path.c_str());
|
||||
|
||||
p = obs_properties_add_list(props, S_TRANSFORM, T_TRANSFORM,
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
obs_property_list_add_int(p, T_TRANSFORM_NONE, S_TRANSFORM_NONE);
|
||||
obs_property_list_add_int(p, T_TRANSFORM_UPPERCASE, S_TRANSFORM_UPPERCASE);
|
||||
obs_property_list_add_int(p, T_TRANSFORM_LOWERCASE, S_TRANSFORM_LOWERCASE);
|
||||
|
||||
obs_property_list_add_int(p, T_TRANSFORM_UPPERCASE,
|
||||
S_TRANSFORM_UPPERCASE);
|
||||
obs_property_list_add_int(p, T_TRANSFORM_LOWERCASE,
|
||||
S_TRANSFORM_LOWERCASE);
|
||||
|
||||
obs_properties_add_bool(props, S_VERTICAL, T_VERTICAL);
|
||||
obs_properties_add_color(props, S_COLOR, T_COLOR);
|
||||
obs_properties_add_int_slider(props, S_OPACITY, T_OPACITY, 0, 100, 1);
|
||||
p = obs_properties_add_int_slider(props, S_OPACITY, T_OPACITY, 0, 100,
|
||||
1);
|
||||
obs_property_int_set_suffix(p, "%");
|
||||
|
||||
p = obs_properties_add_bool(props, S_GRADIENT, T_GRADIENT);
|
||||
obs_property_set_modified_callback(p, gradient_changed);
|
||||
|
||||
obs_properties_add_color(props, S_GRADIENT_COLOR, T_GRADIENT_COLOR);
|
||||
obs_properties_add_int_slider(props, S_GRADIENT_OPACITY,
|
||||
T_GRADIENT_OPACITY, 0, 100, 1);
|
||||
obs_properties_add_float_slider(props, S_GRADIENT_DIR,
|
||||
T_GRADIENT_DIR, 0, 360, 0.1);
|
||||
p = obs_properties_add_int_slider(props, S_GRADIENT_OPACITY,
|
||||
T_GRADIENT_OPACITY, 0, 100, 1);
|
||||
obs_property_int_set_suffix(p, "%");
|
||||
obs_properties_add_float_slider(props, S_GRADIENT_DIR, T_GRADIENT_DIR,
|
||||
0, 360, 0.1);
|
||||
|
||||
obs_properties_add_color(props, S_BKCOLOR, T_BKCOLOR);
|
||||
obs_properties_add_int_slider(props, S_BKOPACITY, T_BKOPACITY,
|
||||
0, 100, 1);
|
||||
p = obs_properties_add_int_slider(props, S_BKOPACITY, T_BKOPACITY, 0,
|
||||
100, 1);
|
||||
obs_property_int_set_suffix(p, "%");
|
||||
|
||||
p = obs_properties_add_list(props, S_ALIGN, T_ALIGN,
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||
obs_property_list_add_string(p, T_ALIGN_LEFT, S_ALIGN_LEFT);
|
||||
OBS_COMBO_TYPE_LIST,
|
||||
OBS_COMBO_FORMAT_STRING);
|
||||
obs_property_list_add_string(p, T_ALIGN_LEFT, S_ALIGN_LEFT);
|
||||
obs_property_list_add_string(p, T_ALIGN_CENTER, S_ALIGN_CENTER);
|
||||
obs_property_list_add_string(p, T_ALIGN_RIGHT, S_ALIGN_RIGHT);
|
||||
obs_property_list_add_string(p, T_ALIGN_RIGHT, S_ALIGN_RIGHT);
|
||||
|
||||
p = obs_properties_add_list(props, S_VALIGN, T_VALIGN,
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||
obs_property_list_add_string(p, T_VALIGN_TOP, S_VALIGN_TOP);
|
||||
OBS_COMBO_TYPE_LIST,
|
||||
OBS_COMBO_FORMAT_STRING);
|
||||
obs_property_list_add_string(p, T_VALIGN_TOP, S_VALIGN_TOP);
|
||||
obs_property_list_add_string(p, T_VALIGN_CENTER, S_VALIGN_CENTER);
|
||||
obs_property_list_add_string(p, T_VALIGN_BOTTOM, S_VALIGN_BOTTOM);
|
||||
|
||||
|
|
@ -970,14 +992,15 @@ static obs_properties_t *get_properties(void *data)
|
|||
|
||||
obs_properties_add_int(props, S_OUTLINE_SIZE, T_OUTLINE_SIZE, 1, 20, 1);
|
||||
obs_properties_add_color(props, S_OUTLINE_COLOR, T_OUTLINE_COLOR);
|
||||
obs_properties_add_int_slider(props, S_OUTLINE_OPACITY,
|
||||
T_OUTLINE_OPACITY, 0, 100, 1);
|
||||
p = obs_properties_add_int_slider(props, S_OUTLINE_OPACITY,
|
||||
T_OUTLINE_OPACITY, 0, 100, 1);
|
||||
obs_property_int_set_suffix(p, "%");
|
||||
|
||||
p = obs_properties_add_bool(props, S_CHATLOG_MODE, T_CHATLOG_MODE);
|
||||
obs_property_set_modified_callback(p, chatlog_mode_changed);
|
||||
|
||||
obs_properties_add_int(props, S_CHATLOG_LINES, T_CHATLOG_LINES,
|
||||
1, 1000, 1);
|
||||
obs_properties_add_int(props, S_CHATLOG_LINES, T_CHATLOG_LINES, 1, 1000,
|
||||
1);
|
||||
|
||||
p = obs_properties_add_bool(props, S_EXTENTS, T_EXTENTS);
|
||||
obs_property_set_modified_callback(p, extents_modified);
|
||||
|
|
@ -997,28 +1020,20 @@ bool obs_module_load(void)
|
|||
si.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW;
|
||||
si.get_properties = get_properties;
|
||||
|
||||
si.get_name = [] (void*)
|
||||
{
|
||||
return obs_module_text("TextGDIPlus");
|
||||
si.get_name = [](void *) { return obs_module_text("TextGDIPlus"); };
|
||||
si.create = [](obs_data_t *settings, obs_source_t *source) {
|
||||
return (void *)new TextSource(source, settings);
|
||||
};
|
||||
si.create = [] (obs_data_t *settings, obs_source_t *source)
|
||||
{
|
||||
return (void*)new TextSource(source, settings);
|
||||
si.destroy = [](void *data) {
|
||||
delete reinterpret_cast<TextSource *>(data);
|
||||
};
|
||||
si.destroy = [] (void *data)
|
||||
{
|
||||
delete reinterpret_cast<TextSource*>(data);
|
||||
si.get_width = [](void *data) {
|
||||
return reinterpret_cast<TextSource *>(data)->cx;
|
||||
};
|
||||
si.get_width = [] (void *data)
|
||||
{
|
||||
return reinterpret_cast<TextSource*>(data)->cx;
|
||||
si.get_height = [](void *data) {
|
||||
return reinterpret_cast<TextSource *>(data)->cy;
|
||||
};
|
||||
si.get_height = [] (void *data)
|
||||
{
|
||||
return reinterpret_cast<TextSource*>(data)->cy;
|
||||
};
|
||||
si.get_defaults = [] (obs_data_t *settings)
|
||||
{
|
||||
si.get_defaults = [](obs_data_t *settings) {
|
||||
obs_data_t *font_obj = obs_data_create();
|
||||
obs_data_set_default_string(font_obj, "face", "Arial");
|
||||
obs_data_set_default_int(font_obj, "size", 36);
|
||||
|
|
@ -1040,21 +1055,19 @@ bool obs_module_load(void)
|
|||
obs_data_set_default_bool(settings, S_EXTENTS_WRAP, true);
|
||||
obs_data_set_default_int(settings, S_EXTENTS_CX, 100);
|
||||
obs_data_set_default_int(settings, S_EXTENTS_CY, 100);
|
||||
obs_data_set_default_int(settings, S_TRANSFORM, S_TRANSFORM_NONE);
|
||||
obs_data_set_default_int(settings, S_TRANSFORM,
|
||||
S_TRANSFORM_NONE);
|
||||
|
||||
obs_data_release(font_obj);
|
||||
};
|
||||
si.update = [] (void *data, obs_data_t *settings)
|
||||
{
|
||||
reinterpret_cast<TextSource*>(data)->Update(settings);
|
||||
si.update = [](void *data, obs_data_t *settings) {
|
||||
reinterpret_cast<TextSource *>(data)->Update(settings);
|
||||
};
|
||||
si.video_tick = [] (void *data, float seconds)
|
||||
{
|
||||
reinterpret_cast<TextSource*>(data)->Tick(seconds);
|
||||
si.video_tick = [](void *data, float seconds) {
|
||||
reinterpret_cast<TextSource *>(data)->Tick(seconds);
|
||||
};
|
||||
si.video_render = [] (void *data, gs_effect_t*)
|
||||
{
|
||||
reinterpret_cast<TextSource*>(data)->Render();
|
||||
si.video_render = [](void *data, gs_effect_t *) {
|
||||
reinterpret_cast<TextSource *>(data)->Render();
|
||||
};
|
||||
|
||||
obs_register_source(&si);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue