From 4e0de7b8057f8e7cffa82e16c20e41dd90b83c61 Mon Sep 17 00:00:00 2001 From: routersys Date: Mon, 24 Aug 2026 19:04:38 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A6=8B=E5=87=BA=E3=81=97=E3=81=AE=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=82=92=E6=9C=AC=E4=BD=93=E3=81=AE=E6=8F=8F=E7=94=BB?= =?UTF-8?q?=E3=81=AB=E5=90=88=E3=82=8F=E3=81=9B=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DockModel.cpp | 9 +++++++- src/DockModel.h | 1 + src/PanelLayout.cpp | 53 ++++++++++++++++++++++++++++++++++---------- src/PanelLayout.h | 3 +++ src/StyleMetrics.cpp | 3 +++ src/StyleMetrics.h | 3 +++ 6 files changed, 59 insertions(+), 13 deletions(-) diff --git a/src/DockModel.cpp b/src/DockModel.cpp index a237e6f..a934bcf 100644 --- a/src/DockModel.cpp +++ b/src/DockModel.cpp @@ -12,6 +12,12 @@ void DockModel::Clear() { region_ = RECT{}; } +bool DockModel::BuildRegion() { + Clear(); + region_ = DockRegion(); + return region_.right > 0 && region_.bottom > 0; +} + bool DockModel::Build() { Clear(); if (!layout_.Build()) return false; @@ -21,7 +27,8 @@ bool DockModel::Build() { DockPanel entry = {}; entry.rect = panel.rect; entry.title = panel.title; - entry.probe = POINT{ panel.rect.left + kProbeInset, panel.rect.top + kProbeInset }; + const int top = panel.HasTitle() ? panel.title.top : panel.rect.top; + entry.probe = POINT{ panel.rect.left + kProbeInset, top + kProbeInset }; entry.stack = panel.stack; entry.order = panel.order; entry.area = kAreaUnknown; diff --git a/src/DockModel.h b/src/DockModel.h index 4923411..f9418d7 100644 --- a/src/DockModel.h +++ b/src/DockModel.h @@ -22,6 +22,7 @@ struct DockPanel { class DockModel { public: bool Build(); + bool BuildRegion(); void Clear(); const RECT& Region() const { return region_; } diff --git a/src/PanelLayout.cpp b/src/PanelLayout.cpp index d6778f6..a5b2dc3 100644 --- a/src/PanelLayout.cpp +++ b/src/PanelLayout.cpp @@ -9,6 +9,19 @@ namespace dl { static const RECT kEmptyBand = {}; +struct HeaderStyle { + int color; + int height; +}; + +RECT DockRegion() { + HWND host = HostWindow(); + RECT client = {}; + if (!host || !GetClientRect(host, &client)) return kEmptyBand; + RefreshStyle(); + return RECT{ 0, 0, client.right, client.bottom - Style().footerHeight }; +} + int PanelLayout::ClassifyRow(int y, int x0, int x1) const { const StyleMetrics& style = Style(); int borders = 0; @@ -74,29 +87,47 @@ std::vector PanelLayout::SplitBands(const RECT& area, StackAxis axis) cons return bands; } -RECT PanelLayout::TitleBand(const RECT& area) const { +RECT PanelLayout::TitleBandFrom(const RECT& area, int top) const { const StyleMetrics& style = Style(); const int left = area.left + 1; const int right = area.right - 1; - if (right - left <= 0) return kEmptyBand; + if (right - left <= 0 || top >= area.bottom) return kEmptyBand; - const int top = surface_.At(left, area.top) == style.windowBorder ? area.top + 1 : area.top; - const int colors[2] = { style.titleHeader, style.grouping }; - const int heights[2] = { style.titleHeaderHeight, style.settingItemHeight }; - for (int i = 0; i < 2; i++) { + const HeaderStyle styles[] = { + { style.titleHeader, style.titleHeaderHeight }, + { 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; bool glyph = false; bool full = false; - while (top + rows < area.bottom && RowMostly(top + rows, left, right, colors[i], &full)) { + while (top + rows < area.bottom && RowMostly(top + rows, left, right, header.color, &full)) { if (!full) glyph = true; rows++; } - if (rows > 0 && glyph && abs(rows - heights[i]) <= 1) + if (rows > 0 && glyph && abs(rows - header.height) <= 1) return RECT{ area.left, top, area.right, top + rows }; } return kEmptyBand; } +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); + + const RECT second = TitleBandFrom(area, first.bottom); + if (second.bottom <= second.top) return first; + return RECT{ area.left, first.top, area.right, second.bottom }; +} + void PanelLayout::Divide(const RECT& area, int stack, int order) { for (const StackAxis axis : { StackAxis::Vertical, StackAxis::Horizontal }) { const std::vector bands = SplitBands(area, axis); @@ -116,12 +147,10 @@ bool PanelLayout::Build() { region_ = kEmptyBand; HWND host = HostWindow(); - if (!host) return false; RECT client = {}; - if (!GetClientRect(host, &client)) return false; + if (!host || !GetClientRect(host, &client)) return false; - RefreshStyle(); - const RECT region = { 0, 0, client.right, client.bottom - Style().footerHeight }; + const RECT region = DockRegion(); if (region.right <= 0 || region.bottom <= 0) return false; if (!surface_.Capture(host, client.right, client.bottom)) return false; diff --git a/src/PanelLayout.h b/src/PanelLayout.h index bc98e1b..1e8a56c 100644 --- a/src/PanelLayout.h +++ b/src/PanelLayout.h @@ -7,6 +7,8 @@ namespace dl { +RECT DockRegion(); + enum class StackAxis { Vertical, Horizontal }; struct Panel { @@ -34,6 +36,7 @@ private: int ClassifyColumn(int x, int y0, int y1) const; 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; RECT TitleBand(const RECT& area) const; void Divide(const RECT& area, int stack, int order); diff --git a/src/StyleMetrics.cpp b/src/StyleMetrics.cpp index f3f89ed..3a60a20 100644 --- a/src/StyleMetrics.cpp +++ b/src/StyleMetrics.cpp @@ -12,9 +12,12 @@ void RefreshStyle() { g_style.windowBorder = ColorCode("WindowBorder"); g_style.titleHeader = ColorCode("TitleHeader"); g_style.grouping = ColorCode("Grouping"); + g_style.groupingHover = ColorCode("GroupingHover"); + g_style.groupingSelect = ColorCode("GroupingSelect"); g_style.windowSeparatorSize = LayoutSize("WindowSeparatorSize"); g_style.titleHeaderHeight = LayoutSize("TitleHeaderHeight"); g_style.settingItemHeight = LayoutSize("SettingItemHeight"); + g_style.groupTabHeight = LayoutSize("GroupTabHeight"); g_style.footerHeight = LayoutSize("FooterHeight"); g_loaded = true; } diff --git a/src/StyleMetrics.h b/src/StyleMetrics.h index 5e0182e..dd2792f 100644 --- a/src/StyleMetrics.h +++ b/src/StyleMetrics.h @@ -7,9 +7,12 @@ struct StyleMetrics { int windowBorder; int titleHeader; int grouping; + int groupingHover; + int groupingSelect; int windowSeparatorSize; int titleHeaderHeight; int settingItemHeight; + int groupTabHeight; int footerHeight; };