Because you didn’t change the bottom position, the last parameter of the BRect()s, so the height of the stringviews are now 10 pixels smaller, down from 20 (30-10) to 10 (30-20). While with the default 12pt system font size, 20 pixels are enough to fully display a text height , 10 pixels are not.
May I suggest you switching to use the Layout Kit to place your sub views in order to stop struggling about manual placement of views to compose a window all while getting dynamic relayout on window size change?
Here a sample code:
#include <Application.h>
#include <LayoutBuilder.h>
#include <StringView.h>
#include <Window.h>
class MainWindow : public BWindow
{
public:
MainWindow(const char* title)
:
BWindow(BRect(100, 100, 500, 300), title, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE)
{
BStringView* letterV = new BStringView("letter", "Letter");
BStringView* codeV = new BStringView("code", "Code");
BLayoutBuilder::Group<>(this, B_HORIZONTAL)
.Add(letterV)
.Add(codeV)
.End();
Show();
}
};
class App : public BApplication
{
public:
App() : BApplication("application/x-vnd.fabianoo-demo")
{
new MainWindow("ITU");
}
};
int
main()
{
App* app = new App();
app->Run();
delete app;
return 0;
}
This code use the Layout Kit to construct a very similar MainWindow content.
You will notice that only the window now have a BRect (for its initial position and size), but use a BLayoutBuilder to construct its content (hence the “this” parameter).
Here it add the two BStringViews in an horizontal group. The Layout Kit will automatically manage their position, based on auto-computed optimal size of both views. As the window is resizable, you can also see that it does that not only at construction time but live.
I’m not saying that learning the geometry logic of views hierarchy within a window is not useful, but if you find it a bit too much boilerplate for your taste, consider instead learning to use the Layout Kit right now.
By looking a many Haiku open source apps code, starting by Haiku builtin ones in src/apps code base, you could learn quicker how to build UI layouting.
You can always go back to deeper manual geometry topic later…