From 9f599e316504943eec5d2fa854f7c99c575616b7 Mon Sep 17 00:00:00 2001 From: ItsOhen Date: Tue, 17 Mar 2026 17:43:53 +0100 Subject: window/rules: add scrolling_width (#13754) --- src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp | 13 +++++++------ src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/layout/algorithm/tiled') diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp index 5de27b97..8a5b2d59 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.cpp @@ -304,22 +304,22 @@ SScrollingData::SScrollingData(CScrollingAlgorithm* algo) : algorithm(algo) { controller = makeUnique(SCROLL_DIR_RIGHT); } -SP SScrollingData::add() { +SP SScrollingData::add(std::optional width) { auto col = columns.emplace_back(makeShared(self.lock())); col->self = col; - size_t stripIdx = controller->addStrip(algorithm->defaultColumnWidth()); + size_t stripIdx = controller->addStrip(width.value_or(algorithm->defaultColumnWidth())); controller->getStrip(stripIdx).userData = col; return col; } -SP SScrollingData::add(int after) { +SP SScrollingData::add(int after, std::optional width) { auto col = makeShared(self.lock()); col->self = col; columns.insert(columns.begin() + after + 1, col); - controller->insertStrip(after, algorithm->defaultColumnWidth()); + controller->insertStrip(after, width.value_or(algorithm->defaultColumnWidth())); controller->getStrip(after + 1).userData = col; return col; @@ -594,9 +594,10 @@ void CScrollingAlgorithm::newTarget(SP target) { SP droppingData = droppingOn ? dataFor(droppingOn->layoutTarget()) : nullptr; SP droppingColumn = droppingData ? droppingData->column.lock() : nullptr; + const auto width = target->window()->m_ruleApplicator->static_.scrollingWidth; if (!droppingColumn) { - auto col = m_scrollingData->add(); + auto col = m_scrollingData->add(width); col->add(target); m_scrollingData->fitCol(col); } else { @@ -610,7 +611,7 @@ void CScrollingAlgorithm::newTarget(SP target) { m_scrollingData->fitCol(droppingColumn); } else { auto idx = m_scrollingData->idx(droppingColumn); - auto col = idx == -1 ? m_scrollingData->add() : m_scrollingData->add(idx); + auto col = idx == -1 ? m_scrollingData->add(width) : m_scrollingData->add(idx, width); col->add(target); m_scrollingData->fitCol(col); } diff --git a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp index d95b3197..1b2b1d1e 100644 --- a/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp +++ b/src/layout/algorithm/tiled/scrolling/ScrollingAlgorithm.hpp @@ -68,8 +68,8 @@ namespace Layout::Tiled { UP controller; - SP add(); - SP add(int after); + SP add(std::optional width = std::nullopt); + SP add(int after, std::optional width = std::nullopt); int64_t idx(SP c); void remove(SP c); double maxWidth(); -- cgit v1.2.3