Changing layout at runtime

Is it possible to replace view added by BLayoutBuilder at runtime? Also is it possible delete all to recreate layout?

For example I want to change upper part while keeping lower part in following window.
Installer

4 Likes

There is Auckland Layout Editor https://depot.haiku-os.org/ale but I’m not sure if that’s what you need.

Isnt this a task for BCardLayout? https://www.haiku-os.org/docs/api/classBCardLayout.html
Add the different (upper) Layouts to this Layout and then just switch between the visible Layout…

1 Like

Thanks. I didn’t know about BCardLayout. Many parts of Layout API are still not documented.

1 Like

Yes, for this job, BCardView is what you want. But in general, BLayouts have AddItem/RemoveItem functions just like Qt/GTK/etc. layouts do, so you can individually add and remove items. BLayoutBuilder is just a nicer way, syntactically, of doing things.

What’s the purpose of an installer, though? You can just distribute HPKG files for your applications, and they will open in HaikuDepot where users can choose to install/uninstall them.

1 Like

Currently I am just practice to create complex GUI with Layout API. Installer GUI design is based on NSIS. I think that installer is more user friendly and flexible than opening HPKG with HaikuDepot: installer allows to show license, select components, enter user registration code etc. Internally installer can contain and install HPKG files including case when multiple HPKG files are contained and installed according selected components.

1 Like

There is actually logic in the Package Kit for this, the GUI to actually show the license is just not implemented (probably because nothing so far needed it.)

I think there is a ticket (or maybe one was just never created) about making “HPKG bundles” which would include functionality like this.

Most proprietary applications ask for this after they have been started for the first time, yes? At least it’s rather rare for the installer to do it these days.

1 Like

In some software installed components depends on purchased product version (trial, home, pro etc.). Microsoft Office use this. I know some other software that install different components depending on registration key.

Installer can store encrypted contents to prevent extraction and illegal distribution and use registration key for decryption.

Also current package installing interface is worse than traditional installers: it display a lot of useless non-functional elements that are not needed for non-repository package like rating, change log and not working screenshot area. Some different interface should be used that is independent of HaikuDepot.

We should then change HaikuDepot to not have these when they are unavailable/can’t be added, so that it can be used for this purpose also, then.

1 Like

I tried to use AddCards, but all items are displayed simultaneously at start:
installer2

When switching cards issue is fixed:
installer3

layout building code:

BLayoutBuilder::Group<>(fIntroContainerView, B_VERTICAL, B_USE_DEFAULT_SPACING)
	.SetInsets(B_USE_DEFAULT_SPACING)
	.Add(fIntroTitleView, 0)
	.Add(fIntroContentView, 0)
	.AddGlue()
	.End();

BLayoutBuilder::Group<>(fHeaderContainerView, B_HORIZONTAL, 0)
	.Add(fHeaderView)
	.AddGroup(B_VERTICAL, 0)
		.Add(fTitleView, 0)
		.Add(fSubtitleView, 0)
		.AddGlue()
		.End()
	.End();

BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
	.AddCards()
		.GetLayout(&fCardLayout)
		.AddGroup(B_VERTICAL, 0)
			.AddGroup(B_HORIZONTAL, 0)
				.Add(fWizardView, 0)
				.Add(fIntroContainerView)
				.End()
			.End()
		.AddGroup(B_VERTICAL, 0)
			.Add(fHeaderContainerView)
			.Add(new BSeparatorView(B_HORIZONTAL))
			.AddGroup(B_VERTICAL, B_USE_DEFAULT_SPACING)
				.SetInsets(B_USE_DEFAULT_SPACING)
				.Add(fLicenseCaption1View, 0)
				.Add(new BScrollView("scrollview", fLicenseView, 0, true, true, B_PLAIN_BORDER))
				.Add(fLicenseCaption2View, 0)
				.End()
			.End()
		.End()
	.Add(new BSeparatorView(B_HORIZONTAL))
	.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.AddGlue()
		.Add(fBackView)
		.Add(fNextView)
		.Add(fCancelView)
		.End()
	.End();

Is it a bug or I am doing something wrong?

1 Like

I’d recommend just using BLayoutBuilder::Cards<> directly. But I’m not sure whether or not this is a bug; mostly I’ve just used BCardView without the builder. It looks like a bug, though.

Following workaround is working:

fCardLayout->SetVisibleItem(1);
fCardLayout->SetVisibleItem(0);

It seems that BCardLayout don’t handle not BView items properly.

1 Like

Trac ticket: #15854.

1 Like

I get another problem: BScrollView is not working with layout, window can’t be shrinked to enable scroll bars.
installer5

1 Like

And another problem: minimum window size is improperly calculated for BTextView with word wrapping.
installer6

1 Like

The BTextView problem is well known (in our own Installer, in TeamMonitor, …). BTextView should be rewritten/reworked, and while we’re at it, it should use ICU to compute line breaks.

BScrollView works in many places (most of apps bundled with Haiku use the layout kit and there are scroll views in many places without problems). However, it usually needs something else to constrain the window size. If everything fits, why would it make itself smaller? If no other widget is constraining it, you may need to use SetExplicitMinSize() and/or SetExplicitPreferredSize().

As for using HaikuDepot as the way to install packages when you already have downloaded a .hpkg, well, I don’t see the point. HaikuDepot is already trying (and failing, I’d say, for now) to be both a package manager in Linux style and an App Store in Android style. It can’t also be an Install wizard in Windows style. Sharing some code if needed, yes, why not. But forcing everything into the same app? Especially when Haiku also ship with SoftwareUpdater and Repositories preferences, which I think could be merged into HaikuDepot?

1 Like

If there are a lot of items in BScrollView, window height can go outside of screen. In my case installer window height should not be too big.

I think that HaikuDepot responsibility should be only exploring and installing packages in repository. Installing of non-repository packages should be done with different program. I also think that it should be separate program for managing installed packages, it should list both pkg and hpkg packages and should have option to hide auto-installed dependencies.

Is there a ticket for this issue?
Update: most close ticket that I found: #9400.