Files
crosspoint-reader-mod/chat-summaries/2026-02-15_13-00-summary.md
cottongin dfbc931c14 mod: Phase 1 - bring forward mod-exclusive files with ActivityManager migration
Brings ~55 mod-exclusive files to the upstream-based mod/master-resync branch:

Activities (migrated to new ActivityManager pattern):
- Clock/Time: SetTimeActivity, SetTimezoneOffsetActivity, NtpSyncActivity
- Dictionary: DictionaryDefinitionActivity, DictionarySuggestionsActivity,
  DictionaryWordSelectActivity, LookedUpWordsActivity
- Bookmark: EpubReaderBookmarkSelectionActivity
- Book management: BookManageMenuActivity, EndOfBookMenuActivity
- OPDS: OpdsServerListActivity, OpdsSettingsActivity
- Utility: DirectoryPickerActivity, NumericStepperActivity

Utilities (unchanged):
- BookManager, BookSettings, BookmarkStore, BootNtpSync
- Dictionary, LookupHistory, TimeSync, OpdsServerStore

Libraries: PlaceholderCover, TableData, ChapterXPathIndexer
Scripts: inject_mod_version, generate_book_icon, preview_placeholder_cover
Docs: KOReader sync XPath mapping

Migration changes:
- ActivityWithSubactivity -> Activity base class
- Callback constructors -> finish()/setResult() pattern
- enterNewActivity() -> startActivityForResult()
- Activity::RenderLock&& -> RenderLock&&

These files won't compile yet - they reference mod settings and I18n
strings that will be added in subsequent phases.

Made-with: Cursor
2026-03-07 15:10:00 -05:00

50 lines
2.7 KiB
Markdown

# Table Rendering Tweaks: Centering, Line Breaks, Padding
## Task Description
Three visual tweaks to the EPUB table rendering based on comparison with a Wikipedia article (Anders Celsius):
1. Full-width spanning rows (like "Anders Celsius", "Scientific career", "Signature") should be center-aligned
2. `<br>` tags and block elements within table cells should create actual line breaks (e.g., "(aged 42)" then "Uppsala, Sweden" on the next line)
3. Cell padding was too tight — text too close to grid borders
## Changes Made
### 1. Forced Line Breaks in Table Cells
**`lib/Epub/Epub/ParsedText.h`**:
- Added `std::vector<bool> forceBreakAfter` member to track mandatory line break positions
- Added `void addLineBreak()` public method
**`lib/Epub/Epub/ParsedText.cpp`**:
- `addWord()`: grows `forceBreakAfter` vector alongside other word vectors
- `addLineBreak()`: sets `forceBreakAfter.back() = true` on the last word
- `computeLineBreaks()` (DP algorithm): respects forced breaks — cannot extend a line past a forced break point, and forced breaks override continuation groups
- `computeHyphenatedLineBreaks()` (greedy): same — stops line at forced break, won't backtrack past one
- `hyphenateWordAtIndex()`: when splitting a word, transfers the forced break flag to the remainder (last part)
**`lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp`** — `startNewTextBlock()`:
- When `inTable`, instead of being a no-op, now: flushes the word buffer, calls `addLineBreak()` on the current ParsedText, and resets `nextWordContinues`
- This means `<br>`, `<p>`, `<div>` etc. within table cells now produce real visual line breaks
### 2. Center-Aligned Full-Width Spanning Cells
**`lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp`** — `processTable()`:
- Before laying out a cell's content, checks if `cell.colspan >= numCols` (spans full table width)
- If so, sets the cell's BlockStyle alignment to `CssTextAlign::Center`
- This correctly centers section headers and title rows in Wikipedia infobox-style tables
### 3. Increased Cell Padding
**`lib/Epub/Epub/parsers/ChapterHtmlSlimParser.cpp`**:
- `TABLE_CELL_PAD_X`: 2 → 4 pixels (horizontal padding)
- Added `TABLE_CELL_PAD_Y = 2` pixels (vertical padding)
- Row height now includes `2 * TABLE_CELL_PAD_Y` for top/bottom padding
**`lib/Epub/Epub/Page.cpp`**:
- `TABLE_CELL_PADDING_X`: 2 → 4 pixels (matches parser constant)
- Added `TABLE_CELL_PADDING_Y = 2` pixels
- Cell text Y position now accounts for vertical padding: `baseY + 1 + TABLE_CELL_PADDING_Y`
## Follow-up Items
- The padding constants are duplicated between `ChapterHtmlSlimParser.cpp` and `Page.cpp` — could be unified into a shared header
- Vertical centering within cells (when a cell has fewer lines than the tallest cell) is not implemented