v2.3.1
This commit is contained in:
+55
-9
@@ -547,7 +547,15 @@ def make_section_slide(prs, slide_spec, colors, fs):
|
||||
|
||||
|
||||
def make_content_slide(prs, slide_spec, project_dir, workspace_path, colors, is_dark, fs, warnings, bg_image=None):
|
||||
"""Generate a content slide with title + bullets/body."""
|
||||
"""Generate a content slide.
|
||||
|
||||
Layouts (slide_spec["layout"]):
|
||||
"split-right" (default) — small title top, text left, image right
|
||||
"split-left" — small title top, image left, text right
|
||||
"text" — full-width text, image ignored
|
||||
"fullscreen" — image fills slide, title/text overlaid at bottom
|
||||
"""
|
||||
layout = (slide_spec.get("layout") or "split-right").lower()
|
||||
slide = prs.slides.add_slide(prs.slide_layouts[6])
|
||||
|
||||
# Background
|
||||
@@ -557,7 +565,35 @@ def make_content_slide(prs, slide_spec, project_dir, workspace_path, colors, is_
|
||||
set_slide_bg(slide, colors["background"])
|
||||
|
||||
has_title = bool(slide_spec.get("title"))
|
||||
has_image = bool(slide_spec.get("image_path"))
|
||||
has_image = bool(slide_spec.get("image_path")) and layout != "text"
|
||||
|
||||
# ── Fullscreen layout: image fills slide, text/title overlaid ─────────────
|
||||
if layout == "fullscreen" and has_image:
|
||||
resolved = resolve_image_path(slide_spec["image_path"], project_dir, workspace_path)
|
||||
add_image_or_placeholder(slide, resolved,
|
||||
Inches(0), Inches(0), SLIDE_W, SLIDE_H,
|
||||
warnings, fit_mode="cover")
|
||||
# Semi-transparent dark bar at bottom for text legibility
|
||||
bar_h = Inches(2.0)
|
||||
bar_y = SLIDE_H - bar_h
|
||||
add_shape_rect(slide, Inches(0), bar_y, SLIDE_W, bar_h, "000000")
|
||||
bar_shape = slide.shapes[-1]
|
||||
bar_shape.fill.fore_color.rgb = hex_to_rgb("000000")
|
||||
bar_shape.fill.transparency = 0.45
|
||||
# Title and body overlaid on dark bar
|
||||
if has_title:
|
||||
add_text_box(slide, Inches(0.6), bar_y + Inches(0.15), Inches(12.0), Inches(0.7),
|
||||
slide_spec["title"], font_size=Pt(fs["slide_title"]),
|
||||
color_hex="FFFFFF", bold=True)
|
||||
body_text = slide_spec.get("body") or slide_spec.get("content")
|
||||
bullets = slide_spec.get("bullets") or slide_spec.get("bullet_points")
|
||||
if bullets:
|
||||
body_text = " ● ".join(str(b) for b in bullets)
|
||||
if body_text:
|
||||
add_text_box(slide, Inches(0.6), bar_y + Inches(0.9), Inches(12.0), Inches(0.9),
|
||||
body_text, font_size=Pt(fs["body"]), color_hex="E0E0E0")
|
||||
return slide
|
||||
|
||||
content_y = Inches(1.5) if has_title else Inches(0.5)
|
||||
content_h = SLIDE_H - content_y - Inches(0.3)
|
||||
|
||||
@@ -568,13 +604,23 @@ def make_content_slide(prs, slide_spec, project_dir, workspace_path, colors, is_
|
||||
add_shape_rect(slide, L_MARGIN, Inches(1.15), Inches(2), Inches(0.04),
|
||||
colors["accent"])
|
||||
|
||||
# ── Two-column layout when image present ──────────────────────────────────
|
||||
# ── Column geometry ───────────────────────────────────────────────────────
|
||||
if has_image:
|
||||
text_ratio = _auto_text_ratio(slide_spec)
|
||||
text_col_w = CONTENT_W * text_ratio - COL_GAP / 2
|
||||
img_col_x = L_MARGIN + text_col_w + COL_GAP
|
||||
img_col_w = CONTENT_W * (1 - text_ratio) - COL_GAP / 2
|
||||
if layout == "split-left":
|
||||
# Image left, text right
|
||||
img_col_x = L_MARGIN
|
||||
img_col_w = CONTENT_W * (1 - text_ratio) - COL_GAP / 2
|
||||
text_col_x = img_col_x + img_col_w + COL_GAP
|
||||
text_col_w = CONTENT_W * text_ratio - COL_GAP / 2
|
||||
else:
|
||||
# split-right (default): text left, image right
|
||||
text_col_x = L_MARGIN
|
||||
text_col_w = CONTENT_W * text_ratio - COL_GAP / 2
|
||||
img_col_x = L_MARGIN + text_col_w + COL_GAP
|
||||
img_col_w = CONTENT_W * (1 - text_ratio) - COL_GAP / 2
|
||||
else:
|
||||
text_col_x = L_MARGIN
|
||||
text_col_w = CONTENT_W
|
||||
img_col_x = None
|
||||
img_col_w = None
|
||||
@@ -587,16 +633,16 @@ def make_content_slide(prs, slide_spec, project_dir, workspace_path, colors, is_
|
||||
bullet_fs = Pt(override) if override else Pt(fs["bullets"])
|
||||
|
||||
if bullet_items and len(bullet_items) > 0:
|
||||
add_bullet_list(slide, L_MARGIN, content_y, text_col_w, content_h,
|
||||
add_bullet_list(slide, text_col_x, content_y, text_col_w, content_h,
|
||||
bullet_items, font_size=bullet_fs,
|
||||
color_hex=colors["body"],
|
||||
bullet_color_hex=colors["accent"])
|
||||
elif body_text:
|
||||
add_text_box(slide, L_MARGIN, content_y, text_col_w, content_h,
|
||||
add_text_box(slide, text_col_x, content_y, text_col_w, content_h,
|
||||
body_text, font_size=body_fs, color_hex=colors["body"])
|
||||
|
||||
# ── Image column ──────────────────────────────────────────────────────────
|
||||
if has_image:
|
||||
if has_image and img_col_x is not None:
|
||||
resolved = resolve_image_path(slide_spec["image_path"], project_dir, workspace_path)
|
||||
add_image_or_placeholder(slide, resolved,
|
||||
img_col_x, content_y, img_col_w, content_h,
|
||||
|
||||
Reference in New Issue
Block a user