Merge branch 'master' into jgrpp
# Conflicts: # src/genworld_gui.cpp # src/group_gui.cpp # src/saveload/saveload.cpp # src/settings_gui.cpp # src/toolbar_gui.cpp # src/vehicle_gui.cpp # src/vehicle_gui_base.h # src/widgets/dropdown.cpp # src/widgets/dropdown_type.h
This commit is contained in:
@@ -53,19 +53,20 @@ public:
|
||||
|
||||
public:
|
||||
CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff);
|
||||
CoreTextVisualRun(CoreTextVisualRun &&other) = default;
|
||||
|
||||
virtual const GlyphID *GetGlyphs() const { return &this->glyphs[0]; }
|
||||
virtual const float *GetPositions() const { return &this->positions[0]; }
|
||||
virtual const int *GetGlyphToCharMap() const { return &this->glyph_to_char[0]; }
|
||||
const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; }
|
||||
const float *GetPositions() const override { return &this->positions[0]; }
|
||||
const int *GetGlyphToCharMap() const override { return &this->glyph_to_char[0]; }
|
||||
|
||||
virtual const Font *GetFont() const { return this->font; }
|
||||
virtual int GetLeading() const { return this->font->fc->GetHeight(); }
|
||||
virtual int GetGlyphCount() const { return (int)this->glyphs.size(); }
|
||||
const Font *GetFont() const override { return this->font; }
|
||||
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
||||
int GetGlyphCount() const override { return (int)this->glyphs.size(); }
|
||||
int GetAdvance() const { return this->total_advance; }
|
||||
};
|
||||
|
||||
/** A single line worth of VisualRuns. */
|
||||
class CoreTextLine : public AutoDeleteSmallVector<CoreTextVisualRun *>, public ParagraphLayouter::Line {
|
||||
class CoreTextLine : public std::vector<CoreTextVisualRun>, public ParagraphLayouter::Line {
|
||||
public:
|
||||
CoreTextLine(CTLineRef line, const FontMap &fontMapping, const CoreTextParagraphLayoutFactory::CharType *buff)
|
||||
{
|
||||
@@ -78,17 +79,17 @@ public:
|
||||
auto map = fontMapping.begin();
|
||||
while (map < fontMapping.end() - 1 && map->first <= chars.location) map++;
|
||||
|
||||
this->push_back(new CoreTextVisualRun(run, map->second, buff));
|
||||
this->emplace_back(run, map->second, buff);
|
||||
}
|
||||
CFRelease(line);
|
||||
}
|
||||
|
||||
virtual int GetLeading() const;
|
||||
virtual int GetWidth() const;
|
||||
virtual int CountRuns() const { return this->size(); }
|
||||
virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); }
|
||||
int GetLeading() const override;
|
||||
int GetWidth() const override;
|
||||
int CountRuns() const override { return this->size(); }
|
||||
const VisualRun &GetVisualRun(int run) const override { return this->at(run); }
|
||||
|
||||
int GetInternalCharLength(WChar c) const
|
||||
int GetInternalCharLength(WChar c) const override
|
||||
{
|
||||
/* CoreText uses UTF-16 internally which means we need to account for surrogate pairs. */
|
||||
return c >= 0x010000U ? 2 : 1;
|
||||
@@ -100,17 +101,17 @@ public:
|
||||
this->Reflow();
|
||||
}
|
||||
|
||||
virtual ~CoreTextParagraphLayout()
|
||||
~CoreTextParagraphLayout() override
|
||||
{
|
||||
CFRelease(this->typesetter);
|
||||
}
|
||||
|
||||
virtual void Reflow()
|
||||
void Reflow() override
|
||||
{
|
||||
this->cur_offset = 0;
|
||||
}
|
||||
|
||||
virtual const Line *NextLine(int max_width);
|
||||
std::unique_ptr<const Line> NextLine(int max_width) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -187,7 +188,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
|
||||
return typesetter != NULL ? new CoreTextParagraphLayout(typesetter, buff, length, fontMapping) : NULL;
|
||||
}
|
||||
|
||||
/* virtual */ const CoreTextParagraphLayout::Line *CoreTextParagraphLayout::NextLine(int max_width)
|
||||
/* virtual */ std::unique_ptr<const ParagraphLayouter::Line> CoreTextParagraphLayout::NextLine(int max_width)
|
||||
{
|
||||
if (this->cur_offset >= this->length) return NULL;
|
||||
|
||||
@@ -199,7 +200,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
|
||||
CTLineRef line = CTTypesetterCreateLine(this->typesetter, CFRangeMake(this->cur_offset, len));
|
||||
this->cur_offset += len;
|
||||
|
||||
return line != NULL ? new CoreTextLine(line, this->font_map, this->text_buffer) : NULL;
|
||||
return std::unique_ptr<const Line>(line != NULL ? new CoreTextLine(line, this->font_map, this->text_buffer) : NULL);
|
||||
}
|
||||
|
||||
CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font *font, const CoreTextParagraphLayoutFactory::CharType *buff) : font(font)
|
||||
@@ -243,8 +244,8 @@ CoreTextParagraphLayout::CoreTextVisualRun::CoreTextVisualRun(CTRunRef run, Font
|
||||
int CoreTextParagraphLayout::CoreTextLine::GetLeading() const
|
||||
{
|
||||
int leading = 0;
|
||||
for (const CoreTextVisualRun * const &run : *this) {
|
||||
leading = max(leading, run->GetLeading());
|
||||
for (const auto &run : *this) {
|
||||
leading = max(leading, run.GetLeading());
|
||||
}
|
||||
|
||||
return leading;
|
||||
@@ -259,8 +260,8 @@ int CoreTextParagraphLayout::CoreTextLine::GetWidth() const
|
||||
if (this->size() == 0) return 0;
|
||||
|
||||
int total_width = 0;
|
||||
for (const CoreTextVisualRun * const &run : *this) {
|
||||
total_width += run->GetAdvance();
|
||||
for (const auto &run : *this) {
|
||||
total_width += run.GetAdvance();
|
||||
}
|
||||
|
||||
return total_width;
|
||||
|
||||
@@ -30,10 +30,10 @@ class OSXStringIterator : public StringIterator {
|
||||
size_t cur_pos; ///< Current iteration position.
|
||||
|
||||
public:
|
||||
virtual void SetString(const char *s);
|
||||
virtual size_t SetCurPosition(size_t pos);
|
||||
virtual size_t Next(IterType what);
|
||||
virtual size_t Prev(IterType what);
|
||||
void SetString(const char *s) override;
|
||||
size_t SetCurPosition(size_t pos) override;
|
||||
size_t Next(IterType what) override;
|
||||
size_t Prev(IterType what) override;
|
||||
|
||||
static StringIterator *Create();
|
||||
};
|
||||
|
||||
@@ -90,30 +90,31 @@ public:
|
||||
|
||||
public:
|
||||
UniscribeVisualRun(const UniscribeRun &range, int x);
|
||||
virtual ~UniscribeVisualRun()
|
||||
UniscribeVisualRun(UniscribeVisualRun &&other) noexcept;
|
||||
~UniscribeVisualRun() override
|
||||
{
|
||||
free(this->glyph_to_char);
|
||||
}
|
||||
|
||||
virtual const GlyphID *GetGlyphs() const { return &this->glyphs[0]; }
|
||||
virtual const float *GetPositions() const { return &this->positions[0]; }
|
||||
virtual const int *GetGlyphToCharMap() const;
|
||||
const GlyphID *GetGlyphs() const override { return &this->glyphs[0]; }
|
||||
const float *GetPositions() const override { return &this->positions[0]; }
|
||||
const int *GetGlyphToCharMap() const override;
|
||||
|
||||
virtual const Font *GetFont() const { return this->font; }
|
||||
virtual int GetLeading() const { return this->font->fc->GetHeight(); }
|
||||
virtual int GetGlyphCount() const { return this->num_glyphs; }
|
||||
const Font *GetFont() const override { return this->font; }
|
||||
int GetLeading() const override { return this->font->fc->GetHeight(); }
|
||||
int GetGlyphCount() const override { return this->num_glyphs; }
|
||||
int GetAdvance() const { return this->total_advance; }
|
||||
};
|
||||
|
||||
/** A single line worth of VisualRuns. */
|
||||
class UniscribeLine : public AutoDeleteSmallVector<UniscribeVisualRun *>, public ParagraphLayouter::Line {
|
||||
class UniscribeLine : public std::vector<UniscribeVisualRun>, public ParagraphLayouter::Line {
|
||||
public:
|
||||
virtual int GetLeading() const;
|
||||
virtual int GetWidth() const;
|
||||
virtual int CountRuns() const { return (uint)this->size(); }
|
||||
virtual const VisualRun *GetVisualRun(int run) const { return this->at(run); }
|
||||
int GetLeading() const override;
|
||||
int GetWidth() const override;
|
||||
int CountRuns() const override { return (uint)this->size(); }
|
||||
const VisualRun &GetVisualRun(int run) const override { return this->at(run); }
|
||||
|
||||
int GetInternalCharLength(WChar c) const
|
||||
int GetInternalCharLength(WChar c) const override
|
||||
{
|
||||
/* Uniscribe uses UTF-16 internally which means we need to account for surrogate pairs. */
|
||||
return c >= 0x010000U ? 2 : 1;
|
||||
@@ -125,15 +126,15 @@ public:
|
||||
this->Reflow();
|
||||
}
|
||||
|
||||
virtual ~UniscribeParagraphLayout() {}
|
||||
~UniscribeParagraphLayout() override {}
|
||||
|
||||
virtual void Reflow()
|
||||
void Reflow() override
|
||||
{
|
||||
this->cur_range = this->ranges.begin();
|
||||
this->cur_range_offset = 0;
|
||||
}
|
||||
|
||||
virtual const Line *NextLine(int max_width);
|
||||
std::unique_ptr<const Line> NextLine(int max_width) override;
|
||||
};
|
||||
|
||||
void UniscribeResetScriptCache(FontSize size)
|
||||
@@ -317,7 +318,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
|
||||
return new UniscribeParagraphLayout(ranges, buff);
|
||||
}
|
||||
|
||||
/* virtual */ const ParagraphLayouter::Line *UniscribeParagraphLayout::NextLine(int max_width)
|
||||
/* virtual */ std::unique_ptr<const ParagraphLayouter::Line> UniscribeParagraphLayout::NextLine(int max_width)
|
||||
{
|
||||
std::vector<UniscribeRun>::iterator start_run = this->cur_range;
|
||||
std::vector<UniscribeRun>::iterator last_run = this->cur_range;
|
||||
@@ -403,7 +404,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
|
||||
if (FAILED(ScriptLayout((int)bidi_level.size(), &bidi_level[0], &vis_to_log[0], NULL))) return NULL;
|
||||
|
||||
/* Create line. */
|
||||
UniscribeLine *line = new UniscribeLine();
|
||||
std::unique_ptr<UniscribeLine> line(new UniscribeLine());
|
||||
|
||||
int cur_pos = 0;
|
||||
for (std::vector<INT>::iterator l = vis_to_log.begin(); l != vis_to_log.end(); l++) {
|
||||
@@ -424,7 +425,7 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
|
||||
if (!UniscribeShapeRun(this->text_buffer, run)) return NULL;
|
||||
}
|
||||
|
||||
line->push_back(new UniscribeVisualRun(run, cur_pos));
|
||||
line->emplace_back(run, cur_pos);
|
||||
cur_pos += run.total_advance;
|
||||
}
|
||||
|
||||
@@ -448,8 +449,8 @@ static std::vector<SCRIPT_ITEM> UniscribeItemizeString(UniscribeParagraphLayoutF
|
||||
int UniscribeParagraphLayout::UniscribeLine::GetLeading() const
|
||||
{
|
||||
int leading = 0;
|
||||
for (const UniscribeVisualRun *run : *this) {
|
||||
leading = max(leading, run->GetLeading());
|
||||
for (const auto &run : *this) {
|
||||
leading = max(leading, run.GetLeading());
|
||||
}
|
||||
|
||||
return leading;
|
||||
@@ -462,8 +463,8 @@ int UniscribeParagraphLayout::UniscribeLine::GetLeading() const
|
||||
int UniscribeParagraphLayout::UniscribeLine::GetWidth() const
|
||||
{
|
||||
int length = 0;
|
||||
for (const UniscribeVisualRun *run : *this) {
|
||||
length += run->GetAdvance();
|
||||
for (const auto &run : *this) {
|
||||
length += run.GetAdvance();
|
||||
}
|
||||
|
||||
return length;
|
||||
@@ -484,6 +485,14 @@ UniscribeParagraphLayout::UniscribeVisualRun::UniscribeVisualRun(const Uniscribe
|
||||
this->positions[this->num_glyphs * 2] = advance + x;
|
||||
}
|
||||
|
||||
UniscribeParagraphLayout::UniscribeVisualRun::UniscribeVisualRun(UniscribeVisualRun&& other) noexcept
|
||||
: glyphs(std::move(other.glyphs)), positions(std::move(other.positions)), char_to_glyph(std::move(other.char_to_glyph)),
|
||||
start_pos(other.start_pos), total_advance(other.total_advance), num_glyphs(other.num_glyphs), font(other.font)
|
||||
{
|
||||
this->glyph_to_char = other.glyph_to_char;
|
||||
other.glyph_to_char = NULL;
|
||||
}
|
||||
|
||||
const int *UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() const
|
||||
{
|
||||
if (this->glyph_to_char == NULL) {
|
||||
|
||||
@@ -81,10 +81,10 @@ class UniscribeStringIterator : public StringIterator {
|
||||
size_t cur_pos; ///< Current iteration position.
|
||||
|
||||
public:
|
||||
virtual void SetString(const char *s);
|
||||
virtual size_t SetCurPosition(size_t pos);
|
||||
virtual size_t Next(IterType what);
|
||||
virtual size_t Prev(IterType what);
|
||||
void SetString(const char *s) override;
|
||||
size_t SetCurPosition(size_t pos) override;
|
||||
size_t Next(IterType what) override;
|
||||
size_t Prev(IterType what) override;
|
||||
};
|
||||
|
||||
#endif /* defined(WITH_UNISCRIBE) */
|
||||
|
||||
Reference in New Issue
Block a user