#pragma once #include #include // Pure page-pairing logic for manga mode. Given the natural sizes of the // page images, decides which pages display alone and which form two-page // spreads. Holds no Qt object state and emits nothing — the owning model // drives signals and persistence. class MangaPagination { public: struct Pair { int first = -1; int second = -1; // -1 = solo page }; void clear(); // Portrait viewport: every page solo. Landscape: cover solo, optional // shift page solo, consecutive portrait pages paired, wide pages solo. void rebuild(const QVector &naturalSizes, bool landscape, bool pageShift); int count() const; Pair at(int pairIndex) const; int pairIndexForChunk(int chunkIndex) const; // Chunk to keep on screen across a shift toggle. Anchoring on the // higher-index chunk when shift turns on (and lower when it turns off) // keeps repeated back-and-forth toggling stable with no drift. int anchorChunkForShiftToggle(int currentPairIndex, bool shiftTurningOn) const; private: QVector m_pairs; };