Rename ttext class to avoid t- prefix
This commit is contained in:
parent
90ba2affcf
commit
77cace19db
13 changed files with 102 additions and 102 deletions
|
@ -2870,10 +2870,10 @@ void display::refresh_report(const std::string& report_name, const config * new_
|
|||
if (used_ellipsis) goto skip_element;
|
||||
|
||||
// Draw a text element.
|
||||
font::ttext text;
|
||||
font::pango_text text;
|
||||
if (item->font_rgb_set()) {
|
||||
// font_rgb() has no alpha channel and uses a 0x00RRGGBB
|
||||
// layout instead of 0xRRGGBBAA which is what ttext expects,
|
||||
// layout instead of 0xRRGGBBAA which is what pango_text expects,
|
||||
// so shift the value to the left and add fully-opaque alpha.
|
||||
text.set_foreground_color((item->font_rgb() << 8) + 0xFF);
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ int floating_label::xpos(size_t width) const
|
|||
sdl::timage floating_label::create_image()
|
||||
{
|
||||
if (img_.null()) {
|
||||
font::ttext text;
|
||||
font::pango_text text;
|
||||
text.set_foreground_color((color_.r << 24) | (color_.g << 16) | (color_.b << 8) | 255);
|
||||
text.set_font_size(font_size_);
|
||||
text.set_maximum_width(width_ < 0 ? clip_rect_.w : width_);
|
||||
|
@ -154,7 +154,7 @@ sdl::timage floating_label::create_image()
|
|||
surface floating_label::create_surface()
|
||||
{
|
||||
if (surf_.null()) {
|
||||
font::ttext text;
|
||||
font::pango_text text;
|
||||
text.set_foreground_color((color_.r << 24) | (color_.g << 16) | (color_.b << 8) | 255);
|
||||
text.set_font_size(font_size_);
|
||||
text.set_maximum_width(width_ < 0 ? clip_rect_.w : width_);
|
||||
|
|
|
@ -43,7 +43,7 @@ inline std::string escape_text(const std::string& text)
|
|||
return result;
|
||||
}
|
||||
|
||||
// Escape only the andpersands. This is used by ttext to try to recover from
|
||||
// Escape only the ampersands. This is used by pango_text to try to recover from
|
||||
// markup parsing failure.
|
||||
inline std::string semi_escape_text(const std::string & text) {
|
||||
std::string semi_escaped;
|
||||
|
|
|
@ -23,23 +23,23 @@ namespace font {
|
|||
class p_font
|
||||
{
|
||||
public:
|
||||
p_font(const std::string& name, const unsigned size, font::ttext::FONT_STYLE style)
|
||||
p_font(const std::string& name, const unsigned size, font::pango_text::FONT_STYLE style)
|
||||
: font_(pango_font_description_new())
|
||||
{
|
||||
pango_font_description_set_family(font_, name.c_str());
|
||||
pango_font_description_set_size(font_, size * PANGO_SCALE);
|
||||
|
||||
if(style != ttext::STYLE_NORMAL) {
|
||||
if(style & ttext::STYLE_ITALIC) {
|
||||
if(style != pango_text::STYLE_NORMAL) {
|
||||
if(style & pango_text::STYLE_ITALIC) {
|
||||
pango_font_description_set_style(font_, PANGO_STYLE_ITALIC);
|
||||
}
|
||||
if(style & ttext::STYLE_BOLD) {
|
||||
if(style & pango_text::STYLE_BOLD) {
|
||||
pango_font_description_set_weight(font_, PANGO_WEIGHT_BOLD);
|
||||
}
|
||||
if(style & ttext::STYLE_LIGHT) {
|
||||
if(style & pango_text::STYLE_LIGHT) {
|
||||
pango_font_description_set_weight(font_, PANGO_WEIGHT_LIGHT);
|
||||
}
|
||||
if(style & ttext::STYLE_UNDERLINE) {
|
||||
if(style & pango_text::STYLE_UNDERLINE) {
|
||||
/* Do nothing here, underline is a property of the layout. */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
namespace font {
|
||||
|
||||
ttext::ttext()
|
||||
pango_text::pango_text()
|
||||
#if PANGO_VERSION_CHECK(1,22,0)
|
||||
: context_(pango_font_map_create_context(pango_cairo_font_map_get_default()))
|
||||
#else
|
||||
|
@ -90,7 +90,7 @@ ttext::ttext()
|
|||
cairo_font_options_destroy(fo);
|
||||
}
|
||||
|
||||
ttext::~ttext()
|
||||
pango_text::~pango_text()
|
||||
{
|
||||
if(context_) {
|
||||
g_object_unref(context_);
|
||||
|
@ -101,38 +101,38 @@ ttext::~ttext()
|
|||
surface_.assign(nullptr);
|
||||
}
|
||||
|
||||
surface ttext::render() const
|
||||
surface pango_text::render() const
|
||||
{
|
||||
this->rerender();
|
||||
return surface_;
|
||||
}
|
||||
|
||||
|
||||
int ttext::get_width() const
|
||||
int pango_text::get_width() const
|
||||
{
|
||||
return this->get_size().x;
|
||||
}
|
||||
|
||||
int ttext::get_height() const
|
||||
int pango_text::get_height() const
|
||||
{
|
||||
return this->get_size().y;
|
||||
}
|
||||
|
||||
gui2::point ttext::get_size() const
|
||||
gui2::point pango_text::get_size() const
|
||||
{
|
||||
this->recalculate();
|
||||
|
||||
return gui2::point(rect_.width, rect_.height);
|
||||
}
|
||||
|
||||
bool ttext::is_truncated() const
|
||||
bool pango_text::is_truncated() const
|
||||
{
|
||||
this->recalculate();
|
||||
|
||||
return (pango_layout_is_ellipsized(layout_) != 0);
|
||||
}
|
||||
|
||||
unsigned ttext::insert_text(const unsigned offset, const std::string& text)
|
||||
unsigned pango_text::insert_text(const unsigned offset, const std::string& text)
|
||||
{
|
||||
if (text.empty() || length_ == maximum_length_) {
|
||||
return 0;
|
||||
|
@ -152,18 +152,18 @@ unsigned ttext::insert_text(const unsigned offset, const std::string& text)
|
|||
return len;
|
||||
}
|
||||
|
||||
bool ttext::insert_unicode(const unsigned offset, ucs4::char_t unicode)
|
||||
bool pango_text::insert_unicode(const unsigned offset, ucs4::char_t unicode)
|
||||
{
|
||||
return this->insert_unicode(offset, ucs4::string(1, unicode)) == 1;
|
||||
}
|
||||
|
||||
unsigned ttext::insert_unicode(const unsigned offset, const ucs4::string& unicode)
|
||||
unsigned pango_text::insert_unicode(const unsigned offset, const ucs4::string& unicode)
|
||||
{
|
||||
const utf8::string insert = unicode_cast<utf8::string>(unicode);
|
||||
return this->insert_text(offset, insert);
|
||||
}
|
||||
|
||||
gui2::point ttext::get_cursor_position(
|
||||
gui2::point pango_text::get_cursor_position(
|
||||
const unsigned column, const unsigned line) const
|
||||
{
|
||||
this->recalculate();
|
||||
|
@ -207,7 +207,7 @@ gui2::point ttext::get_cursor_position(
|
|||
return gui2::point(PANGO_PIXELS(rect.x), PANGO_PIXELS(rect.y));
|
||||
}
|
||||
|
||||
std::string ttext::get_token(const gui2::point & position, const char * delim) const
|
||||
std::string pango_text::get_token(const gui2::point & position, const char * delim) const
|
||||
{
|
||||
this->recalculate();
|
||||
|
||||
|
@ -239,7 +239,7 @@ std::string ttext::get_token(const gui2::point & position, const char * delim) c
|
|||
return txt.substr(l,r-l);
|
||||
}
|
||||
|
||||
std::string ttext::get_link(const gui2::point & position) const
|
||||
std::string pango_text::get_link(const gui2::point & position) const
|
||||
{
|
||||
if (!link_aware_) {
|
||||
return "";
|
||||
|
@ -254,7 +254,7 @@ std::string ttext::get_link(const gui2::point & position) const
|
|||
}
|
||||
}
|
||||
|
||||
gui2::point ttext::get_column_line(const gui2::point& position) const
|
||||
gui2::point pango_text::get_column_line(const gui2::point& position) const
|
||||
{
|
||||
this->recalculate();
|
||||
|
||||
|
@ -288,7 +288,7 @@ gui2::point ttext::get_column_line(const gui2::point& position) const
|
|||
}
|
||||
}
|
||||
|
||||
bool ttext::set_text(const std::string& text, const bool markedup)
|
||||
bool pango_text::set_text(const std::string& text, const bool markedup)
|
||||
{
|
||||
if(markedup != markedup_text_ || text != text_) {
|
||||
// assert(layout_);
|
||||
|
@ -296,7 +296,7 @@ bool ttext::set_text(const std::string& text, const bool markedup)
|
|||
const ucs4::string wide = unicode_cast<ucs4::string>(text);
|
||||
const std::string narrow = unicode_cast<utf8::string>(wide);
|
||||
if(text != narrow) {
|
||||
ERR_GUI_L << "ttext::" << __func__
|
||||
ERR_GUI_L << "pango_text::" << __func__
|
||||
<< " text '" << text
|
||||
<< "' contains invalid utf-8, trimmed the invalid parts.\n";
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ bool ttext::set_text(const std::string& text, const bool markedup)
|
|||
return true;
|
||||
}
|
||||
|
||||
ttext& ttext::set_family_class(font::family_class fclass)
|
||||
pango_text& pango_text::set_family_class(font::family_class fclass)
|
||||
{
|
||||
if(fclass != font_class_) {
|
||||
font_class_ = fclass;
|
||||
|
@ -334,7 +334,7 @@ ttext& ttext::set_family_class(font::family_class fclass)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext& ttext::set_font_size(const unsigned font_size)
|
||||
pango_text& pango_text::set_font_size(const unsigned font_size)
|
||||
{
|
||||
unsigned int actual_size = preferences::font_scaled(font_size);
|
||||
if(actual_size != font_size_) {
|
||||
|
@ -346,7 +346,7 @@ ttext& ttext::set_font_size(const unsigned font_size)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext& ttext::set_font_style(const ttext::FONT_STYLE font_style)
|
||||
pango_text& pango_text::set_font_style(const pango_text::FONT_STYLE font_style)
|
||||
{
|
||||
if(font_style != font_style_) {
|
||||
font_style_ = font_style;
|
||||
|
@ -357,7 +357,7 @@ ttext& ttext::set_font_style(const ttext::FONT_STYLE font_style)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext& ttext::set_foreground_color(const Uint32 color)
|
||||
pango_text& pango_text::set_foreground_color(const Uint32 color)
|
||||
{
|
||||
if(color != foreground_color_) {
|
||||
foreground_color_ = color;
|
||||
|
@ -367,12 +367,12 @@ ttext& ttext::set_foreground_color(const Uint32 color)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext &ttext::set_foreground_color(const SDL_Color color)
|
||||
pango_text &pango_text::set_foreground_color(const SDL_Color color)
|
||||
{
|
||||
return this->set_foreground_color((color.r << 16) + (color.g << 8) + color.b);
|
||||
}
|
||||
|
||||
ttext& ttext::set_maximum_width(int width)
|
||||
pango_text& pango_text::set_maximum_width(int width)
|
||||
{
|
||||
if(width <= 0) {
|
||||
width = -1;
|
||||
|
@ -405,7 +405,7 @@ ttext& ttext::set_maximum_width(int width)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext& ttext::set_characters_per_line(const unsigned characters_per_line)
|
||||
pango_text& pango_text::set_characters_per_line(const unsigned characters_per_line)
|
||||
{
|
||||
if(characters_per_line != characters_per_line_) {
|
||||
characters_per_line_ = characters_per_line;
|
||||
|
@ -417,7 +417,7 @@ ttext& ttext::set_characters_per_line(const unsigned characters_per_line)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext& ttext::set_maximum_height(int height, bool multiline)
|
||||
pango_text& pango_text::set_maximum_height(int height, bool multiline)
|
||||
{
|
||||
if(height <= 0) {
|
||||
height = -1;
|
||||
|
@ -436,7 +436,7 @@ ttext& ttext::set_maximum_height(int height, bool multiline)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext& ttext::set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
|
||||
pango_text& pango_text::set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
|
||||
{
|
||||
if(ellipse_mode != ellipse_mode_) {
|
||||
// assert(context_);
|
||||
|
@ -450,7 +450,7 @@ ttext& ttext::set_ellipse_mode(const PangoEllipsizeMode ellipse_mode)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext &ttext::set_alignment(const PangoAlignment alignment)
|
||||
pango_text &pango_text::set_alignment(const PangoAlignment alignment)
|
||||
{
|
||||
if (alignment != alignment_) {
|
||||
pango_layout_set_alignment(layout_, alignment);
|
||||
|
@ -461,7 +461,7 @@ ttext &ttext::set_alignment(const PangoAlignment alignment)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext& ttext::set_maximum_length(const size_t maximum_length)
|
||||
pango_text& pango_text::set_maximum_length(const size_t maximum_length)
|
||||
{
|
||||
if(maximum_length != maximum_length_) {
|
||||
maximum_length_ = maximum_length;
|
||||
|
@ -474,7 +474,7 @@ ttext& ttext::set_maximum_length(const size_t maximum_length)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext& ttext::set_link_aware(bool b)
|
||||
pango_text& pango_text::set_link_aware(bool b)
|
||||
{
|
||||
if (link_aware_ != b) {
|
||||
calculation_dirty_ = true;
|
||||
|
@ -484,7 +484,7 @@ ttext& ttext::set_link_aware(bool b)
|
|||
return *this;
|
||||
}
|
||||
|
||||
ttext& ttext::set_link_color(const std::string & color)
|
||||
pango_text& pango_text::set_link_color(const std::string & color)
|
||||
{
|
||||
if(color != link_color_) {
|
||||
link_color_ = color;
|
||||
|
@ -496,7 +496,7 @@ ttext& ttext::set_link_color(const std::string & color)
|
|||
}
|
||||
|
||||
|
||||
void ttext::recalculate(const bool force) const
|
||||
void pango_text::recalculate(const bool force) const
|
||||
{
|
||||
if(calculation_dirty_ || force) {
|
||||
// assert(layout_);
|
||||
|
@ -507,7 +507,7 @@ void ttext::recalculate(const bool force) const
|
|||
p_font font{get_font_families(font_class_), font_size_, font_style_};
|
||||
pango_layout_set_font_description(layout_, font.get());
|
||||
|
||||
if(font_style_ & ttext::STYLE_UNDERLINE) {
|
||||
if(font_style_ & pango_text::STYLE_UNDERLINE) {
|
||||
PangoAttrList *attribute_list = pango_attr_list_new();
|
||||
pango_attr_list_insert(attribute_list
|
||||
, pango_attr_underline_new(PANGO_UNDERLINE_SINGLE));
|
||||
|
@ -552,7 +552,7 @@ void ttext::recalculate(const bool force) const
|
|||
: (maximum_width + hack) * PANGO_SCALE);
|
||||
pango_layout_get_pixel_extents(layout_, nullptr, &rect_);
|
||||
|
||||
DBG_GUI_L << "ttext::" << __func__
|
||||
DBG_GUI_L << "pango_text::" << __func__
|
||||
<< " text '" << gui2::debug_truncate(text_)
|
||||
<< "' maximum_width " << maximum_width
|
||||
<< " hack " << hack
|
||||
|
@ -563,7 +563,7 @@ void ttext::recalculate(const bool force) const
|
|||
} while(maximum_width != -1
|
||||
&& hack >= 0 && rect_.x + rect_.width > maximum_width);
|
||||
|
||||
DBG_GUI_L << "ttext::" << __func__
|
||||
DBG_GUI_L << "pango_text::" << __func__
|
||||
<< " text '" << gui2::debug_truncate(text_)
|
||||
<< "' font_size " << font_size_
|
||||
<< " markedup_text " << markedup_text_
|
||||
|
@ -573,7 +573,7 @@ void ttext::recalculate(const bool force) const
|
|||
<< " result " << rect_
|
||||
<< ".\n";
|
||||
if(maximum_width != -1 && rect_.x + rect_.width > maximum_width) {
|
||||
DBG_GUI_L << "ttext::" << __func__
|
||||
DBG_GUI_L << "pango_text::" << __func__
|
||||
<< " text '" << gui2::debug_truncate(text_)
|
||||
<< " ' width " << rect_.x + rect_.width
|
||||
<< " greater as the wanted maximum of " << maximum_width
|
||||
|
@ -639,7 +639,7 @@ static void from_cairo_format(Uint32 & c)
|
|||
c = (static_cast<Uint32>(a) << 24) | (static_cast<Uint32>(r) << 16) | (static_cast<Uint32>(g) << 8) | static_cast<Uint32>(b);
|
||||
}
|
||||
|
||||
void ttext::rerender(const bool force) const
|
||||
void pango_text::rerender(const bool force) const
|
||||
{
|
||||
if(surface_dirty_ || force) {
|
||||
// assert(layout_);
|
||||
|
@ -698,7 +698,7 @@ void ttext::rerender(const bool force) const
|
|||
}
|
||||
}
|
||||
|
||||
void ttext::create_surface_buffer(const size_t size) const
|
||||
void pango_text::create_surface_buffer(const size_t size) const
|
||||
{
|
||||
// clear old buffer
|
||||
surface_.assign(nullptr);
|
||||
|
@ -709,11 +709,11 @@ void ttext::create_surface_buffer(const size_t size) const
|
|||
for (auto & c : surface_buffer_) { c = 0; }
|
||||
}
|
||||
|
||||
bool ttext::set_markup(const std::string & text) {
|
||||
bool pango_text::set_markup(const std::string & text) {
|
||||
return this->set_markup_helper(link_aware_ ? this->format_link_tokens(text) : text);
|
||||
}
|
||||
|
||||
std::string ttext::format_link_tokens(const std::string & text) const {
|
||||
std::string pango_text::format_link_tokens(const std::string & text) const {
|
||||
std::string delim = " \n\r\t";
|
||||
// Tokenize according to these delimiters, and stream the results of `handle_token` on each token to get the new text.
|
||||
|
||||
|
@ -735,7 +735,7 @@ std::string ttext::format_link_tokens(const std::string & text) const {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string ttext::handle_token(const std::string & token) const
|
||||
std::string pango_text::handle_token(const std::string & token) const
|
||||
{
|
||||
if (looks_like_url(token)) {
|
||||
return format_as_link(token, link_color_);
|
||||
|
@ -744,7 +744,7 @@ std::string ttext::handle_token(const std::string & token) const
|
|||
}
|
||||
}
|
||||
|
||||
bool ttext::set_markup_helper(const std::string& text)
|
||||
bool pango_text::set_markup_helper(const std::string& text)
|
||||
{
|
||||
if(pango_parse_markup(text.c_str(), text.size()
|
||||
, 0, nullptr, nullptr, nullptr, nullptr)) {
|
||||
|
@ -774,7 +774,7 @@ bool ttext::set_markup_helper(const std::string& text)
|
|||
, 0, nullptr, nullptr, nullptr, nullptr)) {
|
||||
|
||||
/* Fixing the ampersands didn't work. */
|
||||
ERR_GUI_L << "ttext::" << __func__
|
||||
ERR_GUI_L << "pango_text::" << __func__
|
||||
<< " text '" << text
|
||||
<< "' has broken markup, set to normal text.\n";
|
||||
|
||||
|
@ -783,7 +783,7 @@ bool ttext::set_markup_helper(const std::string& text)
|
|||
}
|
||||
|
||||
/* Replacement worked, still warn the user about the error. */
|
||||
ERR_GUI_L << "ttext::" << __func__
|
||||
ERR_GUI_L << "pango_text::" << __func__
|
||||
<< " text '" << text
|
||||
<< "' has unescaped ampersands '&', escaped them.\n";
|
||||
|
||||
|
|
|
@ -72,16 +72,16 @@ namespace font {
|
|||
* render the text. See http://pango.org for more info.
|
||||
*
|
||||
*/
|
||||
class ttext
|
||||
class pango_text
|
||||
{
|
||||
public:
|
||||
|
||||
ttext();
|
||||
pango_text();
|
||||
|
||||
ttext(const ttext &) = delete;
|
||||
ttext & operator = (const ttext &) = delete;
|
||||
pango_text(const pango_text &) = delete;
|
||||
pango_text & operator = (const pango_text &) = delete;
|
||||
|
||||
~ttext();
|
||||
~pango_text();
|
||||
|
||||
/**
|
||||
* Returns the rendered text.
|
||||
|
@ -218,33 +218,33 @@ public:
|
|||
|
||||
const std::string& text() const { return text_; }
|
||||
|
||||
ttext& set_family_class(font::family_class fclass);
|
||||
pango_text& set_family_class(font::family_class fclass);
|
||||
|
||||
ttext& set_font_size(const unsigned font_size);
|
||||
pango_text& set_font_size(const unsigned font_size);
|
||||
|
||||
ttext& set_font_style(const FONT_STYLE font_style);
|
||||
pango_text& set_font_style(const FONT_STYLE font_style);
|
||||
|
||||
ttext& set_foreground_color(const Uint32 color);
|
||||
pango_text& set_foreground_color(const Uint32 color);
|
||||
|
||||
ttext& set_foreground_color(const SDL_Color color);
|
||||
pango_text& set_foreground_color(const SDL_Color color);
|
||||
|
||||
ttext& set_maximum_width(int width);
|
||||
pango_text& set_maximum_width(int width);
|
||||
|
||||
ttext& set_characters_per_line(const unsigned characters_per_line);
|
||||
pango_text& set_characters_per_line(const unsigned characters_per_line);
|
||||
|
||||
ttext& set_maximum_height(int height, bool multiline);
|
||||
pango_text& set_maximum_height(int height, bool multiline);
|
||||
|
||||
ttext& set_ellipse_mode(const PangoEllipsizeMode ellipse_mode);
|
||||
pango_text& set_ellipse_mode(const PangoEllipsizeMode ellipse_mode);
|
||||
|
||||
ttext& set_alignment(const PangoAlignment alignment);
|
||||
pango_text& set_alignment(const PangoAlignment alignment);
|
||||
|
||||
ttext& set_maximum_length(const size_t maximum_length);
|
||||
pango_text& set_maximum_length(const size_t maximum_length);
|
||||
|
||||
bool link_aware() const { return link_aware_; }
|
||||
|
||||
ttext& set_link_aware(bool b);
|
||||
pango_text& set_link_aware(bool b);
|
||||
|
||||
ttext& set_link_color(const std::string & color);
|
||||
pango_text& set_link_color(const std::string & color);
|
||||
private:
|
||||
|
||||
/***** ***** ***** ***** Pango variables ***** ***** ***** *****/
|
||||
|
|
|
@ -1174,7 +1174,7 @@ timage::tresize_mode timage::get_resize_mode(const std::string& resize_mode)
|
|||
/***** ***** ***** ***** ***** TEXT ***** ***** ***** ***** *****/
|
||||
|
||||
/** Definition of a text shape. */
|
||||
class ttext : public tcanvas::tshape
|
||||
class text_shape : public tcanvas::tshape
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -1184,7 +1184,7 @@ public:
|
|||
* http://www.wesnoth.org/wiki/GUICanvasWML#Text
|
||||
* for more information.
|
||||
*/
|
||||
explicit ttext(const config& cfg);
|
||||
explicit text_shape(const config& cfg);
|
||||
|
||||
/** Implement shape::draw(). */
|
||||
void draw(surface& canvas,
|
||||
|
@ -1204,7 +1204,7 @@ private:
|
|||
unsigned font_size_;
|
||||
|
||||
/** The style of the text. */
|
||||
font::ttext::FONT_STYLE font_style_;
|
||||
font::pango_text::FONT_STYLE font_style_;
|
||||
|
||||
/** The alignment of the text. */
|
||||
tformula<PangoAlignment> text_alignment_;
|
||||
|
@ -1286,7 +1286,7 @@ private:
|
|||
* @end{parent}{name="generic/state/draw/"}
|
||||
*/
|
||||
|
||||
ttext::ttext(const config& cfg)
|
||||
text_shape::text_shape(const config& cfg)
|
||||
: x_(cfg["x"])
|
||||
, y_(cfg["y"])
|
||||
, w_(cfg["w"])
|
||||
|
@ -1312,7 +1312,7 @@ ttext::ttext(const config& cfg)
|
|||
}
|
||||
}
|
||||
|
||||
void ttext::draw(surface& canvas,
|
||||
void text_shape::draw(surface& canvas,
|
||||
SDL_Renderer* /*renderer*/,
|
||||
const game_logic::map_formula_callable& variables)
|
||||
{
|
||||
|
@ -1328,7 +1328,7 @@ void ttext::draw(surface& canvas,
|
|||
return;
|
||||
}
|
||||
|
||||
static font::ttext text_renderer;
|
||||
static font::pango_text text_renderer;
|
||||
|
||||
text_renderer.set_link_aware(link_aware_(variables))
|
||||
.set_link_color(link_color_(variables));
|
||||
|
@ -1500,7 +1500,7 @@ void tcanvas::parse_cfg(const config& cfg)
|
|||
} else if(type == "image") {
|
||||
shapes_.push_back(std::make_shared<timage>(data));
|
||||
} else if(type == "text") {
|
||||
shapes_.push_back(std::make_shared<ttext>(data));
|
||||
shapes_.push_back(std::make_shared<text_shape>(data));
|
||||
} else if(type == "pre_commit") {
|
||||
|
||||
/* note this should get split if more preprocessing is used. */
|
||||
|
|
|
@ -59,7 +59,7 @@ struct tresolution_definition_
|
|||
unsigned text_extra_height;
|
||||
unsigned text_font_size;
|
||||
font::family_class text_font_family;
|
||||
font::ttext::FONT_STYLE text_font_style;
|
||||
font::pango_text::FONT_STYLE text_font_style;
|
||||
|
||||
std::vector<tstate_definition> state;
|
||||
};
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
/**
|
||||
* Returns the number of characters per line.
|
||||
*
|
||||
* This value is used to call @ref ttext::set_characters_per_line
|
||||
* This value is used to call @ref pango_text::set_characters_per_line
|
||||
* (indirectly).
|
||||
*
|
||||
* @returns The characters per line. This implementation
|
||||
|
@ -146,7 +146,7 @@ public:
|
|||
* Returns whether the label should be link_aware, in
|
||||
* in rendering and in searching for links with get_link.
|
||||
*
|
||||
* This value is used to call @ref ttext::set_link_aware
|
||||
* This value is used to call @ref pango_text::set_link_aware
|
||||
* (indirectly).
|
||||
*
|
||||
* @returns The link aware status. This impl always
|
||||
|
@ -157,7 +157,7 @@ public:
|
|||
/**
|
||||
* Returns the color string to be used with links.
|
||||
*
|
||||
* This value is used to call @ref ttext::set_link_color
|
||||
* This value is used to call @ref pango_text::set_link_color
|
||||
* (indirectly).
|
||||
*
|
||||
* @returns The link color string. This impl returns "#ffff00".
|
||||
|
@ -439,7 +439,7 @@ protected:
|
|||
int x_offset,
|
||||
int y_offset) override;
|
||||
|
||||
/** Exposes font::ttext::get_token, for the text label of this control */
|
||||
/** Exposes font::pango_text::get_token, for the text label of this control */
|
||||
std::string get_label_token(const gui2::point & position, const char * delimiters = " \n\r\t") const;
|
||||
|
||||
std::string get_label_link(const gui2::point & position) const;
|
||||
|
@ -474,7 +474,7 @@ private:
|
|||
/**
|
||||
* Contains a helper cache for the rendering.
|
||||
*
|
||||
* Creating a ttext object is quite expensive and is done on various
|
||||
* Creating a pango_text object is quite expensive and is done on various
|
||||
* occasions so it's cached here.
|
||||
*
|
||||
* @todo Maybe if still too slow we might also copy this cache to the
|
||||
|
@ -482,7 +482,7 @@ private:
|
|||
* Unfortunately that would make the dependency between the classes bigger
|
||||
* as wanted.
|
||||
*/
|
||||
mutable font::ttext renderer_;
|
||||
mutable font::pango_text renderer_;
|
||||
|
||||
/** The maximum width for the text in a control. */
|
||||
int text_maximum_width_;
|
||||
|
|
|
@ -50,23 +50,23 @@ SDL_Rect create_rect(const point& origin, const point& size)
|
|||
return sdl::create_rect(origin.x, origin.y, size.x, size.y);
|
||||
}
|
||||
|
||||
font::ttext::FONT_STYLE decode_font_style(const std::string& style)
|
||||
font::pango_text::FONT_STYLE decode_font_style(const std::string& style)
|
||||
{
|
||||
static std::map<std::string, font::ttext::FONT_STYLE> font_style_map = {
|
||||
{"normal", font::ttext::STYLE_NORMAL},
|
||||
{"bold", font::ttext::STYLE_BOLD},
|
||||
{"italic", font::ttext::STYLE_ITALIC},
|
||||
{"underline", font::ttext::STYLE_UNDERLINE},
|
||||
{"light", font::ttext::STYLE_LIGHT},
|
||||
static std::map<std::string, font::pango_text::FONT_STYLE> font_style_map = {
|
||||
{"normal", font::pango_text::STYLE_NORMAL},
|
||||
{"bold", font::pango_text::STYLE_BOLD},
|
||||
{"italic", font::pango_text::STYLE_ITALIC},
|
||||
{"underline", font::pango_text::STYLE_UNDERLINE},
|
||||
{"light", font::pango_text::STYLE_LIGHT},
|
||||
};
|
||||
|
||||
if(style.empty()) {
|
||||
return font::ttext::STYLE_NORMAL;
|
||||
return font::pango_text::STYLE_NORMAL;
|
||||
}
|
||||
|
||||
if(font_style_map.find(style) == font_style_map.end()) {
|
||||
ERR_GUI_G << "Unknown style '" << style << "' using 'normal' instead." << std::endl;
|
||||
return font::ttext::STYLE_NORMAL;
|
||||
return font::pango_text::STYLE_NORMAL;
|
||||
}
|
||||
|
||||
return font_style_map[style];
|
||||
|
|
|
@ -98,7 +98,7 @@ std::string encode_text_alignment(const PangoAlignment alignment);
|
|||
*
|
||||
* @returns The font style.
|
||||
*/
|
||||
font::ttext::FONT_STYLE decode_font_style(const std::string& style);
|
||||
font::pango_text::FONT_STYLE decode_font_style(const std::string& style);
|
||||
|
||||
/**
|
||||
* Returns a default error message if a mandatory widget is omitted.
|
||||
|
|
|
@ -217,7 +217,7 @@ protected:
|
|||
text_.set_font_size(font_size);
|
||||
}
|
||||
|
||||
void set_font_style(const font::ttext::FONT_STYLE font_style)
|
||||
void set_font_style(const font::pango_text::FONT_STYLE font_style)
|
||||
{
|
||||
text_.set_font_style(font_style);
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ private:
|
|||
tstate state_;
|
||||
|
||||
/** The text entered in the widget. */
|
||||
font::ttext text_;
|
||||
font::pango_text text_;
|
||||
|
||||
/** Start of the selected text. */
|
||||
size_t selection_start_;
|
||||
|
|
|
@ -290,14 +290,14 @@ void part_ui::render_title_box()
|
|||
titlebox_y = titlebox_padding;
|
||||
titlebox_max_h = base_rect_.h - 2*titlebox_padding;
|
||||
|
||||
font::ttext t;
|
||||
font::pango_text t;
|
||||
if(!t.set_text(titletxt, true)) {
|
||||
ERR_NG << "Text: Invalid markup in '"
|
||||
<< titletxt << "' rendered as is.\n";
|
||||
t.set_text(titletxt, false);
|
||||
}
|
||||
|
||||
t.set_font_style(font::ttext::STYLE_NORMAL)
|
||||
t.set_font_style(font::pango_text::STYLE_NORMAL)
|
||||
.set_font_size(titlebox_font_size)
|
||||
.set_foreground_color(titlebox_font_color)
|
||||
.set_maximum_width(titlebox_max_w)
|
||||
|
@ -433,7 +433,7 @@ void part_ui::render_story_box()
|
|||
|
||||
skip_ = false;
|
||||
last_key_ = true;
|
||||
font::ttext t;
|
||||
font::pango_text t;
|
||||
bool scan_finished = false;
|
||||
SDL_Rect scan = {0,0,0,0};
|
||||
SDL_Rect dstrect = {0,0,0,0};
|
||||
|
@ -480,7 +480,7 @@ void part_ui::render_story_box()
|
|||
<< p_.text() << "' rendered as is.\n";
|
||||
t.set_text(p_.text(), false);
|
||||
}
|
||||
t.set_font_style(font::ttext::STYLE_NORMAL)
|
||||
t.set_font_style(font::pango_text::STYLE_NORMAL)
|
||||
.set_alignment(story_text_alignment)
|
||||
.set_font_size(storybox_font_size)
|
||||
.set_foreground_color(storybox_font_color)
|
||||
|
@ -572,7 +572,7 @@ void part_ui::render_story_box()
|
|||
//dstrect.x = text_x_;
|
||||
dstrect.y = fix_text_y + scan.y + storybox_padding;
|
||||
// NOTE: ::blit_surface() screws up with antialiasing and hinting when
|
||||
// on backgroundless (e.g. black) screens; ttext::draw()
|
||||
// on backgroundless (e.g. black) screens; pango_text::draw()
|
||||
// uses it nonetheless, no idea why...
|
||||
// Here we'll use CVideo::blit_surface() instead.
|
||||
video_.blit_surface(dstrect.x, dstrect.y, txtsurf, &scan);
|
||||
|
|
Loading…
Add table
Reference in a new issue