Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DockableAdded event raised and additional proportional dock nesting created when Dockable is moved #350

Open
Sputnik24 opened this issue Aug 2, 2024 · 0 comments

Comments

@Sputnik24
Copy link

Hi,

I observed a behaviour in my application I did not observe before.

  • When I move a dockable the DockableInit and DockableAdd events are raised.
    Background: In my app I react on DockableAdded and Removed adding/removing dockable info in a list. I found this out as those elements where added everytime I moved the tool. This did not happen before.
  • Additionally, I see that the DockLayout which I store in a json on closing the tool, each time I move a dockable, an additional ProportionalDock is created which leads to a new nesting everytime. This makes the layout json larger and larger.

Sample code, logs and layout json:

_factory.DockableInit += (_, e) =>
    Log.Debug($"Dockable init: {e.Dockable?.Title ?? "no title"} ({e.Dockable?.Id ?? "no id"})");
_factory.DockableMoved += (_, e) =>
    Log.Debug($"Dockable moved: {e.Dockable?.Title ?? "no title"} ({e.Dockable?.Id ?? "no id"})");
_factory.DockableAdded += (_, e) => {
    Log.Debug($"Dockable added: {e.Dockable?.Title ?? "no title"} ({e.Dockable?.Id ?? "no id"})");
    if (e.Dockable is not ToolDock { ActiveDockable: IToolBase addedTool }) return;
    Log.Debug($"Tool added: {addedTool.Title} (Id: {addedTool.Id})");
};
_factory.DockableClosed += (_, e) => {
    Log.Debug($"Dockable removed: {e.Dockable?.Title ?? "no title"} ({e.Dockable?.Id ?? "no id"})");
    if (e.Dockable is not IToolBase removedTool) return;
    Log.Debug($"Tool removed: {removedTool.Title} (Id: {removedTool.Id})");
};

Logs and Layout json after adding a Dock (good case, I guess):

"13:31:24.037" "Debug" "Main" "Dockable init: ()"\r\n
"13:31:24.495" "Debug" "Main" "Dockable added: ()"
"13:31:24.495" "Debug" "Main" "Dockable init: MyTool (045a8b2c-40ed-4836-b373-c5b9a6ff1d91)"
"13:31:24.495" "Debug" "Main" "Dockable init: ()"
"13:31:24.495" "Debug" "Main" "Dockable added: ()"
"13:31:24.495" "Debug" "Main" "Tool added: MyTool (Id: 045a8b2c-40ed-4836-b373-c5b9a6ff1d91)"

{
	"$id": "1",
	"$type": "Dock.Model.ReactiveUI.Controls.RootDock, Dock.Model.ReactiveUI",
	"IsFocusableRoot": true,
	"VisibleDockables": [
		{
			"$id": "2",
			"$type": "MyTool.ViewModels.MainDockViewModel, MyTool",
			"IsFocusableRoot": true,
			"VisibleDockables": [
				{
					"$id": "3",
					"$type": "Dock.Model.ReactiveUI.Controls.ProportionalDock, Dock.Model.ReactiveUI",
					"Orientation": 1,
					"VisibleDockables": [
						{
							"$id": "4",
							"$type": "Dock.Model.ReactiveUI.Controls.ToolDock, Dock.Model.ReactiveUI",
							"Alignment": -1,
							"IsExpanded": false,
							"AutoHide": true,
							"GripMode": 0,
							"VisibleDockables": [
								{
									"$id": "5",
									"$type": "MyTool.ViewModels.Tools.LoggingViewModel, MyTool"
								}
							],
							"ActiveDockable": {
								"$ref": "5"
							},
							"Proportion": 0.75,
							"Dock": 0,
							"IsActive": true,
							"IsEmpty": false,
							"OpenedDockablesCount": 1
						},
						{
							"$id": "6",
							"$type": "Dock.Model.ReactiveUI.Controls.ProportionalDockSplitter, Dock.Model.ReactiveUI"
						},
						{
							"$id": "7",
							"$type": "Dock.Model.ReactiveUI.Controls.ToolDock, Dock.Model.ReactiveUI",
							"Alignment": -1,
							"IsExpanded": false,
							"AutoHide": true,
							"GripMode": 0,
							"VisibleDockables": [
								{
									"$id": "8",
									"$type": "MyTool.Tool.FullTemplate.ViewModels.FullTemplateToolViewModel, MyTool.Tool.FullTemplate",
									"SettingsViewModel": {
										"$id": "9",
										"$type": "MyTool.Tool.FullTemplate.ViewModels.FullTemplateSettingsViewModel, MyTool.Tool.FullTemplate",
										"BoolSetting": false,
										"IntSetting": "0"
									}
								}
							],
							"ActiveDockable": {
								"$ref": "8"
							},
							"Proportion": 0.25,
							"Dock": 0,
							"IsActive": false,
							"IsEmpty": false,
							"OpenedDockablesCount": 1
						}
					],
					"Proportion": "NaN",
					"Dock": 0,
					"IsActive": false,
					"IsEmpty": false,
					"OpenedDockablesCount": 2
				}
			],
			"ActiveDockable": {
				"$ref": "3"
			},
			"FocusedDockable": {
				"$ref": "5"
			},
			"Proportion": "NaN",
			"Dock": 0,
			"IsActive": false,
			"IsEmpty": false,
			"OpenedDockablesCount": 2
		}
	],
	"ActiveDockable": {
		"$ref": "2"
	},
	"DefaultDockable": {
		"$ref": "2"
	},
	"FocusedDockable": {
		"$ref": "2"
	},
	"Proportion": "NaN",
	"Dock": 0,
	"IsActive": false,
	"IsEmpty": false,
	"OpenedDockablesCount": 2
}

Moving FullTemplateTool. Logs and LayoutJson:

"13:41:12.801" "Debug" "Main" "Dockable init: Logging (a30a89d0-0751-421d-93e6-159ff81b3175)"
"13:41:12.804" "Debug" "Main" "Dockable init: ()"
"13:41:12.804" "Debug" "Main" "Dockable init: Logging (a30a89d0-0751-421d-93e6-159ff81b3175)"
"13:41:12.804" "Debug" "Main" "Dockable init: ()"
"13:41:12.804" "Debug" "Main" "Dockable added: MyTool(197aa9e3-db34-4fcf-a279-095ed94fe215)"
"13:41:12.804" "Debug" "Main" "Dockable moved: MyTool (197aa9e3-db34-4fcf-a279-095ed94fe215)"
"13:41:12.804" "Debug" "Main" "Dockable init: MyTool (197aa9e3-db34-4fcf-a279-095ed94fe215)"
"13:41:12.804" "Debug" "Main" "Dockable added: IToolDock ()"
"13:41:12.804" "Debug" "Main" "Tool added: MyTool (Id: 197aa9e3-db34-4fcf-a279-095ed94fe215)"
"13:41:12.804" "Debug" "Main" "Dockable added: IProportionalDockSplitter ()"
"13:41:12.804" "Debug" "Main" "Dockable added: ()"
"13:41:12.804" "Debug" "Main" "Tool added: Logging (Id: a30a89d0-0751-421d-93e6-159ff81b3175)"
"13:41:12.828" "Debug" "Main" "Dockable added: IToolDock ()"
"13:41:12.828" "Debug" "Main" "Tool added: MyTool (Id: 197aa9e3-db34-4fcf-a279-095ed94fe215)"
"13:41:12.828" "Debug" "Main" "Dockable init: MyTool (197aa9e3-db34-4fcf-a279-095ed94fe215)"
"13:41:12.828" "Debug" "Main" "Dockable init: IToolDock ()"
"13:41:12.828" "Debug" "Main" "Dockable init: IProportionalDockSplitter ()"
"13:41:12.828" "Debug" "Main" "Dockable init: Logging (a30a89d0-0751-421d-93e6-159ff81b3175)"
"13:41:12.828" "Debug" "Main" "Dockable init: ()"
"13:41:12.828" "Debug" "Main" "Dockable init: IProportionalDock ()"
"13:41:12.828" "Debug" "Main" "Dockable init: MyTool (197aa9e3-db34-4fcf-a279-095ed94fe215)"
"13:41:12.828" "Debug" "Main" "Dockable init: IToolDock ()"
"13:41:12.828" "Debug" "Main" "Dockable init: IProportionalDockSplitter ()"
"13:41:12.828" "Debug" "Main" "Dockable init: Logging (a30a89d0-0751-421d-93e6-159ff81b3175)"
"13:41:12.828" "Debug" "Main" "Dockable init: ()"
"13:41:12.828" "Debug" "Main" "Dockable init: IProportionalDock ()"

{
	"$id": "1",
	"$type": "Dock.Model.ReactiveUI.Controls.RootDock, Dock.Model.ReactiveUI",
	"IsFocusableRoot": true,
	"VisibleDockables": [
		{
			"$id": "2",
			"$type": "MyTool.ViewModels.MainDockViewModel, MyTool",
			"IsFocusableRoot": true,
			"VisibleDockables": [
				{
					"$id": "3",
					"$type": "Dock.Model.ReactiveUI.Controls.ProportionalDock, Dock.Model.ReactiveUI",
					"Orientation": 1,
					"VisibleDockables": [
						{
							"$id": "4",
							"$type": "Dock.Model.ReactiveUI.Controls.ProportionalDock, Dock.Model.ReactiveUI",
							"Orientation": 1,
							"VisibleDockables": [
								{
									"$id": "5",
									"$type": "Dock.Model.ReactiveUI.Controls.ToolDock, Dock.Model.ReactiveUI",
									"Alignment": 3,
									"IsExpanded": false,
									"AutoHide": true,
									"GripMode": 0,
									"VisibleDockables": [
										{
											"$id": "6",
											"$type": "MyTool.Tool.FullTemplate.ViewModels.FullTemplateToolViewModel, MyTool.Tool.FullTemplate",
											"SettingsViewModel": {
												"$id": "7",
												"$type": "MyTool.Tool.FullTemplate.ViewModels.FullTemplateSettingsViewModel, MyTool.Tool.FullTemplate",
												"BoolSetting": false,
												"IntSetting": "0"
											}
										}
									],
									"ActiveDockable": {
										"$ref": "6"
									},
									"Proportion": 0.5,
									"Dock": 0,
									"IsActive": false,
									"IsEmpty": false,
									"OpenedDockablesCount": 1
								},
								{
									"$id": "8",
									"$type": "Dock.Model.ReactiveUI.Controls.ProportionalDockSplitter, Dock.Model.ReactiveUI"
								},
								{
									"$id": "9",
									"$type": "Dock.Model.ReactiveUI.Controls.ToolDock, Dock.Model.ReactiveUI",
									"Alignment": -1,
									"IsExpanded": false,
									"AutoHide": true,
									"GripMode": 0,
									"VisibleDockables": [
										{
											"$id": "10",
											"$type": "MyTool.ViewModels.Tools.LoggingViewModel, MyTool"
										}
									],
									"ActiveDockable": {
										"$ref": "10"
									},
									"Proportion": 0.5,
									"Dock": 0,
									"IsActive": true,
									"IsEmpty": false,
									"OpenedDockablesCount": 1
								}
							],
							"ActiveDockable": {
								"$ref": "9"
							},
							"Proportion": 1.0,
							"Dock": 0,
							"IsActive": false,
							"IsEmpty": false,
							"OpenedDockablesCount": 2
						}
					],
					"ActiveDockable": {
						"$ref": "4"
					},
					"Proportion": "NaN",
					"Dock": 0,
					"IsActive": false,
					"IsEmpty": false,
					"OpenedDockablesCount": 2
				}
			],
			"ActiveDockable": {
				"$ref": "3"
			},
			"FocusedDockable": {
				"$ref": "10"
			},
			"Proportion": "NaN",
			"Dock": 0,
			"IsActive": false,
			"IsEmpty": false,
			"OpenedDockablesCount": 2
		}
	],
	"ActiveDockable": {
		"$ref": "2"
	},
	"DefaultDockable": {
		"$ref": "2"
	},
	"FocusedDockable": {
		"$ref": "2"
	},
	"Proportion": "NaN",
	"Dock": 0,
	"IsActive": false,
	"IsEmpty": false,
	"OpenedDockablesCount": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant