mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-12 05:36:59 -04:00
fixed alignment of empty text
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@129 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -128,7 +128,7 @@ void TextViewer::prepare(RotatedDC& dc, const String& text, const TextStyle& sty
|
|||||||
// not prepared yet
|
// not prepared yet
|
||||||
Rotater r(dc, style.getRotation());
|
Rotater r(dc, style.getRotation());
|
||||||
prepareElements(text, style, ctx);
|
prepareElements(text, style, ctx);
|
||||||
prepareLines(dc, text, style);
|
prepareLines(dc, text, style, ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void TextViewer::reset() {
|
void TextViewer::reset() {
|
||||||
@@ -243,13 +243,22 @@ void TextViewer::prepareElements(const String& text, const TextStyle& style, Con
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------- : Layout
|
// ----------------------------------------------------------------------------- : Layout
|
||||||
|
|
||||||
void TextViewer::prepareLines(RotatedDC& dc, const String& text, const TextStyle& style) {
|
void TextViewer::prepareLines(RotatedDC& dc, const String& text, const TextStyle& style, Context& ctx) {
|
||||||
scale = 1;
|
scale = 1;
|
||||||
// find character sizes
|
// find character sizes
|
||||||
vector<CharInfo> chars;
|
vector<CharInfo> chars;
|
||||||
elements.getCharInfo(dc, scale, 0, text.size(), chars);
|
elements.getCharInfo(dc, scale, 0, text.size(), chars);
|
||||||
// try to layout
|
// try to layout
|
||||||
prepareLinesScale(dc, chars, style, false);
|
prepareLinesScale(dc, chars, style, false);
|
||||||
|
// no text, find a dummy height for the single line we have
|
||||||
|
if (lines.size() == 1 && lines[0].width() < 0.0001) {
|
||||||
|
if (style.always_symbol && style.symbol_font.valid()) {
|
||||||
|
lines[0].line_height = style.symbol_font.font->defaultSymbolSize(ctx, style.symbol_font.size).height;
|
||||||
|
} else {
|
||||||
|
dc.SetFont(style.font.font);
|
||||||
|
lines[0].line_height = dc.GetTextExtent(_(" ")).height;
|
||||||
|
}
|
||||||
|
}
|
||||||
// align
|
// align
|
||||||
alignLines(dc, chars, style);
|
alignLines(dc, chars, style);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class TextViewer {
|
|||||||
vector<Line> lines; ///< The lines in the text box
|
vector<Line> lines; ///< The lines in the text box
|
||||||
|
|
||||||
/// Prepare the lines, layout the text
|
/// Prepare the lines, layout the text
|
||||||
void prepareLines(RotatedDC& dc, const String& text, const TextStyle& style);
|
void prepareLines(RotatedDC& dc, const String& text, const TextStyle& style, Context& ctx);
|
||||||
/// Prepare the lines, layout the text; at a specific scale
|
/// Prepare the lines, layout the text; at a specific scale
|
||||||
bool prepareLinesScale(RotatedDC& dc, const vector<CharInfo>& chars, const TextStyle& style, bool stop_if_too_long);
|
bool prepareLinesScale(RotatedDC& dc, const vector<CharInfo>& chars, const TextStyle& style, bool stop_if_too_long);
|
||||||
/// Align the lines within the textbox
|
/// Align the lines within the textbox
|
||||||
|
|||||||
Reference in New Issue
Block a user