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

Layout rebuilding of the paned layout corrupts it #11

Open
pavel-krivanek opened this issue Feb 4, 2022 · 2 comments
Open

Layout rebuilding of the paned layout corrupts it #11

pavel-krivanek opened this issue Feb 4, 2022 · 2 comments

Comments

@pavel-krivanek
Copy link
Contributor

The embedded paned layout gets broken when the layout is rebuilt.

Let's have a paned layout that includes another paned layout, something like this:

	^ SpPanedLayout newHorizontal 
		add: (SpPanedLayout newHorizontal 
			add: #button1;
			add: #button2;
			positionOfSlider: 0.5;
			yourself);
		add: #button3;
		positionOfSlider: 0.5;
		yourself

Then the output window will look like this:

image

Now let's update the layout without changing of the definition:

updateLayout 

	layout := self class defaultLayout.

It makes tha layout with wrong ratios:

image

But even small resizing of the window makes it reasonable again:

image

The testing code:

PanedLayoutIssue.zip

@pavel-krivanek
Copy link
Contributor Author

It does not break this way if the layout uses only one non-embedded paned layout

defaultLayout

	^ SpPanedLayout newHorizontal 
		add: #button2;
		add: #button3;
		yourself

However, the resizing of the window resets the user-set splitter position

@pavel-krivanek
Copy link
Contributor Author

for this particular case, the hackinsh preserving of the old position does the job but we need more general way of doing this

GtkPanedAdapter>>#replaceLayoutWith:

replaceLayoutWith: aLayout

	GRunLoop defer: [ 
		| oldAdapter oldPosition |
		oldAdapter := self presenter adapter.
		oldPosition := (self presenter adapter widget isKindOf: GtkPaned) 
			ifTrue: [ self presenter adapter widget position  ]
			ifFalse: [ nil ].
		self presenter adapter: (aLayout
			buildAdapterFor: self presenter
			bindings: self presenter application adapterBindings).
		oldAdapter cleanupAfterReplacing.
		self presenter owner adapter rebuild.
		oldPosition ifNotNil: [ 
			aLayout adapter widget position: oldPosition ]
	]

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