Changing layout at runtime

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.

Coming from Linux-land here, I suppose that the whole hpkg GUI can be reworked into three parts:

  • Package discovery (a la GNOME Software)
  • Package management (a la Synaptic or Pamac; for Haiku, this is SoftwareUpdater + Repo manager + An installed packages list)
  • A cute little GUI to be used when someone double-clicks a .hpkg
2 Likes

Also: I think the installer thingy is more of a training-wheels app that isn’t going to actually be used for installing stuff.

Another layout API trouble: BBox label is clipped.

Code:

BLayoutItem *CreateTextControlLayoutItem(BTextControl *view)
{
	BGroupLayout *layout;
		BLayoutBuilder::Group<>(B_VERTICAL, 0)
			.GetLayout(&layout)
			.AddGroup(B_HORIZONTAL, 0)
				.Add(view->CreateLabelLayoutItem())
				.AddGlue()
				.End()
			.Add(view->CreateTextViewLayoutItem())
			.End();
	return layout;
}

BBox *NewLabelBox(const char *name, const char *label)
{
	BBox *box = new BBox(name);
	if (label != NULL) {
		box->SetLabel(label);
	}
	return box;
}

TestView::TestView(): PageView("components", false, "Test", "Test page.")
{
	fTeam = new BTextControl("team", "Team:", "0", NULL); fTeam->SetEnabled(false);
	fPort = new BTextControl("port", "Port:", "0", NULL); fPort->SetEnabled(false);
	fToken = new BTextControl("token", "Token:", "0", NULL); fToken->SetEnabled(false);

	fLeftView = new BTextControl("left", "Left:", "0", NULL);
	fTopView = new BTextControl("top", "Top:", "0", NULL);
	fRightView = new BTextControl("right", "Right:", "255", NULL);
	fBottomView = new BTextControl("bottom", "Bottom:", "255", NULL);

	BLayoutBuilder::Group<>(this, B_VERTICAL, B_USE_SMALL_SPACING)
		.SetInsets(B_USE_SMALL_SPACING)
		.Add(
			BLayoutBuilder::Group<>(NewLabelBox("box1", NULL), B_HORIZONTAL, B_USE_SMALL_SPACING)
				.SetInsets(B_USE_SMALL_SPACING)
				.Add(CreateTextControlLayoutItem(fTeam))
				.Add(CreateTextControlLayoutItem(fPort))
				.Add(CreateTextControlLayoutItem(fToken))
				.View())
		.Add(
			BLayoutBuilder::Group<>(NewLabelBox("frame", "Frame"), B_HORIZONTAL, B_USE_SMALL_SPACING)
				.SetInsets(B_USE_SMALL_SPACING)
				.Add(CreateTextControlLayoutItem(fLeftView))
				.Add(CreateTextControlLayoutItem(fTopView))
				.Add(CreateTextControlLayoutItem(fRightView))
				.Add(CreateTextControlLayoutItem(fBottomView))
				.View())
		.AddGlue()
		.End();
}

Result:
layout

2 Likes

I know it’s all a matter of taste, but have to say I like HaikuDepot as single, one-stop package management. In (some?) Linux distros, I without fail pick the wrong app and end up with some tool showing every available software with not much information or screenshots or anything. And it takes an unreasonably long time to be up and responsive…

Nope, I prefer HaikuDepot as is, even though its “Featured packages” has some capacity for improvement. There’s already a simple view mode when double clicking a HPKG. Get the “OpenOriginPackage” Tracker add-on to get the same for any file of a package.

Sorry for the derail. If people want to discuss this further, I can split this into a new thread…

1 Like

I explored FileTypes source code and found that it use following workaround:

.SetInsets(padding, 2*padding, padding, padding)

It is not working properly with big font size:

2 Likes