2014-04-18 19:02:08 +02:00
|
|
|
// Copyright (c) 2014, Thomas Goyne <plorkyeran@aegisub.org>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
|
|
|
//
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
//
|
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
|
|
|
#include "grid_column.h"
|
|
|
|
|
|
|
|
#include "ass_dialogue.h"
|
|
|
|
#include "ass_file.h"
|
|
|
|
#include "compat.h"
|
|
|
|
#include "include/aegisub/context.h"
|
|
|
|
#include "options.h"
|
2014-05-22 01:23:28 +02:00
|
|
|
#include "video_controller.h"
|
2014-04-18 19:02:08 +02:00
|
|
|
|
2014-04-19 02:18:41 +02:00
|
|
|
#include <libaegisub/character_count.h>
|
|
|
|
|
2014-04-18 19:02:08 +02:00
|
|
|
#include <wx/dc.h>
|
|
|
|
|
2015-01-18 23:56:48 +01:00
|
|
|
void WidthHelper::Age() {
|
|
|
|
for (auto it = begin(widths), e = end(widths); it != e; ) {
|
|
|
|
if (it->second.age == age)
|
|
|
|
++it;
|
|
|
|
else
|
|
|
|
it = widths.erase(it);
|
|
|
|
}
|
|
|
|
++age;
|
|
|
|
}
|
|
|
|
|
2014-04-18 19:02:08 +02:00
|
|
|
int WidthHelper::operator()(boost::flyweight<std::string> const& str) {
|
|
|
|
if (str.get().empty()) return 0;
|
|
|
|
auto it = widths.find(str);
|
2015-01-18 23:56:48 +01:00
|
|
|
if (it != end(widths)) {
|
|
|
|
it->second.age = age;
|
|
|
|
return it->second.width;
|
|
|
|
}
|
2015-02-02 05:01:55 +01:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
wxMBConvUTF8 conv;
|
|
|
|
size_t len = conv.ToWChar(nullptr, 0, str.get().c_str(), str.get().size());
|
|
|
|
scratch.resize(len);
|
|
|
|
conv.ToWChar(const_cast<wchar_t *>(scratch.wx_str()), len, str.get().c_str(), str.get().size());
|
2015-01-18 23:56:48 +01:00
|
|
|
int width = dc->GetTextExtent(scratch).GetWidth();
|
2015-02-02 05:01:55 +01:00
|
|
|
#else
|
2015-01-18 23:56:48 +01:00
|
|
|
int width = dc->GetTextExtent(to_wx(str)).GetWidth();
|
2015-02-02 05:01:55 +01:00
|
|
|
#endif
|
|
|
|
|
2015-01-18 23:56:48 +01:00
|
|
|
widths[str] = {width, age};
|
2014-04-18 19:02:08 +02:00
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
int WidthHelper::operator()(std::string const& str) {
|
2015-01-18 23:56:48 +01:00
|
|
|
return dc->GetTextExtent(to_wx(str)).GetWidth();
|
2014-04-18 19:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int WidthHelper::operator()(wxString const& str) {
|
2015-01-18 23:56:48 +01:00
|
|
|
return dc->GetTextExtent(str).GetWidth();
|
2014-04-18 19:02:08 +02:00
|
|
|
}
|
|
|
|
|
2014-05-30 18:09:49 +02:00
|
|
|
int WidthHelper::operator()(const char *str) {
|
2015-01-18 23:56:48 +01:00
|
|
|
return dc->GetTextExtent(wxString::FromUTF8(str)).GetWidth();
|
2014-05-30 18:09:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int WidthHelper::operator()(const wchar_t *str) {
|
2015-01-18 23:56:48 +01:00
|
|
|
return dc->GetTextExtent(str).GetWidth();
|
2014-05-30 18:09:49 +02:00
|
|
|
}
|
|
|
|
|
2014-04-21 16:50:19 +02:00
|
|
|
void GridColumn::UpdateWidth(const agi::Context *c, WidthHelper &helper) {
|
|
|
|
if (!visible) {
|
|
|
|
width = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
width = Width(c, helper);
|
|
|
|
if (width) // 10 is an arbitrary amount of padding
|
|
|
|
width = 10 + std::max(width, helper(Header()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GridColumn::Paint(wxDC &dc, int x, int y, const AssDialogue *d, const agi::Context *c) const {
|
|
|
|
wxString str = Value(d, c);
|
|
|
|
if (Centered())
|
|
|
|
x += (width - 6 - dc.GetTextExtent(str).GetWidth()) / 2;
|
2014-04-21 19:47:20 +02:00
|
|
|
dc.DrawText(str, x + 4, y + 2);
|
2014-04-21 16:50:19 +02:00
|
|
|
}
|
|
|
|
|
2014-04-18 19:02:08 +02:00
|
|
|
namespace {
|
|
|
|
#define COLUMN_HEADER(value) \
|
|
|
|
private: const wxString header = value; \
|
|
|
|
public: wxString const& Header() const override { return header; }
|
|
|
|
#define COLUMN_DESCRIPTION(value) \
|
|
|
|
private: const wxString description = value; \
|
|
|
|
public: wxString const& Description() const override { return description; }
|
|
|
|
|
|
|
|
struct GridColumnLineNumber final : GridColumn {
|
|
|
|
COLUMN_HEADER(_("#"))
|
|
|
|
COLUMN_DESCRIPTION(_("Line Number"))
|
|
|
|
bool Centered() const override { return true; }
|
|
|
|
|
|
|
|
wxString Value(const AssDialogue *d, const agi::Context * = nullptr) const override {
|
|
|
|
return std::to_wstring(d->Row + 1);
|
|
|
|
}
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
2014-04-18 19:02:08 +02:00
|
|
|
return helper(Value(&c->ass->Events.back()));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
T max_value(T AssDialogueBase::*field, EntryList<AssDialogue> const& lines) {
|
|
|
|
T value = 0;
|
|
|
|
for (AssDialogue const& line : lines) {
|
|
|
|
if (line.*field > value)
|
|
|
|
value = line.*field;
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct GridColumnLayer final : GridColumn {
|
|
|
|
COLUMN_HEADER(_("L"))
|
|
|
|
COLUMN_DESCRIPTION(_("Layer"))
|
|
|
|
bool Centered() const override { return true; }
|
|
|
|
|
|
|
|
wxString Value(const AssDialogue *d, const agi::Context *) const override {
|
|
|
|
return d->Layer ? wxString(std::to_wstring(d->Layer)) : wxString();
|
|
|
|
}
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
2014-04-18 19:02:08 +02:00
|
|
|
int max_layer = max_value(&AssDialogue::Layer, c->ass->Events);
|
|
|
|
return max_layer == 0 ? 0 : helper(std::to_wstring(max_layer));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
struct GridColumnTime : GridColumn {
|
|
|
|
bool by_frame = false;
|
|
|
|
|
|
|
|
bool Centered() const override { return true; }
|
|
|
|
void SetByFrame(bool by_frame) override { this->by_frame = by_frame; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GridColumnStartTime final : GridColumnTime {
|
2014-04-18 19:02:08 +02:00
|
|
|
COLUMN_HEADER(_("Start"))
|
|
|
|
COLUMN_DESCRIPTION(_("Start Time"))
|
|
|
|
|
|
|
|
wxString Value(const AssDialogue *d, const agi::Context *c) const override {
|
2014-04-19 15:57:17 +02:00
|
|
|
if (by_frame)
|
2014-04-18 19:02:08 +02:00
|
|
|
return std::to_wstring(c->videoController->FrameAtTime(d->Start, agi::vfr::START));
|
2014-07-06 16:28:58 +02:00
|
|
|
return to_wx(d->Start.GetAssFormatted());
|
2014-04-18 19:02:08 +02:00
|
|
|
}
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
2014-04-18 19:02:08 +02:00
|
|
|
if (!by_frame)
|
|
|
|
return helper(wxS("0:00:00.00"));
|
|
|
|
int frame = c->videoController->FrameAtTime(max_value(&AssDialogue::Start, c->ass->Events), agi::vfr::START);
|
|
|
|
return helper(std::to_wstring(frame));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
struct GridColumnEndTime final : GridColumnTime {
|
2014-04-18 19:02:08 +02:00
|
|
|
COLUMN_HEADER(_("End"))
|
|
|
|
COLUMN_DESCRIPTION(_("End Time"))
|
|
|
|
|
|
|
|
wxString Value(const AssDialogue *d, const agi::Context *c) const override {
|
2014-04-19 15:57:17 +02:00
|
|
|
if (by_frame)
|
2014-04-18 19:02:08 +02:00
|
|
|
return std::to_wstring(c->videoController->FrameAtTime(d->End, agi::vfr::END));
|
2014-07-06 16:28:58 +02:00
|
|
|
return to_wx(d->End.GetAssFormatted());
|
2014-04-18 19:02:08 +02:00
|
|
|
}
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
2014-04-18 19:02:08 +02:00
|
|
|
if (!by_frame)
|
|
|
|
return helper(wxS("0:00:00.00"));
|
|
|
|
int frame = c->videoController->FrameAtTime(max_value(&AssDialogue::End, c->ass->Events), agi::vfr::END);
|
|
|
|
return helper(std::to_wstring(frame));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
int max_width(T AssDialogueBase::*field, EntryList<AssDialogue> const& lines, WidthHelper &helper) {
|
|
|
|
int w = 0;
|
|
|
|
for (AssDialogue const& line : lines) {
|
|
|
|
auto const& v = line.*field;
|
|
|
|
if (v.get().empty()) continue;
|
|
|
|
int width = helper(v);
|
|
|
|
if (width > w)
|
|
|
|
w = width;
|
|
|
|
}
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct GridColumnStyle final : GridColumn {
|
|
|
|
COLUMN_HEADER(_("Style"))
|
|
|
|
COLUMN_DESCRIPTION(_("Style"))
|
|
|
|
bool Centered() const override { return false; }
|
|
|
|
|
|
|
|
wxString Value(const AssDialogue *d, const agi::Context *c) const override {
|
|
|
|
return to_wx(d->Style);
|
|
|
|
}
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
2014-04-18 19:02:08 +02:00
|
|
|
return max_width(&AssDialogue::Style, c->ass->Events, helper);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GridColumnEffect final : GridColumn {
|
|
|
|
COLUMN_HEADER(_("Effect"))
|
|
|
|
COLUMN_DESCRIPTION(_("Effect"))
|
|
|
|
bool Centered() const override { return false; }
|
|
|
|
|
|
|
|
wxString Value(const AssDialogue *d, const agi::Context *) const override {
|
|
|
|
return to_wx(d->Effect);
|
|
|
|
}
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
2014-04-18 19:02:08 +02:00
|
|
|
return max_width(&AssDialogue::Effect, c->ass->Events, helper);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GridColumnActor final : GridColumn {
|
|
|
|
COLUMN_HEADER(_("Actor"))
|
|
|
|
COLUMN_DESCRIPTION(_("Actor"))
|
|
|
|
bool Centered() const override { return false; }
|
|
|
|
|
|
|
|
wxString Value(const AssDialogue *d, const agi::Context *) const override {
|
|
|
|
return to_wx(d->Actor);
|
|
|
|
}
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
2014-04-18 19:02:08 +02:00
|
|
|
return max_width(&AssDialogue::Actor, c->ass->Events, helper);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GridColumnMargin : GridColumn {
|
2014-12-28 21:45:55 +01:00
|
|
|
int index;
|
|
|
|
GridColumnMargin(int index) : index(index) { }
|
|
|
|
|
2014-04-18 19:02:08 +02:00
|
|
|
bool Centered() const override { return true; }
|
|
|
|
|
|
|
|
wxString Value(const AssDialogue *d, const agi::Context *) const override {
|
2014-12-28 21:45:55 +01:00
|
|
|
return d->Margin[index] ? wxString(std::to_wstring(d->Margin[index])) : wxString();
|
2014-04-18 19:02:08 +02:00
|
|
|
}
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
2014-04-18 19:02:08 +02:00
|
|
|
int max = 0;
|
|
|
|
for (AssDialogue const& line : c->ass->Events) {
|
2014-12-28 21:45:55 +01:00
|
|
|
if (line.Margin[index] > max)
|
|
|
|
max = line.Margin[index];
|
2014-04-18 19:02:08 +02:00
|
|
|
}
|
|
|
|
return max == 0 ? 0 : helper(std::to_wstring(max));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-12-28 21:45:55 +01:00
|
|
|
struct GridColumnMarginLeft final : GridColumnMargin {
|
|
|
|
GridColumnMarginLeft() : GridColumnMargin(0) { }
|
2014-04-18 19:02:08 +02:00
|
|
|
COLUMN_HEADER(_("Left"))
|
|
|
|
COLUMN_DESCRIPTION(_("Left Margin"))
|
|
|
|
};
|
|
|
|
|
2014-12-28 21:45:55 +01:00
|
|
|
struct GridColumnMarginRight final : GridColumnMargin {
|
|
|
|
GridColumnMarginRight() : GridColumnMargin(1) { }
|
2014-04-18 19:02:08 +02:00
|
|
|
COLUMN_HEADER(_("Right"))
|
|
|
|
COLUMN_DESCRIPTION(_("Right Margin"))
|
|
|
|
};
|
|
|
|
|
2014-12-28 21:45:55 +01:00
|
|
|
struct GridColumnMarginVert final : GridColumnMargin {
|
|
|
|
GridColumnMarginVert() : GridColumnMargin(2) { }
|
2014-04-18 19:02:08 +02:00
|
|
|
COLUMN_HEADER(_("Vert"))
|
|
|
|
COLUMN_DESCRIPTION(_("Vertical Margin"))
|
|
|
|
};
|
|
|
|
|
2014-04-21 19:47:20 +02:00
|
|
|
wxColor blend(wxColor fg, wxColor bg, double alpha) {
|
|
|
|
return wxColor(
|
|
|
|
wxColor::AlphaBlend(fg.Red(), bg.Red(), alpha),
|
|
|
|
wxColor::AlphaBlend(fg.Green(), bg.Green(), alpha),
|
|
|
|
wxColor::AlphaBlend(fg.Blue(), bg.Blue(), alpha));
|
|
|
|
}
|
|
|
|
|
2014-04-19 05:04:16 +02:00
|
|
|
class GridColumnCPS final : public GridColumn {
|
|
|
|
const agi::OptionValue *ignore_whitespace = OPT_GET("Subtitle/Character Counter/Ignore Whitespace");
|
|
|
|
const agi::OptionValue *ignore_punctuation = OPT_GET("Subtitle/Character Counter/Ignore Punctuation");
|
2014-04-21 20:01:39 +02:00
|
|
|
const agi::OptionValue *cps_warn = OPT_GET("Subtitle/Character Counter/CPS Warning Threshold");
|
|
|
|
const agi::OptionValue *cps_error = OPT_GET("Subtitle/Character Counter/CPS Error Threshold");
|
|
|
|
const agi::OptionValue *bg_color = OPT_GET("Colour/Subtitle Grid/CPS Error");
|
2014-04-19 05:04:16 +02:00
|
|
|
|
|
|
|
public:
|
2014-04-18 19:02:08 +02:00
|
|
|
COLUMN_HEADER(_("CPS"))
|
|
|
|
COLUMN_DESCRIPTION(_("Characters Per Second"))
|
|
|
|
bool Centered() const override { return true; }
|
|
|
|
bool RefreshOnTextChange() const override { return true; }
|
|
|
|
|
|
|
|
wxString Value(const AssDialogue *d, const agi::Context *) const override {
|
2014-04-21 19:47:20 +02:00
|
|
|
return wxS("");
|
|
|
|
}
|
|
|
|
|
|
|
|
int CPS(const AssDialogue *d) const {
|
2014-04-18 23:08:12 +02:00
|
|
|
int duration = d->End - d->Start;
|
2014-04-18 19:02:08 +02:00
|
|
|
auto const& text = d->Text.get();
|
2014-04-18 23:08:12 +02:00
|
|
|
|
2014-04-21 19:48:41 +02:00
|
|
|
if (duration <= 100 || text.size() > static_cast<size_t>(duration))
|
2014-04-21 19:47:20 +02:00
|
|
|
return -1;
|
2014-04-18 23:08:12 +02:00
|
|
|
|
2014-05-05 15:27:37 +02:00
|
|
|
int ignore = agi::IGNORE_BLOCKS;
|
2014-04-19 05:04:16 +02:00
|
|
|
if (ignore_whitespace->GetBool())
|
|
|
|
ignore |= agi::IGNORE_WHITESPACE;
|
|
|
|
if (ignore_punctuation->GetBool())
|
|
|
|
ignore |= agi::IGNORE_PUNCTUATION;
|
|
|
|
|
2014-04-21 19:47:20 +02:00
|
|
|
return agi::CharacterCount(text, ignore) * 1000 / duration;
|
2014-04-18 19:02:08 +02:00
|
|
|
}
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
2014-04-18 19:02:08 +02:00
|
|
|
return helper(wxS("999"));
|
|
|
|
}
|
2014-04-21 19:47:20 +02:00
|
|
|
|
2015-07-17 23:56:22 +02:00
|
|
|
void Paint(wxDC &dc, int x, int y, const AssDialogue *d, const agi::Context *) const override {
|
2014-04-21 19:47:20 +02:00
|
|
|
int cps = CPS(d);
|
2014-04-22 21:35:41 +02:00
|
|
|
if (cps < 0 || cps > 100) return;
|
2014-04-21 19:47:20 +02:00
|
|
|
|
|
|
|
wxString str = std::to_wstring(cps);
|
|
|
|
wxSize ext = dc.GetTextExtent(str);
|
|
|
|
auto tc = dc.GetTextForeground();
|
|
|
|
|
2014-04-21 20:01:39 +02:00
|
|
|
int cps_min = cps_warn->GetInt();
|
|
|
|
int cps_max = std::max<int>(cps_min, cps_error->GetInt());
|
2014-04-21 19:47:20 +02:00
|
|
|
if (cps > cps_min) {
|
|
|
|
double alpha = std::min((double)(cps - cps_min + 1) / (cps_max - cps_min + 1), 1.0);
|
2014-04-21 20:01:39 +02:00
|
|
|
dc.SetBrush(wxBrush(blend(to_wx(bg_color->GetColor()), dc.GetBrush().GetColour(), alpha)));
|
2014-04-21 19:47:20 +02:00
|
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
|
|
dc.DrawRectangle(x, y + 1, width, ext.GetHeight() + 3);
|
|
|
|
dc.SetTextForeground(blend(*wxBLACK, tc, alpha));
|
|
|
|
}
|
|
|
|
|
|
|
|
x += (width + 2 - ext.GetWidth()) / 2;
|
|
|
|
dc.DrawText(str, x, y + 2);
|
|
|
|
dc.SetTextForeground(tc);
|
|
|
|
}
|
2014-04-18 19:02:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class GridColumnText final : public GridColumn {
|
2014-04-21 16:50:19 +02:00
|
|
|
const agi::OptionValue *override_mode;
|
2014-04-18 19:02:08 +02:00
|
|
|
wxString replace_char;
|
|
|
|
|
|
|
|
agi::signal::Connection replace_char_connection;
|
|
|
|
|
|
|
|
public:
|
|
|
|
GridColumnText()
|
2014-04-21 16:50:19 +02:00
|
|
|
: override_mode(OPT_GET("Subtitle/Grid/Hide Overrides"))
|
2014-04-18 19:02:08 +02:00
|
|
|
, replace_char(to_wx(OPT_GET("Subtitle/Grid/Hide Overrides Char")->GetString()))
|
|
|
|
, replace_char_connection(OPT_SUB("Subtitle/Grid/Hide Overrides Char",
|
|
|
|
[&](agi::OptionValue const& v) { replace_char = to_wx(v.GetString()); }))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
COLUMN_HEADER(_("Text"))
|
|
|
|
COLUMN_DESCRIPTION(_("Text"))
|
|
|
|
bool Centered() const override { return false; }
|
|
|
|
bool CanHide() const override { return false; }
|
|
|
|
bool RefreshOnTextChange() const override { return true; }
|
|
|
|
|
|
|
|
wxString Value(const AssDialogue *d, const agi::Context *) const override {
|
|
|
|
wxString str;
|
2014-04-21 16:50:19 +02:00
|
|
|
int mode = override_mode->GetInt();
|
2014-04-18 19:02:08 +02:00
|
|
|
|
|
|
|
// Show overrides
|
2014-04-21 16:50:19 +02:00
|
|
|
if (mode == 0)
|
2014-04-18 19:02:08 +02:00
|
|
|
str = to_wx(d->Text);
|
|
|
|
// Hidden overrides
|
|
|
|
else {
|
2014-04-21 16:50:19 +02:00
|
|
|
auto const& text = d->Text.get();
|
|
|
|
str.reserve(text.size());
|
2014-04-18 19:02:08 +02:00
|
|
|
size_t start = 0, pos;
|
2014-04-21 16:50:19 +02:00
|
|
|
while ((pos = text.find('{', start)) != std::string::npos) {
|
|
|
|
str += to_wx(text.substr(start, pos - start));
|
|
|
|
if (mode == 1)
|
2014-04-18 19:02:08 +02:00
|
|
|
str += replace_char;
|
2014-04-21 16:50:19 +02:00
|
|
|
start = text.find('}', pos);
|
2014-04-18 19:02:08 +02:00
|
|
|
if (start != std::string::npos) ++start;
|
|
|
|
}
|
|
|
|
if (start != std::string::npos)
|
2014-04-21 16:50:19 +02:00
|
|
|
str += to_wx(text.substr(start));
|
2014-04-18 19:02:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Cap length and set text
|
|
|
|
if (str.size() > 512)
|
|
|
|
str = str.Left(512) + "...";
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2014-04-19 15:57:17 +02:00
|
|
|
int Width(const agi::Context *c, WidthHelper &helper) const override {
|
2014-04-18 19:02:08 +02:00
|
|
|
return 5000;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template<typename T>
|
|
|
|
std::unique_ptr<GridColumn> make() {
|
|
|
|
return std::unique_ptr<GridColumn>(new T);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<GridColumn>> GetGridColumns() {
|
|
|
|
std::vector<std::unique_ptr<GridColumn>> ret;
|
|
|
|
ret.push_back(make<GridColumnLineNumber>());
|
|
|
|
ret.push_back(make<GridColumnLayer>());
|
|
|
|
ret.push_back(make<GridColumnStartTime>());
|
|
|
|
ret.push_back(make<GridColumnEndTime>());
|
|
|
|
ret.push_back(make<GridColumnCPS>());
|
|
|
|
ret.push_back(make<GridColumnStyle>());
|
|
|
|
ret.push_back(make<GridColumnActor>());
|
2014-04-28 19:10:33 +02:00
|
|
|
ret.push_back(make<GridColumnEffect>());
|
2014-04-18 19:02:08 +02:00
|
|
|
ret.push_back(make<GridColumnMarginLeft>());
|
|
|
|
ret.push_back(make<GridColumnMarginRight>());
|
|
|
|
ret.push_back(make<GridColumnMarginVert>());
|
|
|
|
ret.push_back(make<GridColumnText>());
|
|
|
|
return ret;
|
|
|
|
}
|