Layout API problem

That´s it, I decided to go with this solution. Thanks for helping me!

@BlueSky I know you’ve already made up your mind, but is this the result you wanted?


5 Likes

It´s a bit hard to judge from the screenshots but this looks more like what I originally wanted. How does your solution look code-wise?

1 Like

The solution was to make the menubar part of the layout group instead of outside of it, then “AddGlue()” and “.SetInsets(B_USE_SMALL_INSETS)” become irrelevant, finally adding a zero to “.AddGroup(B_VERTICAL)” makes the elements close to eachother.

        BLayoutBuilder::Group<>(this, B_VERTICAL)
                .SetInsets(0,0,0,0)
-               .Add(fTopMenuBar)
-               .AddGroup(B_VERTICAL)
-                       .SetInsets(B_USE_SMALL_INSETS)
+               .AddGroup(B_VERTICAL, 0)
+                       .Add(fTopMenuBar)
                        .Add(fileoptionsbox)
                        .Add(tabview)
                        .Add(encodebox)
                        .Add(fStatusBar)
                .End()
-               .AddGlue()
        .Layout();

2 Likes

Why put a vertical group (with AddGroup) inside another vertical group (handled by BLayoutBuilder at the toplevel)?

Good question, i didn’t think of much it actually, because it was already there and i didn’t think of removing it to see what would happen.

Well removing .AddGroup(B_VERTICAL, 0) actually breaks the build.

source/ffgui-window.cpp:398:10: error: request for member 'Layout' in '(&(&(&(&(&(& BLayoutBuilder::Group<>((&((ffguiwin*)this)->ffguiwin::<anonymous>), B_VERTICAL, (float)._anon_97::B_USE_DEFAULT_SPACING).BLayoutBuilder::Group<>::SetInsets((float)0, (float)0, (float)0, (float)0))->BLayoutBuilder::Group<>::Add(((BView*)((ffguiwin*)this)->ffguiwin::fTopMenuBar)))->BLayoutBuilder::Group<>::Add(((BView*)fileoptionsbox)))->BLayoutBuilder::Group<>::Add(((BView*)((ffguiwin*)this)->ffguiwin::tabview)))->BLayoutBuilder::Group<>::Add(((BView*)encodebox)))->BLayoutBuilder::Group<>::Add(((BView*)((ffguiwin*)this)->ffguiwin::fStatusBar)))->BLayoutBuilder::Group<>::<anonymous>.BLayoutBuilder::Base<void*>::End()', which is of non-class type 'void*'
  398 |         .Layout();
      |          ^~~~~~

But it can be fixed by removing the Layout() call and adding a zero to BLayoutBuilder::Group<>(this, B_VERTICAL, 0).
It’s up to @BlueSky what he wants to do.

nice, but whichg solution is prefered one may wonder (like me)? Which is the easier one to follow/understand?

Just curious user here!

I originally defined the, let’s call it secondary, vertical group to be able to set the insets to something non-zero. I have to use insets of 0 on the top vertical group because of the menubar. Of course it doesn’t make sense if the menubar is moved to the secondary vertical group as in khallebal’s example.

Is there a better way to achieve this?

Yes, I suspect you forgot to remove the corresponding .End()

Let’s sum this up a little bit. None of the my layout attempts without the .AddGlue() works, because the menu bar is not in the location it is supposed to be (at the top). Using AddGlue() kind of works, but is still not what I wanted the layout to behave, because if the window is resized there is only free space at the bottom (exactly what AddGlue() is supposed to do), but I want the tab view to expand vertically and everything else not. If somebody wonders why I want the tab view to expand, it`s because of the output tab which can contain quite a bit of text, the only widget in this app that would really benefit from vertical growth.