コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
123e269d2a
|
||
|
|
ca2231ca66
|
||
|
|
26b559cb4d
|
||
|
|
64d809ab73
|
||
|
|
e417c6ff3b
|
||
|
|
a39be56b8c
|
検索条件に一致するファイルはありません
+33
-7
@@ -1,5 +1,5 @@
|
||||
========================================
|
||||
ドッキング配置 for AviUtl ExEdit2 v1.0.1
|
||||
ドッキング配置 for AviUtl ExEdit2 v1.1.0
|
||||
========================================
|
||||
AviUtl ExEdit2 のウィンドウを、ドラッグとドロップだけで配置できるようにする
|
||||
プラグインです。
|
||||
@@ -21,7 +21,7 @@ AviUtl ExEdit2 のウィンドウを、ドラッグとドロップだけで配
|
||||
|
||||
C:\ProgramData\aviutl2\Plugin\
|
||||
|
||||
DockLayout_v1.0.1.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.1.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.1
|
||||
information=ドッキング配置 version 1.1.0
|
||||
uninstallSubFolderFile=0
|
||||
@@ -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" />
|
||||
|
||||
@@ -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,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.1.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.1.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.1.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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
+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.1",
|
||||
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; }
|
||||
新しいイシューから参照
ユーザーをブロックする