Templating: align=center/right in fest positionierter TEXTBOX/FLOWBOX
Der Container wurde horizontal auf die Textbreite geschrumpft, sodass die Ausrichtung wirkungslos blieb. Der Auswahlrahmen für TEXT im Designer folgt jetzt w= bzw. der Zeilenbreite bei align=center/right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d1f3dd5148
commit
702694d4f4
2 files changed
+15
-3
No files matched your search
@@ -209,7 +209,7 @@ public sealed class LayoutOverlayEditor : Control
|
||||
TableElement => "TABLE", ChartElement => "CHART", _ => "?" };
|
||||
var (width, height, resizable) = element switch
|
||||
{
|
||||
TextElement text => (Math.Min(70d, Math.Max(5, PageWidth - text.X)),
|
||||
TextElement text => (TextLineWidth(text),
|
||||
Math.Max(3, PointsToUnit(ParseSize(text.Attributes) * 1.8)), false),
|
||||
ImageElement image => (image.Width * ImageScale(image), image.Height * ImageScale(image), true),
|
||||
_ => ((double)element.Width, element.Height, true),
|
||||
@@ -254,6 +254,18 @@ public sealed class LayoutOverlayEditor : Control
|
||||
private static float ParseSize(IReadOnlyDictionary<string, string> attributes) =>
|
||||
attributes.TryGetValue("size", out var raw) && float.TryParse(raw,
|
||||
System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out var size) ? size : 11;
|
||||
// Mit w= oder align=center/right entspricht der Rahmen der Zeilenbreite, in der der Renderer ausrichtet.
|
||||
private double TextLineWidth(TextElement text)
|
||||
{
|
||||
var remaining = Math.Max(5, PageWidth - text.X);
|
||||
if (text.Attributes.TryGetValue("w", out var raw) && float.TryParse(raw,
|
||||
System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out var width)
|
||||
&& width > 0)
|
||||
return width;
|
||||
return text.Attributes.TryGetValue("align", out var align)
|
||||
&& (align.Equals("center", StringComparison.OrdinalIgnoreCase) || align.Equals("right", StringComparison.OrdinalIgnoreCase))
|
||||
? remaining : Math.Min(70d, remaining);
|
||||
}
|
||||
private static float ImageScale(ImageElement image) => image.Attributes.TryGetValue("scale", out var raw)
|
||||
? LayoutParser.Percentage(raw) : 1;
|
||||
private double PointsToUnit(double points) => PageUnit.ToLowerInvariant() switch
|
||||
|
||||
@@ -333,11 +333,11 @@ public sealed class QuestTemplateRenderer : ITemplateRenderer, ITemplatePreviewR
|
||||
values, template.Manifest, text.Attributes);
|
||||
break;
|
||||
case TextBoxElement box:
|
||||
RenderResolvedText(Position(root, box, unit).Shrink(), box.Content, box.Placeholder, box.Format,
|
||||
RenderResolvedText(Position(root, box, unit).ShrinkVertical(), box.Content, box.Placeholder, box.Format,
|
||||
values, template.Manifest, box.Attributes);
|
||||
break;
|
||||
case FlowBoxElement box:
|
||||
RenderResolvedText(Position(root, box, unit).Shrink(), box.Content, box.Placeholder, box.Format,
|
||||
RenderResolvedText(Position(root, box, unit).ShrinkVertical(), box.Content, box.Placeholder, box.Format,
|
||||
values, template.Manifest, box.Attributes);
|
||||
break;
|
||||
case DrawBoxElement drawing:
|
||||
|
||||
Reference in new issue
Block a user