15 コミット
作成者 SHA1 メッセージ 日付
routersys e62d2e9789 Gitea Actions のワークフローを直す 2026-11-08 10:14:20 +09:00
routersys 7cfe6563d6 過去のタグ用ワークフローを消す 2026-11-08 03:57:06 +09:00
routersys 2726f2eecd Gitea Actions のワークフローを直す 2026-11-08 03:55:05 +09:00
routersys 320c2790ae Gitea Actions の過去のタグ用ワークフローを足す 2026-11-07 22:34:29 +09:00
routersys 2d8bef27ca Gitea Actions のワークフローを直す 2026-11-07 19:59:29 +09:00
routersys 4ec3a4a0e3 Gitea Actions のワークフローを足す 2026-11-07 19:49:58 +09:00
routersys bbbbc46dc7 Merge pull request #1 from routersys/着地予告の一致
着地予告の一致
2026-08-25 08:56:36 +09:00
routersys 123e269d2a 版表記を1.1.0へ上げた
リリース / build-and-release (workflow_dispatch) Actions がタグ v1.1.0 のコミットから作成しました
2026-08-25 00:05:59 +09:00
routersys ca2231ca66 着地予告の仕組みを文書へ書いた 2026-08-25 00:05:32 +09:00
routersys 26b559cb4d 着地予告を再配置の計算から求めるようにした 2026-08-25 00:05:31 +09:00
routersys 64d809ab73 分離した窓の配置を覚える仕組みを追加 2026-08-25 00:05:31 +09:00
routersys e417c6ff3b 配置の再計算を追加 2026-08-25 00:05:31 +09:00
routersys a39be56b8c ログへ調査用の行を残せるようにした 2026-08-25 00:05:30 +09:00
routersys 4324ba458e 版表記を1.0.1へ上げた
リリース / build-and-release (workflow_dispatch) Actions がタグ v1.0.1 のコミットから作成しました
2026-08-24 20:04:04 +09:00
routersys f831ee3b6b タブ列と見出しをまとめて掴める範囲にした 2026-08-24 19:58:06 +09:00
21個のファイルの変更、1134行の追加、107行の削除

検索条件に一致するファイルはありません

+456
ファイルの表示
@@ -0,0 +1,456 @@
name: リリース
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: リリースするタグ
required: true
permissions:
contents: write
jobs:
build-and-release:
runs-on: windows-latest
steps:
- name: ソースコードのチェックアウト
uses: actions/checkout@v4
env:
GIT_CONFIG_COUNT: "2"
GIT_CONFIG_KEY_0: url.https://git.routersys.com/routersys/.insteadOf
GIT_CONFIG_VALUE_0: https://github.com/routersys/
GIT_CONFIG_KEY_1: url.https://git.routersys.com/manju-summoner/YukkuriMovieMaker.Generator.insteadOf
GIT_CONFIG_VALUE_1: https://github.com/manju-summoner/YukkuriMovieMaker.Generator
with:
ref: ${{ inputs.tag || github.ref_name }}
fetch-depth: 0
- name: MSBuild のセットアップ
uses: microsoft/setup-msbuild@v2
- name: タグ名からバージョンを取得
id: version
shell: pwsh
run: |
$tag = "${{ inputs.tag || github.ref_name }}"
echo "TAG=$tag" >> $env:GITHUB_OUTPUT
echo "VERSION=$($tag.TrimStart('v'))" >> $env:GITHUB_OUTPUT
- name: バージョン記載の照合
shell: pwsh
run: |
$tag = "${{ steps.version.outputs.TAG }}"
$version = "${{ steps.version.outputs.VERSION }}"
$problems = @()
$pluginPath = "src/Plugin.cpp"
$plugin = Get-Content $pluginPath -Raw
if (-not $plugin.Contains("ドッキング配置 version $version")) {
$current = if ($plugin -match 'ドッキング配置 version ([^"]*)') { $Matches[1] } else { "記載なし" }
$problems += "$pluginPath のバージョンが $current です。$version にしてください。"
}
$iniPath = ".github/package.ini"
$ini = Get-Content $iniPath -Raw
if (-not $ini.Contains("information=ドッキング配置 version $version")) {
$current = if ($ini -match '(?m)^information=ドッキング配置 version (\S+)') { $Matches[1] } else { "記載なし" }
$problems += "$iniPath の information が $current です。$version にしてください。"
}
$readmePath = ".github/Plugin_Readme.txt"
$readme = Get-Content $readmePath -Raw
if (-not $readme.Contains(" ドッキング配置 for AviUtl ExEdit2 $tag")) {
$current = if ($readme -match '(?m)^ ドッキング配置 for AviUtl ExEdit2 (\S+)') { $Matches[1] } else { "記載なし" }
$problems += "$readmePath の見出しが $current です。$tag にしてください。"
}
$documentPath = "README.md"
$document = Get-Content $documentPath -Raw
foreach ($name in @("DockLayout_$tag.au2pkg.zip", "DockLayout_$tag.zip")) {
if (-not $document.Contains($name)) {
$problems += "$documentPath が $name を案内していません。"
}
}
if ($problems.Count -eq 0) {
Write-Host "バージョン記載は $tag と一致しています"
exit 0
}
foreach ($problem in $problems) {
Write-Host "::error::$problem"
}
Write-Host "::error::リリースの対象は $tag が指すコミットです。タグを付けた後で main へ訂正を積んでも、その訂正はリリースに入りません。タグを削除し、記載を直したコミットを積んでから付け直してください。"
exit 1
- name: プロジェクトのビルド
shell: pwsh
run: |
& msbuild "DockLayout.sln" `
/t:Rebuild `
/p:Configuration=Release `
/p:Platform=x64 `
/v:minimal `
/nologo `
/fl "/flp:LogFile=build.log;Verbosity=minimal;Encoding=UTF-8"
$code = $LASTEXITCODE
$log = @()
if (Test-Path "build.log") {
$log = @(Get-Content "build.log")
$log | ForEach-Object { Write-Host $_ }
}
if ($code -ne 0) {
Write-Host "::error::ビルドに失敗しました。"
exit 1
}
$warnings = @($log | Where-Object { $_ -match '\bwarning\b' })
if ($warnings.Count -gt 0) {
foreach ($warning in $warnings) {
Write-Host "::error::$warning"
}
Write-Host "::error::本リポジトリは警告0を維持します。警告を解消してから付け直してください。"
exit 1
}
- name: パッケージの作成
id: package
shell: pwsh
run: |
$tag = "${{ steps.version.outputs.TAG }}"
$binary = "build/Release/DockLayout.aux2"
$stageRoot = "stage/package"
$plainRoot = "stage/plain/DockLayout"
$pkgName = "DockLayout_$tag.au2pkg.zip"
$zipName = "DockLayout_$tag.zip"
if (-not (Test-Path $binary)) {
Write-Error "ビルド結果が見つかりませんでした: $binary"
exit 1
}
New-Item -ItemType Directory -Path "$stageRoot/Plugin" -Force | Out-Null
Copy-Item $binary "$stageRoot/Plugin/DockLayout.aux2"
Copy-Item ".github/package.ini" "$stageRoot/package.ini"
Copy-Item ".github/Plugin_Readme.txt" "$stageRoot/package.txt"
New-Item -ItemType Directory -Path "$plainRoot/LICENSE" -Force | Out-Null
Copy-Item $binary "$plainRoot/DockLayout.aux2"
Copy-Item ".github/Plugin_Readme.txt" "$plainRoot/Readme.txt"
Copy-Item "LICENSE.txt" "$plainRoot/LICENSE/DockLayout.txt"
Copy-Item ".github/LICENSE/*.txt" "$plainRoot/LICENSE/"
$packaged = Get-Content "$stageRoot/package.txt" -Raw
if (-not $packaged.Contains(" ドッキング配置 for AviUtl ExEdit2 $tag")) {
Write-Error "同梱する package.txt の見出しが $tag と一致しません"
exit 1
}
Compress-Archive -Path "$stageRoot/*" -DestinationPath $pkgName -CompressionLevel Optimal
Compress-Archive -Path "stage/plain/*" -DestinationPath $zipName -CompressionLevel Optimal
echo "PKG_NAME=$pkgName" >> $env:GITHUB_OUTPUT
echo "ZIP_NAME=$zipName" >> $env:GITHUB_OUTPUT
- name: 変更履歴の作成
id: changelog
shell: pwsh
env:
GITEA_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.TAG }}
REPOSITORY: ${{ github.repository }}
SERVER_URL: ${{ github.server_url }}
PACKAGE: ${{ steps.package.outputs.PKG_NAME }}
ARCHIVE: ${{ steps.package.outputs.ZIP_NAME }}
run: |
$tag = $env:TAG
$repository = $env:REPOSITORY
$server = $env:SERVER_URL
$code = [char]0x60
$fence = [string]::new($code, 3)
$unit = [char]0x1f
$previous = ""
$candidates = @(git tag --list "v*" --merged $tag --sort=-creatordate | Where-Object { $_ -ne $tag })
if ($candidates.Count -gt 0) {
$previous = $candidates[0]
}
Write-Host "直前のタグ: $previous"
$range = if ($previous) { "$previous..$tag" } else { $tag }
$log = @(git log "--format=%H%x1f%s%x1f%an%x1f%ad" --date=short $range)
$commits = @()
foreach ($line in $log) {
if (-not $line) { continue }
$fields = $line -split $unit
if ($fields.Count -lt 4) { continue }
$commits += [pscustomobject]@{
Sha = $fields[0]
Subject = $fields[1]
Name = $fields[2]
Date = $fields[3]
Login = ""
Avatar = ""
}
}
Write-Host "コミット数: $($commits.Count)"
$pending = [System.Collections.Generic.HashSet[string]]::new()
foreach ($commit in $commits) {
[void]$pending.Add($commit.Sha)
}
$headers = @{ Authorization = "token $env:GITEA_TOKEN" }
$accounts = @{}
$page = 1
while ($pending.Count -gt 0 -and $page -le 20) {
$rows = @()
try {
$rows = @(Invoke-RestMethod -Uri "$server/api/v1/repos/$repository/commits?sha=$tag&limit=50&page=$page&stat=false&verification=false&files=false" -Headers $headers)
}
catch {
Write-Host "コミットの作者を取得できませんでした: $($_.Exception.Message)"
break
}
if ($rows.Count -eq 0) { break }
foreach ($row in $rows) {
if ($pending.Remove($row.sha)) {
$login = ""
$avatar = ""
if ($row.author) {
$login = [string]$row.author.login
$avatar = [string]$row.author.avatar_url
}
$accounts[$row.sha] = @{ Login = $login; Avatar = $avatar }
}
}
if ($rows.Count -lt 50) { break }
$page++
}
foreach ($commit in $commits) {
if ($accounts.ContainsKey($commit.Sha)) {
$commit.Login = $accounts[$commit.Sha].Login
$commit.Avatar = $accounts[$commit.Sha].Avatar
}
}
$emptyTree = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
$base = if ($previous) { $previous } else { $emptyTree }
$shortstat = (@(git diff --shortstat $base $tag) -join " ")
$changedFiles = 0
$insertions = 0
$deletions = 0
if ($shortstat -match "(\d+) file") { $changedFiles = [int]$Matches[1] }
if ($shortstat -match "(\d+) insertion") { $insertions = [int]$Matches[1] }
if ($shortstat -match "(\d+) deletion") { $deletions = [int]$Matches[1] }
$diffStat = @(git diff --stat $base $tag)
$tagDate = (git log -1 "--format=%ad" --date=short $tag)
$contributors = @($commits |
Group-Object -Property { if ($_.Login) { $_.Login } else { $_.Name } } |
Sort-Object -Property Count -Descending)
function Get-Icon($avatar, $login, $size) {
if (-not $avatar) { return "" }
$sized = if ($avatar.Contains("?")) { "$avatar&s=$($size * 2)" } else { "$avatar" + "?s=$($size * 2)" }
return "<img src=""$sized"" width=""$size"" height=""$size"" alt=""$login""> "
}
$body = [System.Collections.Generic.List[string]]::new()
$body.Add("## 概要")
$body.Add("")
$body.Add("| 項目 | 内容 |")
$body.Add("|---|---|")
$body.Add("| タグ | [$tag]($server/$repository/tree/$tag) |")
$body.Add("| 公開日 | $tagDate |")
if ($previous) {
$body.Add("| 直前のリリース | [$previous]($server/$repository/releases/tag/$previous) |")
}
$body.Add("| コミット数 | $($commits.Count) |")
$body.Add("| 貢献者 | $($contributors.Count) 名 |")
$body.Add("| 変更されたファイル | $changedFiles |")
$body.Add("| 追加された行 | $insertions |")
$body.Add("| 削除された行 | $deletions |")
$body.Add("")
$body.Add("## ダウンロード")
$body.Add("")
$body.Add("| ファイル | 用途 | サイズ |")
$body.Add("|---|---|---|")
foreach ($entry in @(
@{ Path = $env:PACKAGE; Use = "プレビュー画面へドロップしてインストールします" },
@{ Path = $env:ARCHIVE; Use = "手動で配置する場合に使います" })) {
$file = Get-Item $entry.Path
$size = [math]::Round($file.Length / 1MB, 2)
$body.Add("| $($file.Name) | $($entry.Use) | $size MB |")
}
$body.Add("")
$body.Add("## 貢献者")
$body.Add("")
$body.Add("| 貢献者 | コミット数 |")
$body.Add("|---|---|")
foreach ($contributor in $contributors) {
$first = $contributor.Group[0]
if ($first.Login) {
$name = (Get-Icon $first.Avatar $first.Login 40) + "[@$($first.Login)]($server/$($first.Login))"
}
else {
$name = $first.Name
}
$body.Add("| $name | $($contributor.Count) |")
}
$body.Add("")
$body.Add("## 変更履歴")
$body.Add("")
$body.Add("| コミット | 内容 | 貢献者 | 日付 |")
$body.Add("|---|---|---|---|")
$maximumCommits = 300
$listed = 0
foreach ($commit in $commits) {
if ($listed -ge $maximumCommits) { break }
$short = $commit.Sha.Substring(0, 7)
$subject = $commit.Subject -replace '\|', '\|'
if ($commit.Login) {
$author = (Get-Icon $commit.Avatar $commit.Login 20) + "[@$($commit.Login)]($server/$($commit.Login))"
}
else {
$author = $commit.Name
}
$body.Add("| [$code$short$code]($server/$repository/commit/$($commit.Sha)) | $subject | $author | $($commit.Date) |")
$listed++
}
if ($commits.Count -gt $maximumCommits) {
$body.Add("")
$body.Add("残り $($commits.Count - $maximumCommits) 件のコミットは省略しました。")
}
if ($diffStat.Count -gt 0) {
$body.Add("")
$body.Add("## 変更されたファイル")
$body.Add("")
$body.Add("<details>")
$body.Add("<summary>差分の統計</summary>")
$body.Add("")
$body.Add($fence)
$maximumStatLines = 200
$shown = 0
foreach ($line in $diffStat) {
if ($shown -ge $maximumStatLines) { break }
$body.Add($line)
$shown++
}
if ($diffStat.Count -gt $maximumStatLines) {
$body.Add("... 残り $($diffStat.Count - $maximumStatLines) 行は省略しました。")
}
$body.Add($fence)
$body.Add("")
$body.Add("</details>")
}
if ($previous) {
$body.Add("")
$body.Add("## 全ての変更")
$body.Add("")
$body.Add("$server/$repository/compare/$previous...$tag")
}
$path = "release-body.md"
Set-Content -Path $path -Value ($body -join "`n") -Encoding utf8NoBOM
if (-not (Test-Path $path)) {
throw "変更履歴を作成できませんでした。"
}
Write-Host "変更履歴の行数: $($body.Count)"
$global:LASTEXITCODE = 0
- name: Gitea リリースの作成
shell: pwsh
env:
GITEA_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
SERVER_URL: ${{ github.server_url }}
EVENT_NAME: ${{ github.event_name }}
WORKFLOW_NAME: ${{ github.workflow }}
JOB_NAME: ${{ github.job }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_number }}
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
RELEASE_NAME: ${{ steps.version.outputs.TAG }}
RELEASE_BODY: ''
RELEASE_BODY_PATH: release-body.md
RELEASE_DRAFT: false
RELEASE_PRERELEASE: false
RELEASE_FILES: |
${{ steps.package.outputs.PKG_NAME }}
${{ steps.package.outputs.ZIP_NAME }}
run: |
$headers = @{ Authorization = "token $env:GITEA_TOKEN" }
$api = "$env:SERVER_URL/api/v1/repos/$env:REPOSITORY"
$tag = $env:RELEASE_TAG
$body = $env:RELEASE_BODY
if ($env:RELEASE_BODY_PATH -and (Test-Path $env:RELEASE_BODY_PATH)) {
$body = Get-Content $env:RELEASE_BODY_PATH -Raw -Encoding utf8
}
$files = @()
foreach ($pattern in ($env:RELEASE_FILES -split "[`r`n,]+" | Where-Object { $_.Trim() })) {
$found = @(Get-ChildItem -Path $pattern.Trim() -File -ErrorAction SilentlyContinue)
if ($found.Count -eq 0) { throw "リリースに付けるファイルが見つかりません: $pattern" }
$files += $found
}
$payload = @{
tag_name = $tag
name = $env:RELEASE_NAME
body = [string]$body
draft = ($env:RELEASE_DRAFT -eq 'true')
prerelease = ($env:RELEASE_PRERELEASE -eq 'true')
} | ConvertTo-Json
$bytes = [System.Text.Encoding]::UTF8.GetBytes($payload)
$existing = $null
try { $existing = Invoke-RestMethod -Uri "$api/releases/tags/$([System.Uri]::EscapeDataString($tag))" -Headers $headers } catch { }
if ($existing) {
$release = Invoke-RestMethod -Method Patch -Uri "$api/releases/$($existing.id)" -Headers $headers -ContentType "application/json; charset=utf-8" -Body $bytes
foreach ($asset in @($existing.assets)) {
Invoke-RestMethod -Method Delete -Uri "$api/releases/$($existing.id)/assets/$($asset.id)" -Headers $headers | Out-Null
}
} else {
$release = Invoke-RestMethod -Method Post -Uri "$api/releases" -Headers $headers -ContentType "application/json; charset=utf-8" -Body $bytes
}
foreach ($file in $files) {
$name = [System.Uri]::EscapeDataString($file.Name)
Invoke-RestMethod -Method Post -Uri "$api/releases/$($release.id)/assets?name=$name" -Headers $headers -Form @{ attachment = Get-Item $file.FullName } | Out-Null
Write-Host "添付しました: $($file.Name)"
}
Write-Host "リリースを作成しました: $($release.html_url)"
if ($env:EVENT_NAME -eq 'workflow_dispatch') {
try {
$sha = (git rev-parse HEAD).Trim()
$status = @{
state = 'success'
context = "$env:WORKFLOW_NAME / $env:JOB_NAME (workflow_dispatch)"
description = "Actions がタグ $tag のコミットから作成しました"
target_url = $env:RUN_URL
} | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri "$api/statuses/$sha" -Headers $headers -ContentType "application/json; charset=utf-8" -Body ([System.Text.Encoding]::UTF8.GetBytes($status)) | Out-Null
Write-Host "タグのコミット $sha に成功の状態を付けました"
}
catch {
Write-Warning "タグのコミットに状態を付けられませんでした: $($_.Exception.Message)"
}
}
+33 -7
ファイルの表示
@@ -1,5 +1,5 @@
========================================
ドッキング配置 for AviUtl ExEdit2 v1.0.0
ドッキング配置 for AviUtl ExEdit2 v1.1.0
========================================
AviUtl ExEdit2 のウィンドウを、ドラッグとドロップだけで配置できるようにする
プラグインです。
@@ -21,7 +21,7 @@ AviUtl ExEdit2 のウィンドウを、ドラッグとドロップだけで配
C:\ProgramData\aviutl2\Plugin\
DockLayout_v1.0.0.au2pkg.zip をプレビュー画面へドロップしても
DockLayout_v1.1.0.au2pkg.zip をプレビュー画面へドロップしても
インストールできます。
いずれの場合も、確認の画面で「このプラグイン・スクリプトを信頼して
使用する」を選んでください。
@@ -32,18 +32,23 @@ AviUtl ExEdit2 のウィンドウを、ドラッグとドロップだけで配
パネルは、Alt キーを押しながらパネルの中をドラッグしてください。
- ドラッグを始めると、画面の中央に5つのガイドが出ます。左右上下と中央の
エリアに対応していて、落としたガイドのエリアへパネルが移ります。落ちる先は
半透明の枠で示します。
エリアに対応していて、落としたガイドのエリアへパネルが移ります。落とした
後にパネルが置かれる範囲を半透明の枠で示します。この枠は AviUtl ExEdit2 の
再配置を計算したもので、移動元のエリアが空になって他のパネルが広がる場合も
その結果を含めた位置を示します。
- 他のパネルの上へカーソルを重ねると、そのパネルの上にもガイドが出ます。
中央のガイドへ落とすとタブにまとまり、左右または上下のガイドへ落とすと
その位置へ並び順が変わります。並び順のガイドは、同じエリアに並んでいる
パネル同士でだけ出ます。
パネル同士でだけ出ます。まとめる場合の枠はまとまった後の枠全体を、
並べ替えの場合の枠は移動先の枠の位置と大きさを示します。
- 本体のウィンドウの外へ落とすと、パネルが別のウィンドウへ分離します。
パネルは本体の外へ出るため、この操作では枠を出しません。
- 分離したウィンドウのタイトルバーを掴んで本体のウィンドウの上へ運ぶと、
中央にガイドが出ます。そこへ落とすと本体へ戻ります。
中央にガイドが出ます。そこへ落とすと本体へ戻ります。本プラグインで分離した
ウィンドウであれば、戻った後の位置を枠で示します。
- ドラッグの途中で Esc キーを押すと操作を取り消します。
--------------------------------------------------------------------------------
@@ -61,6 +66,15 @@ AviUtl ExEdit2 のウィンドウを、ドラッグとドロップだけで配
- ドラッグを始めた時点で、各パネルがどのエリアに属しているかを調べます。
この時にメニューを画面に出さずに開きますが、編集の状態は変わりません。
- ガイドへ重ねたときに出す枠は、AviUtl ExEdit2 が落とした後に組み直す配置を
計算したものです。区切りの幅は WindowSeparatorSize から2を引いた値で、
長さ L の領域は区切り1本分を足した長さとして扱われます。各枠はその長さの
中で割合に応じた区画を取り、区画の末尾から区切り1本分を除いた範囲に
描かれます。列と帯の大きさは先頭とそれ以外の二分割を繰り返して決まり、
比はそのエリアに属するウィンドウの矩形を囲む範囲の比になります。エリアの
中では各ウィンドウが自分の矩形の大きさの比で区画を取ります。計算した矩形と
実際に描かれた矩形の差は、実測で最大1画素でした。
- 落とした後の操作は、マウスの処理を終えてから発行します。AviUtl ExEdit2 が
配置を組み替える最中に、その処理へ入り込まないようにするためです。
--------------------------------------------------------------------------------
@@ -83,6 +97,18 @@ AviUtl ExEdit2 のウィンドウを、ドラッグとドロップだけで配
- パネルの位置を画面から求めるため、AviUtl ExEdit2 のウィンドウが最小化されて
いる間は配置の操作を行えません。
- タブにまとまっているパネルを掴んだ場合は枠を出しません。AviUtl ExEdit2 は
タブの組から掴んだウィンドウ1枚だけを動かし、残りはその場に留まります。
分かれた後の大きさは画面に出ている情報だけでは決まらないためです。ガイドは
出るので操作はできます。
- 本プラグインを読み込む前から分離していたウィンドウを本体へ戻す場合は枠を
出しません。戻る先は AviUtl ExEdit2 が分離前の配置として保存している値から
決まり、その値は実行中のプラグインから読めないためです。
- パネルがどのエリアに属しているかを読み取れなかった場合も枠を出しません。
確かめられない位置を枠で示さないためです。
--------------------------------------------------------------------------------
■ 注意事項
--------------------------------------------------------------------------------
@@ -135,7 +161,7 @@ AviUtl ExEdit2 のウィンドウを、ドラッグとドロップだけで配
■ サードパーティライセンス
--------------------------------------------------------------------------------
本プラグインは AviUtl ExEdit2 Plugin SDK のヘッダーを使用しています。
ライセンスの全文は DockLayout_v1.0.0.zip の LICENSE フォルダーと、
ライセンスの全文は DockLayout_v1.1.0.zip の LICENSE フォルダーと、
リポジトリの .github/LICENSE に収録しています。
AviUtl ExEdit2 Plugin SDK : Copyright (c) 2025 Kenkun MIT License
--------------------------------------------------------------------------------
+1 -1
ファイルの表示
@@ -1,5 +1,5 @@
[package]
id=DockLayout
name=ドッキング配置
information=ドッキング配置 version 1.0.0
information=ドッキング配置 version 1.1.0
uninstallSubFolderFile=0
+4
ファイルの表示
@@ -94,7 +94,9 @@
<ItemGroup>
<ClCompile Include="src\DockGuides.cpp" />
<ClCompile Include="src\DockModel.cpp" />
<ClCompile Include="src\DockPlan.cpp" />
<ClCompile Include="src\DragSession.cpp" />
<ClCompile Include="src\FloatOrigin.cpp" />
<ClCompile Include="src\FloatWindowHook.cpp" />
<ClCompile Include="src\GuideWindow.cpp" />
<ClCompile Include="src\HostContext.cpp" />
@@ -110,7 +112,9 @@
<ItemGroup>
<ClInclude Include="src\DockGuides.h" />
<ClInclude Include="src\DockModel.h" />
<ClInclude Include="src\DockPlan.h" />
<ClInclude Include="src\DragSession.h" />
<ClInclude Include="src\FloatOrigin.h" />
<ClInclude Include="src\FloatWindowHook.h" />
<ClInclude Include="src\GuideWindow.h" />
<ClInclude Include="src\HostContext.h" />
+12
ファイルの表示
@@ -25,9 +25,15 @@
<ClCompile Include="src\DockModel.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
<ClCompile Include="src\DockPlan.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
<ClCompile Include="src\DragSession.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
<ClCompile Include="src\FloatOrigin.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
<ClCompile Include="src\FloatWindowHook.cpp">
<Filter>ソース ファイル</Filter>
</ClCompile>
@@ -66,9 +72,15 @@
<ClInclude Include="src\DockModel.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
<ClInclude Include="src\DockPlan.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
<ClInclude Include="src\DragSession.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
<ClInclude Include="src\FloatOrigin.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
<ClInclude Include="src\FloatWindowHook.h">
<Filter>ヘッダー ファイル</Filter>
</ClInclude>
+24 -8
ファイルの表示
@@ -24,6 +24,7 @@ AviUtl ExEdit2 のウィンドウを、ドラッグとドロップだけで配
- [4. ウィンドウの分離と結合](#4-ウィンドウの分離と結合)
5. [ガイドの一覧](#ガイドの一覧)
6. [仕組み](#仕組み)
- [着地予告の計算](#着地予告の計算)
7. [制限事項](#制限事項)
8. [注意事項](#注意事項)
9. [ログ表示での確認](#ログ表示での確認)
@@ -55,11 +56,11 @@ AviUtl ExEdit2 のウィンドウ配置は、右クリックメニューの「
## インストール方法
1. [Releases](https://github.com/routersys/AUE2-DockLayout/releases/latest) ページから `DockLayout_v1.0.0.au2pkg.zip` をダウンロードしてください。
1. [Releases](https://github.com/routersys/AUE2-DockLayout/releases/latest) ページから `DockLayout_v1.1.0.au2pkg.zip` をダウンロードしてください。
2. AviUtl ExEdit2 を起動し、ダウンロードしたファイルをプレビュー画面へドロップします。
3. 確認の画面で「このプラグイン・スクリプトを信頼して使用する」を選んでください。インストールの後に AviUtl ExEdit2 が再起動します。
手動で配置する場合は、`DockLayout_v1.0.0.zip` を展開し、`DockLayout.aux2` を下記のフォルダーへ置いてください。次に AviUtl ExEdit2 を起動すると確認の画面が出るので、信頼して使用することを選びます。
手動で配置する場合は、`DockLayout_v1.1.0.zip` を展開し、`DockLayout.aux2` を下記のフォルダーへ置いてください。次に AviUtl ExEdit2 を起動すると確認の画面が出るので、信頼して使用することを選びます。
```
C:\ProgramData\aviutl2\Plugin\
@@ -73,21 +74,21 @@ C:\ProgramData\aviutl2\Plugin\
パネルの見出しをドラッグすると配置の操作が始まります。見出しを持たないパネルは、Alt キーを押しながらパネルの中をドラッグしてください。
ドラッグを始めると、画面の中央に5つのガイドが出ます。左右上下と中央のエリアに対応していて、落としたガイドのエリアへパネルが移ります。カーソルをガイドへ重ねると、落ちる先を半透明の枠で示します。
ドラッグを始めると、画面の中央に5つのガイドが出ます。左右上下と中央のエリアに対応していて、落としたガイドのエリアへパネルが移ります。カーソルをガイドへ重ねると、落とした後にパネルが置かれる範囲を半透明の枠で示します。この枠は AviUtl ExEdit2 の再配置を計算したものです。移動元のエリアが空になって他のパネルが広がる場合も、その結果を含めた位置を示します。
### 2. タブへのまとめ
他のパネルの上へカーソルを重ねると、そのパネルの上にもガイドが出ます。中央のガイドへ落とすと、2つのパネルが同じエリアでタブにまとまります。別のエリアのパネルへ落とした場合も、まず対象のエリアへ移してからまとめます。
他のパネルの上へカーソルを重ねると、そのパネルの上にもガイドが出ます。中央のガイドへ落とすと、2つのパネルが同じエリアでタブにまとまります。別のエリアのパネルへ落とした場合も、まず対象のエリアへ移してからまとめます。枠はまとまった後の枠全体を示します。
### 3. 並び順の入れ替え
パネルの上のガイドのうち、左右または上下に伸びる矢印へ落とすと、そのパネルの手前または後ろへ移ります。並び順のガイドは、同じエリアに並んでいるパネル同士でだけ出ます。矢印の向きは、そのエリアがパネルを縦に並べているか横に並べているかで変わります。
パネルの上のガイドのうち、左右または上下に伸びる矢印へ落とすと、そのパネルの手前または後ろへ移ります。並び順のガイドは、同じエリアに並んでいるパネル同士でだけ出ます。矢印の向きは、そのエリアがパネルを縦に並べているか横に並べているかで変わります。AviUtl ExEdit2 の並べ替えは枠の大きさを保ったまま中身を入れ替えるため、枠は移動先の枠の位置と大きさをそのまま示します。
### 4. ウィンドウの分離と結合
本体のウィンドウの外へ落とすと、パネルが別のウィンドウへ分離します。
本体のウィンドウの外へ落とすと、パネルが別のウィンドウへ分離します。パネルは本体の外へ出るため、この操作では枠を出しません。
分離したウィンドウは、タイトルバーを掴んで本体のウィンドウの上へ運ぶと、中央にガイドが出ます。そこへ落とすと本体へ戻ります。
分離したウィンドウは、タイトルバーを掴んで本体のウィンドウの上へ運ぶと、中央にガイドが出ます。そこへ落とすと本体へ戻ります。本プラグインで分離したウィンドウであれば、戻った後の位置を枠で示します。
ドラッグの途中で Esc キーを押すと操作を取り消します。
@@ -118,6 +119,18 @@ C:\ProgramData\aviutl2\Plugin\
落とした後の操作は、マウスの処理を終えてから発行します。AviUtl ExEdit2 が配置を組み替える最中に、その処理へ入り込まないようにするためです。
### 着地予告の計算
ガイドへ重ねたときに出す枠は、AviUtl ExEdit2 が落とした後に組み直す配置を計算したものです。組み直しの規則は AviUtl ExEdit2 2.1.6a を操作して測り、次のとおりであることを確かめました。
区切りの幅は `WindowSeparatorSize` から2を引いた値です。長さ L の領域は、区切り1本分の幅を足した長さとして扱われます。各枠はその長さの中で割合に応じた区画を取り、区画の末尾から区切り1本分を除いた範囲に描かれます。この対応は逆にもたどれるため、画面から読み取った矩形から AviUtl ExEdit2 が持っている割合をそのまま求められます。
列は左側エリア、中央部分、右側エリアの順に、帯は上側エリア、中央エリア、下側エリアの順に並びます。大きさは先頭とそれ以外の二分割を繰り返して決まり、それぞれの比はそのエリアに属するウィンドウの矩形を囲む範囲の比になります。
エリアの中では、各ウィンドウが自分の矩形の大きさの比で区画を取ります。並ぶ順は矩形の左端、左右のエリアでは上端の小さい順で、同じ値のときは右端または下端の小さい順です。
エリアを変えてもウィンドウが持っている割合は変わらず、組み直しのたびに描かれた結果が新しい割合として保存されます。したがって画面から読み取った矩形だけで次の配置を計算できます。計算した矩形と実際に描かれた矩形の差は、実測で最大1画素でした。領域の先頭に接する枠は上または左の枠線を描かないため、その分だけ全体がずれます。
---
## 制限事項
@@ -127,6 +140,9 @@ C:\ProgramData\aviutl2\Plugin\
- AviUtl ExEdit2 は、ひとつのエリアの中でタブにまとまるウィンドウをひとつの組としてしか扱えません。同じエリアに既にタブの組がある状態で、その組に入っていないパネル同士をまとめることはできないため、その場合はまとめるガイドが出ません。
- 見出しを持たないパネルは、Alt キーを押しながらでないと掴めません。プレビュー編集、レイヤー編集、オブジェクト設定が該当します。
- パネルの位置を画面から求めるため、AviUtl ExEdit2 のウィンドウが最小化されている間は配置の操作を行えません。
- タブにまとまっているパネルを掴んだ場合は枠を出しません。AviUtl ExEdit2 はタブの組から掴んだウィンドウ1枚だけを動かし、残りはその場に留まります。分かれた後の大きさは画面に出ている情報だけでは決まらないためです。ガイドは出るので操作はできます。
- 本プラグインを読み込む前から分離していたウィンドウを本体へ戻す場合は枠を出しません。戻る先は AviUtl ExEdit2 が分離前の配置として保存している値から決まり、その値は実行中のプラグインから読めないためです。
- パネルがどのエリアに属しているかを読み取れなかった場合も枠を出しません。確かめられない位置を枠で示さないためです。
---
@@ -166,7 +182,7 @@ C:\ProgramData\aviutl2\Plugin\
## サードパーティライセンス
本プラグインは以下のサードパーティソフトウェアを使用しています。ライセンスの全文は、リポジトリの [`.github/LICENSE/AviUtl2-PluginSDK.txt`](.github/LICENSE/AviUtl2-PluginSDK.txt) と、配布する `DockLayout_v1.0.0.zip` の `LICENSE` フォルダーに収録しています。
本プラグインは以下のサードパーティソフトウェアを使用しています。ライセンスの全文は、リポジトリの [`.github/LICENSE/AviUtl2-PluginSDK.txt`](.github/LICENSE/AviUtl2-PluginSDK.txt) と、配布する `DockLayout_v1.1.0.zip` の `LICENSE` フォルダーに収録しています。
| ソフトウェア | 用途 | ライセンス | 著作権表示 |
|---|---|---|---|
+89 -36
ファイルの表示
@@ -1,11 +1,12 @@
#include "DockGuides.h"
#include <utility>
#include "DockPlan.h"
#include "HostContext.h"
namespace dl {
static const int kAreaBandDivisor = 4;
static int ButtonSize() {
const int base = LayoutSize("TitleHeaderHeight");
return base > 0 ? base * 2 : 40;
@@ -32,31 +33,6 @@ static bool Empty(const RECT& r) {
return r.right <= r.left || r.bottom <= r.top;
}
static RECT EdgeBand(const RECT& region, int area) {
const int width = (region.right - region.left) / kAreaBandDivisor;
const int height = (region.bottom - region.top) / kAreaBandDivisor;
switch (area) {
case 0: return RECT{ region.left, region.top, region.left + width, region.bottom };
case 1: return RECT{ region.right - width, region.top, region.right, region.bottom };
case 2: return RECT{ region.left, region.top, region.right, region.top + height };
case 3: return RECT{ region.left, region.bottom - height, region.right, region.bottom };
default: break;
}
return RECT{ region.left, region.top + height, region.right, region.bottom - height };
}
static RECT SideHalf(const RECT& r, StackAxis axis, bool after) {
RECT half = r;
if (axis == StackAxis::Vertical) {
const int middle = (r.top + r.bottom) / 2;
(after ? half.top : half.bottom) = middle;
} else {
const int middle = (r.left + r.right) / 2;
(after ? half.left : half.right) = middle;
}
return half;
}
bool CanGroupOnto(const DockModel& model, int source, int target) {
const DockPanel* from = model.Get(source);
const DockPanel* onto = model.Get(target);
@@ -80,13 +56,70 @@ bool CanInsertInto(const DockModel& model, int source, int target) {
from->area != kAreaUnknown && from->area == onto->area;
}
bool BuildInsertPlan(const DockModel& model, int source, int target, bool after, InsertPlan* plan) {
const DockPanel* from = model.Get(source);
const DockPanel* onto = model.Get(target);
if (!from || !onto || !plan) return false;
plan->slots.clear();
for (size_t i = 0; i < model.Panels().size(); i++)
if (model.Panels()[i].stack == from->stack) plan->slots.push_back(static_cast<int>(i));
for (size_t i = 1; i < plan->slots.size(); i++)
for (size_t j = i; j > 0 && model.Panels()[plan->slots[j - 1]].order >
model.Panels()[plan->slots[j]].order; j--)
std::swap(plan->slots[j - 1], plan->slots[j]);
int at = -1, to = -1;
for (size_t i = 0; i < plan->slots.size(); i++) {
if (plan->slots[i] == source) at = static_cast<int>(i);
if (plan->slots[i] == target) to = static_cast<int>(i);
}
if (at < 0 || to < 0) return false;
plan->from = at;
plan->to = after ? (at < to ? to : to + 1) : (at < to ? to - 1 : to);
return plan->to != at;
}
static bool PlanAreaMove(const DockModel& model, int source, int area, RECT* out) {
const DockPanel* from = model.Get(source);
if (!from || from->grouped) return false;
if (from->area == area) { *out = from->rect; return true; }
DockPlan plan;
if (!plan.Load(model)) return false;
if (!plan.SetArea(source, area)) return false;
plan.Compute();
return plan.RectOf(source, out);
}
static bool PlanGroup(const DockModel& model, int source, int target, RECT* out) {
const DockPanel* from = model.Get(source);
if (!from || from->grouped) return false;
DockPlan plan;
if (!plan.Load(model)) return false;
if (!plan.Detach(source)) return false;
plan.Compute();
return plan.RectOf(target, out);
}
static bool PlanMerge(const DockModel& model, const FloatOrigin& incoming, RECT* out) {
DockPlan plan;
if (!plan.Load(model)) return false;
if (!plan.Add(incoming.left, incoming.top, incoming.right, incoming.bottom, incoming.area))
return false;
plan.Compute();
return plan.RectOf(kIncomingPanel, out);
}
void DockGuides::Clear() {
buttons_.clear();
hot_ = -1;
target_ = DropTarget();
}
void DockGuides::AddAreaCross(const DockModel& model) {
void DockGuides::AddAreaCross(const DockModel& model, int source) {
const RECT& region = model.Region();
const POINT center = CenterOf(region);
const int size = ButtonSize();
@@ -106,8 +139,8 @@ void DockGuides::AddAreaCross(const DockModel& model) {
button.icon = icons[area];
button.target.kind = DropKind::Area;
button.target.area = area;
RECT preview = model.AreaRect(area);
button.target.preview = Empty(preview) ? EdgeBand(region, area) : preview;
button.target.known = PlanAreaMove(model, source, area, &button.target.preview);
if (!button.target.known) button.target.preview = RECT{};
buttons_.push_back(button);
}
}
@@ -165,14 +198,32 @@ void DockGuides::AddPanelCluster(const DockModel& model, int source, int hovered
button.target.kind = entry.kind;
button.target.panel = hovered;
button.target.after = entry.after;
button.target.preview = entry.kind == DropKind::Group
? onto->rect
: SideHalf(onto->rect, axis, entry.after);
if (entry.kind == DropKind::Group) {
button.target.known = PlanGroup(model, source, hovered, &button.target.preview);
if (!button.target.known) button.target.preview = RECT{};
}
if (entry.kind == DropKind::Insert) {
InsertPlan plan;
if (BuildInsertPlan(model, source, hovered, entry.after, &plan)) {
const DockPanel* slot = model.Get(plan.slots[plan.to]);
if (slot) {
button.target.preview = slot->rect;
button.target.known = true;
}
} else {
const DockPanel* from = model.Get(source);
if (from) {
button.target.preview = from->rect;
button.target.known = true;
}
}
}
buttons_.push_back(button);
}
}
void DockGuides::Update(const DockModel& model, int source, POINT cursor, bool inside) {
void DockGuides::Update(const DockModel& model, int source, POINT cursor, bool inside,
const FloatOrigin* incoming) {
buttons_.clear();
hot_ = -1;
target_ = DropTarget();
@@ -184,10 +235,12 @@ void DockGuides::Update(const DockModel& model, int source, POINT cursor, bool i
button.rect = CenteredRect(CenterOf(model.Region()), ButtonSize());
button.icon = GuideIcon::Merge;
button.target.kind = DropKind::Merge;
button.target.preview = model.Region();
if (incoming && incoming->area != kAreaUnknown)
button.target.known = PlanMerge(model, *incoming, &button.target.preview);
if (!button.target.known) button.target.preview = RECT{};
buttons_.push_back(button);
} else {
AddAreaCross(model);
AddAreaCross(model, source);
const int hovered = model.IndexAt(cursor);
if (hovered >= 0 && hovered != source) AddPanelCluster(model, source, hovered);
}
+12 -2
ファイルの表示
@@ -4,6 +4,7 @@
#include <vector>
#include "DockModel.h"
#include "FloatOrigin.h"
#include "WindowMenu.h"
namespace dl {
@@ -20,6 +21,7 @@ struct DropTarget {
int area = kAreaUnknown;
int panel = -1;
bool after = false;
bool known = false;
RECT preview = {};
};
@@ -29,9 +31,16 @@ struct GuideButton {
DropTarget target;
};
struct InsertPlan {
std::vector<int> slots;
int from = -1;
int to = -1;
};
class DockGuides {
public:
void Update(const DockModel& model, int source, POINT cursor, bool inside);
void Update(const DockModel& model, int source, POINT cursor, bool inside,
const FloatOrigin* incoming);
void Clear();
const std::vector<GuideButton>& Buttons() const { return buttons_; }
@@ -39,7 +48,7 @@ public:
const DropTarget& Target() const { return target_; }
private:
void AddAreaCross(const DockModel& model);
void AddAreaCross(const DockModel& model, int source);
void AddPanelCluster(const DockModel& model, int source, int hovered);
std::vector<GuideButton> buttons_;
@@ -49,5 +58,6 @@ private:
bool CanGroupOnto(const DockModel& model, int source, int target);
bool CanInsertInto(const DockModel& model, int source, int target);
bool BuildInsertPlan(const DockModel& model, int source, int target, bool after, InsertPlan* plan);
}
+249
ファイルの表示
@@ -0,0 +1,249 @@
#include "DockPlan.h"
#include <algorithm>
#include "StyleMetrics.h"
#include "WindowMenu.h"
namespace dl {
namespace {
const int kBandAreas[3] = { 2, 4, 3 };
const double kRound = 1e-6;
struct Span {
double low;
double high;
};
struct Slot {
int low;
int high;
};
void Nest(const std::vector<Span>& spans, double start, double total, int separator,
std::vector<Slot>* out) {
if (spans.empty()) return;
if (spans.size() == 1) {
out->push_back(Slot{ static_cast<int>(start + kRound),
static_cast<int>(start + total - separator + kRound) });
return;
}
const double first = spans[0].high - spans[0].low;
double low = spans[1].low;
double high = spans[1].high;
for (size_t i = 2; i < spans.size(); i++) {
low = min(low, spans[i].low);
high = max(high, spans[i].high);
}
const double rest = high - low;
const double slot = first + rest > 0 ? total * first / (first + rest)
: total / static_cast<double>(spans.size());
out->push_back(Slot{ static_cast<int>(start + kRound),
static_cast<int>(start + slot - separator + kRound) });
Nest(std::vector<Span>(spans.begin() + 1, spans.end()), start + slot, total - slot,
separator, out);
}
std::vector<Slot> Spread(const std::vector<double>& weights, int start, int length, int separator) {
std::vector<Slot> slots;
double total = 0;
for (double weight : weights) total += weight;
if (total <= 0 || length <= 0) return slots;
double at = start;
const double extended = static_cast<double>(length) + separator;
for (double weight : weights) {
const double size = weight / total * extended;
slots.push_back(Slot{ static_cast<int>(at + kRound),
static_cast<int>(at + size - separator + kRound) });
at += size;
}
return slots;
}
Span Bounds(const std::vector<PlanItem*>& members, bool vertical) {
Span span = vertical ? Span{ members[0]->top, members[0]->bottom }
: Span{ members[0]->left, members[0]->right };
for (const PlanItem* item : members) {
span.low = min(span.low, vertical ? item->top : item->left);
span.high = max(span.high, vertical ? item->bottom : item->right);
}
return span;
}
void SortMembers(std::vector<PlanItem*>& members, bool vertical) {
std::stable_sort(members.begin(), members.end(),
[vertical](const PlanItem* a, const PlanItem* b) {
const double al = vertical ? a->top : a->left;
const double bl = vertical ? b->top : b->left;
if (al != bl) return al < bl;
return (vertical ? a->bottom : a->right) < (vertical ? b->bottom : b->right);
});
}
void StackVertical(std::vector<PlanItem*>& members, int left, int right,
int top, int bottom, int separator) {
SortMembers(members, true);
std::vector<double> weights;
for (const PlanItem* item : members) weights.push_back(item->bottom - item->top);
const std::vector<Slot> slots = Spread(weights, top, bottom - top, separator);
for (size_t i = 0; i < slots.size() && i < members.size(); i++)
members[i]->rect = RECT{ left, slots[i].low, right, slots[i].high };
}
void StackHorizontal(std::vector<PlanItem*>& members, int left, int right,
int top, int bottom, int separator) {
SortMembers(members, false);
std::vector<double> weights;
for (const PlanItem* item : members) weights.push_back(item->right - item->left);
const std::vector<Slot> slots = Spread(weights, left, right - left, separator);
for (size_t i = 0; i < slots.size() && i < members.size(); i++)
members[i]->rect = RECT{ slots[i].low, top, slots[i].high, bottom };
}
void LayoutMiddle(const std::vector<PlanItem*>& members, int left, int right,
int top, int bottom, int separator) {
std::vector<PlanItem*> bands[3];
for (PlanItem* item : members) {
for (int i = 0; i < 3; i++)
if (item->area == kBandAreas[i]) bands[i].push_back(item);
}
std::vector<Span> spans;
std::vector<int> present;
for (int i = 0; i < 3; i++) {
if (bands[i].empty()) continue;
spans.push_back(Bounds(bands[i], true));
present.push_back(i);
}
std::vector<Slot> rows;
Nest(spans, top, static_cast<double>(bottom - top) + separator, separator, &rows);
for (size_t i = 0; i < rows.size() && i < present.size(); i++)
StackHorizontal(bands[present[i]], left, right, rows[i].low, rows[i].high, separator);
}
}
int SeparatorWidth() {
const int size = Style().windowSeparatorSize - 2;
return size > 0 ? size : 1;
}
bool DockPlan::Load(const DockModel& model) {
items_.clear();
region_ = model.Region();
separator_ = SeparatorWidth();
const double width = static_cast<double>(region_.right - region_.left) + separator_;
const double height = static_cast<double>(region_.bottom - region_.top) + separator_;
if (width <= separator_ || height <= separator_) return false;
for (size_t i = 0; i < model.Panels().size(); i++) {
const DockPanel& panel = model.Panels()[i];
if (panel.area == kAreaUnknown) return false;
PlanItem item = {};
item.panel = static_cast<int>(i);
item.left = (panel.rect.left - region_.left) / width;
item.top = (panel.rect.top - region_.top) / height;
item.right = (panel.rect.right - region_.left + separator_) / width;
item.bottom = (panel.rect.bottom - region_.top + separator_) / height;
item.area = panel.area;
items_.push_back(item);
}
return !items_.empty();
}
bool DockPlan::SetArea(int panel, int area) {
for (size_t i = 0; i < items_.size(); i++) {
if (items_[i].panel != panel) continue;
const PlanItem moved = items_[i];
items_.erase(items_.begin() + i);
items_.push_back(moved);
items_.back().area = area;
return true;
}
return false;
}
bool DockPlan::Add(double left, double top, double right, double bottom, int area) {
if (items_.empty()) return false;
PlanItem item = {};
item.panel = kIncomingPanel;
item.left = left;
item.top = top;
item.right = right;
item.bottom = bottom;
item.area = area;
items_.push_back(item);
return true;
}
bool DockPlan::Detach(int panel) {
for (size_t i = 0; i < items_.size(); i++) {
if (items_[i].panel != panel) continue;
items_.erase(items_.begin() + i);
return true;
}
return false;
}
void DockPlan::Compute() {
for (PlanItem& item : items_) item.rect = RECT{};
if (items_.empty()) return;
std::vector<PlanItem*> groups[3];
for (PlanItem& item : items_) {
if (item.area == 0) groups[0].push_back(&item);
else if (item.area == 1) groups[2].push_back(&item);
else groups[1].push_back(&item);
}
std::vector<Span> spans;
std::vector<int> present;
for (int i = 0; i < 3; i++) {
if (groups[i].empty()) continue;
spans.push_back(Bounds(groups[i], false));
present.push_back(i);
}
std::vector<Slot> columns;
Nest(spans, region_.left, static_cast<double>(region_.right - region_.left) + separator_,
separator_, &columns);
for (size_t i = 0; i < columns.size() && i < present.size(); i++) {
std::vector<PlanItem*>& members = groups[present[i]];
if (present[i] == 1)
LayoutMiddle(members, columns[i].low, columns[i].high,
region_.top, region_.bottom, separator_);
else
StackVertical(members, columns[i].low, columns[i].high,
region_.top, region_.bottom, separator_);
}
}
bool DockPlan::NormalizedOf(int panel, double* left, double* top,
double* right, double* bottom) const {
for (const PlanItem& item : items_) {
if (item.panel != panel) continue;
*left = item.left;
*top = item.top;
*right = item.right;
*bottom = item.bottom;
return true;
}
return false;
}
bool DockPlan::RectOf(int panel, RECT* out) const {
for (const PlanItem& item : items_) {
if (item.panel != panel) continue;
if (item.rect.right <= item.rect.left || item.rect.bottom <= item.rect.top) return false;
*out = item.rect;
return true;
}
return false;
}
}
+40
ファイルの表示
@@ -0,0 +1,40 @@
#pragma once
#include <windows.h>
#include <vector>
#include "DockModel.h"
namespace dl {
inline constexpr int kIncomingPanel = -2;
struct PlanItem {
int panel;
double left;
double top;
double right;
double bottom;
int area;
RECT rect;
};
class DockPlan {
public:
bool Load(const DockModel& model);
bool SetArea(int panel, int area);
bool Add(double left, double top, double right, double bottom, int area);
bool Detach(int panel);
void Compute();
bool RectOf(int panel, RECT* out) const;
bool NormalizedOf(int panel, double* left, double* top, double* right, double* bottom) const;
private:
std::vector<PlanItem> items_;
RECT region_ = {};
int separator_ = 0;
};
int SeparatorWidth();
}
+53 -30
ファイルの表示
@@ -1,11 +1,12 @@
#include "DragSession.h"
#include <stdlib.h>
#include <utility>
#include <vector>
#include "DockGuides.h"
#include "DockModel.h"
#include "DockPlan.h"
#include "FloatOrigin.h"
#include "GuideWindow.h"
#include "HostContext.h"
#include "Log.h"
@@ -82,6 +83,20 @@ static POINT ToScreen(HWND window, POINT clientPt) {
return pt;
}
static void TraceGuides() {
const std::vector<GuideButton>& buttons = g_guides.Buttons();
for (size_t i = 0; i < buttons.size(); i++) {
const GuideButton& button = buttons[i];
LogTraceF(L"guide %d kind %d button %d %d %d %d known %d preview %d %d %d %d",
static_cast<int>(i), static_cast<int>(button.target.kind),
button.rect.left, button.rect.top, button.rect.right, button.rect.bottom,
button.target.known ? 1 : 0,
button.target.preview.left, button.target.preview.top,
button.target.preview.right, button.target.preview.bottom);
}
LogTraceF(L"guide end hot %d", g_guides.Hot());
}
bool DragSession::Holding() const { return phase_ == Phase::Armed; }
bool DragSession::Dragging() const { return phase_ == Phase::Dragging; }
@@ -113,12 +128,15 @@ bool DragSession::BeginFloat(HWND window) {
bool DragSession::Start() {
panel_ = -1;
hasOrigin_ = false;
if (window_ == HostWindow()) {
if (!g_model.Build()) return false;
panel_ = g_model.IndexAt(origin_);
if (panel_ < 0) return false;
} else if (!g_model.BuildRegion()) {
return false;
} else {
const bool built = g_model.Build();
if (built) hasOrigin_ = FloatOriginOf(window_, &floatOrigin_);
if (!built && !g_model.BuildRegion()) return false;
}
g_guides.Clear();
@@ -139,7 +157,8 @@ void DragSession::Track(POINT screenPt) {
const POINT hostPt = ToHostClient(screenPt);
const bool inside = PtInRect(&g_model.Region(), hostPt) != 0;
g_guides.Update(g_model, panel_, hostPt, inside);
g_guides.Update(g_model, panel_, hostPt, inside, hasOrigin_ ? &floatOrigin_ : nullptr);
TraceGuides();
Overlay().Update(g_guides);
}
@@ -157,40 +176,44 @@ void DragSession::ExecuteGroup(int target) {
void DragSession::ExecuteInsert(int target, bool after) {
const DockPanel* from = g_model.Get(panel_);
const DockPanel* onto = g_model.Get(target);
if (!from || !onto) return;
InsertPlan plan;
if (!from || !BuildInsertPlan(g_model, panel_, target, after, &plan)) return;
std::vector<const DockPanel*> slots;
for (const DockPanel& panel : g_model.Panels())
if (panel.stack == from->stack) slots.push_back(&panel);
for (size_t i = 1; i < slots.size(); i++)
for (size_t j = i; j > 0 && slots[j - 1]->order > slots[j]->order; j--)
std::swap(slots[j - 1], slots[j]);
int at = -1, to = -1;
for (size_t i = 0; i < slots.size(); i++) {
if (slots[i] == from) at = static_cast<int>(i);
if (slots[i] == onto) to = static_cast<int>(i);
}
if (at < 0 || to < 0) return;
const int destination = after ? (at < to ? to : to + 1) : (at < to ? to - 1 : to);
if (destination == at) return;
const int step = destination < at ? -1 : 1;
const int step = plan.to < plan.from ? -1 : 1;
const WindowCommand command = step < 0 ? WindowCommand::MoveUp : WindowCommand::MoveDown;
const POINT grab = { origin_.x - from->rect.left, origin_.y - from->rect.top };
for (int index = at; index != destination; index += step) {
const RECT& slot = slots[index]->rect;
const POINT point = { min(slot.left + grab.x, slot.right - 1),
min(slot.top + grab.y, slot.bottom - 1) };
for (int index = plan.from; index != plan.to; index += step) {
const DockPanel* slot = g_model.Get(plan.slots[index]);
if (!slot) return;
const POINT point = { min(slot->rect.left + grab.x, slot->rect.right - 1),
min(slot->rect.top + grab.y, slot->rect.bottom - 1) };
InvokeWindowCommand(HostWindow(), point, command);
}
LogF(L"ドッキング配置: パネルの並び順を変えました");
}
void DragSession::ExecuteDetach() {
const DockPanel* from = g_model.Get(panel_);
if (!from) return;
DockPlan plan;
FloatOrigin origin;
const bool known = plan.Load(g_model) &&
plan.NormalizedOf(panel_, &origin.left, &origin.top,
&origin.right, &origin.bottom);
origin.area = from->area;
if (!InvokeWindowCommand(HostWindow(), origin_, WindowCommand::Detach)) return;
LogF(L"ドッキング配置: パネルを分離しました");
if (known) SetPendingFloat(origin);
}
void DragSession::Execute() {
const DropTarget target = g_guides.Target();
LogTraceF(L"drop kind %d known %d preview %d %d %d %d",
static_cast<int>(target.kind), target.known ? 1 : 0,
target.preview.left, target.preview.top,
target.preview.right, target.preview.bottom);
switch (target.kind) {
case DropKind::Area: {
const DockPanel* from = g_model.Get(panel_);
@@ -206,8 +229,7 @@ void DragSession::Execute() {
ExecuteInsert(target.panel, target.after);
return;
case DropKind::Detach:
if (InvokeWindowCommand(HostWindow(), origin_, WindowCommand::Detach))
LogF(L"ドッキング配置: パネルを分離しました");
ExecuteDetach();
return;
case DropKind::Merge: {
RECT client = {};
@@ -219,6 +241,7 @@ void DragSession::Execute() {
};
for (const POINT& point : candidates) {
if (!InvokeWindowCommand(window_, point, WindowCommand::Merge)) continue;
ForgetFloat(window_);
LogF(L"ドッキング配置: ウィンドウを本体へ戻しました");
return;
}
+5
ファイルの表示
@@ -2,6 +2,8 @@
#include <windows.h>
#include "FloatOrigin.h"
namespace dl {
class DragSession {
@@ -25,6 +27,7 @@ private:
void Execute();
void ExecuteGroup(int target);
void ExecuteInsert(int target, bool after);
void ExecuteDetach();
void Replay(POINT screenPt);
void Reset();
@@ -33,6 +36,8 @@ private:
POINT origin_ = {};
int panel_ = -1;
bool pending_ = false;
bool hasOrigin_ = false;
FloatOrigin floatOrigin_;
};
DragSession& Drag();
+61
ファイルの表示
@@ -0,0 +1,61 @@
#include "FloatOrigin.h"
#include <vector>
namespace dl {
struct Entry {
HWND window;
FloatOrigin origin;
};
static std::vector<Entry> g_entries;
static bool g_pending = false;
static FloatOrigin g_pendingOrigin;
void SetPendingFloat(const FloatOrigin& origin) {
g_pending = true;
g_pendingOrigin = origin;
}
bool TakePendingFloat(FloatOrigin* out) {
if (!g_pending) return false;
g_pending = false;
if (out) *out = g_pendingOrigin;
return true;
}
void RememberFloat(HWND window, const FloatOrigin& origin) {
if (!window) return;
for (Entry& entry : g_entries) {
if (entry.window != window) continue;
entry.origin = origin;
return;
}
g_entries.push_back(Entry{ window, origin });
}
void ForgetFloat(HWND window) {
for (size_t i = 0; i < g_entries.size(); i++) {
if (g_entries[i].window != window) continue;
g_entries.erase(g_entries.begin() + i);
return;
}
}
bool FloatOriginOf(HWND window, FloatOrigin* out) {
for (const Entry& entry : g_entries) {
if (entry.window != window) continue;
if (out) *out = entry.origin;
return true;
}
return false;
}
void ClearFloatOrigins() {
g_entries.clear();
g_pending = false;
}
}
+23
ファイルの表示
@@ -0,0 +1,23 @@
#pragma once
#include <windows.h>
namespace dl {
struct FloatOrigin {
double left = 0;
double top = 0;
double right = 0;
double bottom = 0;
int area = -1;
};
void SetPendingFloat(const FloatOrigin& origin);
bool TakePendingFloat(FloatOrigin* out);
void RememberFloat(HWND window, const FloatOrigin& origin);
void ForgetFloat(HWND window);
bool FloatOriginOf(HWND window, FloatOrigin* out);
void ClearFloatOrigins();
}
+5
ファイルの表示
@@ -4,6 +4,7 @@
#include <vector>
#include "DragSession.h"
#include "FloatOrigin.h"
#include "HostContext.h"
namespace dl {
@@ -60,6 +61,7 @@ static LRESULT CALLBACK FloatProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) {
case WM_NCDESTROY: {
if (Drag().Window() == hwnd) Drag().Cancel();
const LRESULT result = CallOriginalProc(hwnd, msg, wp, lp);
ForgetFloat(hwnd);
Unhook(hwnd);
return result;
}
@@ -86,6 +88,9 @@ static BOOL CALLBACK Collect(HWND window, LPARAM) {
SetWindowProc(window, (WNDPROC)SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)FloatProc));
g_hooked.push_back(window);
FloatOrigin origin;
if (TakePendingFloat(&origin)) RememberFloat(window, origin);
return TRUE;
}
+1 -1
ファイルの表示
@@ -148,7 +148,7 @@ void Paint(Canvas& canvas, const DockGuides& guides) {
const DropTarget& target = guides.Target();
const RECT& preview = target.preview;
if (target.kind != DropKind::None && target.kind != DropKind::Detach &&
if (target.kind != DropKind::None && target.known &&
preview.right > preview.left && preview.bottom > preview.top) {
canvas.Fill(preview, accent, kPreviewFillAlpha);
canvas.Frame(preview, kPreviewEdgeWidth, accent, kPreviewEdgeAlpha);
+30 -13
ファイルの表示
@@ -10,6 +10,23 @@ void SetLogHandle(LOG_HANDLE* handle) {
g_log = handle;
}
#ifdef DL_DEBUG_LOG
static void WriteTrace(const wchar_t* text) {
static wchar_t logPath[MAX_PATH] = {};
if (!logPath[0]) {
wchar_t dir[MAX_PATH] = {};
if (GetTempPathW(MAX_PATH, dir))
_snwprintf_s(logPath, _TRUNCATE, L"%sDockLayout.log", dir);
}
if (!logPath[0]) return;
FILE* f = nullptr;
if (_wfopen_s(&f, logPath, L"a+, ccs=UTF-8") == 0 && f) {
fwprintf(f, L"%s\n", text);
fclose(f);
}
}
#endif
void LogF(const wchar_t* fmt, ...) {
wchar_t buf[1024];
va_list ap; va_start(ap, fmt);
@@ -17,19 +34,19 @@ void LogF(const wchar_t* fmt, ...) {
va_end(ap);
if (g_log) g_log->log(g_log, buf);
#ifdef DL_DEBUG_LOG
static wchar_t logPath[MAX_PATH] = {};
if (!logPath[0]) {
wchar_t dir[MAX_PATH] = {};
if (GetTempPathW(MAX_PATH, dir))
_snwprintf_s(logPath, _TRUNCATE, L"%sDockLayout.log", dir);
}
if (logPath[0]) {
FILE* f = nullptr;
if (_wfopen_s(&f, logPath, L"a+, ccs=UTF-8") == 0 && f) {
fwprintf(f, L"%s\n", buf);
fclose(f);
}
}
WriteTrace(buf);
#endif
}
void LogTraceF(const wchar_t* fmt, ...) {
#ifdef DL_DEBUG_LOG
wchar_t buf[1024];
va_list ap; va_start(ap, fmt);
_vsnwprintf_s(buf, _TRUNCATE, fmt, ap);
va_end(ap);
WriteTrace(buf);
#else
(void)fmt;
#endif
}
+1
ファイルの表示
@@ -8,6 +8,7 @@ namespace dl {
void SetLogHandle(LOG_HANDLE* handle);
void LogF(const wchar_t* fmt, ...);
void LogTraceF(const wchar_t* fmt, ...);
void LogWarn(const wchar_t* text);
}
+31 -8
ファイルの表示
@@ -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) {
+1
ファイルの表示
@@ -37,6 +37,7 @@ private:
bool RowMostly(int y, int x0, int x1, int color, bool* full) const;
std::vector<RECT> 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);
+3 -1
ファイルの表示
@@ -1,6 +1,7 @@
#include <windows.h>
#include "DragSession.h"
#include "FloatOrigin.h"
#include "FloatWindowHook.h"
#include "GuideWindow.h"
#include "HostContext.h"
@@ -14,7 +15,7 @@ using namespace dl;
COMMON_PLUGIN_TABLE common_plugin_table = {
L"ドッキング配置",
L"ドッキング配置 version 1.0.0",
L"ドッキング配置 version 1.1.0",
};
EXTERN_C __declspec(dllexport) COMMON_PLUGIN_TABLE* GetCommonPluginTable(void) {
@@ -42,6 +43,7 @@ EXTERN_C __declspec(dllexport) void UninitializePlugin() {
UninstallFloatWindowHook();
UninstallHostWindowHook();
UninstallWindowMenuHook();
ClearFloatOrigins();
}
BOOL APIENTRY DllMain(HMODULE, DWORD, LPVOID) { return TRUE; }