Tabbed component content type


#1

This component looks to be designed a little bit differently then expected. I’m not able to add widgets to the tab pages directly.

Can someone give me a short explanation of how to take advantage of this component? It looks like “content type” has two different approaches, but I’d like to understand the pros and cons of each.


#2

You give it your own component to use for each tab, so those components can contain whatever widgets you like…


#3

OK, that’s flexible.

But my elderly brain is stuck - who gets the “on-click” message?
The containing component?

What are the differences between using “named component” and loading a file?


#4

“on-click”? I think you’re talking about some other framework there! Have a look at some of the demo code, and Component::mouseDown, mouseUp, etc.

Genuinely no idea what you mean. What file? Loaded where/how? Why would a file have anything to do with a component’s name?


#5

[quote=“gordcoder”]OK, that’s flexible.

But my elderly brain is stuck - who gets the “on-click” message?
The containing component?
[/quote]

The TabbedComponent class does all of the heavy lifting. There are two different ways to manage tabs provided by JUCE. The TabbedComponent class, and the TabbedButtonBar. You’re either conflating these classes, or looking for one to behave as the other.

The basic form is the TabbedButtonBar. It’ll give you a tab component that merely displays a tab collection. It’s up to you to create, position, and manage the ‘tabs’ when the user switches as the active tab.

The TabbedComponent is a general purpose high level implementation of the lower level TabbedComponent class. Here all of the tab switching and component displaying logic is managed for you. You need merely create components that will represent your tab pages, and pass it to a call to TabbedComponent::addTab(). When the user selects the tab, the component will be automatically shown.

For both classes you create sub-classes and override currentTabChanged() to be told when the user has selected a new tab. In the case of TabbedButtonBar, this is pretty much essential. In the case of TabbedComponent you only need to do this if something extra needs to happen when a tab component is shown.

[quote]
What are the differences between using “named component” and loading a file?[/quote]

Everything and nothing; the two don’t relate. Naming a component is just a convenience thing. You are essentially setting an arbitrary string for the component which can be helpful for descriptively locating it amongst its peers for example. JUCE doesn’t have a native ‘serialize component’ style feature if that’s what you’re looking for. It wouldn’t be too difficult to get a component serializer working if you need one. Check out the ValueTree[1] class. It makes it extremely simple to describe arbitrary data and serialize to XML, or a bin file.

[1] We need either the love, or ‘we’re not worthy’ smilies!


#6

Yep! For me, the appeal of Juce was the familiar feel, but then reality and details rear their heads as you try to code. Yeah, the demo needs more attention from me.

[quote=“jules”]

Genuinely no idea what you mean. What file? Loaded where/how? Why would a file have anything to do with a component’s name?[/quote]

Sorry for not explaining

As displayed in “The Jucer”, the “content type” property of the tabbedComponent object offers two choices: Jucer content component, and Named content component. Setting it to the first option results in a new file name property appearing, it seems that a file can be loaded as the “page” for a specific tab.

Just hoping for some insight into the differences, like when components in the current tab need to call member functions of components in the parent page & vice versa.


#7

(Bump) and sorry for not explaining before:

As displayed in “The Jucer”, the “content type” property of the tabbedComponent object offers two choices: Jucer content component, and Named content component. Setting it to the first option results in a new file name property appearing, it seems that a file can be loaded as the “page” for a specific tab.

Just hoping for some insight into the differences, like when components in the current tab need to call member functions of components in the parent page & vice versa.[/quote]