From f831ee3b6b2c28e7dabbb4b88a70d79459d64ee3 Mon Sep 17 00:00:00 2001 From: routersys Date: Mon, 24 Aug 2026 19:58:06 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=83=96=E5=88=97=E3=81=A8=E8=A6=8B?= =?UTF-8?q?=E5=87=BA=E3=81=97=E3=82=92=E3=81=BE=E3=81=A8=E3=82=81=E3=81=A6?= =?UTF-8?q?=E6=8E=B4=E3=82=81=E3=82=8B=E7=AF=84=E5=9B=B2=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/PanelLayout.cpp | 39 +++++++++++++++++++++++++++++++-------- src/PanelLayout.h | 1 + 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/PanelLayout.cpp b/src/PanelLayout.cpp index a5b2dc3..2a59997 100644 --- a/src/PanelLayout.cpp +++ b/src/PanelLayout.cpp @@ -98,9 +98,6 @@ RECT PanelLayout::TitleBandFrom(const RECT& area, int top) const { { style.grouping, style.settingItemHeight }, { style.groupingHover, style.settingItemHeight }, { style.groupingSelect, style.settingItemHeight }, - { style.grouping, style.groupTabHeight }, - { style.groupingHover, style.groupTabHeight }, - { style.groupingSelect, style.groupTabHeight }, }; for (const HeaderStyle& header : styles) { int rows = 0; @@ -116,16 +113,42 @@ RECT PanelLayout::TitleBandFrom(const RECT& area, int top) const { return kEmptyBand; } +int PanelLayout::GroupTabRows(const RECT& area, int top) const { + const StyleMetrics& style = Style(); + const int left = area.left + 1; + const int right = area.right - 1; + const int span = right - left; + if (span <= 0) return 0; + + int rows = 0; + while (top + rows < area.bottom) { + int hits = 0; + for (int x = left; x < right; x++) { + const int color = surface_.At(x, top + rows); + if (color == style.grouping || color == style.groupingHover || + color == style.groupingSelect) + hits++; + } + if (hits * 2 <= span) break; + rows++; + } + return rows; +} + RECT PanelLayout::TitleBand(const RECT& area) const { const StyleMetrics& style = Style(); const int top = surface_.At(area.left + 1, area.top) == style.windowBorder ? area.top + 1 : area.top; - const RECT first = TitleBandFrom(area, top); - if (first.bottom <= first.top) return TitleBandFrom(area, top + style.groupTabHeight); + RECT band = TitleBandFrom(area, top); + if (band.bottom <= band.top) { + const int rows = GroupTabRows(area, top); + if (abs(rows - (style.groupTabHeight - 2)) > 1) return kEmptyBand; + band = RECT{ area.left, top, area.right, top + rows }; + } - const RECT second = TitleBandFrom(area, first.bottom); - if (second.bottom <= second.top) return first; - return RECT{ area.left, first.top, area.right, second.bottom }; + const RECT below = TitleBandFrom(area, band.bottom + 1); + if (below.bottom <= below.top) return band; + return RECT{ area.left, band.top, area.right, below.bottom }; } void PanelLayout::Divide(const RECT& area, int stack, int order) { diff --git a/src/PanelLayout.h b/src/PanelLayout.h index 1e8a56c..fd8bd76 100644 --- a/src/PanelLayout.h +++ b/src/PanelLayout.h @@ -37,6 +37,7 @@ private: bool RowMostly(int y, int x0, int x1, int color, bool* full) const; std::vector SplitBands(const RECT& area, StackAxis axis) const; RECT TitleBandFrom(const RECT& area, int top) const; + int GroupTabRows(const RECT& area, int top) const; RECT TitleBand(const RECT& area) const; void Divide(const RECT& area, int stack, int order);